aboutsummaryrefslogtreecommitdiff
path: root/js/controllers
diff options
context:
space:
mode:
authorAnanya Sen2012-04-26 12:57:56 -0700
committerAnanya Sen2012-04-26 12:57:56 -0700
commitb2132103b12e499f26e6e0f311d48555a9f733ff (patch)
tree2eaa000b460e4be3c8050a369318584b2591e8d7 /js/controllers
parent07c611323c109aaa2208ebc15a354b81c3f04a0d (diff)
parent902dc18296fc78f3b8e67d952c42981d926bb2fc (diff)
downloadninja-b2132103b12e499f26e6e0f311d48555a9f733ff.tar.gz
Merge branch 'refs/heads/ninja-internal-master' into Codeview-improvements
Conflicts: js/controllers/document-controller.js Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js/controllers')
-rwxr-xr-xjs/controllers/document-controller.js74
-rwxr-xr-xjs/controllers/elements/element-controller.js16
-rwxr-xr-xjs/controllers/elements/shapes-controller.js20
-rwxr-xr-xjs/controllers/elements/stage-controller.js2
4 files changed, 87 insertions, 25 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index 0d9b37ed..1cb66d3f 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
16var Document = require("js/document/document-html").HtmlDocument;
15//////////////////////////////////////////////////////////////////////// 17////////////////////////////////////////////////////////////////////////
16// 18//
17var DocumentController = exports.DocumentController = Montage.create(Component, { 19var 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,12 +481,15 @@ 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 491
436 this.application.ninja.stage.stageView.showCodeViewBar(false); 492 this.application.ninja.stage.stageView.showCodeViewBar(false);
437 this.application.ninja.stage.stageView.restoreAllPanels(); 493 this.application.ninja.stage.stageView.restoreAllPanels();
438 } 494 }
439 }, 495 },
@@ -528,7 +584,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
528 this.application.ninja.stage.stageView.showRulers(); 584 this.application.ninja.stage.stageView.showRulers();
529 }else{ 585 }else{
530 //hide the iframe when switching to code view 586 //hide the iframe when switching to code view
531 document.getElementById("iframeContainer").style.display="none"; 587 document.getElementById("iframeContainer").style.display = "none";
532 } 588 }
533 } 589 }
534 } 590 }
diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js
index 35a543ac..452d09f1 100755
--- a/js/controllers/elements/element-controller.js
+++ b/js/controllers/elements/element-controller.js
@@ -152,16 +152,24 @@ exports.ElementController = Montage.create(Component, {
152 this.setProperty(el, "border-image", color.color.css); 152 this.setProperty(el, "border-image", color.color.css);
153 this.setProperty(el, "border-color", "none"); 153 this.setProperty(el, "border-color", "none");
154 if(color.borderInfo) { 154 if(color.borderInfo) {
155 this.setProperty(el, "border-width", color.borderInfo.borderWidth + color.borderInfo.borderUnits); 155 if(color.borderInfo.borderWidth) {
156 this.setProperty(el, "border-style", color.borderInfo.borderStyle); 156 this.setProperty(el, "border-width", color.borderInfo.borderWidth + color.borderInfo.borderUnits);
157 }
158 if(color.borderInfo.borderStyle) {
159 this.setProperty(el, "border-style", color.borderInfo.borderStyle);
160 }
157 } 161 }
158 break; 162 break;
159 default: 163 default:
160 this.setProperty(el, "border-image", "none"); 164 this.setProperty(el, "border-image", "none");
161 this.setProperty(el, "border-color", color.color.css); 165 this.setProperty(el, "border-color", color.color.css);
162 if(color.borderInfo) { 166 if(color.borderInfo) {
163 this.setProperty(el, "border-width", color.borderInfo.borderWidth + color.borderInfo.borderUnits); 167 if(color.borderInfo.borderWidth) {
164 this.setProperty(el, "border-style", color.borderInfo.borderStyle); 168 this.setProperty(el, "border-width", color.borderInfo.borderWidth + color.borderInfo.borderUnits);
169 }
170 if(color.borderInfo.borderStyle) {
171 this.setProperty(el, "border-style", color.borderInfo.borderStyle);
172 }
165 } 173 }
166 }