diff options
author | Eric Guzman | 2012-05-18 21:51:08 -0700 |
---|---|---|
committer | Eric Guzman | 2012-05-18 21:51:08 -0700 |
commit | 84097be9d7dd3403a0ac12f8c039d3ffc5281cfc (patch) | |
tree | 4f03ddf6620be09d4a755bdf647da2adc1df8908 /js/controllers/document-controller.js | |
parent | 13da56e791b7478ad3dbb8162a583a6b2c8c4b6b (diff) | |
parent | 10471fc02fa75040baf337bc62ff683854793f81 (diff) | |
download | ninja-84097be9d7dd3403a0ac12f8c039d3ffc5281cfc.tar.gz |
Merge branch 'dom-architecture' of github.com:Motorola-Mobility/ninja-internal into CSSPanelUpdates
Diffstat (limited to 'js/controllers/document-controller.js')
-rwxr-xr-x | js/controllers/document-controller.js | 95 |
1 files changed, 47 insertions, 48 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index cf46e73e..f6b850b2 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js | |||
@@ -145,18 +145,19 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
145 | value: function(event) { | 145 | value: function(event) { |
146 | // | 146 | // |
147 | if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ | 147 | if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ |
148 | // | 148 | //Currently we don't need a callback handler |
149 | this.activeDocument.model.save(this.testCallback.bind(this)); //this.fileSaveResult.bind(this) | 149 | //this.activeDocument.model.save(this.saveExecuted.bind(this)); |
150 | this.activeDocument.model.save(); | ||
150 | } else { | 151 | } else { |
151 | //Error: | 152 | //Error: cloud not available and/or no active document |
152 | } | 153 | } |
153 | } | 154 | } |
154 | }, | 155 | }, |
155 | testCallback: { | 156 | //////////////////////////////////////////////////////////////////// |
157 | // | ||
158 | saveExecuted: { | ||
156 | value: function (value) { | 159 | value: function (value) { |
157 | console.log(value); | 160 | //File saved, any callbacks or events should go here |
158 | //TODO: Move this to the model.save() | ||
159 | this.activeDocument.model.needsSave = false; | ||
160 | } | 161 | } |
161 | }, | 162 | }, |
162 | //////////////////////////////////////////////////////////////////// | 163 | //////////////////////////////////////////////////////////////////// |
@@ -177,8 +178,8 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
177 | value: function(event) { | 178 | value: function(event) { |
178 | var saveAsSettings = event._event.settings || {}; | 179 | var saveAsSettings = event._event.settings || {}; |
179 | if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ | 180 | if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ |
180 | saveAsSettings.fileName = this.activeDocument.name; | 181 | saveAsSettings.fileName = this.activeDocument.model.file.name; |
181 | saveAsSettings.folderUri = this.activeDocument.uri.substring(0, this.activeDocument.uri.lastIndexOf("/")); | 182 | saveAsSettings.folderUri = this.activeDocument.model.file.uri.substring(0, this.activeDocument.model.file.uri.lastIndexOf("/")); |
182 | saveAsSettings.callback = this.saveAsCallback.bind(this); | 183 | saveAsSettings.callback = this.saveAsCallback.bind(this); |
183 | this.application.ninja.newFileController.showSaveAsDialog(saveAsSettings); | 184 | this.application.ninja.newFileController.showSaveAsDialog(saveAsSettings); |
184 | } | 185 | } |
@@ -454,58 +455,56 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
454 | // Open document callback | 455 | // Open document callback |
455 | _onOpenDocument: { | 456 | _onOpenDocument: { |
456 | value: function(doc){ | 457 | value: function(doc){ |
457 | 458 | var currentDocument; | |
458 | if(this.activeDocument) { | 459 | if(this.activeDocument) { |
459 | // There is a document currently opened | 460 | // There is a document currently opened |
461 | currentDocument = this.activeDocument; | ||
460 | 462 | ||
461 | |||
462 | |||
463 | //this.application.ninja.stage.stageView.showCodeViewBar(false); | ||
464 | //this.application.ninja.stage.stageView.restoreAllPanels(); | 463 | //this.application.ninja.stage.stageView.restoreAllPanels(); |
465 | |||
466 | // | ||
467 | /* | ||
468 | if(this.activeDocument.currentView === "design"){ | ||
469 | this.activeDocument.saveAppState(); | ||
470 | this.activeDocument.container.parentNode.style["display"] = "none"; | ||
471 | this.application.ninja.stage.hideCanvas(true); | ||
472 | this.application.ninja.stage.stageView.hideRulers(); | ||
473 | } | ||
474 | |||
475 | this.activeDocument.container.style["display"] = "none"; | ||
476 | */ | ||
477 | |||
478 | /* | ||
479 | this.activeDocument.container.style["display"] = "block"; | ||
480 | if(this.activeDocument.currentView === "design"){ | ||
481 | this.activeDocument.container.parentNode.style["display"] = "block"; | ||
482 | this.activeDocument.restoreAppState(); | ||
483 | }else{ | ||
484 | //hide the iframe when switching to code view | ||
485 | document.getElementById("iframeContainer").style.display = "none"; | ||
486 | } | ||
487 | |||
488 | */ | ||
489 | // hide current document | ||
490 | } else { | 464 | } else { |
491 | // There is no document opened | 465 | // There is no document opened |
492 | 466 | ||
493 | // Set the active document | 467 | // Show the rulers |
494 | this.activeDocument = doc; | 468 | // TODO: Move this indo design view |
469 | this.application.ninja.stage.stageView.showRulers(); | ||
495 | 470 | ||
496 | // Show the canvas | 471 | // Show the canvas |
497 | this.application.ninja.stage.hideCanvas(false); | 472 | this.application.ninja.stage.hideCanvas(false); |
473 | } | ||
498 | 474 | ||
499 | // Show the rulers | 475 | // Set the active document |
500 | // TODO: Move this indo design view | 476 | this.activeDocument = doc; |
501 | this.application.ninja.stage.stageView.showRulers(); | 477 | |
478 | // Initialize the documentRoot styles | ||
479 | this.initializeRootStyles(doc.documentRoot); | ||
480 | // Flag to stop stylesheet dirty event | ||
481 | this._hackInitialStyles = false; | ||
502 | 482 | ||
503 | // Initialize the documentRoot styles | 483 | this.switchDocuments(currentDocument, doc, true); |
504 | this.initializeRootStyles(doc.documentRoot); | 484 | } |
505 | // Flag to stop stylesheet dirty event | 485 | }, |
506 | this._hackInitialStyles = false; | 486 | |
487 | switchDocuments: { | ||
488 | value: function(currentDocument, newDocument, didCreate) { | ||
489 | |||
490 | if(currentDocument) { | ||
491 | currentDocument.serializeDocument(); | ||
507 | 492 | ||
508 | NJevent("onOpenDocument", doc); | 493 | this.application.ninja.selectionController._selectionContainer = null; |
494 | currentDocument.model.views.design.propertiesPanel.clear(); | ||
495 | currentDocument.model.views.design.hide(); | ||
496 | } | ||
497 | |||
498 | this.application.ninja.stage.clearAllCanvas(); | ||
499 | |||
500 | if(didCreate) { | ||
501 | newDocument.model.views.design.iframe.style.opacity = 1; | ||
502 | NJevent("onOpenDocument", newDocument); | ||
503 | } else { | ||
504 | this.activeDocument = newDocument; | ||
505 | newDocument.model.views.design.show(); | ||
506 | newDocument.deserializeDocument(); | ||
507 | NJevent("onSwitchDocument"); | ||
509 | } | 508 | } |
510 | } | 509 | } |
511 | }, | 510 | }, |