diff options
-rwxr-xr-x | js/data/menu-data.js | 6 | ||||
-rwxr-xr-x | js/io/document/document-controller.js | 19 | ||||
-rwxr-xr-x | js/io/document/text-document.js | 1 | ||||
-rwxr-xr-x | js/stage/stage-view.reel/stage-view.js | 29 | ||||
-rwxr-xr-x | js/stage/stage.reel/stage.js | 15 |
5 files changed, 52 insertions, 18 deletions
diff --git a/js/data/menu-data.js b/js/data/menu-data.js index bafc30da..07337fa0 100755 --- a/js/data/menu-data.js +++ b/js/data/menu-data.js | |||
@@ -37,7 +37,8 @@ exports.MenuData = Montage.create( Montage, { | |||
37 | { | 37 | { |
38 | "displayText" : "Save", | 38 | "displayText" : "Save", |
39 | "hasSubMenu" : false, | 39 | "hasSubMenu" : false, |
40 | "enabled": true | 40 | "enabled": true, |
41 | "action": "executeSave" | ||
41 | }, | 42 | }, |
42 | { | 43 | { |
43 | "displayText" : "Save As", | 44 | "displayText" : "Save As", |
@@ -48,7 +49,8 @@ exports.MenuData = Montage.create( Montage, { | |||
48 | { | 49 | { |
49 | "displayText" : "Save All", | 50 | "displayText" : "Save All", |
50 | "hasSubMenu" : false, | 51 | "hasSubMenu" : false, |
51 | "enabled": true | 52 | "enabled": true, |
53 | "action": "executeSaveAll" | ||
52 | }, | 54 | }, |
53 | { | 55 | { |
54 | "displayText" : "", | 56 | "displayText" : "", |
diff --git a/js/io/document/document-controller.js b/js/io/document/document-controller.js index 51575a24..1a5d6058 100755 --- a/js/io/document/document-controller.js +++ b/js/io/document/document-controller.js | |||
@@ -72,6 +72,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
72 | this.eventManager.addEventListener("appLoaded", this, false); | 72 | this.eventManager.addEventListener("appLoaded", this, false); |
73 | this.eventManager.addEventListener("executeFileOpen", this, false); | 73 | this.eventManager.addEventListener("executeFileOpen", this, false); |
74 | this.eventManager.addEventListener("executeNewFile", this, false); | 74 | this.eventManager.addEventListener("executeNewFile", this, false); |
75 | this.eventManager.addEventListener("executeSave", this, false); | ||
75 | } | 76 | } |
76 | }, | 77 | }, |
77 | 78 | ||
@@ -87,8 +88,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
87 | pickerSettings.callback = this.openFileWithURI; | 88 | pickerSettings.callback = this.openFileWithURI; |
88 | pickerSettings.callbackScope = this; | 89 | pickerSettings.callbackScope = this; |
89 | this.application.ninja.filePickerController.showFilePicker(pickerSettings); | 90 | this.application.ninja.filePickerController.showFilePicker(pickerSettings); |
90 | |||
91 | //this.openDocument({"type": "js", "source": this.tmpSourceForTesting}); | ||
92 | } | 91 | } |
93 | }, | 92 | }, |
94 | 93 | ||
@@ -101,6 +100,12 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
101 | } | 100 | } |
102 | }, | 101 | }, |
103 | 102 | ||
103 | handleExecuteSave: { | ||
104 | value: function(event) { | ||
105 | this.activeDocument.save(); | ||
106 | } | ||
107 | }, | ||
108 | |||
104 | createNewFile:{ | 109 | createNewFile:{ |
105 | value:function(newFileObj){ | 110 | value:function(newFileObj){ |
106 | //console.log(newFileObj);//contains the template uri and the new file uri | 111 | //console.log(newFileObj);//contains the template uri and the new file uri |
@@ -240,7 +245,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
240 | 245 | ||
241 | //if file dirty then save | 246 | //if file dirty then save |
242 | if(this.activeDocument.dirtyFlag === true){ | 247 | if(this.activeDocument.dirtyFlag === true){ |
243 | this.activeDocument.save(true); | 248 | this.activeDocument.save(true /*remove the codemirror div after saving*/); |
244 | this.activeDocument.dirtyFlag=false; | 249 | this.activeDocument.dirtyFlag=false; |
245 | } | 250 | } |
246 | 251 | ||
@@ -382,12 +387,13 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
382 | _hideCurrentDocument: { | 387 | _hideCurrentDocument: { |
383 | value: function() { | 388 | value: function() { |
384 | if(this.activeDocument) { | 389 | if(this.activeDocument) { |
385 | this.activeDocument.container.style["display"] = "none"; | 390 | if(this.activeDocument.currentView === "design"){ |
386 | if(this.activeDocument.currentView === "design" || this.activeDocument.currentView === "design"){ | 391 | this.application.ninja.stage.saveStageScroll(); |
387 | this.activeDocument.container.parentNode.style["display"] = "none"; | 392 | this.activeDocument.container.parentNode.style["display"] = "none"; |
388 | this.application.ninja.stage.hideCanvas(true); | 393 | this.application.ninja.stage.hideCanvas(true); |
389 | this.application.ninja.stage.stageView.hideRulers(); | 394 | this.application.ninja.stage.stageView.hideRulers(); |
390 | } | 395 | } |
396 | this.activeDocument.container.style["display"] = "none"; | ||
391 | } | 397 | } |
392 | } | 398 | } |
393 | }, | 399 | }, |
@@ -396,8 +402,9 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
396 | value: function() { | 402 | value: function() { |
397 | if(this.activeDocument) { | 403 | if(this.activeDocument) { |
398 | this.activeDocument.container.style["display"] = "block"; | 404 | this.activeDocument.container.style["display"] = "block"; |
399 | if(this.activeDocument.currentView === "design" || this.activeDocument.currentView === "design"){ | 405 | if(this.activeDocument.currentView === "design"){ |
400 | this.activeDocument.container.parentNode.style["display"] = "block"; | 406 | this.activeDocument.container.parentNode.style["display"] = "block"; |
407 | this.application.ninja.stage.applySavedScroll(); | ||
401 | this.application.ninja.stage.hideCanvas(false); | 408 | this.application.ninja.stage.hideCanvas(false); |
402 | this.application.ninja.stage.stageView.showRulers(); | 409 | this.application.ninja.stage.stageView.showRulers(); |
403 | } | 410 | } |
diff --git a/js/io/document/text-document.js b/js/io/document/text-document.js index 683c513c..7db8e91a 100755 --- a/js/io/document/text-document.js +++ b/js/io/document/text-document.js | |||
@@ -100,6 +100,7 @@ var TextDocument = exports.TextDocument = Montage.create(baseDocumentModule.Base | |||
100 | var codemirrorDiv = this.textArea.parentNode.querySelector(".CodeMirror"); | 100 | var codemirrorDiv = this.textArea.parentNode.querySelector(".CodeMirror"); |
101 | if(!!codemirrorDiv){codemirrorDiv.parentNode.removeChild(codemirrorDiv);} | 101 | if(!!codemirrorDiv){codemirrorDiv.parentNode.removeChild(codemirrorDiv);} |
102 | } | 102 | } |
103 | //console.log("$$$saved : "+this.uri+" : "+this.textArea.value); | ||
103 | //persist to filesystem | 104 | //persist to filesystem |
104 | } | 105 | } |
105 | } | 106 | } |
diff --git a/js/stage/stage-view.reel/stage-view.js b/js/stage/stage-view.reel/stage-view.js index 6f20b87b..f8817b13 100755 --- a/js/stage/stage-view.reel/stage-view.js +++ b/js/stage/stage-view.reel/stage-view.js | |||
@@ -76,10 +76,7 @@ exports.StageView = Montage.create(Component, { | |||
76 | // Temporary function to create a Codemirror text view | 76 | // Temporary function to create a Codemirror text view |
77 | createTextView: { | 77 | createTextView: { |
78 | value: function(doc) { | 78 | value: function(doc) { |
79 | //save current document | 79 | this.application.ninja.documentController.activeDocument.save(true /*remove the codemirror div after saving*/); |
80 | if(this.application.ninja.documentController.activeDocument.currentView === "code"){ | ||
81 | this.application.ninja.documentController.activeDocument.save(true); | ||
82 | } | ||
83 | this.application.ninja.documentController._hideCurrentDocument(); | 80 | this.application.ninja.documentController._hideCurrentDocument(); |
84 | this.hideOtherDocuments(doc.uuid); | 81 | this.hideOtherDocuments(doc.uuid); |
85 | var type; | 82 | var type; |
@@ -100,7 +97,14 @@ exports.StageView = Montage.create(Component, { | |||
100 | doc.editor = CodeMirror.fromTextArea(doc.textArea, { | 97 | doc.editor = CodeMirror.fromTextArea(doc.textArea, { |
101 | lineNumbers: true, | 98 | lineNumbers: true, |
102 | mode: type, | 99 | mode: type, |
103 | onChange: function(){doc.dirtyFlag=true;}, | 100 | onChange: function(){ |
101 | var historySize = doc.editor.historySize(); | ||
102 | if((historySize.undo===0 && historySize.redo===0) || (historySize.undo>0)){ | ||
103 | doc.dirtyFlag=true; | ||
104 | }else if(historySize.undo===0 && historySize.redo>0){ | ||
105 | doc.dirtyFlag=false; | ||
106 | } | ||
107 | }, | ||
104 | onCursorActivity: function() { | 108 | onCursorActivity: function() { |
105 | //documentController._codeEditor.editor.setLineClass(documentController._codeEditor.hline, null); | 109 | //documentController._codeEditor.editor.setLineClass(documentController._codeEditor.hline, null); |
106 | //documentController._codeEditor.hline = documentController._codeEditor.editor.setLineClass(documentController._codeEditor.editor.getCursor().line, "activeline"); | 110 | //documentController._codeEditor.hline = documentController._codeEditor.editor.setLineClass(documentController._codeEditor.editor.getCursor().line, "activeline"); |
@@ -118,13 +122,16 @@ exports.StageView = Montage.create(Component, { | |||
118 | 122 | ||
119 | switchDocument:{ | 123 | switchDocument:{ |
120 | value: function(doc){ | 124 | value: function(doc){ |
125 | this.application.ninja.documentController.activeDocument.save(true /*remove the codemirror div after saving*/); | ||
121 | 126 | ||
122 | //if dirty SAVE codemirror into textarea | 127 | this.application.ninja.documentController._hideCurrentDocument(); |
123 | if(this.application.ninja.documentController.activeDocument.currentView === "code"){ | 128 | |
124 | this.application.ninja.documentController.activeDocument.save(true); | 129 | |
130 | if(this.application.ninja.documentController.activeDocument.currentView === "design"){ | ||
131 | console.log("scrollLeft: "+ this.application.ninja.stage._iframeContainer.scrollLeft); | ||
132 | console.log("scrollTop: "+ this.application.ninja.stage._iframeContainer.scrollTop); | ||
125 | } | 133 | } |
126 | 134 | ||
127 | this.application.ninja.documentController._hideCurrentDocument(); | ||
128 | 135 | ||
129 | this.application.ninja.documentController.activeDocument = doc; | 136 | this.application.ninja.documentController.activeDocument = doc; |
130 | 137 | ||
@@ -148,7 +155,7 @@ exports.StageView = Montage.create(Component, { | |||
148 | doc.editor = CodeMirror.fromTextArea(doc.textArea, { | 155 | doc.editor = CodeMirror.fromTextArea(doc.textArea, { |
149 | lineNumbers: true, | 156 | lineNumbers: true, |
150 | mode: type, | 157 | mode: type, |
151 | onChange: function(){doc.dirtyFlag=true;}, | 158 | onChange: function(){doc.dirtyFlag=true;console.log("undo stack:",doc.editor.historySize());}, |
152 | onCursorActivity: function() { | 159 | onCursorActivity: function() { |
153 | //documentController._codeEditor.editor.setLineClass(documentController._codeEditor.hline, null); | 160 | //documentController._codeEditor.editor.setLineClass(documentController._codeEditor.hline, null); |
154 | //documentController._codeEditor.hline = documentController._codeEditor.editor.setLineClass(documentController._codeEditor.editor.getCursor().line, "activeline"); | 161 | //documentController._codeEditor.hline = documentController._codeEditor.editor.setLineClass(documentController._codeEditor.editor.getCursor().line, "activeline"); |
@@ -160,6 +167,8 @@ exports.StageView = Montage.create(Component, { | |||
160 | 167 | ||
161 | if(this.application.ninja.documentController.activeDocument.documentType === "htm" || this.application.ninja.documentController.activeDocument.documentType === "html") { | 168 | if(this.application.ninja.documentController.activeDocument.documentType === "htm" || this.application.ninja.documentController.activeDocument.documentType === "html") { |
162 | this.application.ninja.stage._scrollFlag = true; // TODO HACK to prevent type error on Hide/Show Iframe | 169 | this.application.ninja.stage._scrollFlag = true; // TODO HACK to prevent type error on Hide/Show Iframe |
170 | |||
171 | |||
163 | // TODO dispatch event here | 172 | // TODO dispatch event here |
164 | // appDelegateModule.MyAppDelegate.onSetActiveDocument(); | 173 | // appDelegateModule.MyAppDelegate.onSetActiveDocument(); |
165 | } | 174 | } |
diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 9e2df5a2..4364b45d 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js | |||
@@ -876,5 +876,20 @@ exports.Stage = Montage.create(Component, { | |||
876 | 876 | ||
877 | this.stageDeps.snapManager.updateWorkingPlaneFromView(); | 877 | this.stageDeps.snapManager.updateWorkingPlaneFromView(); |
878 | } |