diff options
author | hwc487 | 2012-02-22 10:58:40 -0800 |
---|---|---|
committer | hwc487 | 2012-02-22 10:58:40 -0800 |
commit | 1a72686c9b915c488f9b430995787d2176671561 (patch) | |
tree | 849ca3d54f68c6c327c3daa240b48c7be6f73e91 /js/controllers/document-controller.js | |
parent | bb441ec8f8080cdaa52257a40531c62c47028667 (diff) | |
parent | 2f24dafec79583547fe663d5a387d8ef15aae3bf (diff) | |
download | ninja-1a72686c9b915c488f9b430995787d2176671561.tar.gz |
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into integration
Diffstat (limited to 'js/controllers/document-controller.js')
-rwxr-xr-x | js/controllers/document-controller.js | 49 |
1 files changed, 23 insertions, 26 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 1f339fe7..7491ef9f 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js | |||
@@ -66,35 +66,37 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
66 | 66 | ||
67 | 67 | ||
68 | 68 | ||
69 | handleWebRequest: { | ||
70 | value: function (request) { | ||
71 | if (request.url.indexOf('js/document/templates/montage-html') !== -1) { | ||
72 | 69 | ||
73 | console.log(request); | ||
74 | 70 | ||
75 | //TODO: Figure out why active document is not available here | ||
76 | 71 | ||
77 | if (this._hackRootFlag) { | ||
78 | |||
79 | //console.log(request.url.split('/')[request.url.split('/').length-1]); | ||
80 | //console.log(this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController._activeDocument.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split('/')[request.url.split('/').length-1]); | ||
81 | 72 | ||
73 | //////////////////////////////////////////////////////////////////// | ||
74 | // | ||
75 | handleWebRequest: { | ||
76 | value: function (request) { | ||
77 | if (this._hackRootFlag && request.url.indexOf('js/document/templates/montage-html') !== -1) { | ||
78 | //TODO: Optimize creating string | ||
82 | 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]}; | 79 | 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]}; |
83 | } | 80 | } |
84 | } | 81 | } |
85 | } | ||
86 | }, | 82 | }, |
87 | 83 | //////////////////////////////////////////////////////////////////// | |
88 | 84 | // | |
89 | handleAppLoaded: { | 85 | handleAppLoaded: { |
90 | value: function() { | 86 | value: function() { |
91 | // | 87 | //Adding an intercept to resources loaded to ensure user assets load from cloud simulator |
92 | |||
93 | chrome.webRequest.onBeforeRequest.addListener(this.handleWebRequest.bind(this), {urls: ["<all_urls>"]}, ["blocking"]); | 88 | chrome.webRequest.onBeforeRequest.addListener(this.handleWebRequest.bind(this), {urls: ["<all_urls>"]}, ["blocking"]); |
94 | |||
95 | } | 89 | } |
96 | }, | 90 | }, |
91 | //////////////////////////////////////////////////////////////////// | ||
97 | 92 | ||
93 | |||
94 | |||
95 | |||
96 | |||
97 | |||
98 | |||
99 | |||
98 | handleExecuteFileOpen: { | 100 | handleExecuteFileOpen: { |
99 | value: function(event) { | 101 | value: function(event) { |
100 | var pickerSettings = event._event.settings || {}; | 102 | var pickerSettings = event._event.settings || {}; |
@@ -118,28 +120,21 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
118 | //TODO: Check for appropiate structures | 120 | //TODO: Check for appropiate structures |
119 | handleExecuteSave: { | 121 | handleExecuteSave: { |
120 | value: function(event) { | 122 | value: function(event) { |
123 | if(!!this.activeDocument){ | ||
121 | //Text and HTML document classes should return the same save object for fileSave | 124 | //Text and HTML document classes should return the same save object for fileSave |
122 | this.application.ninja.ioMediator.fileSave(this.activeDocument.save(), this.fileSaveResult.bind(this)); | 125 | this.application.ninja.ioMediator.fileSave(this.activeDocument.save(), this.fileSaveResult.bind(this)); |
123 | } | 126 | } |
127 | } | ||
124 | }, | 128 | }, |
125 | //////////////////////////////////////////////////////////////////// | 129 | //////////////////////////////////////////////////////////////////// |
126 | // | 130 | // |
127 | fileSaveResult: { | 131 | fileSaveResult: { |
128 | value: function (result) { | 132 | value: function (result) { |
129 | if(result.status === 204){ | 133 | if(result.status === 204){ |
130 | this.clearDocumentDirtyFlag(); | 134 | this.activeDocument.needsSave = false; |
131 | } | 135 | } |
132 | } | 136 | } |
133 | }, | 137 | }, |
134 | //////////////////////////////////////////////////////////////////// | ||
135 | |||
136 | |||
137 | clearDocumentDirtyFlag:{ | ||
138 | value: function(){ | ||
139 | this.activeDocument.dirtyFlag = false; | ||
140 | } | ||
141 | }, | ||
142 | |||
143 | 138 | ||
144 | createNewFile:{ | 139 | createNewFile:{ |
145 | value:function(newFileObj){ | 140 | value:function(newFileObj){ |
@@ -278,7 +273,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
278 | 273 | ||
279 | closeDocument: { | 274 | closeDocument: { |
280 | value: function(id) { | 275 | value: function(id) { |
281 | if(this.activeDocument.dirtyFlag === true){ | 276 | if(this.activeDocument.needsSave === true){ |
282 | //if file dirty then alert user to save | 277 | //if file dirty then alert user to save |
283 | } | 278 | } |
284 | 279 | ||
@@ -301,6 +296,8 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
301 | this._removeDocumentView(doc.container); | 296 | this._removeDocumentView(doc.container); |
302 | this.application.ninja.stage.stageView.hideRulers(); | 297 | this.application.ninja.stage.stageView.hideRulers(); |
303 | document.getElementById("iframeContainer").style.display="block"; | 298 | document.getElementById("iframeContainer").style.display="block"; |
299 | |||
300 | this.application.ninja.stage.hideCanvas(true); | ||
304 | } | 301 | } |
305 | } | 302 | } |
306 | }, | 303 | }, |