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 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'js/document/document-html.js') 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: { -- cgit v1.2.3