Mercurial > code > home > repos > light9
diff light9/web/edit-choice.coffee @ 1378:64239c6651de
start edit-choice polymer version
Ignore-this: f9abf03b69c723712f4e7857c856b81b
author | Drew Perttula <drewp@bigasterisk.com> |
---|---|
date | Wed, 08 Jun 2016 07:04:16 +0000 |
parents | |
children | 5805056fdf93 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/light9/web/edit-choice.coffee Wed Jun 08 07:04:16 2016 +0000 @@ -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 +