diff options
Diffstat (limited to 'js/controllers')
-rwxr-xr-x | js/controllers/document-controller.js | 73 | ||||
-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, 165 insertions, 151 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index ddaeb061..4be0767a 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js | |||
@@ -10,8 +10,10 @@ 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; | 14 | |
15 | // New Document Objects | ||
16 | var Document = require("js/document/document-html").HtmlDocument; | ||
15 | //////////////////////////////////////////////////////////////////////// | 17 | //////////////////////////////////////////////////////////////////////// |
16 | // | 18 | // |
17 | var DocumentController = exports.DocumentController = Montage.create(Component, { | 19 | var DocumentController = exports.DocumentController = Montage.create(Component, { |
@@ -19,6 +21,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
19 | value: false | 21 | value: false |
20 | }, | 22 | }, |
21 | 23 | ||
24 | webTemplate: { | ||
25 | value: false | ||
26 | }, | ||
27 | |||
22 | _documents: { | 28 | _documents: { |
23 | value: [] | 29 | value: [] |
24 | }, | 30 | }, |
@@ -65,6 +71,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
65 | this.eventManager.addEventListener("styleSheetDirty", this, false); | 71 | this.eventManager.addEventListener("styleSheetDirty", this, false); |
66 | 72 | ||
67 | this.eventManager.addEventListener("addComponentFirstDraw", this, false); | 73 | this.eventManager.addEventListener("addComponentFirstDraw", this, false); |
74 | |||
75 | // Temporary add listeners for the new stage templates | ||
76 | this.eventManager.addEventListener("executeWebpageOpen", this, false); | ||
77 | this.eventManager.addEventListener("executeNewWebpage", this, false); | ||
68 | } | 78 | } |
69 | }, | 79 | }, |
70 | 80 | ||
@@ -130,6 +140,20 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
130 | } | 140 | } |
131 | }, | 141 | }, |
132 | 142 | ||
143 | handleExecuteWebpageOpen: { | ||
144 | value: function(event) { | ||
145 | this.webTemplate = true; | ||
146 | this.handleExecuteFileOpen(event); | ||
147 | } | ||
148 | }, | ||
149 | |||
150 | handleExecuteNewWebpage: { | ||
151 | value: function(event) { | ||
152 | this.webTemplate = true; | ||
153 | this.handleExecuteNewFile(event); | ||
154 | } | ||
155 | }, | ||
156 | |||
133 | handleExecuteNewFile: { | 157 | handleExecuteNewFile: { |
134 | value: function(event) { | 158 | value: function(event) { |
135 | var newFileSettings = event._event.settings || {}; | 159 | var newFileSettings = event._event.settings || {}; |
@@ -235,7 +259,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
235 | this.creatingNewFile = true;//flag for timeline to identify new file flow | 259 | this.creatingNewFile = true;//flag for timeline to identify new file flow |
236 | 260 | ||
237 | this.application.ninja.ioMediator.fileOpen(response.uri, this.openFileCallback.bind(this)); | 261 | this.application.ninja.ioMediator.fileOpen(response.uri, this.openFileCallback.bind(this)); |
238 | }else if(!!response && !response.success){ | 262 | } else if(!!response && !response.success){ |
239 | //Todo: restrict directory path to the sandbox, in the dialog itself | 263 | //Todo: restrict directory path to the sandbox, in the dialog itself |
240 | alert("Unable to create file.\n [Error: Forbidden directory]"); | 264 | alert("Unable to create file.\n [Error: Forbidden directory]"); |
241 | } | 265 | } |
@@ -268,7 +292,12 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
268 | this.isNewFilePath = false;//reset path identifier flag | 292 | this.isNewFilePath = false;//reset path identifier flag |
269 | 293 | ||
270 | //Sending full response object | 294 | //Sending full response object |
271 | this.openDocument(response); | 295 | // TODO: Unify those 2 methods. Using if/else for the new template |
296 | if(this.webTemplate) { | ||
297 | this.openWebDocument(response); | ||
298 | } else { | ||
299 | this.openDocument(response); | ||
300 | } | ||
272 | } else if (!!response && (response.status === 404)){ | 301 | } else if (!!response && (response.status === 404)){ |
273 | alert("Unable to open file.\n [Error: File does not exist]"); | 302 | alert("Unable to open file.\n [Error: File does not exist]"); |
274 | } else if (!!response && (response.status === 500)){ | 303 | } else if (!!response && (response.status === 500)){ |
@@ -311,7 +340,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
311 | this.documentHackReference = doc; | 340 | this.documentHackReference = doc; |
312 | // | 341 | // |
313 | switch (doc.extension) { | 342 | switch (doc.extension) { |
314 | case 'html': case 'html': | 343 | case 'html': |
315 | //Open in designer view | 344 | //Open in designer view |
316 | Montage.create(HTMLDocument).initialize(doc, Uuid.generate(), this._createIframeElement(), this._onOpenDocument.bind(this)); | 345 | Montage.create(HTMLDocument).initialize(doc, Uuid.generate(), this._createIframeElement(), this._onOpenDocument.bind(this)); |
317 | break; | 346 | break; |
@@ -327,6 +356,30 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
327 | } | 356 | } |
328 | } | 357 | } |
329 | }, | 358 | }, |
359 | openWebDocument: { | ||
360 | value: function(doc) { | ||
361 | // TODO: HACKS to remove | ||
362 | this.documentHackReference = doc; | ||
363 | document.getElementById("iframeContainer").style.overflow = "hidden"; | ||
364 | // | ||
365 | switch (doc.extension) { | ||
366 | case 'html': | ||
367 | //Open in designer view | ||
368 | this._hackRootFlag = false; | ||
369 | Montage.create(Document).init(doc, this, this._onOpenDocument); | ||
370 | break; | ||
371 | default: | ||
372 | //Open in code view | ||
373 | var code = Montage.create(TextDocument, {"source": {value: doc.content}}), docuuid = Uuid.generate(), textArea; | ||
374 | textArea = this.application.ninja.stage.stageView.createTextAreaElement(docuuid); | ||
375 | code.initialize(doc, docuuid, textArea, textArea.parentNode); | ||
376 | //code.init(doc.name, doc.uri, doc.extension, null, docuuid); | ||
377 | code.textArea.value = doc.content; | ||
378 | this.application.ninja.stage.stageView.createTextView(code); | ||
379 | break; | ||
380 | } | ||
381 | } | ||
382 | }, | ||
330 | //////////////////////////////////////////////////////////////////// | 383 | //////////////////////////////////////////////////////////////////// |
331 | 384 | ||
332 | openProjectWithURI: { | 385 | openProjectWithURI: { |
@@ -428,11 +481,13 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
428 | 481 | ||
429 | this.activeDocument = doc; | 482 | this.activeDocument = doc; |
430 | 483 | ||
431 | this._showCurrentDocument(); | 484 | if(!this.webTemplate) { |
485 | this._showCurrentDocument(); | ||
486 | } | ||
487 | |||
488 | this.webTemplate = false; | ||
432 | 489 | ||
433 | NJevent("onOpenDocument", doc); | 490 | NJevent("onOpenDocument", doc); |
434 | // appDelegateModule.MyAppDelegate.onSetActiveDocument(); | ||
435 | |||
436 | } | 491 | } |
437 | }, | 492 | }, |
438 | 493 | ||
@@ -526,7 +581,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
526 | this.application.ninja.stage.stageView.showRulers(); | 581 | this.application.ninja.stage.stageView.showRulers(); |
527 | }else{ | 582 | }else{ |
528 | //hide the iframe when switching to code view | 583 | //hide the iframe when switching to code view |
529 | document.getElementById("iframeContainer").style.display="none"; | 584 | document.getElementById("iframeContainer").style.display = "none"; |
530 | } | 585 | } |
531 | } | 586 | } |
532 | } | 587 | } |
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" |