From 7bdcab084d1991361ba8d37a7435efd229648630 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Tue, 1 May 2012 10:12:40 -0700 Subject: Setting up new architecture for I/O --- js/document/models/base.js | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'js/document/models') diff --git a/js/document/models/base.js b/js/document/models/base.js index f237e793..f4dbbc0b 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -21,18 +21,26 @@ exports.BaseDocumentModel = Montage.create(Montage, { file: { value: null }, - + //////////////////////////////////////////////////////////////////// + // _name: { value: null }, - + //////////////////////////////////////////////////////////////////// + // _isActive: { value: null }, - + //////////////////////////////////////////////////////////////////// + // _needsSave: { value: null }, + //////////////////////////////////////////////////////////////////// + // + _currentView: { + value: null + }, //////////////////////////////////////////////////////////////////// // njdata: { @@ -42,6 +50,26 @@ exports.BaseDocumentModel = Montage.create(Montage, { // views: { value: null + }, + //////////////////////////////////////////////////////////////////// + // + save: { + value: null + }, + //////////////////////////////////////////////////////////////////// + // + saveAs: { + value: null + }, + //////////////////////////////////////////////////////////////////// + // + saveAll: { + value: null + }, + //////////////////////////////////////////////////////////////////// + // + close: { + value: null } //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 4ba680a7e9168d0f505a81e42a287dfbc54b4d7d Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Tue, 1 May 2012 15:26:37 -0700 Subject: Preliminary IO to new DOM view --- js/document/models/base.js | 55 +++++++++++++++++++++++++++++++++++----------- js/document/models/html.js | 1 - 2 files changed, 42 insertions(+), 14 deletions(-) (limited to 'js/document/models') diff --git a/js/document/models/base.js b/js/document/models/base.js index f4dbbc0b..3bb69f6b 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -6,36 +6,49 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot //////////////////////////////////////////////////////////////////////// // -var Montage = require("montage/core/core").Montage; +var Montage = require("montage/core/core").Montage, + Component = require("montage/ui/component").Component; //////////////////////////////////////////////////////////////////////// // -exports.BaseDocumentModel = Montage.create(Montage, { +exports.BaseDocumentModel = Montage.create(Component, { //////////////////////////////////////////////////////////////////// // hasTemplate: { - enumerable: false, value: false }, //////////////////////////////////////////////////////////////////// // - file: { + _file: { value: null }, - //////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////// // - _name: { - value: null + file: { + get: function() {return this._file;}, + set: function(value) {this._file = value;} }, //////////////////////////////////////////////////////////////////// // _isActive: { value: null + }, + //////////////////////////////////////////////////////////////////// + // + isActive: { + get: function() {return this._isActive;}, + set: function(value) {this._isActive = value;} }, //////////////////////////////////////////////////////////////////// // _needsSave: { value: null }, + //////////////////////////////////////////////////////////////////// + // + needsSave: { + get: function() {return this._needsSave;}, + set: function(value) {this._needsSave = value;} + }, //////////////////////////////////////////////////////////////////// // _currentView: { @@ -43,33 +56,49 @@ exports.BaseDocumentModel = Montage.create(Montage, { }, //////////////////////////////////////////////////////////////////// // - njdata: { - value: null + currentView: { + get: function() {return this._currentView;}, + set: function(value) {this._currentView = value;} }, //////////////////////////////////////////////////////////////////// // views: { value: null }, + //////////////////////////////////////////////////////////////////// + // + switchViewTo: { + value: function () { + // + } + }, //////////////////////////////////////////////////////////////////// // save: { - value: null + value: function () { + // + } }, //////////////////////////////////////////////////////////////////// // saveAs: { - value: null + value: function () { + // + } }, //////////////////////////////////////////////////////////////////// // saveAll: { - value: null + value: function () { + // + } }, //////////////////////////////////////////////////////////////////// // close: { - value: null + value: function () { + // + } } //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// diff --git a/js/document/models/html.js b/js/document/models/html.js index ff57454b..f45a0e21 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js @@ -14,7 +14,6 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { //////////////////////////////////////////////////////////////////// // hasTemplate: { - enumerable: false, value: false } //////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From efe62dff2ba6894551fb9679d150255bae5af36e Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 4 May 2012 16:00:14 -0700 Subject: Draw 3d grid by default since app model is not hooked up yet. Signed-off-by: Nivesh Rajbhandari --- js/document/models/html.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'js/document/models') diff --git a/js/document/models/html.js b/js/document/models/html.js index f45a0e21..5eedb731 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js @@ -15,6 +15,10 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { // hasTemplate: { value: false + }, + + draw3DGrid: { + value: false } //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From b8c27edc106818ff84f93ebe30ce50359a03885b Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Mon, 7 May 2012 13:21:31 -0700 Subject: Adding webGL support for opening files Added I/O for loading webGL on open file. I/O support for saving to come. --- js/document/models/base.js | 13 +++ js/document/models/html.js | 197 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 207 insertions(+), 3 deletions(-) (limited to 'js/document/models') diff --git a/js/document/models/base.js b/js/document/models/base.js index 3bb69f6b..746922ad 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -72,6 +72,19 @@ exports.BaseDocumentModel = Montage.create(Component, { // } }, + //////////////////////////////////////////////////////////////////// + // + browserPreview: { + value: function (browser) { + // + switch (browser) { + case 'chrome': + break; + default: + break; + } + } + }, //////////////////////////////////////////////////////////////////// // save: { diff --git a/js/document/models/html.js b/js/document/models/html.js index 5eedb731..e0a18850 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js @@ -7,7 +7,10 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot //////////////////////////////////////////////////////////////////////// // var Montage = require("montage/core/core").Montage, - BaseDocumentModel = require("js/document/models/base").BaseDocumentModel; + BaseDocumentModel = require("js/document/models/base").BaseDocumentModel, + MaterialsModel = require("js/models/materials-model").MaterialsModel, + NJUtils = require("js/lib/NJUtils").NJUtils, + GLWorld = require("js/lib/drawing/world").World; //////////////////////////////////////////////////////////////////////// // exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { @@ -16,10 +19,198 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { hasTemplate: { value: false }, - + //////////////////////////////////////////////////////////////////// + // draw3DGrid: { value: false - } + }, + //////////////////////////////////////////////////////////////////// + // + _glData: { + value: null + }, + //////////////////////////////////////////////////////////////////// + // + glData: { + // + get: function() { + // + var elt = this.views.design.iframe.contentWindow.document.body; + // + if (elt) { + var matLib = MaterialsModel.exportMaterials(); + this._glData = [matLib]; + this.collectGLData(elt, this._glData ); + } else { + this._glData = null + } + // + return this._glData; + }, + // + set: function(value) { + // + var elt = this.views.design.iframe.contentWindow.document.body; + // + if (elt) { + /* + // Use this code to test the runtime version of WebGL + var cdm = new NinjaCvsRt.CanvasDataManager(); + cdm.loadGLData(elt, value, null ); + */ + + // + var i, nWorlds= value.length; + // + for (i = 0; i < nWorlds; i++) { + // get the data for the next canvas + var importStr = value[i], id, jObj, index = importStr.indexOf(';'), matLibStr, matLibObj, startIndex, endIndex, canvas, useWebGL, world; + // determine if it is the new (JSON) or old style format + if ((importStr[0] === 'v') && (index < 24)) { + // JSON format. pull off the + importStr = importStr.substr(index+1); + jObj = JSON.parse(importStr); + id = jObj.id; + } else { + // at this point the data could be either the materials library or + // an old style world. We can determine which by converting the string + // to an object via JSON.parse. That operation will fail if the string + // is an old style world. + matLibStr = 'materialLibrary;'; + index = importStr.indexOf(matLibStr); + if (index == 0) { + importStr = importStr.substr(matLibStr.length); + matLibObj = JSON.parse(importStr); + MaterialsModel.importMaterials(matLibObj); + } else { + startIndex = importStr.indexOf("id: "); + if (startIndex >= 0) { + endIndex = importStr.indexOf("\n", startIndex); + if (endIndex > 0) id = importStr.substring(startIndex+4, endIndex); + } + } + } + // + if (id != null) { + // + canvas = this.findCanvasWithID(id, elt); + // + if (canvas) { + // + if (!canvas.elementModel) { + NJUtils.makeElementModel(canvas, "Canvas", "shape", true); + } + // + if (canvas.elementModel) { + if (canvas.elementModel.shapeModel.GLWorld) { + canvas.elementModel.shapeModel.GLWorld.clearTree(); + } + // + if (jObj) { + useWebGL = jObj.webGL; + world = new GLWorld(canvas, useWebGL); + world.importJSON(jObj); + } + // + this.buildShapeModel(canvas.elementModel, world); + } + } + } + } + } + } + }, + //////////////////////////////////////////////////////////////////// + // + findCanvasWithID: { + value: function(id, elt) { + // + var i, child, nKids, foundElt, cid = elt.getAttribute("data-RDGE-id"); + // + if (cid == id) return elt; + // + if (elt.children) { + nKids = elt.children.length; + for (i=0; i= 0) { - endIndex = importStr.indexOf("\n", startIndex); - if (endIndex > 0) id = importStr.substring(startIndex+4, endIndex); - } - } - } - // - if (id != null) { - // - canvas = this.findCanvasWithID(id, elt); - // - if (canvas) { - // - if (!canvas.elementModel) { - NJUtils.makeElementModel(canvas, "Canvas", "shape", true); - } - // - if (canvas.elementModel) { - if (canvas.elementModel.shapeModel.GLWorld) { - canvas.elementModel.shapeModel.GLWorld.clearTree(); - } - // - if (jObj) { - useWebGL = jObj.webGL; - world = new GLWorld(canvas, useWebGL); - world.importJSON(jObj); - } - // - this.buildShapeModel(canvas.elementModel, world); - } - } - } - } - } - } - }, - //////////////////////////////////////////////////////////////////// - // - findCanvasWithID: { - value: function(id, elt) { - // - var i, child, nKids, foundElt, cid = elt.getAttribute("data-RDGE-id"); - // - if (cid == id) return elt; - // - if (elt.children) { - nKids = elt.children.length; - for (i=0; i --- js/document/models/html.js | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'js/document/models') diff --git a/js/document/models/html.js b/js/document/models/html.js index 1639a8e2..2764a6d6 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js @@ -26,9 +26,36 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { // webGlHelper: { value: webGlDocumentHelper - } + }, //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// + userComponents: { + value: {} + }, + + /** + * Add a reference to a component instance to the userComponents hash using the + * element UUID + */ + setComponentInstance: { + value: function(instance, el) { + this.userComponents[el.uuid] = instance; + } + }, + + /** + * Returns the component instance obj from the element + */ + getComponentFromElement: { + value: function(el) { + if(el) { + if(el.uuid) return this.userComponents[el.uuid]; + } else { + return null; + } + } + } + }); //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// \ No newline at end of file -- cgit v1.2.3 From 3811f72f8cd8caaa2d13fa695b918f25facb85c5 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Wed, 9 May 2012 16:28:13 -0700 Subject: Preliminary Montage Template Cleanup The template creator is currently not returning serializing code, but does clean the document. Need to investigate reason why, currently all components are removed on save. --- js/document/models/html.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'js/document/models') diff --git a/js/document/models/html.js b/js/document/models/html.js index 2764a6d6..b57ff832 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js @@ -22,30 +22,30 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { draw3DGrid: { value: false }, + //////////////////////////////////////////////////////////////////// + // + baseHref: { + value: null + }, //////////////////////////////////////////////////////////////////// // webGlHelper: { value: webGlDocumentHelper }, - //////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////// + // userComponents: { value: {} }, - - /** - * Add a reference to a component instance to the userComponents hash using the - * element UUID - */ + //////////////////////////////////////////////////////////////////// + //Add a reference to a component instance to the userComponents hash using the element UUID setComponentInstance: { value: function(instance, el) { this.userComponents[el.uuid] = instance; } }, - - /** - * Returns the component instance obj from the element - */ + //////////////////////////////////////////////////////////////////// + //Returns the component instance obj from the element getComponentFromElement: { value: function(el) { if(el) { @@ -55,7 +55,8 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { } } } - + //////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////// }); //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// \ No newline at end of file -- cgit v1.2.3 From fb7a3aa9ce0d9b99dca79cfb89951b5c51523250 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 10 May 2012 14:54:38 -0700 Subject: Adding partial close functionality --- js/document/models/base.js | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) (limited to 'js/document/models') diff --git a/js/document/models/base.js b/js/document/models/base.js index 2bbbe501..ebfb73b8 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -60,6 +60,11 @@ exports.BaseDocumentModel = Montage.create(Component, { get: function() {return this._currentView;}, set: function(value) {this._currentView = value;} }, + //////////////////////////////////////////////////////////////////// + // + parentContainer: { + value: null + }, //////////////////////////////////////////////////////////////////// // views: { @@ -114,6 +119,12 @@ exports.BaseDocumentModel = Montage.create(Component, { // save: { value: function (callback) { + // + if (this.needsSave) { + //Save + } else { + //Ignore command + } // if (this.currentView === this.views.design) { // @@ -129,18 +140,18 @@ exports.BaseDocumentModel = Montage.create(Component, { } else { //TODO: Add logic to save code view data } - // - if (this.needsSave) { - //Save - } else { - //Ignore command - } } }, //////////////////////////////////////////////////////////////////// // saveAll: { value: function (callback) { + // + if (this.needsSave) { + //Save + } else { + //Ignore command + } // if (this.currentView === this.views.design) { // @@ -156,12 +167,7 @@ exports.BaseDocumentModel = Montage.create(Component, { } else { //TODO: Add logic to save code view data } - // - if (this.needsSave) { - //Save - } else { - //Ignore command - } + } }, //////////////////////////////////////////////////////////////////// @@ -179,13 +185,24 @@ exports.BaseDocumentModel = Montage.create(Component, { //////////////////////////////////////////////////////////////////// // close: { - value: function () { + value: function (view, callback) { + //Outcome of close (pending on save logic) + var success; // if (this.needsSave) { //Prompt user to save of lose data } else { //Close file + success = true; + } + // + if (this.views.design && (!view || view === 'design')) { + // + this.parentContainer.removeChild(this.views.design.iframe); + this.views.design = null; } + // + if (callback) callback(success); } } //////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From c87e538fdc337639bc4d54bb087dbf2b4f20297f Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 11 May 2012 14:41:20 -0700 Subject: Adding support for new templates This is supported for NEW and OPEN, SAVE is not supported yet by I/O. Saving works, but it will not be a banner template. --- js/document/models/base.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'js/document/models') diff --git a/js/document/models/base.js b/js/document/models/base.js index ebfb73b8..0f58e75c 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -60,6 +60,11 @@ exports.BaseDocumentModel = Montage.create(Component, { get: function() {return this._currentView;}, set: function(value) {this._currentView = value;} }, + //////////////////////////////////////////////////////////////////// + // + fileTemplate: { + value: null + }, //////////////////////////////////////////////////////////////////// // parentContainer: { -- cgit v1.2.3 From bffc9b2a4bd3480a6e369a36660ce402f7e16aba Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Tue, 15 May 2012 12:01:37 -0700 Subject: File save for banner template Adding file save for templates, completing I/O. --- js/document/models/base.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'js/document/models') diff --git a/js/document/models/base.js b/js/document/models/base.js index 0f58e75c..5f2a5893 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -138,6 +138,7 @@ exports.BaseDocumentModel = Montage.create(Component, { file: this.file, webgl: this.webGlHelper.glData, styles: this.getStyleSheets(), + template: this.fileTemplate, document: this.views.design.iframe.contentWindow.document, head: this.views.design.iframe.contentWindow.document.head, body: this.views.design.iframe.contentWindow.document.body @@ -165,6 +166,7 @@ exports.BaseDocumentModel = Montage.create(Component, { file: this.file, webgl: this.webGlHelper.glData, css: this.getStyleSheets(), + template: this.fileTemplate, document: this.views.design.iframe.contentWindow.document, head: this.views.design.iframe.contentWindow.document.head, body: this.views.design.iframe.contentWindow.document.body -- cgit v1.2.3 From 620ae8f53d4da25c65adb675c0b0ee187e5754fc Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Tue, 15 May 2012 16:49:32 -0700 Subject: Adding special preview for templates --- js/document/models/base.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'js/document/models') diff --git a/js/document/models/base.js b/js/document/models/base.js index 5f2a5893..e8eba89f 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -93,13 +93,21 @@ exports.BaseDocumentModel = Montage.create(Component, { //Currently only supporting current browser (Chrome, obviously) switch (this.browser) { case 'chrome': - window.open(this.url); + if (this.template.type === 'banner' || this.template.type === 'animation') { + window.open('/js/document/templates/preview/banner.html?width='+this.template.size.width+'&height='+this.template.size.height+'&url='+this.url); + } else { + window.open(this.url); + } break; default: - window.open(this.url); + if (this.template.type === 'banner' || this.template.type === 'animation') { + window.open('/js/document/templates/preview/banner.html?width='+this.template.size.width+'&height='+this.template.size.height+'&url='+this.url); + } else { + window.open(this.url); + } break; } - }.bind({browser: browser, url: url})); + }.bind({browser: browser, url: url, template: this.fileTemplate})); } }, //////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 919a0d0ed35c24b1047281723ddde2ac98fc9a3e Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 15 May 2012 22:36:44 -0700 Subject: document close handler. initial working draft Signed-off-by: Valerio Virgillito --- js/document/models/base.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'js/document/models') diff --git a/js/document/models/base.js b/js/document/models/base.js index 5f2a5893..d34fb2dd 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -206,10 +206,11 @@ exports.BaseDocumentModel = Montage.create(Component, { if (this.views.design && (!view || view === 'design')) { // this.parentContainer.removeChild(this.views.design.iframe); + this.views.design.pauseAndStopVideos(); this.views.design = null; } // - if (callback) callback(success); + return success; } } //////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 5de553a1b3bdd8783ab6ce017ae70369ad92a890 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Wed, 16 May 2012 11:37:05 -0700 Subject: Fixing preview bug Also setting up for Montage component serialization. --- js/document/models/base.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/document/models') diff --git a/js/document/models/base.js b/js/document/models/base.js index f9844b70..033e16f6 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -93,7 +93,7 @@ exports.BaseDocumentModel = Montage.create(Component, { //Currently only supporting current browser (Chrome, obviously) switch (this.browser) { case 'chrome': - if (this.template.type === 'banner' || this.template.type === 'animation') { + if (this.template && (this.template.type === 'banner' || this.template.type === 'animation')) { window.open('/js/document/templates/preview/banner.html?width='+this.template.size.width+'&height='+this.template.size.height+'&url='+this.url); } else { window.open(this.url); -- cgit v1.2.3 From ac750fd9b9c311dcd48c6ee309607edc6fa048e1 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Wed, 16 May 2012 14:22:18 -0700 Subject: Adding basic montage components I/O Only for saving basic components without a reel. --- js/document/models/base.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'js/document/models') diff --git a/js/document/models/base.js b/js/document/models/base.js index 033e16f6..649539ea 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -149,7 +149,8 @@ exports.BaseDocumentModel = Montage.create(Component, { template: this.fileTemplate, document: this.views.design.iframe.contentWindow.document, head: this.views.design.iframe.contentWindow.document.head, - body: this.views.design.iframe.contentWindow.document.body + body: this.views.design.iframe.contentWindow.document.body, + mjsTemplateCreator: this.views.design.iframe.contentWindow.mjsTemplateCreator }, callback.bind(this)); } else { //TODO: Add logic to save code view data @@ -177,7 +178,8 @@ exports.BaseDocumentModel = Montage.create(Component, { template: this.fileTemplate, document: this.views.design.iframe.contentWindow.document, head: this.views.design.iframe.contentWindow.document.head, - body: this.views.design.iframe.contentWindow.document.body + body: this.views.design.iframe.contentWindow.document.body, + mjsTemplateCreator: this.views.design.iframe.contentWindow.mjsTemplateCreator }, callback.bind(this)); } else { //TODO: Add logic to save code view data -- cgit v1.2.3 From 402a369c7bf164c3c6686be3a33f5e36f25e4130 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 16 May 2012 23:19:32 -0700 Subject: document controller and stage view code cleanup Signed-off-by: Valerio Virgillito --- js/document/models/html.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'js/document/models') diff --git a/js/document/models/html.js b/js/document/models/html.js index b57ff832..67457863 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js @@ -16,6 +16,11 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { // hasTemplate: { value: false + }, + //////////////////////////////////////////////////////////////////// + // + selection: { + value: [] }, //////////////////////////////////////////////////////////////////// // -- cgit v1.2.3 From 7a94696e19b14e15261df516e2ba75e693b1313d Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 18 May 2012 00:21:56 -0700 Subject: enabling basic document switching Signed-off-by: Valerio Virgillito --- js/document/models/base.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/document/models') diff --git a/js/document/models/base.js b/js/document/models/base.js index 649539ea..df341b2f 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -30,7 +30,7 @@ exports.BaseDocumentModel = Montage.create(Component, { //////////////////////////////////////////////////////////////////// // _isActive: { - value: null + value: true }, //////////////////////////////////////////////////////////////////// // -- cgit v1.2.3 From 66edf78c7e5df11218ef733686965beab05c7c7d Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 18 May 2012 14:01:00 -0700 Subject: fixing a scrolling issue when multiple documents are switched Signed-off-by: Valerio Virgillito --- js/document/models/html.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'js/document/models') diff --git a/js/document/models/html.js b/js/document/models/html.js index 67457863..a97b4b5a 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js @@ -27,6 +27,23 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { draw3DGrid: { value: false }, + //////////////////////////////////////////////////////////////////// + // + scrollLeft: { + value: null + }, + + scrollTop: { + value: null + }, + + userContentLeft: { + value: null + }, + + userContentTop: { + value: null + }, //////////////////////////////////////////////////////////////////// // baseHref: { -- cgit v1.2.3 From d878aa470074d5698a316512b513949fa22073f2 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 18 May 2012 15:23:15 -0700 Subject: Fixing save logic Moved dirty marker clearing code to model. --- js/document/models/base.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'js/document/models') diff --git a/js/document/models/base.js b/js/document/models/base.js index df341b2f..c99e36c7 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -151,7 +151,7 @@ exports.BaseDocumentModel = Montage.create(Component, { head: this.views.design.iframe.contentWindow.document.head, body: this.views.design.iframe.contentWindow.document.body, mjsTemplateCreator: this.views.design.iframe.contentWindow.mjsTemplateCreator - }, callback.bind(this)); + }, this.handleSaved.bind({callback: callback, model: this})); } else { //TODO: Add logic to save code view data } @@ -180,7 +180,7 @@ exports.BaseDocumentModel = Montage.create(Component, { head: this.views.design.iframe.contentWindow.document.head, body: this.views.design.iframe.contentWindow.document.body, mjsTemplateCreator: this.views.design.iframe.contentWindow.mjsTemplateCreator - }, callback.bind(this)); + }, this.handleSaved.bind({callback: callback, model: this})); } else { //TODO: Add logic to save code view data } @@ -190,7 +190,7 @@ exports.BaseDocumentModel = Montage.create(Component, { //////////////////////////////////////////////////////////////////// // saveAs: { - value: function () { + value: function (callback) { // if (this.needsSave) { //Save current file on memory @@ -199,6 +199,18 @@ exports.BaseDocumentModel = Montage.create(Component, { } } }, + //////////////////////////////////////////////////////////////////// + // + handleSaved: { + value: function (result) { + // + if (result.status === 204) { + this.model.needsSave = false; + } + // + if (this.callback) this.callback(result); + } + }, //////////////////////////////////////////////////////////////////// // close: { -- cgit v1.2.3 From 48beced355a5d4ee959ed41e104b0a343411658c Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 18 May 2012 16:33:10 -0700 Subject: Clean up and adding TODOs --- js/document/models/base.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/document/models') diff --git a/js/document/models/base.js b/js/document/models/base.js index c99e36c7..6d9d2e89 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -100,7 +100,7 @@ exports.BaseDocumentModel = Montage.create(Component, { } break; default: - if (this.template.type === 'banner' || this.template.type === 'animation') { + if (this.template && (this.template.type === 'banner' || this.template.type === 'animation')) { window.open('/js/document/templates/preview/banner.html?width='+this.template.size.width+'&height='+this.template.size.height+'&url='+this.url); } else { window.open(this.url); -- cgit v1.2.3 From 7a22f7b368ef549a5b30c58a0f3900685b764bdb Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Fri, 18 May 2012 16:56:16 -0700 Subject: integrated open code view document in new dom architecture Signed-off-by: Ananya Sen --- js/document/models/text.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'js/document/models') diff --git a/js/document/models/text.js b/js/document/models/text.js index ebf9993e..5a5e86ef 100755 --- a/js/document/models/text.js +++ b/js/document/models/text.js @@ -7,7 +7,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot //////////////////////////////////////////////////////////////////////// // var Montage = require("montage/core/core").Montage, - BaseDocumentModel = require("js/document/models/text").BaseDocumentModel; + BaseDocumentModel = require("js/document/models/base").BaseDocumentModel; //////////////////////////////////////////////////////////////////////// // exports.TextDocumentModel = Montage.create(BaseDocumentModel, { @@ -17,8 +17,6 @@ exports.TextDocumentModel = Montage.create(BaseDocumentModel, { enumerable: false, value: false } - //////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////// }); //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// \ No newline at end of file -- cgit v1.2.3 From 6f5ffa17c72dd0aef7a02e3496154514750143c2 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Fri, 18 May 2012 18:38:09 -0700 Subject: save for code view documents in the new dom architecture Signed-off-by: Ananya Sen --- js/document/models/text.js | 53 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) (limited to 'js/document/models') diff --git a/js/document/models/text.js b/js/document/models/text.js index 5a5e86ef..d21666d0 100755 --- a/js/document/models/text.js +++ b/js/document/models/text.js @@ -16,7 +16,58 @@ exports.TextDocumentModel = Montage.create(BaseDocumentModel, { hasTemplate: { enumerable: false, value: false - } + }, +//////////////////////////////////////////////////////////////////// + // + save: { + enumerable: false, + value: function (callback) { + this.application.ninja.documentController.activeDocument.model.views.code.editor.save();//save to textarea + + var self = this; + + this.application.ninja.ioMediator.fileSave({ + mode: ""+ self.file.extension, + file: self.file, + content:self.views.code.textArea.value + }, this.handleSaved.bind({callback: callback, model: this})); + } + }, +//////////////////////////////////////////////////////////////////// + // + handleSaved: { + value: function (result) { + // + if (result.status === 204) { + this.model.needsSave = false; + } + // + if (this.callback) this.callback(result); + } + }, + //////////////////////////////////////////////////////////////////// + // + close: { + value: function (view, callback) { + //Outcome of close (pending on save logic) + var success; + // + if (this.needsSave) { + //Prompt user to save of lose data + } else { + //Close file + success = true; + } + // + this.views.code.textParentContainer.removeChild(this.views.code.textViewContainer); + this.views.code.restoreAllPanels(); + this.views.code.showCodeViewBar(false); + this.views.code = null; + + // + return success; + } + } }); //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// \ No newline at end of file -- cgit v1.2.3 From c3c2ffc8d057660b7c42b45442885cd0d2d598bc Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Sun, 20 May 2012 15:16:06 -0700 Subject: use documents parent container property Signed-off-by: Ananya Sen --- js/document/models/text.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/document/models') diff --git a/js/document/models/text.js b/js/document/models/text.js index d21666d0..fe02953c 100755 --- a/js/document/models/text.js +++ b/js/document/models/text.js @@ -59,7 +59,7 @@ exports.TextDocumentModel = Montage.create(BaseDocumentModel, { success = true; } // - this.views.code.textParentContainer.removeChild(this.views.code.textViewContainer); + this.parentContainer.removeChild(this.views.code.textViewContainer); this.views.code.restoreAllPanels(); this.views.code.showCodeViewBar(false); this.views.code = null; -- cgit v1.2.3 From 2cc8e58f6bb9f64a7473e62aecd013fa55167231 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Mon, 21 May 2012 16:42:26 -0700 Subject: - added opening multiple code and design view documents - switching between multiple code and design view documents - Note: closing of documents, when multiple documents are open, is not yet implemented Signed-off-by: Ananya Sen --- js/document/models/text.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/document/models') diff --git a/js/document/models/text.js b/js/document/models/text.js index fe02953c..d1252b7d 100755 --- a/js/document/models/text.js +++ b/js/document/models/text.js @@ -60,8 +60,8 @@ exports.TextDocumentModel = Montage.create(BaseDocumentModel, { } // this.parentContainer.removeChild(this.views.code.textViewContainer); - this.views.code.restoreAllPanels(); - this.views.code.showCodeViewBar(false); + this.application.ninja.stage.showCodeViewBar(false); + this.application.ninja.stage.restoreAllPanels(); this.views.code = null; // -- cgit v1.2.3 From 2b207ef8b2594927f8cd6cd63a8483d205cb86c4 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 22 May 2012 15:41:51 -0700 Subject: fixing the selection in multiple documents and some code cleanup Signed-off-by: Valerio Virgillito --- js/document/models/html.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'js/document/models') diff --git a/js/document/models/html.js b/js/document/models/html.js index a97b4b5a..9cc8ce92 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js @@ -21,6 +21,11 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { // selection: { value: [] + }, + //////////////////////////////////////////////////////////////////// + // + selectionContainer: { + value: [] }, //////////////////////////////////////////////////////////////////// // -- cgit v1.2.3 From 5914c5b2209c4b8daac4249bb76cda5c9314c4e6 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 24 May 2012 00:07:23 -0700 Subject: Cleaning up referencing to 'documentRoot' and '_document' Moved to reference new model in DOM architecture rework. This should not affect anything, just moving the references, and also the setting to the render methods in the design view. --- js/document/models/html.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'js/document/models') diff --git a/js/document/models/html.js b/js/document/models/html.js index 9cc8ce92..fd42d4de 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js @@ -63,6 +63,11 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { // userComponents: { value: {} + }, + //////////////////////////////////////////////////////////////////// + // + documentRoot: { + value: null }, //////////////////////////////////////////////////////////////////// //Add a reference to a component instance to the userComponents hash using the element UUID -- cgit v1.2.3