diff options
Diffstat (limited to 'js/controllers')
-rwxr-xr-x | js/controllers/color-controller.js | 4 | ||||
-rwxr-xr-x | js/controllers/document-controller.js | 19 | ||||
-rwxr-xr-x | js/controllers/elements/canvas-controller.js | 14 | ||||
-rwxr-xr-x | js/controllers/elements/component-controller.js | 2 | ||||
-rwxr-xr-x | js/controllers/elements/element-controller.js | 184 | ||||
-rwxr-xr-x | js/controllers/elements/shapes-controller.js | 487 | ||||
-rwxr-xr-x | js/controllers/elements/stage-controller.js | 94 | ||||
-rw-r--r-- | js/controllers/presets-controller.js | 130 | ||||
-rwxr-xr-x | js/controllers/selection-controller.js | 154 | ||||
-rwxr-xr-x | js/controllers/styles-controller.js | 69 |
10 files changed, 718 insertions, 439 deletions
diff --git a/js/controllers/color-controller.js b/js/controllers/color-controller.js index 8e000b19..c6d664cf 100755 --- a/js/controllers/color-controller.js +++ b/js/controllers/color-controller.js | |||
@@ -227,14 +227,14 @@ exports.ColorController = Montage.create(Component, { | |||
227 | // | 227 | // |
228 | this.fill = color; | 228 | this.fill = color; |
229 | // | 229 | // |
230 | if(e._event.wasSetByCode && mode !== 'nocolor') return; | 230 | if(e._event.wasSetByCode) return; |
231 | // | 231 | // |
232 | this.setColor(mode, color, true); | 232 | this.setColor(mode, color, true); |
233 | } else if (input === 'stroke') { | 233 | } else if (input === 'stroke') { |
234 | // | 234 | // |
235 | this.stroke = color; | 235 | this.stroke = color; |
236 | // | 236 | // |
237 | if(e._event.wasSetByCode && mode !== 'nocolor') return; | 237 | if(e._event.wasSetByCode) return; |
238 | 238 | ||
239 | this.setColor(mode, color, false); | 239 | this.setColor(mode, color, false); |
240 | } | 240 | } |
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index d5556fa8..ddaeb061 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js | |||
@@ -38,13 +38,12 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
38 | return this._activeDocument; | 38 | return this._activeDocument; |
39 | }, | 39 | }, |
40 | set: function(doc) { | 40 | set: function(doc) { |
41 | if(!!this._activeDocument) this._activeDocument.isActive = false; | 41 | if(!!this._activeDocument){ this._activeDocument.isActive = false;} |
42 | |||
43 | this._activeDocument = doc; | 42 | this._activeDocument = doc; |
44 | if(!!this._activeDocument){ | 43 | if(!!this._activeDocument){ |
45 | |||
46 | if(this._documents.indexOf(doc) === -1) this._documents.push(doc); | 44 | if(this._documents.indexOf(doc) === -1) this._documents.push(doc); |
47 | this._activeDocument.isActive = true; | 45 | this._activeDocument.isActive = true; |
46 | |||
48 | if(!!this._activeDocument.editor){ | 47 | if(!!this._activeDocument.editor){ |
49 | this._activeDocument.editor.focus(); | 48 | this._activeDocument.editor.focus(); |
50 | } | 49 | } |
@@ -61,6 +60,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
61 | this.eventManager.addEventListener("executeSaveAs", this, false); | 60 | this.eventManager.addEventListener("executeSaveAs", this, false); |
62 | this.eventManager.addEventListener("executeSaveAll", this, false); | 61 | this.eventManager.addEventListener("executeSaveAll", this, false); |
63 | this.eventManager.addEventListener("executeFileClose", this, false); | 62 | this.eventManager.addEventListener("executeFileClose", this, false); |
63 | this.eventManager.addEventListener("executeFileCloseAll", this, false); | ||
64 | 64 | ||
65 | this.eventManager.addEventListener("styleSheetDirty", this, false); | 65 | this.eventManager.addEventListener("styleSheetDirty", this, false); |
66 | 66 | ||
@@ -71,7 +71,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
71 | handleAddComponentFirstDraw: { | 71 | handleAddComponentFirstDraw: { |
72 | value: function (e) { | 72 | value: function (e) { |
73 | //TODO: Add logic to reparse the document for dynamically added styles | 73 | //TODO: Add logic to reparse the document for dynamically added styles |
74 | console.log(e); | 74 | //console.log(e); |
75 | } | 75 | } |
76 | }, | 76 | }, |
77 | 77 | ||
@@ -180,6 +180,17 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
180 | } | 180 | } |
181 | }, | 181 | }, |
182 | //////////////////////////////////////////////////////////////////// | 182 | //////////////////////////////////////////////////////////////////// |
183 | handleExecuteFileCloseAll:{ | ||
184 | value: function(event) { | ||
185 | var i=0; | ||
186 | if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ | ||
187 | while(this._documents.length > 0){ | ||
188 | this.closeDocument(this._documents[this._documents.length -1].uuid); | ||
189 | } | ||
190 | } | ||
191 | } | ||
192 | }, | ||
193 | //////////////////////////////////////////////////////////////////// | ||
183 | // | 194 | // |
184 | fileSaveResult: { | 195 | fileSaveResult: { |
185 | value: function (result) { | 196 | value: function (result) { |
diff --git a/js/controllers/elements/canvas-controller.js b/js/controllers/elements/canvas-controller.js index b5df3911..b8894c18 100755 --- a/js/controllers/elements/canvas-controller.js +++ b/js/controllers/elements/canvas-controller.js | |||
@@ -34,12 +34,12 @@ exports.CanvasController = Montage.create(ElementController, { | |||
34 | } | 34 | } |
35 | } | 35 | } |
36 | }, | 36 | }, |
37 | 37 | ||
38 | setProperties: { | 38 | setProperties: { |
39 | value: function(el, props, index) { | 39 | value: function(element, properties) { |
40 | for(var p in props) { | 40 | for(var property in properties) { |
41 | el.elementModel.controller.setProperty(el, p, props[p][index]); | 41 | this.setProperty(element, property, properties[property]); |
42 | } | 42 | } |
43 | } | 43 | } |
44 | } | 44 | } |
45 | }); \ No newline at end of file | 45 | }); \ No newline at end of file |
diff --git a/js/controllers/elements/component-controller.js b/js/controllers/elements/component-controller.js index 260ee8a0..d902e4a1 100755 --- a/js/controllers/elements/component-controller.js +++ b/js/controllers/elements/component-controller.js | |||
@@ -16,6 +16,7 @@ exports.ComponentController = Montage.create(ElementController, { | |||
16 | switch(prop) { | 16 | switch(prop) { |
17 | case "id": | 17 | case "id": |
18 | case "class": | 18 | case "class": |
19 | case "-webkit-transform-style": | ||
19 | case "left": | 20 | case "left": |
20 | case "top": | 21 | case "top": |
21 | case "width": | 22 | case "width": |
@@ -38,6 +39,7 @@ exports.ComponentController = Montage.create(ElementController, { | |||
38 | switch(p) { | 39 | switch(p) { |
39 | case "id": | 40 | case "id": |
40 | case "class": | 41 | case "class": |
42 | case "-webkit-transform-style": | ||
41 | case "left": | 43 | case "left": |
42 | case "top": | 44 | case "top": |
43 | case "width": | 45 | case "width": |
diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index b35251ad..35a543ac 100755 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js | |||
@@ -5,22 +5,27 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
5 | </copyright> */ | 5 | </copyright> */ |
6 | 6 | ||
7 | var Montage = require("montage/core/core").Montage, | 7 | var Montage = require("montage/core/core").Montage, |
8 | NJComponent = require("js/lib/nj-base").NJComponent; | 8 | Component = require("montage/ui/component").Component; |
9 | 9 | ||
10 | var ElementController = exports.ElementController = Montage.create(NJComponent, { | 10 | exports.ElementController = Montage.create(Component, { |
11 | 11 | ||
12 | addElement: { | 12 | addElement: { |
13 | value: function(el, styles) { | 13 | value: function(el, styles) { |
14 | this.application.ninja.currentDocument.documentRoot.appendChild(el); | 14 | this.application.ninja.currentDocument.documentRoot.appendChild(el); |
15 | // Nested elements - | 15 | // Nested elements - TODO make sure the CSS is correct before nesting elements |
16 | // TODO make sure the CSS is correct before nesting elements | ||
17 | // this.application.ninja.currentSelectedContainer.appendChild(el); | 16 | // this.application.ninja.currentSelectedContainer.appendChild(el); |
18 | this.application.ninja.stylesController.setElementStyles(el, styles); | 17 | if(styles) { |
18 | this.application.ninja.stylesController.setElementStyles(el, styles); | ||
19 | } | ||
19 | } | 20 | } |
20 | }, | 21 | }, |
21 | 22 | ||
23 | // Remove the element from the DOM and clear the GLWord. | ||
22 | removeElement: { | 24 | removeElement: { |
23 | value: function(el) { | 25 | value: function(el) { |
26 | if(el.elementModel && el.elementModel.shapeModel && el.elementModel.shapeModel.GLWorld) { | ||
27 | el.elementModel.shapeModel.GLWorld.clearTree(); | ||
28 | } | ||
24 | el.parentNode.removeChild(el); | 29 | el.parentNode.removeChild(el); |
25 | } | 30 | } |
26 | }, | 31 | }, |
@@ -42,10 +47,10 @@ var ElementController = exports.ElementController = Montage.create(NJComponent, | |||
42 | }, | 47 | }, |
43 | 48 | ||
44 | setProperties: { | 49 | setProperties: { |
45 | value: function(el, props, index) { | 50 | value: function(element, properties) { |
46 | for(var p in props) { | 51 | for(var property in properties) { |
47 | this.application.ninja.stylesController.setElementStyle(el, p, props[p][index]); | 52 | this.application.ninja.stylesController.setElementStyle(element, property, properties[property]); |
48 | } | 53 | } |
49 | } | 54 | } |
50 | }, | 55 | }, |
51 | 56 | ||
@@ -60,37 +65,29 @@ var ElementController = exports.ElementController = Montage.create(NJComponent, | |||
60 | // borderSide : "top", "right", "bottom", or "left" | 65 | // borderSide : "top", "right", "bottom", or "left" |
61 | getColor: { | 66 | getColor: { |
62 | value: function(el, isFill, borderSide) { | 67 | value: function(el, isFill, borderSide) { |
63 | var colorObj, | 68 | var colorObj, color, image; |
64 | color, | ||
65 | image; | ||
66 | 69 | ||
67 | // Return cached value if one exists | 70 |