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.js160
1 files changed, 80 insertions, 80 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index 1a8fec98..bab2ed0e 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -30,14 +30,14 @@ POSSIBILITY OF SUCH DAMAGE.
30 30
31//////////////////////////////////////////////////////////////////////// 31////////////////////////////////////////////////////////////////////////
32// 32//
33var Montage = require("montage/core/core").Montage, 33var Montage = require("montage/core/core").Montage,
34 Component = require("montage/ui/component").Component, 34 Component = require("montage/ui/component").Component,
35 HTMLDocument = require("js/document/document-html").HtmlDocument, 35 HTMLDocument = require("js/document/document-html").HtmlDocument,
36 TextDocument = require("js/document/document-text").TextDocument; 36 TextDocument = require("js/document/document-text").TextDocument;
37//////////////////////////////////////////////////////////////////////// 37////////////////////////////////////////////////////////////////////////
38// 38//
39exports.DocumentController = Montage.create(Component, { 39exports.DocumentController = Montage.create(Component, {
40 // 40 //
41 hasTemplate: { 41 hasTemplate: {
42 value: false 42 value: false
43 }, 43 },
@@ -110,45 +110,45 @@ exports.DocumentController = Montage.create(Component, {
110 } 110 }
111 }, 111 },
112 112
113 //TODO: Ensure these APIs are not needed 113 //TODO: Ensure these APIs are not needed
114 redirectRequests: { 114 redirectRequests: {
115 value: false 115 value: false
116 }, 116 },
117 //////////////////////////////////////////////////////////////////// 117 ////////////////////////////////////////////////////////////////////
118 // 118 //
119 handleWebRequest: { 119 handleWebRequest: {
120 value: function (request) { 120 value: function (request) {
121 //TODO: Check if frameId is proper 121 //TODO: Check if frameId is proper
122 if (this.redirectRequests && request.parentFrameId !== -1) { 122 if (this.redirectRequests && request.parentFrameId !== -1) {
123 //Checking for proper URL redirect (from different directories) 123 //Checking for proper URL redirect (from different directories)
124 if (request.url.indexOf('js/document/templates/banner') !== -1) { 124 if (request.url.indexOf('js/document/templates/banner') !== -1) {
125 return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split(chrome.extension.getURL('js/document/templates/banner/'))[1]}; 125 return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split(chrome.extension.getURL('js/document/templates/banner/'))[1]};
126 } else if (request.url.indexOf('js/document/templates/html') !== -1) { 126 } else if (request.url.indexOf('js/document/templates/html') !== -1) {
127 return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split(chrome.extension.getURL('js/document/templates/html/'))[1]}; 127 return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split(chrome.extension.getURL('js/document/templates/html/'))[1]};
128 } else if (request.url.indexOf('js/document/templates/app') !== -1) { 128 } else if (request.url.indexOf('js/document/templates/app') !== -1) {
129 return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split(chrome.extension.getURL('js/document/templates/app/'))[1]}; 129 return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split(chrome.extension.getURL('js/document/templates/app/'))[1]};
130 } else { 130 } else {
131 //Error, not a valid folder 131 //Error, not a valid folder
132 } 132 }
133 } 133 }
134 } 134 }
135 }, 135 },
136 //////////////////////////////////////////////////////////////////// 136 ////////////////////////////////////////////////////////////////////
137 // 137 //
138 handleAppLoaded: { 138 handleAppLoaded: {
139 value: function() { 139 value: function() {
140 //Checking for app to be loaded through extension 140 //Checking for app to be loaded through extension
141 var check; 141 var check;
142 if (chrome && chrome.app) { 142 if (chrome && chrome.app) {
143 check = chrome.app.getDetails(); 143 check = chrome.app.getDetails();
144 } 144 }
145 if (check !== null) { 145 if (check !== null) {
146 //Adding an intercept to resources loaded to ensure user assets load from cloud simulator 146 //Adding an intercept to resources loaded to ensure user assets load from cloud simulator
147 chrome.webRequest.onBeforeRequest.addListener(this.handleWebRequest.bind(this), {urls: ["<all_urls>"]}, ["blocking"]); 147 chrome.webRequest.onBeforeRequest.addListener(this.handleWebRequest.bind(this), {urls: ["<all_urls>"]}, ["blocking"]);
148 } 148 }
149 } 149 }
150 }, 150 },
151 //////////////////////////////////////////////////////////////////// 151 ////////////////////////////////////////////////////////////////////
152 152
153 153
154 handleExecuteFileOpen: { 154 handleExecuteFileOpen: {
@@ -172,39 +172,39 @@ exports.DocumentController = Montage.create(Component, {
172 } 172 }
173 } 173 }
174 }, 174 },
175 //////////////////////////////////////////////////////////////////// 175 ////////////////////////////////////////////////////////////////////
176 // 176 //
177 handleExecuteSave: { 177 handleExecuteSave: {
178 value: function(event) { 178 value: function(event) {
179 // 179 //
180 if((typeof this.currentDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ 180 if((typeof this.currentDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){
181 //Currently we don't need a callback handler 181 //Currently we don't need a callback handler
182 //this.activeDocument.model.save(this.saveExecuted.bind(this)); 182 //this.activeDocument.model.save(this.saveExecuted.bind(this));
183 this.currentDocument.model.save(); 183 this.currentDocument.model.save();
184 } else { 184 } else {
185 //Error: cloud not available and/or no active document 185 //Error: cloud not available and/or no active document
186 } 186 }
187 } 187 }
188 }, 188 },
189 //////////////////////////////////////////////////////////////////// 189 ////////////////////////////////////////////////////////////////////
190 // 190 //
191 saveExecuted: { 191 saveExecuted: {
192 value: function (value) { 192 value: function (value) {
193 //File saved, any callbacks or events should go here (must be added in handleExecuteSave passed as callback) 193 //File saved, any callbacks or events should go here (must be added in handleExecuteSave passed as callback)
194 } 194 }
195 }, 195 },
196 //////////////////////////////////////////////////////////////////// 196 ////////////////////////////////////////////////////////////////////
197 //TODO: Check for appropiate structures 197 //TODO: Check for appropiate structures
198 handleExecuteSaveAll: { 198 handleExecuteSaveAll: {
199 value: function(event) { 199 value: function(event) {
200 // 200 //
201 if((typeof this.currentDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ 201 if((typeof this.currentDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){
202 // 202 //
203 this.currentDocument.model.saveAll(); 203 this.currentDocument.model.saveAll();
204 } else { 204 } else {
205 //TODO: Add error handling 205 //TODO: Add error handling
206 } 206 }
207 } 207 }
208 }, 208 },
209 //////////////////////////////////////////////////////////////////// 209 ////////////////////////////////////////////////////////////////////
210 handleExecuteSaveAs: { 210 handleExecuteSaveAs: {
@@ -227,16 +227,16 @@ exports.DocumentController = Montage.create(Component, {
227 //////////////////////////////////////////////////////////////////// 227 ////////////////////////////////////////////////////////////////////
228 //TODO: Is this used, should be cleaned up 228 //TODO: Is this used, should be cleaned up
229 handleExecuteFileCloseAll:{ 229 handleExecuteFileCloseAll:{
230 value: function(event) { 230 value: function(event) {
231 if(this.currentDocument && this.application.ninja.coreIoApi.cloudAvailable()){ 231 if(this.currentDocument && this.application.ninja.coreIoApi.cloudAvailable()){
232 while(this.currentDocument.length > 0){ 232 while(this.currentDocument.length > 0){
233 this.closeDocument(this.currentDocument[this.currentDocument.length -1].uuid); 233 this.closeDocument(this.currentDocument[this.currentDocument.length -1].uuid);
234 } 234 }
235 } 235 }
236 } 236 }
237 }, 237 },
238 //////////////////////////////////////////////////////////////////// 238 ////////////////////////////////////////////////////////////////////
239 // 239 //
240 createNewFile:{ 240 createNewFile:{
241 value:function(newFileObj){ 241 value:function(newFileObj){
242 // 242 //
@@ -245,8 +245,8 @@ exports.DocumentController = Montage.create(Component, {
245 this.application.ninja.ioMediator.fileNew(newFileObj.newFilePath, newFileObj.fileTemplateUri, this.openNewFileCallback.bind(this), newFileObj.template); 245 this.application.ninja.ioMediator.fileNew(newFileObj.newFilePath, newFileObj.fileTemplateUri, this.openNewFileCallback.bind(this), newFileObj.template);
246 } 246 }
247 }, 247 },
248 //////////////////////////////////////////////////////////////////// 248 ////////////////////////////////////////////////////////////////////
249 249
250 /** 250 /**
251 * Public method 251 * Public method
252 * doc contains: 252 * doc contains:
@@ -296,7 +296,7 @@ exports.DocumentController = Montage.create(Component, {
296 } 296 }
297 this.isNewFilePath = false;//reset path identifier flag 297 this.isNewFilePath = false;//reset path identifier flag
298 298
299 //Sending full response object 299 //Sending full response object
300 this.openDocument(response); 300 this.openDocument(response);
301 301
302 } else if (!!response && (response.status === 404)){ 302 } else if (!!response && (response.status === 404)){
@@ -309,8 +309,8 @@ exports.DocumentController = Montage.create(Component, {
309 309
310 } 310 }
311 }, 311 },
312 //////////////////////////////////////////////////////////////////// 312 ////////////////////////////////////////////////////////////////////
313 // 313 //
314 saveAsCallback:{ 314 saveAsCallback:{
315 value:function(saveAsDetails){ 315 value:function(saveAsDetails){
316 var fileUri = null, filename = saveAsDetails.filename, destination = saveAsDetails.destination;