From 5946ec8651547f846520add097850470a09df635 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Russo Date: Mon, 23 Jul 2012 19:07:11 -0700 Subject: In Progress: Cleaning up merge Cleaned up new updates. Still pending is adding functionality to parse the document when toggling views and fix Timeline errors. Code view also has some rending issues that will be fixed, this is just a clean up. --- .../layout/document-bar.reel/document-bar.js | 63 +++++++++------------- js/document/document-html.js | 27 +++++----- 2 files changed, 41 insertions(+), 49 deletions(-) diff --git a/js/components/layout/document-bar.reel/document-bar.js b/js/components/layout/document-bar.reel/document-bar.js index 803d2c3a..f5e61a18 100755 --- a/js/components/layout/document-bar.reel/document-bar.js +++ b/js/components/layout/document-bar.reel/document-bar.js @@ -73,12 +73,12 @@ exports.DocumentBar = Montage.create(Component, { _codeEditorWrapper:{ value: null }, - + //////////////////////////////////////////////////////////////////// + // codeEditorWrapper:{ - get : function() { - return this._codeEditorWrapper; - }, - set : function(value) { + get: function() {return this._codeEditorWrapper;}, + set: function(value) { + // if(this._codeEditorWrapper !== value){ this._codeEditorWrapper = value; } @@ -89,9 +89,13 @@ exports.DocumentBar = Montage.create(Component, { btnCode: { value: null }, + //////////////////////////////////////////////////////////////////// + // btnDesign: { value: null }, + //////////////////////////////////////////////////////////////////// + // btnPreview: { value: null }, @@ -209,52 +213,37 @@ exports.DocumentBar = Montage.create(Component, { }, //////////////////////////////////////////////////////////////////// // - renderDesignView: { + showViewDesign: { value: function () { - //Reloading in design view (with updates from other view) - this.reloadView('design', this.fileTemplate); + // + this.showView('design', this.renderDesignView, this.btnDesign, this.btnCode); } }, //////////////////////////////////////////////////////////////////// // - renderCodeView: { + showViewCode: { value: function () { - //Reloading in code view (with updates from other view) - this.reloadView('code', this.fileTemplate); + // + this.showView('code', this.renderCodeView, this.btnCode, this.btnDesign); } }, //////////////////////////////////////////////////////////////////// // - showViewDesign: { - value: function () { - // - if (this._currentDocument.model.currentView !== 'design') { + showView: { + value: function (view, render, aBtn, iBtn) { + //TODO: Remove reference to string view + if (this._currentDocument.model.currentView !== view) { // - this._currentDocument.model.switchViewTo('design'); - this.btnCode.setAttribute('class', 'inactive'); - this.btnDesign.removeAttribute('class'); - //this._currentDocument.model.file.content.body = '
hello
hello
'; - var render = this.renderDesignView.bind(this._currentDocument); - render(); + this._currentDocument.model.switchViewTo(view); + iBtn.setAttribute('class', 'inactive'); + aBtn.removeAttribute('class'); + //TODO: Add document parsing to reload view + this._currentDocument.reloadView(view, this.fileTemplate); } - } + } }, //////////////////////////////////////////////////////////////////// - //TODO: Implement code with that updates the file template through the ninja document parser - showViewCode: { - value: function () { - // - if (this._currentDocument.model.currentView !== 'code') { - // - this._currentDocument.model.switchViewTo('code'); - this.btnDesign.setAttribute('class', 'inactive'); - this.btnCode.removeAttribute('class'); - var render = this.renderCodeView.bind(this._currentDocument); - render(); - } - } - }, - + // handleClick: { value: function(evt) { NJevent("executePreview"); diff --git a/js/document/document-html.js b/js/document/document-html.js index 76157a07..569b6d8b 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js @@ -35,7 +35,7 @@ var Montage = require("montage/core/core").Montage, Component = require("montage/ui/component").Component, HtmlDocumentModel = require("js/document/models/html").HtmlDocumentModel, DesignDocumentView = require("js/document/views/design").DesignDocumentView, - DesignCodeView = require("js/document/views/design-code").DesignCodeView; + CodeDocumentView = require("js/document/views/design-code").DesignCodeView; //////////////////////////////////////////////////////////////////////// // exports.HtmlDocument = Montage.create(Component, { @@ -78,7 +78,6 @@ exports.HtmlDocument = Montage.create(Component, { // init: { value: function(file, context, callback, view, template) { - var designCodeView = DesignCodeView.create(); //Storing callback data for loaded dispatch this.loaded.callback = callback; this.loaded.context = context; @@ -87,7 +86,7 @@ exports.HtmlDocument = Montage.create(Component, { file: {value: file}, fileTemplate: {value: template}, parentContainer: {value: document.getElementById("iframeContainer")}, //Saving reference to parent container of all views (should be changed to buckets approach - views: {value: {'design': DesignDocumentView.create(), 'code': designCodeView}} //TODO: Add code view logic + views: {value: {'design': DesignDocumentView.create(), 'code': CodeDocumentView.create()}} //TODO: Add code view logic }); //Calling the any init routines in the model this.model.init(); @@ -101,10 +100,10 @@ exports.HtmlDocument = Montage.create(Component, { //ERROR: Design View not initialized } - + + //TODO: Make sure you have a boolean to indicate if view was initilize and handle errors (just like design view above) //initialize the code view for the html document and hide it since design is the default view this.model.views.code.initialize(this.model.parentContainer); - this.model.views.code.hide(); @@ -126,8 +125,10 @@ exports.HtmlDocument = Montage.create(Component, { 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}); + } else if (view === 'code'){ + //TODO: Add logic to open document in code view since it's now available } else { - //TODO: Identify default view (probably code) + //TODO: Add error handling } } }, @@ -166,17 +167,19 @@ exports.HtmlDocument = Montage.create(Component, { this._observer.observe(this.model.views.design.document.head, {childList: true}); }.bind(this), template, {viewCallback: this.handleViewReady, context: this}); } else if(view === 'code'){ - //TODO: Identify default view (probably code) - - //TODO:get the html content from the document + + + //TODO: Parse in memory document through template to get current document content = ''+this.model.file.content.head+''+this.model.file.content.body+'';//dummy - + + + // this.model.views.code.load(content); - //Setting current view object to code this.currentView = 'code'; this.model.currentView = this.model.views.code; - + } else { + //TODO: Identify default view (probably code) - Error handling } } }, -- cgit v1.2.3