aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xjs/components/layout/document-bar.reel/document-bar.js2
-rwxr-xr-xjs/io/document/document-controller.js75
-rwxr-xr-xjs/io/document/html-document.js45
-rwxr-xr-xjs/io/document/text-document.js47
-rw-r--r--js/mediators/io-mediator.js6
-rwxr-xr-xjs/stage/stage-view.reel/stage-view.js83
-rwxr-xr-xjs/stage/stage.reel/stage.js33
7 files changed, 136 insertions, 155 deletions
diff --git a/js/components/layout/document-bar.reel/document-bar.js b/js/components/layout/document-bar.reel/document-bar.js
index 44f65804..ea5e3280 100755
--- a/js/components/layout/document-bar.reel/document-bar.js
+++ b/js/components/layout/document-bar.reel/document-bar.js
@@ -95,7 +95,7 @@ exports.DocumentBar = Montage.create(Component, {
95 if(event._event.target.id === this.currentView) return; 95 if(event._event.target.id === this.currentView) return;
96 96
97 this.currentView = event._event.target.id; 97 this.currentView = event._event.target.id;
98 this.application.ninja.documentController.switchViews(event._event.target.id);//switch between design view 98 this.application.ninja.documentController.stage.stageView.switchViews(event._event.target.id);//switch between design view
99 } 99 }
100 }, 100 },
101 101
diff --git a/js/io/document/document-controller.js b/js/io/document/document-controller.js
index 1a5d6058..e36181bf 100755
--- a/js/io/document/document-controller.js
+++ b/js/io/document/document-controller.js
@@ -39,19 +39,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
39 "var options = {}, defaults = CodeMirror.defaults; }" 39 "var options = {}, defaults = CodeMirror.defaults; }"
40 }, 40 },
41 41
42 _codeEditor: {
43 value: {
44 "editor": {
45 value: null,
46 enumerable: false
47 },
48 "hline": {
49 value: null,
50 enumerable: false
51 }
52 }
53 },
54
55 activeDocument: { 42 activeDocument: {
56 get: function() { 43 get: function() {
57 return this._activeDocument; 44 return this._activeDocument;
@@ -64,6 +51,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
64 this._activeDocument = doc; 51 this._activeDocument = doc;
65 this._activeDocument.isActive = true; 52 this._activeDocument.isActive = true;
66 53
54 if(!!this._activeDocument.editor){
55 this._activeDocument.editor.focus();
56 }
57
67 } 58 }
68 }, 59 },
69 60
@@ -73,6 +64,8 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
73 this.eventManager.addEventListener("executeFileOpen", this, false); 64 this.eventManager.addEventListener("executeFileOpen", this, false);
74 this.eventManager.addEventListener("executeNewFile", this, false); 65 this.eventManager.addEventListener("executeNewFile", this, false);
75 this.eventManager.addEventListener("executeSave", this, false); 66 this.eventManager.addEventListener("executeSave", this, false);
67
68 this.eventManager.addEventListener("recordStyleChanged", this, false);
76 } 69 }
77 }, 70 },
78 71
@@ -110,7 +103,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
110 value:function(newFileObj){ 103 value:function(newFileObj){
111 //console.log(newFileObj);//contains the template uri and the new file uri 104 //console.log(newFileObj);//contains the template uri and the new file uri
112 if(!newFileObj) return; 105 if(!newFileObj) return;
113 this.application.ninja.ioMediator.fileNew(newFileObj.newFilePath, newFileObj.fileTemplateUri, {"operation":this.openNewFileCallback, "thisScope":this}); 106 this.application.ninja.ioMediator.fileNew(newFileObj.newFilePath, newFileObj.fileTemplateUri, this.openNewFileCallback.bind(this));
114 107
115 if((newFileObj.fileExtension !== ".html") && (newFileObj.fileExtension !== ".htm")){//open code view 108 if((newFileObj.fileExtension !== ".html") && (newFileObj.fileExtension !== ".htm")){//open code view
116 109
@@ -130,10 +123,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
130 */ 123 */
131 openNewFileCallback:{ 124 openNewFileCallback:{
132 value:function(doc){ 125 value:function(doc){
133 if(!doc){ 126 var response = doc || {"uri":"/Users/xhdq84/Documents/test.js", "success":true};//default just for testing
134 doc = {"type": "js", "name": "filename", "source": "test file content", "uri": "/fs/fsd/"} ; 127 if(!!response && response.success && !!response.uri){
128 this.application.ninja.ioMediator.fileOpen({"uri":response.uri}, this.openFileCallback.bind(this));
135 } 129 }
136 this.openDocument(doc);
137 } 130 }
138 }, 131 },
139 132
@@ -145,7 +138,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
145 } 138 }
146 //console.log("URI is: ", uri); 139 //console.log("URI is: ", uri);
147 140
148 this.application.ninja.ioMediator.fileOpen({"uri":uri}, {"operation":this.openFileCallback, "thisScope":this}); 141 this.application.ninja.ioMediator.fileOpen({"uri":uri}, this.openFileCallback.bind(this));
149 } 142 }
150 }, 143 },
151 144
@@ -242,11 +235,8 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
242 235
243 closeDocument: { 236 closeDocument: {
244 value: function(id) { 237 value: function(id) {
245
246 //if file dirty then save
247 if(this.activeDocument.dirtyFlag === true){ 238 if(this.activeDocument.dirtyFlag === true){
248 this.activeDocument.save(true /*remove the codemirror div after saving*/); 239 //if file dirty then alert user to save
249 this.activeDocument.dirtyFlag=false;
250 } 240 }
251 241
252 var doc = this._findDocumentByUUID(id); 242 var doc = this._findDocumentByUUID(id);
@@ -267,42 +257,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
267 } 257 }
268 }, 258 },
269 259
270 switchViews: {
271 value: function() {
272
273 //save file if dirty
274
275 this.application.ninja.stage.saveScroll();
276 this._hideCurrentDocument();
277
278 if(this.activeDocument.currentView === "design") {
279 this._textHolder.style.display = "none";
280 this.activeDocument.container.style["display"] = "block";
281 this.application.ninja.stage._scrollFlag = true;
282 //this._showCurrentDocument();
283 this.application.ninja.stage.restoreScroll();
284
285 } else {
286 this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe
287
288 var codeview = this.activeDocument.container;
289 //this._textHolder.style.display = "block";
290 //codeview.firstChild.innerHTML = this.activeDocument.iframe.contentWindow.document.body.parentNode.innerHTML;
291
292// this._codeEditor.editor = CodeMirror.fromTextArea(codeview.firstChild, {
293// lineNumbers: true,
294// mode: "htmlmixed",
295// onCursorActivity: function() {
296// DocumentController._codeEditor.editor.setLineClass(DocumentController._codeEditor.hline, null);
297// DocumentController._codeEditor.hline = DocumentController._codeEditor.editor.setLineClass(DocumentController._codeEditor.editor.getCursor().line, "activeline");
298// }
299// });
300// this._codeEditor.hline = DocumentController._codeEditor.editor.setLineClass(0, "activeline");
301 }
302 }
303 },
304
305
306 // Document has been loaded into the Iframe. Dispatch the event. 260 // Document has been loaded into the Iframe. Dispatch the event.
307 // Event Detail: Contains the current ActiveDocument 261 // Event Detail: Contains the current ActiveDocument
308 _onOpenDocument: { 262 _onOpenDocument: {
@@ -388,11 +342,12 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
388 value: function() { 342 value: function() {
389 if(this.activeDocument) { 343 if(this.activeDocument) {
390 if(this.activeDocument.currentView === "design"){ 344 if(this.activeDocument.currentView === "design"){
391 this.application.ninja.stage.saveStageScroll(); 345 this.application.ninja.stage.saveScroll();
392 this.activeDocument.container.parentNode.style["display"] = "none"; 346 this.activeDocument.container.parentNode.style["display"] = "none";
393 this.application.ninja.stage.hideCanvas(true); 347 this.application.ninja.stage.hideCanvas(true);
394 this.application.ninja.stage.stageView.hideRulers(); 348 this.application.ninja.stage.stageView.hideRulers();
395 } 349 }
350
396 this.activeDocument.container.style["display"] = "none"; 351 this.activeDocument.container.style["display"] = "none";
397 } 352 }
398 } 353 }
@@ -404,7 +359,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
404 this.activeDocument.container.style["display"] = "block"; 359 this.activeDocument.container.style["display"] = "block";
405 if(this.activeDocument.currentView === "design"){ 360 if(this.activeDocument.currentView === "design"){
406 this.activeDocument.container.parentNode.style["display"] = "block"; 361 this.activeDocument.container.parentNode.style["display"] = "block";
407 this.application.ninja.stage.applySavedScroll(); 362 this.application.ninja.stage.restoreScroll();
408 this.application.ninja.stage.hideCanvas(false); 363 this.application.ninja.stage.hideCanvas(false);
409 this.application.ninja.stage.stageView.showRulers(); 364 this.application.ninja.stage.stageView.showRulers();
410 } 365 }
diff --git a/js/io/document/html-document.js b/js/io/document/html-document.js
index 8e1eb614..d51cd279 100755
--- a/js/io/document/html-document.js
+++ b/js/io/document/html-document.js
@@ -36,18 +36,13 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base
36 36
37 _zoomFactor: { value: 100, enumerable: false }, 37 _zoomFactor: { value: 100, enumerable: false },
38 38
39 _codeEditor: {
40 value: {
41 "editor": { value: null, enumerable: false },
42 "hline": { value: null, enumerable: false }
43 }
44 },
45
46
47 // PUBLIC MEMBERS 39 // PUBLIC MEMBERS
48 cssLoadInterval: { value: null, enumerable: false }, 40 cssLoadInterval: { value: null, enumerable: false },
49 41
50 codeViewDocument:{ 42 _savedLeftScroll: {value:null},
43 _savedTopScroll: {value:null},