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 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'js/document/models/base.js') 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; } } -- 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/base.js') 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 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'js/document/models/base.js') 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 }, //////////////////////////////////////////////////////////////////// // -- cgit v1.2.3 From 806974142d44afdd23534bf2d18eff0a8e701e0c Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 8 Jun 2012 16:59:59 -0700 Subject: rewrite: currentSelectedContainer -> domContainer Fixed the currentSelectedContainer by removing bindings and using property change on the current document added the red outline back. Signed-off-by: Valerio Virgillito --- js/document/models/base.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'js/document/models/base.js') diff --git a/js/document/models/base.js b/js/document/models/base.js index 5fa06259..1307e0c0 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -65,6 +65,9 @@ exports.BaseDocumentModel = Montage.create(Component, { _selection: { value: [] }, + domContainer: { + value: null + }, //////////////////////////////////////////////////////////////////// // selection: { -- cgit v1.2.3