diff --git a/light9/web/edit-choice.coffee b/light9/web/edit-choice.coffee new file mode 100644 --- /dev/null +++ b/light9/web/edit-choice.coffee @@ -0,0 +1,34 @@ +RDFS = 'http://www.w3.org/2000/01/rdf-schema#' +Polymer + is: "edit-choice", + properties: + graph: {type: Object, notify: true}, + uri: {type: String, notify: true}, + label: {type: String, notify: true} + + observers: [ + 'gotGraph(graph, uri)' + ] + + dragover: (event) -> + event.preventDefault() + event.dataTransfer.dropEffect = 'copy' + @$.box.classList.add('over') + + dragleave: (event) -> + @$.box.classList.remove('over') + + drop: (event) -> + event.preventDefault() + @uri = event.dataTransfer.getData('text/uri-list') + @updateLabel() + + gotGraph: -> + @graph.runHandler(@updateLabel.bind(@)) + + updateLabel: -> + @label = try + @graph.stringValue(@uri, RDFS + 'label') + catch + @uri + diff --git a/light9/web/edit-choice.html b/light9/web/edit-choice.html new file mode 100644 --- /dev/null +++ b/light9/web/edit-choice.html @@ -0,0 +1,32 @@ + + + + + + +