aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/document-controller.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers/document-controller.js')
-rwxr-xr-xjs/controllers/document-controller.js33
1 files changed, 26 insertions, 7 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index 87e93465..ddaeb061 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -38,13 +38,12 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
38 return this._activeDocument; 38 return this._activeDocument;
39 }, 39 },
40 set: function(doc) { 40 set: function(doc) {
41 if(!!this._activeDocument) this._activeDocument.isActive = false; 41 if(!!this._activeDocument){ this._activeDocument.isActive = false;}
42
43 this._activeDocument = doc; 42 this._activeDocument = doc;
44 if(!!this._activeDocument){ 43 if(!!this._activeDocument){
45
46 if(this._documents.indexOf(doc) === -1) this._documents.push(doc); 44 if(this._documents.indexOf(doc) === -1) this._documents.push(doc);
47 this._activeDocument.isActive = true; 45 this._activeDocument.isActive = true;
46
48 if(!!this._activeDocument.editor){ 47 if(!!this._activeDocument.editor){
49 this._activeDocument.editor.focus(); 48 this._activeDocument.editor.focus();
50 } 49 }
@@ -61,25 +60,33 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
61 this.eventManager.addEventListener("executeSaveAs", this, false); 60 this.eventManager.addEventListener("executeSaveAs", this, false);
62 this.eventManager.addEventListener("executeSaveAll", this, false); 61 this.eventManager.addEventListener("executeSaveAll", this, false);
63 this.eventManager.addEventListener("executeFileClose", this, false); 62 this.eventManager.addEventListener("executeFileClose", this, false);
63 this.eventManager.addEventListener("executeFileCloseAll", this, false);
64 64
65 this.eventManager.addEventListener("styleSheetDirty", this, false); 65 this.eventManager.addEventListener("styleSheetDirty", this, false);
66 66
67 this.eventManager.addEventListener("addComponentFirstDraw", this, false);
67 } 68 }
68 }, 69 },
69 70
70 71 handleAddComponentFirstDraw: {
72 value: function (e) {
73 //TODO: Add logic to reparse the document for dynamically added styles
74 //console.log(e);
75 }
76 },
71 77
72 78
73 79
74 80
75 81
76 //////////////////////////////////////////////////////////////////// 82////////////////////////////////////////////////////////////////////
77 // 83 //
78 handleWebRequest: { 84 handleWebRequest: {
79 value: function (request) { 85 value: function (request) {
80 //TODO: Check if frameId is proper 86 //TODO: Check if frameId is proper
81 if (this._hackRootFlag && request.parentFrameId !== -1) { 87 if (this._hackRootFlag && request.parentFrameId !== -1) {
82 //TODO: Optimize creating string 88 //TODO: Optimize creating string
89 //console.log(request);
83 //console.log(this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1], request.url); 90 //console.log(this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1], request.url);
84 //return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split('/')[request.url.split('/').length-1]}; 91 //return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split('/')[request.url.split('/').length-1]};
85 return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split(chrome.extension.getURL('js/document/templates/montage-html/'))[1]}; 92 return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split(chrome.extension.getURL('js/document/templates/montage-html/'))[1]};
@@ -103,6 +110,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
103 }, 110 },
104 //////////////////////////////////////////////////////////////////// 111 ////////////////////////////////////////////////////////////////////
105 112
113
106 114
107 115
108 116
@@ -172,6 +180,17 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
172 } 180 }
173 }, 181 },
174 //////////////////////////////////////////////////////////////////// 182 ////////////////////////////////////////////////////////////////////
183 handleExecuteFileCloseAll:{
184 value: function(event) {
185 var i=0;
186 if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){
187 while(this._documents.length > 0){
188 this.closeDocument(this._documents[this._documents.length -1].uuid);
189 }
190 }
191 }
192 },
193 ////////////////////////////////////////////////////////////////////
175 // 194 //
176 fileSaveResult: { 195 fileSaveResult: {
177 value: function (result) { 196 value: function (result) {
@@ -372,7 +391,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
372 nextDocumentIndex = closeDocumentIndex - 1; 391 nextDocumentIndex = closeDocumentIndex - 1;
373 } 392 }
374 this.application.ninja.stage.stageView.switchDocument(this._documents[nextDocumentIndex]); 393 this.application.ninja.stage.stageView.switchDocument(this._documents[nextDocumentIndex]);
375 if(typeof this.activeDocument.stopVideos !== "undefined"){doc.stopVideos();} 394 if(typeof doc.stopVideos !== "undefined"){doc.stopVideos();}
376 this._removeDocumentView(doc.container); 395 this._removeDocumentView(doc.container);
377 }else if(this._documents.length === 0){ 396 }else if(this._documents.length === 0){
378 if(typeof this.activeDocument.pauseAndStopVideos !== "undefined"){ 397 if(typeof this.activeDocument.pauseAndStopVideos !== "undefined"){