aboutsummaryrefslogtreecommitdiff
path: root/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
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')
-rwxr-xr-xjs/controllers/document-controller.js26
-rwxr-xr-xjs/controllers/styles-controller.js10
-rw-r--r--js/io/ui/save-as-dialog.reel/save-as-dialog.js4
3 files changed, 30 insertions, 10 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
diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js
index 662816f5..addfc24e 100755
--- a/js/controllers/styles-controller.js
+++ b/js/controllers/styles-controller.js
@@ -1236,11 +1236,17 @@ var stylesController = exports.StylesController = Montage.create(Component, {
1236 1236
1237 clearDirtyStyleSheets : { 1237 clearDirtyStyleSheets : {
1238 value: function(doc) { 1238 value: function(doc) {
1239 if(!doc) { 1239 this.dirtyStyleSheets.length = 0;
1240
1241 if(doc) {
1242 var stillDirty = this.dirtyStyleSheets.filter(function(sheet) {
1243 return sheet.document !== doc;
1244 });
1240 this.dirtyStyleSheets = null; 1245 this.dirtyStyleSheets = null;
1241 this.dirtyStyleSheets = []; 1246 this.dirtyStyleSheets = stillDirty;
1242 } 1247 }
1243 1248
1249
1244 } 1250 }
1245 }, 1251 },
1246 1252
diff --git a/js/io/ui/save-as-dialog.reel/save-as-dialog.js b/js/io/ui/save-as-dialog.reel/save-as-dialog.js
index 0a322b99..c60a92f9 100644
--- a/js/io/ui/save-as-dialog.reel/save-as-dialog.js
+++ b/js/io/ui/save-as-dialog.reel/save-as-dialog.js
@@ -111,7 +111,7 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, {
111 handleOkButtonAction:{ 111 handleOkButtonAction:{
112 value: function(evt){ 112 value: function(evt){
113 var filename = this.fileName, 113 var filename = this.fileName,
114 newFileDirectory = this.newFileDirectory, 114 newFileDirectory = this.folderUri,
115 success = true; 115 success = true;
116 if(this.isValidFileName(this.fileName) && this.isValidUri(this.folderUri) && !this.checkFileExists(this.fileName, this.folderUri)){ 116 if(this.isValidFileName(this.fileName) && this.isValidUri(this.folderUri) && !this.checkFileExists(this.fileName, this.folderUri)){
117 try{ 117 try{
@@ -128,7 +128,7 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, {
128 } 128 }
129 }catch(e){ 129 }catch(e){
130 success = false; 130 success = false;
131 console.log("[ERROR] Failed to save: "+ this.fileName + " at "+ this.newFileDirectory); 131 console.log("[ERROR] Failed to save: "+ this.fileName + " at "+ newFileDirectory);
132 console.log(e.stack); 132 console.log(e.stack);
133 } 133 }
134 134