aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rwxr-xr-xjs/controllers/document-controller.js194
-rwxr-xr-xjs/data/menu-data.js4
-rwxr-xr-xjs/stage/stage-view.reel/stage-view.js33
3 files changed, 59 insertions, 172 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index ecb988ff..1796f9b5 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -21,10 +21,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
21 value: false 21 value: false
22 }, 22 },
23 23
24 webTemplate: {
25 value: false
26 },
27
28 _documents: { 24 _documents: {
29 value: [] 25 value: []
30 }, 26 },
@@ -75,10 +71,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
75 this.eventManager.addEventListener("executeFileCloseAll", this, false); 71 this.eventManager.addEventListener("executeFileCloseAll", this, false);
76 72
77 this.eventManager.addEventListener("styleSheetDirty", this, false); 73 this.eventManager.addEventListener("styleSheetDirty", this, false);
78
79 // Temporary add listeners for the new stage templates
80 this.eventManager.addEventListener("executeWebpageOpen", this, false);
81 this.eventManager.addEventListener("executeNewWebpage", this, false);
82 } 74 }
83 }, 75 },
84 76
@@ -138,20 +130,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
138 } 130 }
139 }, 131 },
140 132
141 handleExecuteWebpageOpen: {
142 value: function(event) {
143 this.webTemplate = true;
144 this.handleExecuteFileOpen(event);
145 }
146 },
147
148 handleExecuteNewWebpage: {
149 value: function(event) {
150 this.webTemplate = true;
151 this.handleExecuteNewFile(event);
152 }
153 },
154
155 handleExecuteNewFile: { 133 handleExecuteNewFile: {
156 value: function(event) { 134 value: function(event) {
157 var newFileSettings = event._event.settings || {}; 135 var newFileSettings = event._event.settings || {};
@@ -304,12 +282,8 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
304 this.isNewFilePath = false;//reset path identifier flag 282 this.isNewFilePath = false;//reset path identifier flag
305 283
306 //Sending full response object 284 //Sending full response object
307 // TODO: Unify those 2 methods. Using if/else for the new template 285 this.openDocument(response);
308 if(this.webTemplate) { 286
309 this.openWebDocument(response);
310 } else {
311 this.openDocument(response);
312 }
313 } else if (!!response && (response.status === 404)){ 287 } else if (!!response && (response.status === 404)){
314 alert("Unable to open file.\n [Error: File does not exist]"); 288 alert("Unable to open file.\n [Error: File does not exist]");
315 } else if (!!response && (response.status === 500)){ 289 } else if (!!response && (response.status === 500)){
@@ -345,30 +319,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
345 }, 319 },
346 320
347 //////////////////////////////////////////////////////////////////// 321 ////////////////////////////////////////////////////////////////////
348 openDocument: { 322 openDocument: {
349 value: function(doc) {
350
351 //
352 this.documentHackReference = doc;
353 //
354 switch (doc.extension) {
355 case 'html':
356 //Open in designer view
357 Montage.create(HTMLDocument).initialize(doc, Uuid.generate(), this._createIframeElement(), this._onOpenDocument.bind(this));
358 break;
359 default:
360 //Open in code view
361 var code = Montage.create(TextDocument, {"source": {value: doc.content}}), docuuid = Uuid.generate(), textArea;
362 textArea = this.application.ninja.stage.stageView.createTextAreaElement(docuuid);
363 code.initialize(doc, docuuid, textArea, textArea.parentNode);
364 //code.init(doc.name, doc.uri, doc.extension, null, docuuid);
365 code.textArea.value = doc.content;
366 this.application.ninja.stage.stageView.createTextView(code);
367 break;
368 }
369 }
370 },
371 openWebDocument: {
372 value: function(doc) { 323 value: function(doc) {
373 var template, dimensions; 324 var template, dimensions;
374 if (doc.content.body.indexOf('Ninja-Banner Dimensions@@@') !== -1) { 325 if (doc.content.body.indexOf('Ninja-Banner Dimensions@@@') !== -1) {
@@ -484,14 +435,14 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
484 } 435 }
485 this.application.ninja.stage.stageView.switchDocument(this._documents[nextDocumentIndex]); 436 this.application.ninja.stage.stageView.switchDocument(this._documents[nextDocumentIndex]);
486 if(typeof doc.stopVideos !== "undefined"){doc.stopVideos();} 437 if(typeof doc.stopVideos !== "undefined"){doc.stopVideos();}
487 this._removeDocumentView(doc.container); 438 doc.container.parentNode.removeChild(doc.container);
488 }else if(this._documents.length === 0){ 439 }else if(this._documents.length === 0){
489 // See above 440 // See above
490 }else{//closing inactive document tab - just clear DOM 441 }else{//closing inactive document tab - just clear DOM
491 if(typeof doc.pauseAndStopVideos !== "undefined"){ 442 if(typeof doc.pauseAndStopVideos !== "undefined"){
492 doc.pauseAndStopVideos(); 443 doc.pauseAndStopVideos();
493 } 444 }
494 this._removeDocumentView(doc.container); 445 doc.container.parentNode.removeChild(doc.container);
495 } 446 }
496 447
497 NJevent("closeDocument", doc.uri); 448 NJevent("closeDocument", doc.uri);
@@ -500,41 +451,65 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
500 } 451 }
501 }, 452 },
502 453
503 // Document has been loaded into the Iframe. Dispatch the event. 454 // Open document callback
504 // Event Detail: Contains the current ActiveDocument
505 _onOpenDocument: { 455 _onOpenDocument: {
506 value: function(doc){ 456 value: function(doc){
507 this.application.ninja.currentDocument = doc;
508 this._hideCurrentDocument();
509 this.application.ninja.stage.stageView.hideOtherDocuments(doc.uuid);
510 457
511 this.application.ninja.stage.hideCanvas(false); 458 if(this.activeDocument) {
459 // There is a document currently opened
512 460
513 this.activeDocument = doc; 461// this.application.ninja.stage.stageView.showCodeViewBar(false);
462// this.application.ninja.stage.stageView.restoreAllPanels();
514 463
515 if(!this.webTemplate) { 464 //
516 this._showCurrentDocument(); 465 /*
466 if(this.activeDocument.currentView === "design"){
467 this.activeDocument.saveAppState();
468 this.activeDocument.container.parentNode.style["display"] = "none";
469 this.application.ninja.stage.hideCanvas(true);
470 this.application.ninja.stage.stageView.hideRulers();
471 }
472
473 this.activeDocument.container.style["display"] = "none";
474 */
475 // hide current document
517 } else { 476 } else {
518 this.application.ninja.stage.stageView.showRulers(); 477 // There is no document opened
519 }
520 478
521 this.webTemplate = false; 479 // Set the active document
480 this.activeDocument = doc;
522 481
523 this._initializeBodyStyles(); 482 // Show the canvas
524 NJevent("onOpenDocument", doc); 483 this.application.ninja.stage.hideCanvas(false);
484
485 // Show the rulers
486 // TODO: Move this indo design view
487 this.application.ninja.stage.stageView.showRulers();
525 488
526 this.application.ninja.stage.stageView.showCodeViewBar(false); 489 // Initialize the documentRoot styles
527 this.application.ninja.stage.stageView.restoreAllPanels(); 490 this.initializeRootStyles(doc.documentRoot);
491 // Flag to stop stylesheet dirty event
492 this._hackInitialStyles = false;
528 493
529 // Flag to stop stylesheet dirty event 494 NJevent("onOpenDocument", doc);
530 this._hackInitialStyles = false; 495 }
531 } 496 }
532 }, 497 },
533 498
534 499
535 _onOpenTextDocument: { 500 _onOpenTextDocument: {
536 value: function(doc) { 501 value: function(doc) {
537 this._hideCurrentDocument(); 502 if(this.activeDocument) {
503 if(this.activeDocument.currentView === "design"){
504 this.activeDocument.saveAppState();
505 this.activeDocument.container.parentNode.style["display"] = "none";
506 this.application.ninja.stage.hideCanvas(true);
507 this.application.ninja.stage.stageView.hideRulers();
508 }
509
510 this.activeDocument.container.style["display"] = "none";
511 }
512
538 this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe 513 this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe
539 this.activeDocument = doc; 514 this.activeDocument = doc;
540 515
@@ -589,21 +564,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
589 } 564 }
590 }, 565 },