diff options
author | Ananya Sen | 2012-03-06 16:42:10 -0800 |
---|---|---|
committer | Ananya Sen | 2012-03-06 16:42:10 -0800 |
commit | 92c311c527b864f35aa98dba950da677746d4708 (patch) | |
tree | f77bf9c2d19b7f0e31215275614f90f53002f3cc /js/controllers | |
parent | b00a0da52ae29eefb45c8b28f7c782c7ebfa4b57 (diff) | |
download | ninja-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')
-rwxr-xr-x | js/controllers/document-controller.js | 26 | ||||
-rwxr-xr-x | js/controllers/styles-controller.js | 10 |
2 files changed, 28 insertions, 8 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 | ||