diff options
author | Pushkar Joshi | 2012-06-06 07:54:11 -0700 |
---|---|---|
committer | Pushkar Joshi | 2012-06-06 07:54:11 -0700 |
commit | cfa1402ac2ce831a83a9d4263d06c452c157a414 (patch) | |
tree | adb8f1f1ad1c4dd1e7e9eee1bd206f1ec338d20c /js/controllers/elements | |
parent | 8606ee7ec851cb0a971e7556eba5d9386f1b3639 (diff) | |
parent | 5ba54dc275b07e7b2d0ed14751761d1e663d3d14 (diff) | |
download | ninja-cfa1402ac2ce831a83a9d4263d06c452c157a414.tar.gz |
Merge branch 'pentool' into brushtool
Diffstat (limited to 'js/controllers/elements')
-rwxr-xr-x | js/controllers/elements/component-controller.js | 4 | ||||
-rwxr-xr-x | js/controllers/elements/element-controller.js | 26 | ||||
-rwxr-xr-x | js/controllers/elements/shapes-controller.js | 4 |
3 files changed, 28 insertions, 6 deletions
diff --git a/js/controllers/elements/component-controller.js b/js/controllers/elements/component-controller.js index 5b0aaeac..dd0766df 100755 --- a/js/controllers/elements/component-controller.js +++ b/js/controllers/elements/component-controller.js | |||
@@ -11,7 +11,7 @@ exports.ComponentController = Montage.create(ElementController, { | |||
11 | 11 | ||
12 | getProperty: { | 12 | getProperty: { |
13 | value: function(el, prop) { | 13 | value: function(el, prop) { |
14 | var component = el.controller || this.application.ninja.currentDocument.model.getComponentFromElement(el); | 14 | var component = el.controller; |
15 | 15 | ||
16 | switch(prop) { | 16 | switch(prop) { |
17 | case "id": | 17 | case "id": |
@@ -34,7 +34,7 @@ exports.ComponentController = Montage.create(ElementController, { | |||
34 | 34 | ||
35 | setProperty: { | 35 | setProperty: { |
36 | value: function(el, p, value) { | 36 | value: function(el, p, value) { |
37 | var component = el.controller || this.application.ninja.currentDocument.model.getComponentFromElement(el); | 37 | var component = el.controller; |
38 | 38 | ||
39 | switch(p) { | 39 | switch(p) { |
40 | case "id": | 40 | case "id": |
diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index 20225c61..01e132d7 100755 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js | |||
@@ -11,6 +11,9 @@ exports.ElementController = Montage.create(Component, { | |||
11 | 11 | ||
12 | addElement: { | 12 | addElement: { |
13 | value: function(el, styles) { | 13 | value: function(el, styles) { |
14 | |||
15 | if (el.getAttribute) el.setAttribute('data-ninja-node', 'true'); | ||
16 | |||
14 | if(this.application.ninja.timeline.currentLayerSelected) { | 17 | if(this.application.ninja.timeline.currentLayerSelected) { |
15 | var selectedLayerIndex = this.application.ninja.timeline.getLayerIndexByID(this.application.ninja.timeline.currentLayerSelected.layerData.layerID); | 18 | var selectedLayerIndex = this.application.ninja.timeline.getLayerIndexByID(this.application.ninja.timeline.currentLayerSelected.layerData.layerID); |
16 | 19 | ||
@@ -159,8 +162,6 @@ exports.ElementController = Montage.create(Component, { | |||
159 | el.elementModel.stroke = null; | 162 | el.elementModel.stroke = null; |
160 | return; | 163 | return; |
161 | case 'gradient': | 164 | case 'gradient': |
162 | this.setProperty(el, "border-image", color.color.css); | ||
163 | this.setProperty(el, "border-color", "none"); | ||
164 | if(color.borderInfo) { | 165 | if(color.borderInfo) { |
165 | if(color.borderInfo.borderWidth) { | 166 | if(color.borderInfo.borderWidth) { |
166 | this.setProperty(el, "border-width", color.borderInfo.borderWidth + color.borderInfo.borderUnits); | 167 | this.setProperty(el, "border-width", color.borderInfo.borderWidth + color.borderInfo.borderUnits); |
@@ -169,9 +170,11 @@ exports.ElementController = Montage.create(Component, { | |||
169 | this.setProperty(el, "border-style", color.borderInfo.borderStyle); | 170 | this.setProperty(el, "border-style", color.borderInfo.borderStyle); |
170 | } | 171 | } |
171 | } | 172 | } |
173 | this.setGradientBorder(el, color.color.gradientMode, color.color.css); | ||
172 | break; | 174 | break; |
173 | default: | 175 | default: |
174 | this.setProperty(el, "border-image", "none"); | 176 | this.setProperty(el, "border-image", "none"); |
177 | this.setProperty(el, "border-image-slice", ""); | ||
175 | this.setProperty(el, "border-color", color.color.css); | 178 | this.setProperty(el, "border-color", color.color.css); |
176 | if(color.borderInfo) { | 179 | if(color.borderInfo) { |
177 | if(color.borderInfo.borderWidth) { | 180 | if(color.borderInfo.borderWidth) { |
@@ -188,6 +191,25 @@ exports.ElementController = Montage.create(Component, { | |||
188 | } | 191 | } |
189 | }, | 192 | }, |
190 | 193 | ||
194 | setGradientBorder: { | ||
195 | value: function(el, gradientMode, css) { | ||
196 | if(gradientMode === "radial") { | ||
197 | this.setProperty(el, "border-image", css.replace("ellipse", "circle")); | ||
198 | } else { | ||
199 | this.setProperty(el, "border-image", css); | ||
200 | } | ||
201 | this.setProperty(el, "border-color", "none"); | ||
202 | // gradient slice = borderWidth/totalWidth | ||
203 | var b = parseInt(this.getProperty(el, "border-left-width", true)), | ||
204 | w = parseInt(this.getProperty(el, "width", true)), | ||
205 | h = parseInt(this.getProperty(el, "height", true)); | ||
206 | if(h > w) { | ||
207 | w = h; | ||
208 | } | ||
209 | this.setProperty(el, "border-image-slice", Math.floor(b/(w+b+b) * 100) + "%"); | ||
210 | } | ||
211 | }, | ||
212 | |||
191 | getStroke: { | 213 | getStroke: { |
192 | value: function(el) { | 214 | value: function(el) { |
193 | // TODO - Need to figure out which border side user wants | 215 | // TODO - Need to figure out which border side user wants |
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index 38f133b5..626dedb6 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js | |||
@@ -213,7 +213,7 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
213 | default: | 213 | default: |
214 | CanvasController.setProperty(el, p, value); | 214 | CanvasController.setProperty(el, p, value); |
215 | } | 215 | } |
216 | this.application.ninja.documentController.activeDocument.model.needsSave = true; | 216 | this.application.ninja.currentDocument.model.needsSave = true; |
217 | } | 217 | } |
218 | }, | 218 | }, |
219 | 219 | ||
@@ -559,7 +559,7 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
559 | } | 559 | } |
560 | } | 560 | } |
561 | el.elementModel.shapeModel.GLWorld.render(); | 561 | el.elementModel.shapeModel.GLWorld.render(); |
562 | this.application.ninja.documentController.activeDocument.model.needsSave = true; | 562 | this.application.ninja.currentDocument.model.needsSave = true; |
563 | } | 563 | } |
564 | }, | 564 | }, |
565 | 565 | ||