From 4c3aac5eabd93052b1554a03d78235215bb49db4 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 29 May 2012 00:34:40 -0700 Subject: document bindings phase 1 - using array controller to bind the current document to all ninja components - removed open document event - removed references to the document controller Signed-off-by: Valerio Virgillito --- 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 d1252b7d..0135b9ba 100755 --- a/js/document/models/text.js +++ b/js/document/models/text.js @@ -22,7 +22,7 @@ exports.TextDocumentModel = Montage.create(BaseDocumentModel, { save: { enumerable: false, value: function (callback) { - this.application.ninja.documentController.activeDocument.model.views.code.editor.save();//save to textarea + this.application.ninja.currentDocument.model.views.code.editor.save();//save to textarea var self = this; -- cgit v1.2.3 From e1fe603a7c002073f8ac13623f8cc8dc43efb59d Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 31 May 2012 10:27:46 -0700 Subject: fixing selection when switching documents Signed-off-by: Valerio Virgillito --- js/document/models/base.js | 5 +++++ js/document/models/html.js | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'js/document/models') diff --git a/js/document/models/base.js b/js/document/models/base.js index 6d9d2e89..886a4ef0 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -62,6 +62,11 @@ exports.BaseDocumentModel = Montage.create(Component, { }, //////////////////////////////////////////////////////////////////// // + selection: { + value: [] + }, + //////////////////////////////////////////////////////////////////// + // fileTemplate: { value: null }, diff --git a/js/document/models/html.js b/js/document/models/html.js index fd42d4de..9f5599a2 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js @@ -19,11 +19,6 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { }, //////////////////////////////////////////////////////////////////// // - selection: { - value: [] - }, - //////////////////////////////////////////////////////////////////// - // selectionContainer: { value: [] }, -- cgit v1.2.3 From 6079ceedb5b340c78ecd02f27dfa734eedccf512 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 1 Jun 2012 00:39:14 -0700 Subject: making the document bar handle the current document to hide/show itself Signed-off-by: Valerio Virgillito --- js/document/models/text.js | 1 - 1 file changed, 1 deletion(-) (limited to 'js/document/models') diff --git a/js/document/models/text.js b/js/document/models/text.js index 0135b9ba..6cb61d48 100755 --- a/js/document/models/text.js +++ b/js/document/models/text.js @@ -60,7 +60,6 @@ exports.TextDocumentModel = Montage.create(BaseDocumentModel, { } // this.parentContainer.removeChild(this.views.code.textViewContainer); - this.application.ninja.stage.showCodeViewBar(false); this.application.ninja.stage.restoreAllPanels(); this.views.code = null; -- cgit v1.2.3 From 94190d38d659b05a0f071e88134651c2484629f6 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 1 Jun 2012 13:47:22 -0700 Subject: Fixing webGL helper --- js/document/models/html.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'js/document/models') diff --git a/js/document/models/html.js b/js/document/models/html.js index fd42d4de..0fe33990 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js @@ -17,6 +17,14 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { hasTemplate: { value: false }, + //////////////////////////////////////////////////////////////////// + //Called by the document immidiately after the model is created + init: { + value:function() { + //Creating instance of the webGL helper for this model + this.webGlHelper = webGlDocumentHelper.create(); + } + }, //////////////////////////////////////////////////////////////////// // selection: { @@ -57,7 +65,7 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { //////////////////////////////////////////////////////////////////// // webGlHelper: { - value: webGlDocumentHelper + value: null }, //////////////////////////////////////////////////////////////////// // -- cgit v1.2.3 From 75fc82ce49d6f1eb05dc950b46292d42b5856005 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 1 Jun 2012 16:19:04 -0700 Subject: fixing some selection container changes and the breadcrumb not drawing initially Signed-off-by: Valerio Virgillito --- js/document/models/base.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'js/document/models') diff --git a/js/document/models/base.js b/js/document/models/base.js index 886a4ef0..76a5e62b 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -62,9 +62,18 @@ exports.BaseDocumentModel = Montage.create(Component, { }, //////////////////////////////////////////////////////////////////// // - selection: { + _selection: { value: [] }, + + selection: { + get: function() { + return this._selection; + }, + set: function(value) { + this._selection = value; + } + }, //////////////////////////////////////////////////////////////////// // fileTemplate: { -- cgit v1.2.3 From 3f9cbffd7986cc5f42720ba38ca82c6424ba8916 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Mon, 4 Jun 2012 11:58:53 -0700 Subject: Adding lib copy blocking to preview This fixes an issue with launching preview before libraries were copied, hence, first time run would fail. Need to add a feedback screen for this process. --- js/document/models/base.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'js/document/models') diff --git a/js/document/models/base.js b/js/document/models/base.js index 76a5e62b..27f7d43f 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -103,7 +103,7 @@ exports.BaseDocumentModel = Montage.create(Component, { //Generating URL for document var url = this.application.ninja.coreIoApi.rootUrl + this.file.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]; //TODO: Add logic to prompt user to save (all) before preview - this.saveAll(function (result) { + this.saveAll(null,function (result) { //Currently only supporting current browser (Chrome, obviously) switch (this.browser) { case 'chrome': @@ -145,7 +145,7 @@ exports.BaseDocumentModel = Montage.create(Component, { //////////////////////////////////////////////////////////////////// // save: { - value: function (callback) { + value: function (callback, libCopyCallback) { // if (this.needsSave) { //Save @@ -165,7 +165,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 - }, this.handleSaved.bind({callback: callback, model: this})); + }, this.handleSaved.bind({callback: callback, model: this}), libCopyCallback); } else { //TODO: Add logic to save code view data } @@ -174,7 +174,7 @@ exports.BaseDocumentModel = Montage.create(Component, { //////////////////////////////////////////////////////////////////// // saveAll: { - value: function (callback) { + value: function (callback, libCopyCallback) { // if (this.needsSave) { //Save @@ -194,7 +194,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 - }, this.handleSaved.bind({callback: callback, model: this})); + }, this.handleSaved.bind({callback: callback, model: this}), libCopyCallback); } else { //TODO: Add logic to save code view data } -- cgit v1.2.3 From 1b8586c07951accbc3c0f3951966e4e258b0c5d9 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Mon, 4 Jun 2012 15:34:57 -0700 Subject: Adding saving blocking screen This is for chrome preview, also fixed other preview bug with plain files not opening in preview. --- js/document/models/base.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'js/document/models') diff --git a/js/document/models/base.js b/js/document/models/base.js index 27f7d43f..0957145a 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -99,11 +99,20 @@ exports.BaseDocumentModel = Montage.create(Component, { //////////////////////////////////////////////////////////////////// //TODO: Add API to allow other browser support browserPreview: { - value: function (browser) { + value: function (browser, screen, context) { + //Making call to show feedback screen + if (screen) screen.show(context); //Generating URL for document var url = this.application.ninja.coreIoApi.rootUrl + this.file.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]; //TODO: Add logic to prompt user to save (all) before preview - this.saveAll(null,function (result) { + this.saveAll(null,function (success) { + //Making call to show feedback screen + if (screen) screen.hide(context); + //TODO: Add error handling logic + if (!success) { + console.log('Error!'); + return; + } //Currently only supporting current browser (Chrome, obviously) switch (this.browser) { case 'chrome': -- cgit v1.2.3 From e28eb9158a50d7e6d97dbc68066e591ac600c241 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 5 Jun 2012 21:40:44 -0700 Subject: removing all model creators. The elementModel is now a getter that will create a new model when needed. Signed-off-by: Valerio Virgillito --- js/document/models/html.js | 23 ----------------------- 1 file changed, 23 deletions(-) (limited to 'js/document/models') diff --git a/js/document/models/html.js b/js/document/models/html.js index 9aa0d27e..a367f95f 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js @@ -62,33 +62,10 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { webGlHelper: { value: null }, - //////////////////////////////////////////////////////////////////// - // - userComponents: { - value: {} - }, //////////////////////////////////////////////////////////////////// // documentRoot: { value: null - }, - //////////////////////////////////////////////////////////////////// - //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; - } - } } //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 6a0f150f49be656e0725bc77b452a3141dddd47c Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Wed, 6 Jun 2012 13:46:02 -0700 Subject: Cleaning up Removed reference of model in design view, clean up slightly, need to implement binding later. --- js/document/models/base.js | 37 +++++++++++++++++++++---------------- js/document/models/html.js | 25 +++++++++++++++---------- 2 files changed, 36 insertions(+), 26 deletions(-) (limited to 'js/document/models') diff --git a/js/document/models/base.js b/js/document/models/base.js index 0957145a..a3644815 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -65,7 +65,8 @@ exports.BaseDocumentModel = Montage.create(Component, { _selection: { value: [] }, - + //////////////////////////////////////////////////////////////////// + // selection: { get: function() { return this._selection; @@ -134,20 +135,22 @@ exports.BaseDocumentModel = Montage.create(Component, { } }, //////////////////////////////////////////////////////////////////// - // + //Gets all stylesheets in document getStyleSheets: { value: function () { - // + //Array to store styles (style and link tags) var styles = []; - // + //Looping through document sytles for (var k in this.views.design.iframe.contentWindow.document.styleSheets) { + //Check for styles to has proper propeties if (this.views.design.iframe.contentWindow.document.styleSheets[k].ownerNode && this.views.design.iframe.contentWindow.document.styleSheets[k].ownerNode.getAttribute) { + //Check for ninja-template styles, if so, exclude if (this.views.design.iframe.contentWindow.document.styleSheets[k].ownerNode.getAttribute('data-ninja-template') === null) { styles.push(this.views.design.iframe.contentWindow.document.styleSheets[k]); } } } - // + //Returning filtered results return styles; } }, @@ -155,7 +158,7 @@ exports.BaseDocumentModel = Montage.create(Component, { // save: { value: function (callback, libCopyCallback) { - // + //TODO: Implement on demand logic if (this.needsSave) { //Save } else { @@ -184,7 +187,7 @@ exports.BaseDocumentModel = Montage.create(Component, { // saveAll: { value: function (callback, libCopyCallback) { - // + //TODO: Implement on demand logic if (this.needsSave) { //Save } else { @@ -214,47 +217,49 @@ exports.BaseDocumentModel = Montage.create(Component, { // saveAs: { value: function (callback) { - // + //TODO: Implement on demand logic if (this.needsSave) { //Save current file on memory } else { //Copy file from disk } + //TODO: Add functionality } }, //////////////////////////////////////////////////////////////////// // handleSaved: { value: function (result) { - // + //Checking for success code in save if (result.status === 204) { + //Clearing flag with successful save this.model.needsSave = false; } - // + //Making callback call if specifed with results of operation if (this.callback) this.callback(result); } }, //////////////////////////////////////////////////////////////////// - // + //TODO: Implement better logic to include different views on single document close: { value: function (view, callback) { //Outcome of close (pending on save logic) var success; // if (this.needsSave) { - //Prompt user to save of lose data + //TODO: Prompt user to save or lose data } else { //Close file success = true; } - // + //Checking for view mode to close if (this.views.design && (!view || view === 'design')) { - // + //TODO: Create a destroy method, this is messy + this.views.design.pauseAndStopVideos(); this.parentContainer.removeChild(this.views.design.iframe); - this.views.design.pauseAndStopVideos(); this.views.design = null; } - // + //Returning result of operation return success; } } diff --git a/js/document/models/html.js b/js/document/models/html.js index 9aa0d27e..0f88229d 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js @@ -40,22 +40,32 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { scrollLeft: { value: null }, - + //////////////////////////////////////////////////////////////////// + // scrollTop: { value: null }, - + //////////////////////////////////////////////////////////////////// + // userContentLeft: { value: null }, - + //////////////////////////////////////////////////////////////////// + // userContentTop: { value: null }, //////////////////////////////////////////////////////////////////// - // + //TODO: Convert to bindings + documentRoot: { + get: function() {return this.views.design._documentRoot;}, + set: function(value) {this.views.design._documentRoot = value;} + }, + //////////////////////////////////////////////////////////////////// + //TODO: Convert to bindings baseHref: { - value: null + get: function() {return this.views.design._baseHref;}, + set: function(value) {this.views.design._baseHref = value;} }, //////////////////////////////////////////////////////////////////// // @@ -66,11 +76,6 @@ 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 From 0efbbf8287517b755be1774f6aa49947bed50a0d Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 7 Jun 2012 11:24:29 -0700 Subject: Adding unique ID to canvas data folders Also set up for tracking ID created, will be adding support for parsing files without saving later, but flag is now present. --- js/document/models/base.js | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'js/document/models') diff --git a/js/document/models/base.js b/js/document/models/base.js index a3644815..c69c54a9 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -90,6 +90,11 @@ exports.BaseDocumentModel = Montage.create(Component, { views: { value: null }, + //////////////////////////////////////////////////////////////////// + // + libs: { + value: {montage: false, canvas: false, montageId: null, canvasId: null} + }, //////////////////////////////////////////////////////////////////// // switchViewTo: { @@ -167,8 +172,9 @@ exports.BaseDocumentModel = Montage.create(Component, { // if (this.currentView === this.views.design) { // - this.application.ninja.ioMediator.fileSave({ + var save = this.application.ninja.ioMediator.fileSave({ mode: 'html', + libs: this.libs, file: this.file, webgl: this.webGlHelper.glData, styles: this.getStyleSheets(), @@ -178,6 +184,17 @@ exports.BaseDocumentModel = Montage.create(Component, { body: this.views.design.iframe.contentWindow.document.body, mjsTemplateCreator: this.views.design.iframe.contentWindow.mjsTemplateCreator }, this.handleSaved.bind({callback: callback, model: this}), libCopyCallback); + //TODO: Improve detection during save routine + if (save) { + if (save.montageId) { + this.libs.montageId = save.montageId; + this.libs.montage = true; + } + if (save.canvasId) { + this.libs.canvasId = save.canvasId; + this.libs.canvas = true; + } + } } else { //TODO: Add logic to save code view data } @@ -196,8 +213,9 @@ exports.BaseDocumentModel = Montage.create(Component, { // if (this.currentView === this.views.design) { // - this.application.ninja.ioMediator.fileSave({ + var save = this.application.ninja.ioMediator.fileSave({ mode: 'html', + libs: this.libs, file: this.file, webgl: this.webGlHelper.glData, css: this.getStyleSheets(), @@ -207,6 +225,17 @@ exports.BaseDocumentModel = Montage.create(Component, { body: this.views.design.iframe.contentWindow.document.body, mjsTemplateCreator: this.views.design.iframe.contentWindow.mjsTemplateCreator }, this.handleSaved.bind({callback: callback, model: this}), libCopyCallback); + //TODO: Improve detection during save routine + if (save) { + if (save.montageId) { + this.libs.montageId = save.montageId; + this.libs.montage = true; + } + if (save.canvasId) { + this.libs.canvasId = save.canvasId; + this.libs.canvas = true; + } + } } else { //TODO: Add logic to save code view data } -- cgit v1.2.3 From 8da49b093e01a62c5b2009da075c2ccd2b1b6f5a Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 7 Jun 2012 14:39:12 -0700 Subject: Fixing unique ID store --- js/document/models/base.js | 10 +++------- js/document/models/html.js | 2 ++ 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'js/document/models') diff --git a/js/document/models/base.js b/js/document/models/base.js index c69c54a9..5fa06259 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -68,12 +68,8 @@ exports.BaseDocumentModel = Montage.create(Component, { //////////////////////////////////////////////////////////////////// // selection: { - get: function() { - return this._selection; - }, - set: function(value) { - this._selection = value; - } + get: function() {return this._selection;}, + set: function(value) {this._selection = value;} }, //////////////////////////////////////////////////////////////////// // @@ -93,7 +89,7 @@ exports.BaseDocumentModel = Montage.create(Component, { //////////////////////////////////////////////////////////////////// // libs: { - value: {montage: false, canvas: false, montageId: null, canvasId: null} + value: null }, //////////////////////////////////////////////////////////////////// // diff --git a/js/document/models/html.js b/js/document/models/html.js index 6bdc6546..7064c6e3 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js @@ -23,6 +23,8 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { value:function() { //Creating instance of the webGL helper for this model this.webGlHelper = webGlDocumentHelper.create(); + // + this.libs = {montage: false, canvas: false, montageId: null, canvasId: null}; } }, //////////////////////////////////////////////////////////////////// -- cgit v1.2.3