diff options
Diffstat (limited to 'js/panels/css-panel/declaration.reel/declaration.js')
-rw-r--r-- | js/panels/css-panel/declaration.reel/declaration.js | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/js/panels/css-panel/declaration.reel/declaration.js b/js/panels/css-panel/declaration.reel/declaration.js index 34819df5..0cc98951 100644 --- a/js/panels/css-panel/declaration.reel/declaration.js +++ b/js/panels/css-panel/declaration.reel/declaration.js | |||
@@ -14,6 +14,14 @@ exports.Declaration = Montage.create(Component, { | |||
14 | console.log("declaration - template did load"); | 14 | console.log("declaration - template did load"); |
15 | } | 15 | } |
16 | }, | 16 | }, |
17 | prepareForDraw : { | ||
18 | value: function(e) { | ||
19 | console.log("Declaration :: prepare for draw"); | ||
20 | this._element.addEventListener('drop', this, false); | ||
21 | this.element.addEventListener('dragenter', this, false); | ||
22 | this.element.addEventListener('dragleave', this, false); | ||
23 | } | ||
24 | }, | ||
17 | _declaration: { | 25 | _declaration: { |
18 | value: null | 26 | value: null |
19 | }, | 27 | }, |
@@ -95,11 +103,58 @@ exports.Declaration = Montage.create(Component, { | |||
95 | }, | 103 | }, |
96 | distinct: true | 104 | distinct: true |
97 | }, | 105 | }, |
106 | |||
107 | /* drag/drop events */ | ||
108 | handleDrop : { | ||
109 | value: function(e) { | ||
110 | console.log('dropped'); | ||
111 | } | ||
112 | }, | ||
113 | handleDragenter : { | ||
114 | value: function(e) { | ||
115 | console.log("dec - drag enter"); | ||
116 | this.element.classList.add("drag-over"); | ||
117 | } | ||
118 | }, | ||
119 | handleDragleave : { | ||
120 | value: function(e) { | ||
121 | if(this.element === e._event.toElement || this._containsElement(e._event.toElement)) { | ||
122 | //// Dragged-over element is inside of component element | ||
123 | //// I.e. it's not really a "drag leave" | ||
124 | e.stopPropagation(); | ||
125 | e.preventDefault(); | ||
126 | return false; | ||
127 | } | ||
128 | |||
129 | console.log("DECLARATION - ELEMENT NOT IN DEC", e._event.toElement); | ||
130 | |||
131 | //console.log("dec - drag leave"); | ||
132 | this.element.classList.remove("drag-over"); | ||
133 | } | ||
134 | }, | ||
135 | |||
98 | draw: { | 136 | draw: { |
99 | value: function() { | 137 | value: function() { |
100 | if(this._declaration) { | 138 | if(this._declaration) { |
101 | 139 | ||
102 | } | 140 | } |
103 | } | 141 | } |
142 | }, | ||
143 | |||
144 | _containsElement : { | ||
145 | value: function(innerElement) { | ||
146 | var isInComponent = false, | ||
147 | parent = innerElement.parentNode; | ||
148 | |||
149 | while (parent !== document) { | ||
150 | if(parent === this.element) { | ||
151 | isInComponent = true; | ||
152 | break; | ||
153 | } | ||
154 | parent = parent.parentNode; | ||
155 | } | ||
156 | |||
157 | return isInComponent; | ||
158 | } | ||
104 | } | 159 | } |
105 | }); \ No newline at end of file | 160 | }); \ No newline at end of file |