aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorValerio Virgillito2012-05-16 23:19:32 -0700
committerValerio Virgillito2012-05-16 23:19:32 -0700
commit402a369c7bf164c3c6686be3a33f5e36f25e4130 (patch)
tree96550b64edc3d6b4fc63c40b957fb1ff5ff3babe /js
parentc26de5fa7b909a53b103b72027b5cbe7c3e1c49f (diff)
downloadninja-402a369c7bf164c3c6686be3a33f5e36f25e4130.tar.gz
document controller and stage view code cleanup
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'js')
-rwxr-xr-xjs/controllers/document-controller.js33
-rwxr-xr-xjs/document/document-html.js21
-rwxr-xr-xjs/document/html-document.js26
-rwxr-xr-xjs/document/models/html.js5
-rwxr-xr-xjs/stage/stage-view.reel/stage-view.js17
5 files changed, 55 insertions, 47 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index 1796f9b5..cf46e73e 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -458,8 +458,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
458 if(this.activeDocument) { 458 if(this.activeDocument) {
459 // There is a document currently opened 459 // There is a document currently opened
460 460
461// this.application.ninja.stage.stageView.showCodeViewBar(false); 461
462// this.application.ninja.stage.stageView.restoreAllPanels(); 462
463 //this.application.ninja.stage.stageView.showCodeViewBar(false);
464 //this.application.ninja.stage.stageView.restoreAllPanels();
463 465
464 // 466 //
465 /* 467 /*
@@ -472,6 +474,18 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
472 474
473 this.activeDocument.container.style["display"] = "none"; 475 this.activeDocument.container.style["display"] = "none";
474 */ 476 */
477
478 /*
479 this.activeDocument.container.style["display"] = "block";
480 if(this.activeDocument.currentView === "design"){
481 this.activeDocument.container.parentNode.style["display"] = "block";
482 this.activeDocument.restoreAppState();
483 }else{
484 //hide the iframe when switching to code view
485 document.getElementById("iframeContainer").style.display = "none";
486 }
487
488 */
475 // hide current document 489 // hide current document
476 } else { 490 } else {
477 // There is no document opened 491 // There is no document opened
@@ -564,21 +578,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
564 } 578 }
565 }, 579 },
566 580
567 _showCurrentDocument: {
568 value: function() {
569 if(this.activeDocument) {
570 this.activeDocument.container.style["display"] = "block";
571 if(this.activeDocument.currentView === "design"){
572 this.activeDocument.container.parentNode.style["display"] = "block";
573 this.activeDocument.restoreAppState();
574 }else{
575 //hide the iframe when switching to code view
576 document.getElementById("iframeContainer").style.display = "none";
577 }
578 }
579 }
580 },
581
582 handleStyleSheetDirty:{ 581 handleStyleSheetDirty:{
583 value:function(){ 582 value:function(){
584 if(!this._hackInitialStyles) { 583 if(!this._hackInitialStyles) {
diff --git a/js/document/document-html.js b/js/document/document-html.js
index a26b74d5..56d9db02 100755
--- a/js/document/document-html.js
+++ b/js/document/document-html.js
@@ -134,14 +134,29 @@ exports.HtmlDocument = Montage.create(Component, {
134 }, 134 },
135 //////////////////////////////////////////////////////////////////// 135 ////////////////////////////////////////////////////////////////////
136 // 136 //
137 saveAppState: { 137 serializeDocument: {
138 value: function () { 138 value: function () {
139 //TODO: Import functionality 139 // There are not needed for now ssince we cannot change them
140 //this.gridHorizontalSpacing = this.application.ninja.stage.drawUtils.gridHorizontalSpacing;
141 //this.gridVerticalSpacing = this.application.ninja.stage.drawUtils.gridVerticalSpacing;
142
143 // Serialize the current scroll position
144 // TODO: Implement
145
146 // Serialize the selection
147 this.model.selection = this.application.ninja.selectedElements.slice(0);
148 this.draw3DGrid = this.application.ninja.appModel.show3dGrid;
149
150 // Serialize the undo
151 // TODO: Save the montage undo queue
152
153 // Pause the videos
154 this.model.views.design.pauseVideos();
140 } 155 }
141 }, 156 },
142 //////////////////////////////////////////////////////////////////// 157 ////////////////////////////////////////////////////////////////////
143 // 158 //
144 restoreAppState: { 159 deserializeDocument: {
145 value: function () { 160 value: function () {
146 //TODO: Import functionality 161 //TODO: Import functionality
147 } 162 }
diff --git a/js/document/html-document.js b/js/document/html-document.js
index 6a84abdf..68c2a9fb 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -920,32 +920,6 @@ exports.HTMLDocument = Montage.create(TextDocument, {
920 } 920 }
921 } 921 }
922 }, 922 },
923 ////////////////////////////////////////////////////////////////////
924 saveAppState:{
925 enumerable: false,
926 value: function () {
927
928 this.savedLeftScroll = this.application.ninja.stage._iframeContainer.scrollLeft;
929 this.savedTopScroll = this.application.ninja.stage._iframeContainer.scrollTop;
930
931 this.gridHorizontalSpacing = this.application.ninja.stage.drawUtils.gridHorizontalSpacing;
932 this.gridVerticalSpacing = this.application.ninja.stage.drawUtils.gridVerticalSpacing;
933
934 if(typeof this.application.ninja.selectedElements !== 'undefined'){
935 this.selectionModel = this.application.ninja.selectedElements.slice(0);
936 }
937
938 this.draw3DGrid = this.application.ninja.appModel.show3dGrid;
939
940 //persist a clone of history per document
941 this.undoStack = this.application.ninja.undocontroller.undoQueue.slice(0);
942 this.redoStack = this.application.ninja.undocontroller.redoQueue.slice(0);
943 this.application.ninja.undocontroller.clearHistory();//clear history to give the next document a fresh start
944
945 //pause videos on switching or closing the document, so that the browser does not keep downloading the media data
946 this.pauseVideos();
947 }
948 },
949 923
950 //////////////////////////////////////////////////////////////////// 924 ////////////////////////////////////////////////////////////////////
951 restoreAppState:{ 925 restoreAppState:{
diff --git a/js/document/models/html.js b/js/document/models/html.js
index b57ff832..67457863 100755
--- a/js/document/models/html.js
+++ b/js/document/models/html.js
@@ -17,6 +17,11 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, {
17 hasTemplate: { 17 hasTemplate: {
18 value: false 18 value: false
19 }, 19 },
20 ////////////////////////////////////////////////////////////////////
21 //
22 selection: {
23 value: []
24 },
20 //////////////////////////////////////////////////////////////////// 25 ////////////////////////////////////////////////////////////////////
21 // 26 //
22 draw3DGrid: { 27 draw3DGrid: {
diff --git a/js/stage/stage-view.reel/stage-view.js b/js/stage/stage-view.reel/stage-view.js
index 7680103d..ba94fadf 100755
--- a/js/stage/stage-view.reel/stage-view.js
+++ b/js/stage/stage-view.reel/stage-view.js
@@ -120,7 +120,22 @@ exports.StageView = Montage.create(Component, {
120 } 120 }
121 121
122 this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe 122 this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe
123 this.application.ninja.documentController._showCurrentDocument(); 123
124
125// this.application.ninja.documentController._showCurrentDocument();
126 // Inline function below
127 if(this.activeDocument) {
128 this.activeDocument.container.style["display"] = "block";
129 if(this.activeDocument.currentView === "design"){
130 this.activeDocument.container.parentNode.style["display"] = "block";
131 this.activeDocument.restoreAppState();
132 } else {
133 //hide the iframe when switching to code view
134 document.getElementById("iframeContainer").style.display = "none";
135 }
136 }
137
138
124 //focus editor 139 //focus editor
125 if(!!this.application.ninja.documentController.activeDocument && !!this.application.ninja.documentController.activeDocument.editor){ 140 if(!!this.application.ninja.documentController.activeDocument && !!this.application.ninja.documentController.activeDocument.editor){
126 this.application.ninja.documentController.activeDocument.editor.focus(); 141 this.application.ninja.documentController.activeDocument.editor.focus();