aboutsummaryrefslogtreecommitdiff
path: root/js/panels/css-panel/declaration.reel
diff options
context:
space:
mode:
authorEric Guzman2012-04-13 01:45:31 -0700
committerEric Guzman2012-04-13 01:45:31 -0700
commitdb9d44fea7856a8fba9e9e306dafa8777f1eb015 (patch)
treef05f18a6908c5becaa936c38bcc75e593f2ae7d7 /js/panels/css-panel/declaration.reel
parente39cc380ef2c0479f57b35dcadedccb0fb3fd22f (diff)
downloadninja-db9d44fea7856a8fba9e9e306dafa8777f1eb015.tar.gz
CSS Panel - Add drag and drop UI
Diffstat (limited to 'js/panels/css-panel/declaration.reel')
-rw-r--r--js/panels/css-panel/declaration.reel/declaration.css3
-rw-r--r--js/panels/css-panel/declaration.reel/declaration.js55
2 files changed, 58 insertions, 0 deletions
diff --git a/js/panels/css-panel/declaration.reel/declaration.css b/js/panels/css-panel/declaration.reel/declaration.css
index 77257fec..e37d89d2 100644
--- a/js/panels/css-panel/declaration.reel/declaration.css
+++ b/js/panels/css-panel/declaration.reel/declaration.css
@@ -9,4 +9,7 @@
9} 9}
10.treeRoot > .style-shorthand-branch > dl { 10.treeRoot > .style-shorthand-branch > dl {
11 margin-top: 4px; 11 margin-top: 4px;
12}
13.drag-over {
14 /*background-color: red;*/
12} \ No newline at end of file 15} \ No newline at end of file
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