diff options
author | Jose Antonio Marquez Russo | 2012-02-24 15:44:57 -0800 |
---|---|---|
committer | Jose Antonio Marquez Russo | 2012-02-24 15:44:57 -0800 |
commit | 97c0efb645b1e0488112c1b7bfd7fa4864eae3dc (patch) | |
tree | ae6c6587af2ab5ec34f86ac05d342ecf8ebfc0c7 /js/controllers/document-controller.js | |
parent | c916a2a5fec0c96bd1c6f56af82543da9b69c33c (diff) | |
parent | b056b4bef5982466d80d72e5cbb31e63087990e1 (diff) | |
download | ninja-97c0efb645b1e0488112c1b7bfd7fa4864eae3dc.tar.gz |
Merge pull request #19 from ananyasen/FileIO
FileIO branch pull request
Diffstat (limited to 'js/controllers/document-controller.js')
-rwxr-xr-x | js/controllers/document-controller.js | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index d5d0cf42..02031922 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js | |||
@@ -195,6 +195,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
195 | value:function(doc){ | 195 | value:function(doc){ |
196 | var response = doc || null;//default just for testing | 196 | var response = doc || null;//default just for testing |
197 | if(!!response && response.success && (response.status!== 500) && !!response.uri){ | 197 | if(!!response && response.success && (response.status!== 500) && !!response.uri){ |
198 | this.creatingNewFile = true;//flag for timeline to identify new file flow | ||
198 | this.application.ninja.ioMediator.fileOpen(response.uri, this.openFileCallback.bind(this)); | 199 | this.application.ninja.ioMediator.fileOpen(response.uri, this.openFileCallback.bind(this)); |
199 | }else if(!!response && !response.success){ | 200 | }else if(!!response && !response.success){ |
200 | //Todo: restrict directory path to the sandbox, in the dialog itself | 201 | //Todo: restrict directory path to the sandbox, in the dialog itself |
@@ -222,6 +223,11 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
222 | value:function(response){ | 223 | value:function(response){ |
223 | //TODO: Add UI to handle error codes, shouldn't be alert windows | 224 | //TODO: Add UI to handle error codes, shouldn't be alert windows |
224 | if(!!response && (response.status === 204)) { | 225 | if(!!response && (response.status === 204)) { |
226 | |||
227 | if((typeof this.creatingNewFile === 'undefined') || (this.creatingNewFile !== true)){//not from new file flow | ||
228 | this.creatingNewFile = false; | ||
229 | } | ||
230 | |||
225 | //Sending full response object | 231 | //Sending full response object |
226 | this.openDocument(response); | 232 | this.openDocument(response); |
227 | } else if (!!response && (response.status === 404)){ | 233 | } else if (!!response && (response.status === 404)){ |
@@ -332,6 +338,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
332 | 338 | ||
333 | this.application.ninja.stage.hideCanvas(true); | 339 | this.application.ninja.stage.hideCanvas(true); |
334 | } | 340 | } |
341 | |||
342 | NJevent("closeDocument", doc.uri); | ||
343 | |||
344 | doc=null; | ||
335 | } | 345 | } |
336 | }, | 346 | }, |
337 | 347 | ||
@@ -339,7 +349,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
339 | // Event Detail: Contains the current ActiveDocument | 349 | // Event Detail: Contains the current ActiveDocument |
340 | _onOpenDocument: { | 350 | _onOpenDocument: { |
341 | value: function(doc){ | 351 | value: function(doc){ |
342 | //var data = DocumentManager.activeDocument; | 352 | this.application.ninja.currentDocument = doc; |
343 | this._hideCurrentDocument(); | 353 | this._hideCurrentDocument(); |
344 | this.application.ninja.stage.stageView.hideOtherDocuments(doc.uuid); | 354 | this.application.ninja.stage.stageView.hideOtherDocuments(doc.uuid); |
345 | 355 | ||
@@ -423,7 +433,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
423 | value: function() { | 433 | value: function() { |
424 | if(this.activeDocument) { | 434 | if(this.activeDocument) { |
425 | if(this.activeDocument.currentView === "design"){ | 435 | if(this.activeDocument.currentView === "design"){ |
426 | this.application.ninja.stage.saveScroll(); | 436 | this.activeDocument.saveAppState(); |
427 | this.activeDocument.container.parentNode.style["display"] = "none"; | 437 | this.activeDocument.container.parentNode.style["display"] = "none"; |
428 | this.application.ninja.stage.hideCanvas(true); | 438 | this.application.ninja.stage.hideCanvas(true); |
429 | this.application.ninja.stage.stageView.hideRulers(); | 439 | this.application.ninja.stage.stageView.hideRulers(); |
@@ -440,7 +450,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
440 | this.activeDocument.container.style["display"] = "block"; | 450 | this.activeDocument.container.style["display"] = "block"; |
441 | if(this.activeDocument.currentView === "design"){ | 451 | if(this.activeDocument.currentView === "design"){ |
442 | this.activeDocument.container.parentNode.style["display"] = "block"; | 452 | this.activeDocument.container.parentNode.style["display"] = "block"; |
443 | this.application.ninja.stage.restoreScroll(); | 453 | this.activeDocument.restoreAppState(); |
444 | this.application.ninja.stage.hideCanvas(false); | 454 | this.application.ninja.stage.hideCanvas(false); |
445 | this.application.ninja.stage.stageView.showRulers(); | 455 | this.application.ninja.stage.stageView.showRulers(); |
446 | }else{ | 456 | }else{ |