annotate web/edit-choice.coffee @ 2404:9cbc93f80b05

cleanup
author drewp@bigasterisk.com
date Fri, 17 May 2024 17:41:22 -0700
parents 4556eebe5d73
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1901
7fe81130b735 move web logging to https://github.com/visionmedia/debug/ so it can have channels that can be turned off
Drew Perttula <drewp@bigasterisk.com>
parents: 1753
diff changeset
1 log = debug('editchoice')
1378
64239c6651de start edit-choice polymer version
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
2 RDFS = 'http://www.w3.org/2000/01/rdf-schema#'
1382
b4d81ecf055c drop effect uri onto rows, make note
Drew Perttula <drewp@bigasterisk.com>
parents: 1380
diff changeset
3
b4d81ecf055c drop effect uri onto rows, make note
Drew Perttula <drewp@bigasterisk.com>
parents: 1380
diff changeset
4
b4d81ecf055c drop effect uri onto rows, make note
Drew Perttula <drewp@bigasterisk.com>
parents: 1380
diff changeset
5
b4d81ecf055c drop effect uri onto rows, make note
Drew Perttula <drewp@bigasterisk.com>
parents: 1380
diff changeset
6 window.setupDrop = (senseElem, highlightElem, coordinateOriginElem, onDrop) ->
b4d81ecf055c drop effect uri onto rows, make note
Drew Perttula <drewp@bigasterisk.com>
parents: 1380
diff changeset
7
b4d81ecf055c drop effect uri onto rows, make note
Drew Perttula <drewp@bigasterisk.com>
parents: 1380
diff changeset
8 highlight = -> highlightElem.classList.add('dragging')
b4d81ecf055c drop effect uri onto rows, make note
Drew Perttula <drewp@bigasterisk.com>
parents: 1380
diff changeset
9 unhighlight = -> highlightElem.classList.remove('dragging')
b4d81ecf055c drop effect uri onto rows, make note
Drew Perttula <drewp@bigasterisk.com>
parents: 1380
diff changeset
10
b4d81ecf055c drop effect uri onto rows, make note
Drew Perttula <drewp@bigasterisk.com>
parents: 1380
diff changeset
11 senseElem.addEventListener 'drag', (event) =>
b4d81ecf055c drop effect uri onto rows, make note
Drew Perttula <drewp@bigasterisk.com>
parents: 1380
diff changeset
12
b4d81ecf055c drop effect uri onto rows, make note
Drew Perttula <drewp@bigasterisk.com>
parents: 1380
diff changeset
13 senseElem.addEventListener 'dragstart', (event) =>
b4d81ecf055c drop effect uri onto rows, make note
Drew Perttula <drewp@bigasterisk.com>
parents: 1380
diff changeset
14
b4d81ecf055c drop effect uri onto rows, make note
Drew Perttula <drewp@bigasterisk.com>
parents: 1380
diff changeset
15 senseElem.addEventListener 'dragend', (event) =>
b4d81ecf055c drop effect uri onto rows, make note
Drew Perttula <drewp@bigasterisk.com>
parents: 1380
diff changeset
16
b4d81ecf055c drop effect uri onto rows, make note
Drew Perttula <drewp@bigasterisk.com>
parents: 1380
diff changeset
17 senseElem.addEventListener 'dragover', (event) =>
b4d81ecf055c drop effect uri onto rows, make note
Drew Perttula <drewp@bigasterisk.com>
parents: 1380
diff changeset
18 event.preventDefault()
b4d81ecf055c drop effect uri onto rows, make note
Drew Perttula <drewp@bigasterisk.com>
parents: 1380
diff changeset
19 event.dataTransfer.dropEffect = 'copy'
b4d81ecf055c drop effect uri onto rows, make note
Drew Perttula <drewp@bigasterisk.com>
parents: 1380
diff changeset
20 highlight()
b4d81ecf055c drop effect uri onto rows, make note
Drew Perttula <drewp@bigasterisk.com>
parents: 1380
diff changeset
21
b4d81ecf055c drop effect uri onto rows, make note
Drew Perttula <drewp@bigasterisk.com>
parents: 1380
diff changeset
22 senseElem.addEventListener 'dragenter', (event) =>
b4d81ecf055c drop effect uri onto rows, make note
Drew Perttula <drewp@bigasterisk.com>
parents: 1380
diff changeset
23 highlight()
b4d81ecf055c drop effect uri onto rows, make note
Drew Perttula <drewp@bigasterisk.com>
parents: 1380
diff changeset
24
b4d81ecf055c drop effect uri onto rows, make note
Drew Perttula <drewp@bigasterisk.com>
parents: 1380
diff changeset
25 senseElem.addEventListener 'dragleave', (event) =>
b4d81ecf055c drop effect uri onto rows, make note
Drew Perttula <drewp@bigasterisk.com>
parents: 1380
diff changeset
26 unhighlight()
b4d81ecf055c drop effect uri onto rows, make note
Drew Perttula <drewp@bigasterisk.com>
parents: 1380
diff changeset
27
b4d81ecf055c drop effect uri onto rows, make note
Drew Perttula <drewp@bigasterisk.com>
parents: 1380
diff changeset
28 senseElem.addEventListener 'drop', (event) ->
b4d81ecf055c drop effect uri onto rows, make note
Drew Perttula <drewp@bigasterisk.com>
parents: 1380
diff changeset
29 event.preventDefault()
b4d81ecf055c drop effect uri onto rows, make note
Drew Perttula <drewp@bigasterisk.com>
parents: 1380
diff changeset
30 uri = event.dataTransfer.getData('text/uri-list')
b4d81ecf055c drop effect uri onto rows, make note
Drew Perttula <drewp@bigasterisk.com>
parents: 1380
diff changeset
31
b4d81ecf055c drop effect uri onto rows, make note
Drew Perttula <drewp@bigasterisk.com>
parents: 1380
diff changeset
32 pos = if coordinateOriginElem?
b4d81ecf055c drop effect uri onto rows, make note
Drew Perttula <drewp@bigasterisk.com>
parents: 1380
diff changeset
33 root = coordinateOriginElem.getBoundingClientRect()
b4d81ecf055c drop effect uri onto rows, make note
Drew Perttula <drewp@bigasterisk.com>
parents: 1380
diff changeset
34 $V([event.pageX - root.left, event.pageY - root.top])
b4d81ecf055c drop effect uri onto rows, make note
Drew Perttula <drewp@bigasterisk.com>
parents: 1380
diff changeset
35 else
b4d81ecf055c drop effect uri onto rows, make note
Drew Perttula <drewp@bigasterisk.com>
parents: 1380
diff changeset
36 null
b4d81ecf055c drop effect uri onto rows, make note
Drew Perttula <drewp@bigasterisk.com>
parents: 1380
diff changeset
37
1693
53f751982ddf WIP polymer2 upgrade, timeline rewrite
drewp@bigasterisk.com
parents: 1663
diff changeset
38 try
53f751982ddf WIP polymer2 upgrade, timeline rewrite
drewp@bigasterisk.com
parents: 1663
diff changeset
39 onDrop(uri, pos)
53f751982ddf WIP polymer2 upgrade, timeline rewrite
drewp@bigasterisk.com
parents: 1663
diff changeset
40 catch e
1901
7fe81130b735 move web logging to https://github.com/visionmedia/debug/ so it can have channels that can be turned off
Drew Perttula <drewp@bigasterisk.com>
parents: 1753
diff changeset
41 log(e)
1382
b4d81ecf055c drop effect uri onto rows, make note
Drew Perttula <drewp@bigasterisk.com>
parents: 1380
diff changeset
42 unhighlight()
b4d81ecf055c drop effect uri onto rows, make note
Drew Perttula <drewp@bigasterisk.com>
parents: 1380
diff changeset
43
b4d81ecf055c drop effect uri onto rows, make note
Drew Perttula <drewp@bigasterisk.com>
parents: 1380
diff changeset
44
b4d81ecf055c drop effect uri onto rows, make note
Drew Perttula <drewp@bigasterisk.com>
parents: 1380
diff changeset
45
1731
e06c2c105035 workaround for coffee issue with static getters. polymer wasn't seeing my attributes at all
Drew Perttula <drewp@bigasterisk.com>
parents: 1714
diff changeset
46 coffeeElementSetup(class EditChoice extends Polymer.Element
1753
3c997bc6d380 fix some coffee lint
Drew Perttula <drewp@bigasterisk.com>
parents: 1746
diff changeset
47 @is: "edit-choice",
3c997bc6d380 fix some coffee lint
Drew Perttula <drewp@bigasterisk.com>
parents: 1746
diff changeset
48 @getter_properties:
3c997bc6d380 fix some coffee lint
Drew Perttula <drewp@bigasterisk.com>
parents: 1746
diff changeset
49 graph: {type: Object, notify: true},
3c997bc6d380 fix some coffee lint
Drew Perttula <drewp@bigasterisk.com>
parents: 1746
diff changeset
50 uri: {type: String, notify: true},
1378
64239c6651de start edit-choice polymer version
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
51
1753
3c997bc6d380 fix some coffee lint
Drew Perttula <drewp@bigasterisk.com>
parents: 1746
diff changeset
52 _setUri: (u) ->
3c997bc6d380 fix some coffee lint
Drew Perttula <drewp@bigasterisk.com>
parents: 1746
diff changeset
53 @uri = u
3c997bc6d380 fix some coffee lint
Drew Perttula <drewp@bigasterisk.com>
parents: 1746
diff changeset
54 @dispatchEvent(new CustomEvent('edited'))
1746
84adc69fdf8a fix inlineattrs setup and effect editing
Drew Perttula <drewp@bigasterisk.com>
parents: 1731
diff changeset
55
1753
3c997bc6d380 fix some coffee lint
Drew Perttula <drewp@bigasterisk.com>
parents: 1746
diff changeset
56 connectedCallback: ->
3c997bc6d380 fix some coffee lint
Drew Perttula <drewp@bigasterisk.com>
parents: 1746
diff changeset
57 super.connectedCallback()
3c997bc6d380 fix some coffee lint
Drew Perttula <drewp@bigasterisk.com>
parents: 1746
diff changeset
58 setupDrop(@$.box, @$.box, null, @_setUri.bind(@))
1380
5805056fdf93 fix a lot of refresh and cleanup issues
Drew Perttula <drewp@bigasterisk.com>
parents: 1378
diff changeset
59
1753
3c997bc6d380 fix some coffee lint
Drew Perttula <drewp@bigasterisk.com>
parents: 1746
diff changeset
60 unlink: ->
3c997bc6d380 fix some coffee lint
Drew Perttula <drewp@bigasterisk.com>
parents: 1746
diff changeset
61 @_setUri(null)
1731
e06c2c105035 workaround for coffee issue with static getters. polymer wasn't seeing my attributes at all
Drew Perttula <drewp@bigasterisk.com>
parents: 1714
diff changeset
62 )