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/base.js') 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 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 13 deletions(-) (limited to 'js/document/models/base.js') 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 () { + // + } } //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// -- 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 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'js/document/models/base.js') 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: { -- cgit v1.2.3 From 4504972c1f3b9bf1d02a4484a07a8a85cf9ccee2 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Tue, 8 May 2012 10:37:38 -0700 Subject: Adding Chrome Preview --- js/document/models/base.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'js/document/models/base.js') diff --git a/js/document/models/base.js b/js/document/models/base.js index 746922ad..5667fb24 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -68,19 +68,24 @@ exports.BaseDocumentModel = Montage.create(Component, { //////////////////////////////////////////////////////////////////// // switchViewTo: { - value: function () { + value: function (view) { // } }, //////////////////////////////////////////////////////////////////// - // + //TODO: Add API to allow other browser support browserPreview: { value: function (browser) { - // + + //TODO: Add file save before previewing + + //Currently only supporting current browser (Chrome, obviously) switch (browser) { case 'chrome': + window.open(this.application.ninja.coreIoApi.rootUrl + this.file.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]); break; default: + window.open(this.application.ninja.coreIoApi.rootUrl + this.file.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]); break; } } -- cgit v1.2.3 From a1e8540f5656e62db6a89f3af7829be6b259b7ed Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Tue, 8 May 2012 17:33:13 -0700 Subject: Adding SAVE for I/O Adding save functionality to new template. Need to implement user UI for prompts and also clean up... --- js/document/models/base.js | 102 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 86 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 5667fb24..2bbbe501 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -76,39 +76,104 @@ exports.BaseDocumentModel = Montage.create(Component, { //TODO: Add API to allow other browser support browserPreview: { value: function (browser) { - - //TODO: Add file save before previewing - - //Currently only supporting current browser (Chrome, obviously) - switch (browser) { - case 'chrome': - window.open(this.application.ninja.coreIoApi.rootUrl + this.file.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]); - break; - default: - window.open(this.application.ninja.coreIoApi.rootUrl + this.file.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]); - break; - } + //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) { + //Currently only supporting current browser (Chrome, obviously) + switch (this.browser) { + case 'chrome': + window.open(this.url); + break; + default: + window.open(this.url); + break; + } + }.bind({browser: browser, url: url})); } }, + //////////////////////////////////////////////////////////////////// + // + getStyleSheets: { + value: function () { + // + var styles = []; + // + for (var k in this.views.design.iframe.contentWindow.document.styleSheets) { + if (this.views.design.iframe.contentWindow.document.styleSheets[k].ownerNode && this.views.design.iframe.contentWindow.document.styleSheets[k].ownerNode.getAttribute) { + 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]); + } + } + } + // + return styles; + } + }, //////////////////////////////////////////////////////////////////// // save: { - value: function () { + value: function (callback) { // + if (this.currentView === this.views.design) { + // + this.application.ninja.ioMediator.fileSave({ + mode: 'html', + file: this.file, + webgl: this.webGlHelper.glData, + styles: this.getStyleSheets(), + document: this.views.design.iframe.contentWindow.document, + head: this.views.design.iframe.contentWindow.document.head, + body: this.views.design.iframe.contentWindow.document.body + }, callback.bind(this)); + } else { + //TODO: Add logic to save code view data + } + // + if (this.needsSave) { + //Save + } else { + //Ignore command + } } }, //////////////////////////////////////////////////////////////////// // - saveAs: { - value: function () { + saveAll: { + value: function (callback) { + // + if (this.currentView === this.views.design) { + // + this.application.ninja.ioMediator.fileSave({ + mode: 'html', + file: this.file, + webgl: this.webGlHelper.glData, + css: this.getStyleSheets(), + document: this.views.design.iframe.contentWindow.document, + head: this.views.design.iframe.contentWindow.document.head, + body: this.views.design.iframe.contentWindow.document.body + }, callback.bind(this)); + } else { + //TODO: Add logic to save code view data + } // + if (this.needsSave) { + //Save + } else { + //Ignore command + } } }, //////////////////////////////////////////////////////////////////// // - saveAll: { + saveAs: { value: function () { // + if (this.needsSave) { + //Save current file on memory + } else { + //Copy file from disk + } } }, //////////////////////////////////////////////////////////////////// @@ -116,6 +181,11 @@ exports.BaseDocumentModel = Montage.create(Component, { close: { value: function () { // + if (this.needsSave) { + //Prompt user to save of lose data + } else { + //Close 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/base.js') 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/base.js') 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/base.js') 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/base.js') 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/base.js') 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/base.js') 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/base.js') 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 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/base.js') 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 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/base.js') 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/base.js') 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