From db4f235dc9fd6f2242dee481d2f377005cf23596 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 24 Jul 2012 16:56:52 -0700 Subject: adding a viewIdentifier to the model to enable design/code switch Todo: - Cleanup and remove listeners - Finish stage reload - Add remaining bindings. Signed-off-by: Valerio Virgillito --- js/document/document-html.js | 15 ++++++++++++++- js/document/models/base.js | 15 +++++++++++++++ js/document/views/code.js | 4 ++-- js/document/views/design-code.js | 27 ++------------------------- js/document/views/design.js | 4 ++-- 5 files changed, 35 insertions(+), 30 deletions(-) (limited to 'js/document') diff --git a/js/document/document-html.js b/js/document/document-html.js index a59f5848..f3163339 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js @@ -164,7 +164,7 @@ exports.HtmlDocument = Montage.create(Component, { //Adding observer to know when template is ready this._observer = new WebKitMutationObserver(this.handleTemplateReady.bind(this)); this._observer.observe(this.model.views.design.document.head, {childList: true}); - }.bind(this), template, {viewCallback: this.handleViewReady, context: this}); + }.bind(this), template, {viewCallback: this.handleReloadViewReady, context: this}); } else if(view === 'code'){ //TODO: Add logic to handle external changed files //Checking for template type and not saving external data @@ -176,6 +176,7 @@ exports.HtmlDocument = Montage.create(Component, { //Setting current view object to code this.currentView = 'code'; this.model.currentView = this.model.views.code; + this.model.currentViewIdentifier = this.model.currentView.identifier; } else { //TODO: Identify default view (probably code) - Error handling } @@ -200,10 +201,22 @@ exports.HtmlDocument = Montage.create(Component, { if(typeof this.model.domContainer !== "undefined") { this.model.domContainer = this.model.documentRoot; } + this.model.currentViewIdentifier = this.model.currentView.identifier; //Making callback after view is loaded this.loaded.callback.call(this.loaded.context, this); } }, + handleReloadViewReady: { + value: function(mObjects) { + this.model.mObjects = mObjects; + // TODO: Find a better way to initialize this property + // Assign the domContainer to be the document root on open + if(typeof this.model.domContainer !== "undefined") { + this.model.domContainer = this.model.documentRoot; + } + this.model.currentViewIdentifier = this.model.currentView.identifier; + } + }, //////////////////////////////////////////////////////////////////// // closeDocument: { diff --git a/js/document/models/base.js b/js/document/models/base.js index 85a0414f..c44123c3 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -88,6 +88,21 @@ exports.BaseDocumentModel = Montage.create(Component, { }, //////////////////////////////////////////////////////////////////// // + _currentViewIdentifier: { + value: "" + }, + //////////////////////////////////////////////////////////////////// + // + currentViewIdentifier: { + get: function() { + return this._currentViewIdentifier; + }, + set: function(value) { + this._currentViewIdentifier = value; + } + }, + //////////////////////////////////////////////////////////////////// + // _selection: { value: [] }, diff --git a/js/document/views/code.js b/js/document/views/code.js index 05f671b2..0ca87fa9 100755 --- a/js/document/views/code.js +++ b/js/document/views/code.js @@ -39,8 +39,8 @@ var Montage = require("montage/core/core").Montage, exports.CodeDocumentView = Montage.create(BaseDocumentView, { //////////////////////////////////////////////////////////////////// // - hasTemplate: { - value: false + identifier: { + value: "code" }, //////////////////////////////////////////////////////////////////// // diff --git a/js/document/views/design-code.js b/js/document/views/design-code.js index 25073833..44d12549 100644 --- a/js/document/views/design-code.js +++ b/js/document/views/design-code.js @@ -40,8 +40,8 @@ var Montage = require("montage/core/core").Montage, exports.DesignCodeView = Montage.create(CodeDocumentView, { //////////////////////////////////////////////////////////////////// // - hasTemplate: { - value: false + identifier: { + value: "design-code" }, //////////////////////////////////////////////////////////////////// // @@ -75,22 +75,6 @@ exports.DesignCodeView = Montage.create(CodeDocumentView, { this.textViewContainer.style.background = "white"; this.textViewContainer.style.height = "100%"; - - ///todo-remove after the switch view logic is added in all the components - this.application.ninja.stage.collapseAllPanels(); - this.application.ninja.stage.hideCanvas(true); - this.application.ninja.stage.hideRulers(); - - document.getElementsByClassName("bindingView")[0].style.display = "none"; - - //bindingView div needs to be display noned - //timeline error on switching back to design view - - ///-end todo-remove - - - - //todo : update options bar // @@ -106,13 +90,6 @@ exports.DesignCodeView = Montage.create(CodeDocumentView, { } this.textViewContainer.style.display = "none"; - ///todo-remove after the switch view logic is added in all the components - this.application.ninja.stage.restoreAllPanels(false); - this.application.ninja.stage.hideCanvas(false); - this.application.ninja.stage.showRulers(); - ///-end todo-remove - - //todo : update options bar // diff --git a/js/document/views/design.js b/js/document/views/design.js index 548e45e9..97558408 100755 --- a/js/document/views/design.js +++ b/js/document/views/design.js @@ -39,8 +39,8 @@ var Montage = require("montage/core/core").Montage, exports.DesignDocumentView = Montage.create(BaseDocumentView, { //////////////////////////////////////////////////////////////////// // - hasTemplate: { - value: false + identifier: { + value: "design" }, //////////////////////////////////////////////////////////////////// // -- cgit v1.2.3