aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/document-controller.js
diff options
context:
space:
mode:
authorAnanya Sen2012-03-06 16:42:10 -0800
committerAnanya Sen2012-03-06 16:42:10 -0800
commit92c311c527b864f35aa98dba950da677746d4708 (patch)
treef77bf9c2d19b7f0e31215275614f90f53002f3cc /js/controllers/document-controller.js
parentb00a0da52ae29eefb45c8b28f7c782c7ebfa4b57 (diff)
downloadninja-92c311c527b864f35aa98dba950da677746d4708.tar.gz
- detect document style edit [with Eric's input for styles-controller.js]
- integrated save as Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js/controllers/document-controller.js')
-rwxr-xr-xjs/controllers/document-controller.js26
1 files changed, 20 insertions, 6 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index 1f8c58b0..e29148c9 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -157,7 +157,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
157 if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ 157 if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){
158 saveAsSettings.fileName = this.activeDocument.name; 158 saveAsSettings.fileName = this.activeDocument.name;
159 saveAsSettings.folderUri = this.activeDocument.uri.substring(0, this.activeDocument.uri.lastIndexOf("/")); 159 saveAsSettings.folderUri = this.activeDocument.uri.substring(0, this.activeDocument.uri.lastIndexOf("/"));
160 //add callback 160 saveAsSettings.callback = this.saveAsCallback.bind(this);
161 this.application.ninja.newFileController.showSaveAsDialog(saveAsSettings); 161 this.application.ninja.newFileController.showSaveAsDialog(saveAsSettings);
162 } 162 }
163 } 163 }
@@ -166,7 +166,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
166 // 166 //
167 fileSaveResult: { 167 fileSaveResult: {
168 value: function (result) { 168 value: function (result) {
169 if(result.status === 204){ 169 if((result.status === 204) || (result.status === 404)){//204=>existing file || 404=>new file... saved
170 this.activeDocument.needsSave = false; 170 this.activeDocument.needsSave = false;
171 if(this.application.ninja.currentDocument !== null){ 171 if(this.application.ninja.currentDocument !== null){
172 //clear Dirty StyleSheets for the saved document 172 //clear Dirty StyleSheets for the saved document
@@ -254,10 +254,24 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
254 //////////////////////////////////////////////////////////////////// 254 ////////////////////////////////////////////////////////////////////
255 // 255 //
256 saveAsCallback:{ 256 saveAsCallback:{
257 value:function(){ 257 value:function(saveAsDetails){
258 //close current document 258 var fileUri = null, filename = saveAsDetails.filename, destination = saveAsDetails.destination;
259 259 //update document metadata
260 //create a new file 260 this.activeDocument.name = ""+filename;
261 //prepare new file uri
262 if(destination && (destination.charAt(destination.length -1) !== "/")){
263 destination = destination + "/";
264 }
265 fileUri = destination+filename;
266
267 this.activeDocument.uri = fileUri;
268 //save a new file
269 //use the ioMediator.fileSaveAll when implemented
270 this.activeDocument._userDocument.name=filename;
271 this.activeDocument._userDocument.root=destination;
272 this.activeDocument._userDocument.uri=fileUri;
273 this.application.ninja.ioMediator.fileSave(this.activeDocument.save(), this.fileSaveResult.bind(this));
274 //
261 } 275 }
262 }, 276 },
263 277