diff options
Diffstat (limited to 'js/controllers')
-rwxr-xr-x | js/controllers/document-controller.js | 32 | ||||
-rwxr-xr-x | js/controllers/elements/canvas-controller.js | 14 | ||||
-rwxr-xr-x | js/controllers/elements/element-controller.js | 112 | ||||
-rwxr-xr-x | js/controllers/elements/shapes-controller.js | 59 | ||||
-rwxr-xr-x | js/controllers/elements/stage-controller.js | 58 |
5 files changed, 128 insertions, 147 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index ddaeb061..1fcdf6d0 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js | |||
@@ -10,8 +10,7 @@ var Montage = require("montage/core/core").Montage, | |||
10 | Component = require("montage/ui/component").Component, | 10 | Component = require("montage/ui/component").Component, |
11 | Uuid = require("montage/core/uuid").Uuid, | 11 | Uuid = require("montage/core/uuid").Uuid, |
12 | HTMLDocument = require("js/document/html-document").HTMLDocument, | 12 | HTMLDocument = require("js/document/html-document").HTMLDocument, |
13 | TextDocument = require("js/document/text-document").TextDocument, | 13 | TextDocument = require("js/document/text-document").TextDocument; |
14 | DocumentController; | ||
15 | //////////////////////////////////////////////////////////////////////// | 14 | //////////////////////////////////////////////////////////////////////// |
16 | // | 15 | // |
17 | var DocumentController = exports.DocumentController = Montage.create(Component, { | 16 | var DocumentController = exports.DocumentController = Montage.create(Component, { |
@@ -19,6 +18,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
19 | value: false | 18 | value: false |
20 | }, | 19 | }, |
21 | 20 | ||
21 | webTemplate: { | ||
22 | value: false | ||
23 | }, | ||
24 | |||
22 | _documents: { | 25 | _documents: { |
23 | value: [] | 26 | value: [] |
24 | }, | 27 | }, |
@@ -65,6 +68,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
65 | this.eventManager.addEventListener("styleSheetDirty", this, false); | 68 | this.eventManager.addEventListener("styleSheetDirty", this, false); |
66 | 69 | ||
67 | this.eventManager.addEventListener("addComponentFirstDraw", this, false); | 70 | this.eventManager.addEventListener("addComponentFirstDraw", this, false); |
71 | |||
72 | // Temporary add listeners for the new stage templates | ||
73 | this.eventManager.addEventListener("executeWebpageOpen", this, false); | ||
74 | this.eventManager.addEventListener("executeNewWebpage", this, false); | ||
68 | } | 75 | } |
69 | }, | 76 | }, |
70 | 77 | ||
@@ -130,6 +137,20 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
130 | } | 137 | } |
131 | }, | 138 | }, |
132 | 139 | ||
140 | handleExecuteWebpageOpen: { | ||
141 | value: function(event) { | ||
142 | this.webTemplate = true; | ||
143 | this.handleExecuteFileOpen(event); | ||
144 | } | ||
145 | }, | ||
146 | |||
147 | handleExecuteNewWebpage: { | ||
148 | value: function(event) { | ||
149 | this.webTemplate = true; | ||
150 | this.handleExecuteNewFile(event); | ||
151 | } | ||
152 | }, | ||
153 | |||
133 | handleExecuteNewFile: { | 154 | handleExecuteNewFile: { |
134 | value: function(event) { | 155 | value: function(event) { |
135 | var newFileSettings = event._event.settings || {}; | 156 | var newFileSettings = event._event.settings || {}; |
@@ -235,7 +256,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
235 | this.creatingNewFile = true;//flag for timeline to identify new file flow | 256 | this.creatingNewFile = true;//flag for timeline to identify new file flow |
236 | 257 | ||
237 | this.application.ninja.ioMediator.fileOpen(response.uri, this.openFileCallback.bind(this)); | 258 | this.application.ninja.ioMediator.fileOpen(response.uri, this.openFileCallback.bind(this)); |
238 | }else if(!!response && !response.success){ | 259 | } else if(!!response && !response.success){ |
239 | //Todo: restrict directory path to the sandbox, in the dialog itself | 260 | //Todo: restrict directory path to the sandbox, in the dialog itself |
240 | alert("Unable to create file.\n [Error: Forbidden directory]"); | 261 | alert("Unable to create file.\n [Error: Forbidden directory]"); |
241 | } | 262 | } |
@@ -311,9 +332,9 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
311 | this.documentHackReference = doc; | 332 | this.documentHackReference = doc; |
312 | // | 333 | // |
313 | switch (doc.extension) { | 334 | switch (doc.extension) { |
314 | case 'html': case 'html': | 335 | case 'html': |
315 | //Open in designer view | 336 | //Open in designer view |
316 | Montage.create(HTMLDocument).initialize(doc, Uuid.generate(), this._createIframeElement(), this._onOpenDocument.bind(this)); | 337 | Montage.create(HTMLDocument).initialize(doc, Uuid.generate(), this._createIframeElement(), this._onOpenDocument.bind(this), this.webTemplate); |
317 | break; | 338 | break; |
318 | default: | 339 | default: |
319 | //Open in code view | 340 | //Open in code view |
@@ -420,6 +441,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
420 | // Event Detail: Contains the current ActiveDocument | 441 | // Event Detail: Contains the current ActiveDocument |
421 | _onOpenDocument: { | 442 | _onOpenDocument: { |
422 | value: function(doc){ | 443 | value: function(doc){ |
444 | this.webTemplate = false; | ||
423 | this.application.ninja.currentDocument = doc; | 445 | this.application.ninja.currentDocument = doc; |
424 | this._hideCurrentDocument(); | 446 | this._hideCurrentDocument(); |
425 | this.application.ninja.stage.stageView.hideOtherDocuments(doc.uuid); | 447 | this.application.ninja.stage.stageView.hideOtherDocuments(doc.uuid); |
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/element-controller.js b/js/controllers/elements/element-controller.js index 2ac84452..35a543ac 100755 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js | |||
@@ -47,10 +47,10 @@ exports.ElementController = Montage.create(Component, { | |||
47 | }, | 47 | }, |
48 | 48 | ||
49 | setProperties: { | 49 | setProperties: { |
50 | value: function(el, props, index) { | 50 | value: function(element, properties) { |
51 | for(var p in props) { | 51 | for(var property in properties) { |
52 | this.application.ninja.stylesController.setElementStyle(el, p, props[p][index]); | 52 | this.application.ninja.stylesController.setElementStyle(element, property, properties[property]); |
53 | } | 53 | } |
54 | } | 54 | } |
55 | }, | 55 | }, |
56 | 56 | ||
@@ -65,37 +65,29 @@ exports.ElementController = Montage.create(Component, { | |||
65 | // borderSide : "top", "right", "bottom", or "left" | 65 | // borderSide : "top", "right", "bottom", or "left" |
66 | getColor: { | 66 | getColor: { |
67 | value: function(el, isFill, borderSide) { | 67 | value: function(el, isFill, borderSide) { |
68 | var colorObj, | 68 | var colorObj, color, image; |
69 | color, | ||
70 | image; | ||
71 | 69 | ||
72 | // Return cached value if one exists | 70 | // Return cached value if one exists |
73 | if(isFill) | 71 | if(isFill) { |
74 | { | 72 | if(el.elementModel.fill) { |
75 | if(el.elementModel.fill) | ||
76 | { | ||
77 | return el.elementModel.fill; | 73 | return el.elementModel.fill; |
78 | } | 74 | } |
79 | //TODO: Once logic for color and gradient is established, this needs to be revised | 75 | //TODO: Once logic for color and gradient is established, this needs to be revised |
80 | color = this.getProperty(el, "background-color"); | 76 | color = this.getProperty(el, "background-color"); |
81 | image = this.getProperty(el, "background-image"); | 77 | image = this.getProperty(el, "background-image"); |
82 | } | 78 | } else { |
83 | else | ||
84 | { | ||
85 | // Try getting border color from specific side first | 79 | // Try getting border color from specific side first |
86 | if(borderSide) | 80 | if(borderSide) { |
87 | { | ||
88 | color = this.getProperty(el, "border-" + borderSide + "-color"); | 81 | color = this.getProperty(el, "border-" + borderSide + "-color"); |
89 | image = this.getProperty(el, "border-" + borderSide + "-image"); | 82 | image = this.getProperty(el, "border-" + borderSide + "-image"); |
90 | } | 83 | } |
91 | 84 | ||
92 | // If no color was found, look up the shared border color | 85 | // If no color was found, look up the shared border color |
93 | if(!color && !image) | 86 | if(!color && !image) { |
94 | { | 87 | if(el.elementModel.stroke) { |
95 | if(el.elementModel.stroke) | ||
96 | { | ||
97 | return el.elementModel.stroke; | 88 | return el.elementModel.stroke; |
98 | } | 89 | } |
90 | |||
99 | color = this.getProperty(el, "border-color"); | 91 | color = this.getProperty(el, "border-color"); |
100 | image = this.getProperty(el, "border-image"); | 92 | image = this.getProperty(el, "border-image"); |
101 | } | 93 | } |
@@ -112,17 +104,12 @@ exports.ElementController = Montage.create(Component, { | |||
112 | } | 104 | } |
113 | 105 | ||
114 | // Update cache | 106 | // Update cache |
115 | if(isFill) | 107 | if(isFill) { |
116 | { | ||
117 | el.elementModel.fill = colorObj; | 108 | el.elementModel.fill = colorObj; |
118 | } | 109 | } else if(!borderSide) { |
119 | else if(!borderSide) | ||
120 | { | ||
121 | // TODO - Need to update border style and width also | 110 | // TODO - Need to update border style and width also |
122 | el.elementModel.stroke = colorObj; | 111 | el.elementModel.stroke = colorObj; |