From cdaeb7e05e4d59832b9896f6995e0163e3decf50 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Mon, 16 Jul 2012 14:48:47 -0700 Subject: New: Adding switch view method Added a method to switch views from code and design. (Code is not currently supported) --- js/document/models/base.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'js/document') diff --git a/js/document/models/base.js b/js/document/models/base.js index c7e2de69..a9bbd6db 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -91,6 +91,8 @@ exports.BaseDocumentModel = Montage.create(Component, { _selection: { value: [] }, + //////////////////////////////////////////////////////////////////// + // domContainer: { value: null }, @@ -120,7 +122,8 @@ exports.BaseDocumentModel = Montage.create(Component, { libs: { value: null }, - + //////////////////////////////////////////////////////////////////// + // _mObjects: { value: [] }, @@ -138,6 +141,23 @@ exports.BaseDocumentModel = Montage.create(Component, { switchViewTo: { value: function (view) { // + switch (view) { + case 'design': + // + if (this.views.design) this.views.design.show(); + if (this.views.code) this.views.code.hide(); + this.currentView = this.views.design; + break; + case 'code': + // + if (this.views.code) this.views.code.show(); + if (this.views.design) this.views.design.hide(); + this.currentView = this.views.code; + break; + default: + //Error + break; + } } }, //////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From a402ae19732f7aeb53de27e3f25f72e9c42a453c Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Mon, 16 Jul 2012 14:50:50 -0700 Subject: New: Added switching view functionality to document UI This now let's you switch between code and design views in all documents opened that support design view. Code view for these documents is currently unsupported, so this is just to hook up the UI to the new methods. Code view will be added next. --- js/document/document-html.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'js/document') diff --git a/js/document/document-html.js b/js/document/document-html.js index 142ffe4a..5079cfca 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js @@ -130,6 +130,8 @@ exports.HtmlDocument = Montage.create(Component, { this._observer = null; } }, + //////////////////////////////////////////////////////////////////// + // handleViewReady: { value: function(mObjects) { this.model.mObjects = mObjects; -- cgit v1.2.3 From 17d464e5bd224cdd8940855409359b411325f1df Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Tue, 17 Jul 2012 11:25:41 -0700 Subject: New: Adding re-render method to switching view This now re-renders the design view when switching from code view. There are many outstanding issues, the Time-Line completely breaks and blocks Ninja, it is unknown why, there are too many dependencies. To make it work, we disabled that feature, although this check in does not include that, so it can be fixed proper. Also, the document controller creates a new tab per switch as it does not check that it is the same document. That bug must also be fixed. Finally, we need to hook up a new code view to the document, the current code view will not work as desired, so a new code view must be built and implemented. --- js/document/document-html.js | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) (limited to 'js/document') diff --git a/js/document/document-html.js b/js/document/document-html.js index 5079cfca..b7dacf6a 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js @@ -76,7 +76,7 @@ exports.HtmlDocument = Montage.create(Component, { //////////////////////////////////////////////////////////////////// // init: { - value:function(file, context, callback, view, template) { + value: function(file, context, callback, view, template) { //Storing callback data for loaded dispatch this.loaded.callback = callback; this.loaded.context = context; @@ -122,6 +122,44 @@ exports.HtmlDocument = Montage.create(Component, { } }, //////////////////////////////////////////////////////////////////// + //TODO: Make into one method to use here and one init + reloadView: { + value: function (view, template) { + // + this.model.parentContainer.removeChild(this.model.views.design.iframe); + //Initiliazing views and hiding + if (this.model.views.design.initialize(this.model.parentContainer)) { + //Hiding iFrame, just initiliazing + this.model.views.design.hide(); + //Setting the iFrame property for reference in helper class + this.model.webGlHelper.iframe = this.model.views.design.iframe; + } else { + //ERROR: Design View not initialized + } + // + if (view === 'design') { + //TODO: Remove reference and use as part of model + this.currentView = 'design'; + //Setting current view object to design + this.model.currentView = this.model.views.design; + //Showing design iFrame + this.model.views.design.show(); + this.model.views.design.iframe.style.opacity = 0; + this.model.views.design.content = this.model.file.content; + //TODO: Improve reference (probably through binding values) + this.model.views.design._webGlHelper = this.model.webGlHelper; + //Rendering design view, using observers to know when template is ready + this.model.views.design.render(function () { + //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}); + } else { + //TODO: Identify default view (probably code) + } + } + }, + //////////////////////////////////////////////////////////////////// // handleTemplateReady: { value: function (e) { @@ -140,7 +178,6 @@ exports.HtmlDocument = Montage.create(Component, { if(typeof this.model.domContainer !== "undefined") { this.model.domContainer = this.model.documentRoot; } - //Making callback after view is loaded this.loaded.callback.call(this.loaded.context, this); } -- cgit v1.2.3 From d799a03a52fbf4eaad4e469fabbf84c9bf2cb41d Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Wed, 18 Jul 2012 12:26:08 -0700 Subject: parameterize the parentContainer for text document Signed-off-by: Ananya Sen --- js/document/document-text.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/document') diff --git a/js/document/document-text.js b/js/document/document-text.js index 1fe43494..d06bdefb 100755 --- a/js/document/document-text.js +++ b/js/document/document-text.js @@ -51,13 +51,13 @@ exports.TextDocument = Montage.create(Component, { //////////////////////////////////////////////////////////////////// // init:{ - value: function(file, context, callback, view){ + value: function(file, context, callback, view, parentContainer){ // var codeDocumentView = CodeDocumentView.create(), container = null; //TODO: Why is this initilzied to null? //Creating instance of Text Document Model this.model = Montage.create(TextDocumentModel,{ file: {value: file}, - parentContainer: {value: document.getElementById("codeViewContainer")}, //TODO: Remove reference to this element, should be dynamic + parentContainer: {value: parentContainer}, //TODO: Remove reference to this element, should be dynamic views: {value: {'code': codeDocumentView, 'design': null}} //TODO: Add check if file might have design view, if so, then create it }); //TODO: Add design view logic -- cgit v1.2.3 From c07a7a9d11bc8299fa9686544b18840cc8e640c2 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Mon, 23 Jul 2012 16:59:56 -0700 Subject: show design code editor - first cut Signed-off-by: Ananya Sen --- js/document/document-html.js | 27 +++++++- js/document/views/design-code.js | 130 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 154 insertions(+), 3 deletions(-) create mode 100644 js/document/views/design-code.js (limited to 'js/document') diff --git a/js/document/document-html.js b/js/document/document-html.js index b7dacf6a..76157a07 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js @@ -34,7 +34,8 @@ POSSIBILITY OF SUCH DAMAGE. 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; + DesignDocumentView = require("js/document/views/design").DesignDocumentView, + DesignCodeView = require("js/document/views/design-code").DesignCodeView; //////////////////////////////////////////////////////////////////////// // exports.HtmlDocument = Montage.create(Component, { @@ -77,6 +78,7 @@ 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; @@ -85,7 +87,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': null}} //TODO: Add code view logic + views: {value: {'design': DesignDocumentView.create(), 'code': designCodeView}} //TODO: Add code view logic }); //Calling the any init routines in the model this.model.init(); @@ -98,6 +100,14 @@ exports.HtmlDocument = Montage.create(Component, { } else { //ERROR: Design View not initialized } + + + //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(); + + // if (view === 'design') { //TODO: Remove reference and use as part of model @@ -125,6 +135,7 @@ exports.HtmlDocument = Montage.create(Component, { //TODO: Make into one method to use here and one init reloadView: { value: function (view, template) { + var content; // this.model.parentContainer.removeChild(this.model.views.design.iframe); //Initiliazing views and hiding @@ -154,8 +165,18 @@ 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 { + } else if(view === 'code'){ //TODO: Identify default view (probably code) + + //TODO:get the html content from the 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; + } } }, diff --git a/js/document/views/design-code.js b/js/document/views/design-code.js new file mode 100644 index 00000000..25073833 --- /dev/null +++ b/js/document/views/design-code.js @@ -0,0 +1,130 @@ +/* +Copyright (c) 2012, Motorola Mobility LLC. +All Rights Reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of Motorola Mobility LLC nor the names of its + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + */ + +//////////////////////////////////////////////////////////////////////// +// +var Montage = require("montage/core/core").Montage, + Component = require("montage/ui/component").Component, + CodeDocumentView = require("js/document/views/code").CodeDocumentView; +//////////////////////////////////////////////////////////////////////// +//Code View for the HTML file +// +exports.DesignCodeView = Montage.create(CodeDocumentView, { + //////////////////////////////////////////////////////////////////// + // + hasTemplate: { + value: false + }, + //////////////////////////////////////////////////////////////////// + // + init:{ + value: function (content) { + + } + }, + //////////////////////////////////////////////////////////////////// + // + load:{ + value:function(content){ + //initialize the editor if not yet created + if(this.editor === null){ + //todo: get the proper content + this.textArea.value = content; + this.initializeTextView(this.application.ninja.currentDocument.model.file, this.application.ninja.currentDocument); + return true; + }else{//reload the editor + this.editor.setValue(content); + this.editor.focus(); + } + } + }, + //////////////////////////////////////////////////////////////////// + // + show: { + value: function (callback) { + + this.textViewContainer.style.display = "block"; + 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 + + // + if (callback) callback(); + } + }, + //////////////////////////////////////////////////////////////////// + // + hide: { + value: function (callback) { + if(this.editor){ + this.editor.save();//save to textarea + } + 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 + + // + if (callback) callback(); + } + }, + //////////////////////////////////////////////////////////////////// + // + applyTheme:{ + value:function(themeClass){ + //Todo: change for bucket structure of documents + this.textViewContainer.className = "codeViewContainer "+themeClass; + } + } +}); \ No newline at end of file -- cgit v1.2.3 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. --- js/document/document-html.js | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'js/document') 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 From 2952c2465b9a66076344087f899c5c836ad15ad6 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Russo Date: Mon, 23 Jul 2012 23:05:06 -0700 Subject: New: Adding method to display document in code view Added method to parse in memory document in code view. This allows users to view current in memory document in code view while not saving the document or external files. Still need to handle naming of paths for files that require saving but are not saved (webGL and Montage libraries). Also, need to implement method to switch back from code view to design view, but will need Timeline fixes. --- js/document/document-html.js | 18 ++++++++---------- js/document/mediators/template.js | 12 ++++++------ 2 files changed, 14 insertions(+), 16 deletions(-) (limited to 'js/document') diff --git a/js/document/document-html.js b/js/document/document-html.js index 569b6d8b..81a8912b 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js @@ -135,8 +135,7 @@ exports.HtmlDocument = Montage.create(Component, { //////////////////////////////////////////////////////////////////// //TODO: Make into one method to use here and one init reloadView: { - value: function (view, template) { - var content; + value: function (view, template, doc) { // this.model.parentContainer.removeChild(this.model.views.design.iframe); //Initiliazing views and hiding @@ -167,14 +166,13 @@ 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: 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); + //TODO: Add logic to handle external changed files + //Checking for template type and not saving external data + if (doc.template && (doc.template.type === 'banner' || doc.template.type === 'animation')) { + this.model.views.code.load(this.application.ninja.ioMediator.tmplt.parseNinjaTemplateToHtml(false, doc, true, null).content); + } else { + this.model.views.code.load(this.application.ninja.ioMediator.tmplt.parseNinjaTemplateToHtml(false, doc, false, null).content); + } //Setting current view object to code this.currentView = 'code'; this.model.currentView = this.model.views.code; diff --git a/js/document/mediators/template.js b/js/document/mediators/template.js index 4065f471..c68cfe72 100755 --- a/js/document/mediators/template.js +++ b/js/document/mediators/template.js @@ -47,7 +47,7 @@ exports.TemplateDocumentMediator = Montage.create(Component, { // getAppTemplatesUrlRegEx: { value: function () { - var regex = new RegExp(chrome.extension.getURL(this.application.ninja.currentDocument.model.views.design.iframe.src.split(chrome.extension.getURL('/'))[1]).replace(/\//gi, '\\\/'), 'gi'); + var regex = new RegExp(chrome.extension.getURL(this.application.ninja.currentDocument.model.views.design.document.baseURI.split(chrome.extension.getURL('/'))[1]).replace(/\//gi, '\\\/'), 'gi'); return regex; } }, @@ -326,7 +326,7 @@ exports.TemplateDocumentMediator = Montage.create(Component, { } } } - } else if (template.css) { + } else if (template.css && saveExternalData) { //Getting all style and link tags var styleCounter = 0, docStyles = template.file.content.document.getElementsByTagName('style'), @@ -480,7 +480,7 @@ exports.TemplateDocumentMediator = Montage.create(Component, { //Copy webGL library if needed for (var i in this.application.ninja.coreIoApi.ninjaLibrary.libs) { //Checking for RDGE library to be available - if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'RDGE') { + if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'RDGE' && saveExternalData) { rdgeDirName = (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name + this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase(); rdgeVersion = this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version; this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.file.root, rdgeDirName, function(result) {libsobserver.canvasCopied = result; this.libCopied(libsobserver);}.bind(this)); @@ -564,7 +564,7 @@ exports.TemplateDocumentMediator = Montage.create(Component, { webgllibtag.setAttribute('data-ninja-canvas-json', this.application.ninja.coreIoApi.rootUrl+'/'+cvsDataFileUrl); webgllibtag.setAttribute('data-ninja-canvas-libpath', rdgeDirName); // - if (cvsDataFileCheck.status === 404 || cvsDataFileCheck.status === 204) { + if (saveExternalData && (cvsDataFileCheck.status === 404 || cvsDataFileCheck.status === 204)) { //Saving file cvsDataFileOperation = this.application.ninja.ioMediator.fio.saveFile({uri: cvsDataFilePath, contents: json}); } else { @@ -592,13 +592,13 @@ exports.TemplateDocumentMediator = Montage.create(Component, { //TODO: Make proper Montage method - + var mjsDirName, mjsVersion; //Checking for Montage if (mJsSerialization) { //Copy Montage library if needed for (var i in this.application.ninja.coreIoApi.ninjaLibrary.libs) { //Checking for Montage library to be available - if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'Montage') { + if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'Montage' && saveExternalData) { mjsDirName = (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name + this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase(); mjsVersion = this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version; this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.file.root, mjsDirName, function(result) {libsobserver.montageCopied = result; this.libCopied(libsobserver);}.bind(this)); -- cgit v1.2.3 From 5454cc462903c83a8c3651065b03cc1855db125e Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Tue, 24 Jul 2012 12:11:53 -0700 Subject: New: Adding method to switch from code to design view Added functionality to parse the code view string back into a Ninja template object to redraw design view. Only outstanding bugs are timeline errors and code view layout issues. --- js/document/document-html.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/document') diff --git a/js/document/document-html.js b/js/document/document-html.js index 81a8912b..a59f5848 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js @@ -156,7 +156,7 @@ exports.HtmlDocument = Montage.create(Component, { //Showing design iFrame this.model.views.design.show(); this.model.views.design.iframe.style.opacity = 0; - this.model.views.design.content = this.model.file.content; + this.model.views.design.content = this.application.ninja.ioMediator.tmplt.parseHtmlToNinjaTemplate(doc); //TODO: Improve reference (probably through binding values) this.model.views.design._webGlHelper = this.model.webGlHelper; //Rendering design view, using observers to know when template is ready -- cgit v1.2.3 From 791e1633e2c08543e236b0d25b5edd9aec2a003b Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Tue, 24 Jul 2012 14:42:04 -0700 Subject: New: Adding logic to insert code view save method(s) --- js/document/models/base.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'js/document') diff --git a/js/document/models/base.js b/js/document/models/base.js index a9bbd6db..85a0414f 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -253,8 +253,10 @@ exports.BaseDocumentModel = Montage.create(Component, { this.libs.canvas = true; } } + } else if (this.currentView === this.views.code) { + //TODO: Add save logic for code view } else { - //TODO: Add logic to save code view data + //TODO: Error handle } } }, @@ -294,8 +296,10 @@ exports.BaseDocumentModel = Montage.create(Component, { this.libs.canvas = true; } } + } else if (this.currentView === this.views.code) { + //TODO: Add save logic for code view } else { - //TODO: Add logic to save code view data + //TODO: Error handle } } -- cgit v1.2.3 From 3ec902504a7188b6468d93e9ec194bb97af6222f Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Tue, 24 Jul 2012 15:09:05 -0700 Subject: Update: Copying libraries to disk on switching views This is a temporary fix to allow the code view to show the actually libraries copied to disk, otherwise there is no current feedback to users to know where these files exists (or would) on disk until the operation is made. This allows the user to edit a file consuming libraries in memory to edit in code view and changes reflect such changes without losing track of libraries. --- js/document/mediators/template.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'js/document') diff --git a/js/document/mediators/template.js b/js/document/mediators/template.js index c68cfe72..3f7f53b8 100755 --- a/js/document/mediators/template.js +++ b/js/document/mediators/template.js @@ -480,7 +480,7 @@ exports.TemplateDocumentMediator = Montage.create(Component, { //Copy webGL library if needed for (var i in this.application.ninja.coreIoApi.ninjaLibrary.libs) { //Checking for RDGE library to be available - if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'RDGE' && saveExternalData) { + if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'RDGE') { rdgeDirName = (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name + this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase(); rdgeVersion = this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version; this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.file.root, rdgeDirName, function(result) {libsobserver.canvasCopied = result; this.libCopied(libsobserver);}.bind(this)); @@ -564,7 +564,7 @@ exports.TemplateDocumentMediator = Montage.create(Component, { webgllibtag.setAttribute('data-ninja-canvas-json', this.application.ninja.coreIoApi.rootUrl+'/'+cvsDataFileUrl); webgllibtag.setAttribute('data-ninja-canvas-libpath', rdgeDirName); // - if (saveExternalData && (cvsDataFileCheck.status === 404 || cvsDataFileCheck.status === 204)) { + if (cvsDataFileCheck.status === 404 || cvsDataFileCheck.status === 204) { //Saving file cvsDataFileOperation = this.application.ninja.ioMediator.fio.saveFile({uri: cvsDataFilePath, contents: json}); } else { @@ -598,7 +598,7 @@ exports.TemplateDocumentMediator = Montage.create(Component, { //Copy Montage library if needed for (var i in this.application.ninja.coreIoApi.ninjaLibrary.libs) { //Checking for Montage library to be available - if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'Montage' && saveExternalData) { + if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'Montage') { mjsDirName = (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name + this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase(); mjsVersion = this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version; this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.file.root, mjsDirName, function(result) {libsobserver.montageCopied = result; this.libCopied(libsobserver);}.bind(this)); -- cgit v1.2.3 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 From 7fa0c53c14e9029d2e3960cc81edf91592fd1768 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Wed, 25 Jul 2012 12:26:20 -0700 Subject: added save for code view, fixed code view editor bug, reuse code editor options component in document bar Signed-off-by: Ananya Sen Conflicts: js/document/views/design-code.js Signed-off-by: Ananya Sen --- js/document/models/base.js | 11 +++++++++++ js/document/views/design-code.js | 5 +---- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'js/document') diff --git a/js/document/models/base.js b/js/document/models/base.js index c44123c3..a73b8b20 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -236,6 +236,8 @@ exports.BaseDocumentModel = Montage.create(Component, { // save: { value: function (callback, libCopyCallback) { + var self = this; + //TODO: Implement on demand logic if (this.needsSave) { //Save @@ -270,6 +272,15 @@ exports.BaseDocumentModel = Montage.create(Component, { } } else if (this.currentView === this.views.code) { //TODO: Add save logic for code view + //save to textarea + self.views.code.editor.save(); + //save to disk + this.application.ninja.ioMediator.fileSave({ + mode: 'html-text', + file: self.file, + content:self.views.code.textArea.value + }, this.handleSaved.bind({callback: callback, model: this})); + } else { //TODO: Error handle } diff --git a/js/document/views/design-code.js b/js/document/views/design-code.js index 44d12549..8ad6d555 100644 --- a/js/document/views/design-code.js +++ b/js/document/views/design-code.js @@ -70,10 +70,7 @@ exports.DesignCodeView = Montage.create(CodeDocumentView, { // show: { value: function (callback) { - - this.textViewContainer.style.display = "block"; - this.textViewContainer.style.background = "white"; - this.textViewContainer.style.height = "100%"; + this.textViewContainer.setAttribute("class", "codeViewContainer cm-s-default"); //todo : update options bar -- cgit v1.2.3 From 0262cbeccef538d3aa125eb7cd16d8ca758c82b1 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Wed, 25 Jul 2012 12:27:40 -0700 Subject: added save for code view, fixed code view editor bug, reuse code editor options component in document bar Signed-off-by: Ananya Sen Conflicts: js/document/views/design-code.js Signed-off-by: Ananya Sen --- js/document/views/design-code.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/document') diff --git a/js/document/views/design-code.js b/js/document/views/design-code.js index 8ad6d555..70afe785 100644 --- a/js/document/views/design-code.js +++ b/js/document/views/design-code.js @@ -72,7 +72,7 @@ exports.DesignCodeView = Montage.create(CodeDocumentView, { value: function (callback) { this.textViewContainer.setAttribute("class", "codeViewContainer cm-s-default"); - //todo : update options bar + //todo : update options bar // if (callback) callback(); -- cgit v1.2.3 From fa2e82cf10aaa4900a462410cbb99b5b0433a1b1 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Wed, 25 Jul 2012 12:28:58 -0700 Subject: fixing code editor double vertical scrollbar bug Signed-off-by: Ananya Sen Conflicts: js/document/views/design-code.js Signed-off-by: Ananya Sen --- js/document/views/design-code.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'js/document') diff --git a/js/document/views/design-code.js b/js/document/views/design-code.js index 70afe785..bf6e186f 100644 --- a/js/document/views/design-code.js +++ b/js/document/views/design-code.js @@ -72,7 +72,9 @@ exports.DesignCodeView = Montage.create(CodeDocumentView, { value: function (callback) { this.textViewContainer.setAttribute("class", "codeViewContainer cm-s-default"); - //todo : update options bar + this.textViewContainer.style.display = "block"; + + //todo : update options bar // if (callback) callback(); -- cgit v1.2.3 From aada5dbc179c06f2eb04db1d5651bb48bf32ec82 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Tue, 31 Jul 2012 13:26:48 -0700 Subject: Fix: Enabling preview from code view Added a temp patch to enable preview from code view when viewing HTML document (with design view). This does not save external assets, so CSS and components will not be saved. --- js/document/models/base.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'js/document') diff --git a/js/document/models/base.js b/js/document/models/base.js index a73b8b20..d51806b2 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -323,7 +323,8 @@ exports.BaseDocumentModel = Montage.create(Component, { } } } else if (this.currentView === this.views.code) { - //TODO: Add save logic for code view + //TODO: Add save logic for code view (this is a temp patch) + this.save(libCopyCallback); } else { //TODO: Error handle } -- cgit v1.2.3