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 +++++-- js/document/templates/preview/banner.html | 64 +++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 3 deletions(-) create mode 100755 js/document/templates/preview/banner.html (limited to 'js/document') 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})); } }, //////////////////////////////////////////////////////////////////// diff --git a/js/document/templates/preview/banner.html b/js/document/templates/preview/banner.html new file mode 100755 index 00000000..5838ec91 --- /dev/null +++ b/js/document/templates/preview/banner.html @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file -- 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/document-html.js | 26 ++++---------------------- js/document/html-document.js | 39 --------------------------------------- js/document/models/base.js | 3 ++- 3 files changed, 6 insertions(+), 62 deletions(-) (limited to 'js/document') diff --git a/js/document/document-html.js b/js/document/document-html.js index 9bbea4c9..87c776d5 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js @@ -42,13 +42,6 @@ exports.HtmlDocument = Montage.create(Component, { // exclusionList: { value: ["HTML", "BODY"] //TODO: Update to correct list - }, - //////////////////////////////////////////////////////////////////// - // - uuid: { - get: function() { - return this._uuid; - } }, //////////////////////////////////////////////////////////////////// // @@ -133,21 +126,10 @@ exports.HtmlDocument = Montage.create(Component, { //////////////////////////////////////////////////////////////////// // closeDocument: { - value: function () { - // - this.model.close(null, this.handleCloseDocument.bind(this)); - } - }, - //////////////////////////////////////////////////////////////////// - // - handleCloseDocument: { - value: function (success) { - //TODO: Add logic for handling success or failure - // - this.application.ninja.documentController._documents.splice(this.uuid, 1); - // - NJevent("closeDocument", this.model.file.uri); - //TODO: Delete object here + value: function (context, callback) { + var closed = this.model.close(null); + + callback.call(context, this); } }, //////////////////////////////////////////////////////////////////// diff --git a/js/document/html-document.js b/js/document/html-document.js index 9d083dd8..6a84abdf 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -971,45 +971,6 @@ exports.HTMLDocument = Montage.create(TextDocument, { this.application.ninja.undocontroller.redoQueue = this.redoStack.slice(0); - } - }, - //////////////////////////////////////////////////////////////////// - /** - *pause videos on switching or closing the document, so that the browser does not keep downloading the media data - */ - pauseVideos:{ - value:function(){ - var videosArr = this.documentRoot.getElementsByTagName("video"), i=0; - for(i=0;i --- js/document/templates/banner/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'js/document') diff --git a/js/document/templates/banner/package.json b/js/document/templates/banner/package.json index c8bc02fb..d1e839dc 100755 --- a/js/document/templates/banner/package.json +++ b/js/document/templates/banner/package.json @@ -3,6 +3,7 @@ "lib": "" }, "mappings": { - "montage": "../../../../node_modules/montage/" + "montage": "../../../../node_modules/montage/", + "montage-google": "../../../../node_modules/montage-google/" } } \ No newline at end of file -- cgit v1.2.3 From b2c8041058ab8d16ca49d70ed24ddd29e79f51d2 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 16 May 2012 01:06:05 -0700 Subject: Fixing the package file for the new dom template Signed-off-by: Valerio Virgillito --- js/document/templates/html/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'js/document') diff --git a/js/document/templates/html/package.json b/js/document/templates/html/package.json index c8bc02fb..d1e839dc 100755 --- a/js/document/templates/html/package.json +++ b/js/document/templates/html/package.json @@ -3,6 +3,7 @@ "lib": "" }, "mappings": { - "montage": "../../../../node_modules/montage/" + "montage": "../../../../node_modules/montage/", + "montage-google": "../../../../node_modules/montage-google/" } } \ No newline at end of file -- 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 +- js/document/templates/html/index.html | 5 +++-- js/document/templates/html/main.js | 14 +++++++++++--- js/document/templates/html/package.json | 1 + js/document/views/design.js | 2 +- 5 files changed, 17 insertions(+), 7 deletions(-) (limited to 'js/document') 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); diff --git a/js/document/templates/html/index.html b/js/document/templates/html/index.html index a1b8b242..24159841 100755 --- a/js/document/templates/html/index.html +++ b/js/document/templates/html/index.html @@ -12,6 +12,9 @@ must set the 'data-ninja-template' data-ninja-template="true" --> + + + @@ -58,8 +61,6 @@ return document.elementFromPoint(x,y); } - - diff --git a/js/document/templates/html/main.js b/js/document/templates/html/main.js index d5ac88d5..f45657bb 100644 --- a/js/document/templates/html/main.js +++ b/js/document/templates/html/main.js @@ -3,8 +3,10 @@ No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. */ -var Montage = require("montage/core/core").Montage, - Component = require("montage/ui/component").Component; +var Montage = require("montage/core/core").Montage, + Component = require("montage/ui/component").Component, + Template = require("montage/ui/template").Template, + TemplateCreator = require("tools/template/template-creator").TemplateCreator; exports.Main = Montage.create(Component, { @@ -18,6 +20,7 @@ exports.Main = Montage.create(Component, { templateDidLoad: { value: function(){ var self = this; + // window.addComponent = function(element, data, callback) { var component; @@ -36,7 +39,12 @@ exports.Main = Montage.create(Component, { .end(); }; - + // + window.mjsTemplateCreator = TemplateCreator.create(); + // + window.mjsTemplate = Template.create(); + + // Dispatch event when this template has loaded. /* var newEvent = document.createEvent( "CustomEvent" ); diff --git a/js/document/templates/html/package.json b/js/document/templates/html/package.json index d1e839dc..4f36090a 100755 --- a/js/document/templates/html/package.json +++ b/js/document/templates/html/package.json @@ -4,6 +4,7 @@ }, "mappings": { "montage": "../../../../node_modules/montage/", + "tools": "../../../../node_modules/tools/", "montage-google": "../../../../node_modules/montage-google/" } } \ No newline at end of file diff --git a/js/document/views/design.js b/js/document/views/design.js index c7aab1d7..3b2eb11f 100755 --- a/js/document/views/design.js +++ b/js/document/views/design.js @@ -347,7 +347,7 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { // initMontage: { value: function () { - // + //initWithDocument(window.document) instantiateWithOwnerAndDocument(null, window.document) } }, //////////////////////////////////////////////////////////////////// -- 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 ++++-- js/document/templates/html/main.js | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'js/document') 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 diff --git a/js/document/templates/html/main.js b/js/document/templates/html/main.js index f45657bb..2696dfa0 100644 --- a/js/document/templates/html/main.js +++ b/js/document/templates/html/main.js @@ -42,7 +42,7 @@ exports.Main = Montage.create(Component, { // window.mjsTemplateCreator = TemplateCreator.create(); // - window.mjsTemplate = Template.create(); + window.mjsTemplate = Template.create(); // Dispatch event when this template has loaded. -- cgit v1.2.3 From 96c92ab93bdb6eb2dd42ef275b84d83aef8254bf Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 16 May 2012 14:36:47 -0700 Subject: Fixing selection bugs in new templates. Signed-off-by: Nivesh Rajbhandari --- js/document/document-html.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/document') diff --git a/js/document/document-html.js b/js/document/document-html.js index 87c776d5..a26b74d5 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js @@ -41,7 +41,7 @@ exports.HtmlDocument = Montage.create(Component, { //////////////////////////////////////////////////////////////////// // exclusionList: { - value: ["HTML", "BODY"] //TODO: Update to correct list + value: ["HTML", "BODY", "NINJA-CONTENT"] //TODO: Update to correct list }, //////////////////////////////////////////////////////////////////// // -- cgit v1.2.3 From 5cc5d29736d8bf253e3a168cdd6443e839ffb23c Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Wed, 16 May 2012 15:42:09 -0700 Subject: Fixing serialization referencing (new object per save) --- js/document/templates/html/main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/document') diff --git a/js/document/templates/html/main.js b/js/document/templates/html/main.js index 2696dfa0..ffa3fab2 100644 --- a/js/document/templates/html/main.js +++ b/js/document/templates/html/main.js @@ -40,9 +40,9 @@ exports.Main = Montage.create(Component, { }; // - window.mjsTemplateCreator = TemplateCreator.create(); + window.mjsTemplateCreator = TemplateCreator; // - window.mjsTemplate = Template.create(); + window.mjsTemplate = Template; // Dispatch event when this template has loaded. -- 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/document-html.js | 21 ++++++++++++++++++--- js/document/html-document.js | 26 -------------------------- js/document/models/html.js | 5 +++++ 3 files changed, 23 insertions(+), 29 deletions(-) (limited to 'js/document') diff --git a/js/document/document-html.js b/js/document/document-html.js index a26b74d5..56d9db02 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js @@ -134,14 +134,29 @@ exports.HtmlDocument = Montage.create(Component, { }, //////////////////////////////////////////////////////////////////// // - saveAppState: { + serializeDocument: { value: function () { - //TODO: Import functionality + // There are not needed for now ssince we cannot change them + //this.gridHorizontalSpacing = this.application.ninja.stage.drawUtils.gridHorizontalSpacing; + //this.gridVerticalSpacing = this.application.ninja.stage.drawUtils.gridVerticalSpacing; + + // Serialize the current scroll position + // TODO: Implement + + // Serialize the selection + this.model.selection = this.application.ninja.selectedElements.slice(0); + this.draw3DGrid = this.application.ninja.appModel.show3dGrid; + + // Serialize the undo + // TODO: Save the montage undo queue + + // Pause the videos + this.model.views.design.pauseVideos(); } }, //////////////////////////////////////////////////////////////////// // - restoreAppState: { + deserializeDocument: { value: function () { //TODO: Import functionality } diff --git a/js/document/html-document.js b/js/document/html-document.js index 6a84abdf..68c2a9fb 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -920,32 +920,6 @@ exports.HTMLDocument = Montage.create(TextDocument, { } } }, - //////////////////////////////////////////////////////////////////// - saveAppState:{ - enumerable: false, - value: function () { - - this.savedLeftScroll = this.application.ninja.stage._iframeContainer.scrollLeft; - this.savedTopScroll = this.application.ninja.stage._iframeContainer.scrollTop; - - this.gridHorizontalSpacing = this.application.ninja.stage.drawUtils.gridHorizontalSpacing; - this.gridVerticalSpacing = this.application.ninja.stage.drawUtils.gridVerticalSpacing; - - if(typeof this.application.ninja.selectedElements !== 'undefined'){ - this.selectionModel = this.application.ninja.selectedElements.slice(0); - } - - this.draw3DGrid = this.application.ninja.appModel.show3dGrid; - - //persist a clone of history per document - this.undoStack = this.application.ninja.undocontroller.undoQueue.slice(0); - this.redoStack = this.application.ninja.undocontroller.redoQueue.slice(0); - this.application.ninja.undocontroller.clearHistory();//clear history to give the next document a fresh start - - //pause videos on switching or closing the document, so that the browser does not keep downloading the media data - this.pauseVideos(); - } - }, //////////////////////////////////////////////////////////////////// restoreAppState:{ 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 2ba4a6fab3b81b537521760ee5f95f1bc80027f9 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 17 May 2012 11:09:45 -0700 Subject: Adding default padding for banner templates. Signed-off-by: Nivesh Rajbhandari --- js/document/views/design.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'js/document') diff --git a/js/document/views/design.js b/js/document/views/design.js index 3b2eb11f..2ccb82d1 100755 --- a/js/document/views/design.js +++ b/js/document/views/design.js @@ -184,6 +184,10 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { this._bodyFragment = null; //Calling standard method to finish opening document this.bodyContentLoaded(null); + + // TODO: Clean up this code + this.application.ninja.stage.documentOffsetLeft = parseInt((this.document.body.scrollWidth - this._template.size.width)/2); + this.application.ninja.stage.documentOffsetTop = parseInt((this.document.body.scrollHeight - this._template.size.height)/2); } }, //////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 6ce2f2a5af1bc66d8dbec04abfae2e07f43afcfe Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 17 May 2012 11:22:03 -0700 Subject: Fixed chrome preview for banner templates. Signed-off-by: Nivesh Rajbhandari --- js/document/templates/banner/main.js | 8 +++++++- js/document/templates/banner/package.json | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'js/document') diff --git a/js/document/templates/banner/main.js b/js/document/templates/banner/main.js index d5ac88d5..2acbe8f3 100644 --- a/js/document/templates/banner/main.js +++ b/js/document/templates/banner/main.js @@ -4,7 +4,9 @@ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. */ var Montage = require("montage/core/core").Montage, - Component = require("montage/ui/component").Component; + Component = require("montage/ui/component").Component, + Template = require("montage/ui/template").Template, + TemplateCreator = require("tools/template/template-creator").TemplateCreator; exports.Main = Montage.create(Component, { @@ -37,6 +39,10 @@ exports.Main = Montage.create(Component, { }; + window.mjsTemplateCreator = TemplateCreator; + // + window.mjsTemplate = Template; + // Dispatch event when this template has loaded. /* var newEvent = document.createEvent( "CustomEvent" ); diff --git a/js/document/templates/banner/package.json b/js/document/templates/banner/package.json index d1e839dc..4f36090a 100755 --- a/js/document/templates/banner/package.json +++ b/js/document/templates/banner/package.json @@ -4,6 +4,7 @@ }, "mappings": { "montage": "../../../../node_modules/montage/", + "tools": "../../../../node_modules/tools/", "montage-google": "../../../../node_modules/montage-google/" } } \ No newline at end of file -- cgit v1.2.3 From e713d437a3918b9e417d1a0bc9f11275fc9e6634 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 17 May 2012 12:16:43 -0700 Subject: Sharing app data in banner and html templates Syncing the files to avoid duplicates and ensure consistency. --- js/document/templates/app/main.js | 61 +++++++++++++++++++++++++ js/document/templates/app/package.json | 10 ++++ js/document/templates/banner/index.html | 2 +- js/document/templates/banner/main.js | 55 ---------------------- js/document/templates/banner/package.json | 10 ---- js/document/templates/html/index.html | 2 +- js/document/templates/html/main.js | 57 ----------------------- js/document/templates/html/package.json | 10 ---- js/document/templates/montage-html/package.json | 9 ---- 9 files changed, 73 insertions(+), 143 deletions(-) create mode 100644 js/document/templates/app/main.js create mode 100755 js/document/templates/app/package.json delete mode 100644 js/document/templates/banner/main.js delete mode 100755 js/document/templates/banner/package.json delete mode 100644 js/document/templates/html/main.js delete mode 100755 js/document/templates/html/package.json delete mode 100755 js/document/templates/montage-html/package.json (limited to 'js/document') diff --git a/js/document/templates/app/main.js b/js/document/templates/app/main.js new file mode 100644 index 00000000..a406abdb --- /dev/null +++ b/js/document/templates/app/main.js @@ -0,0 +1,61 @@ +/* + This file contains proprietary software owned by Motorola Mobility, Inc.
+ No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. +
*/ +var Montage = require("montage/core/core").Montage, + Component = require("montage/ui/component").Component, + Template = require("montage/ui/template").Template, + TemplateCreator = require("tools/template/template-creator").TemplateCreator; + +exports.Main = Montage.create(Component, { + + hasTemplate: { + value: false + }, + + /** + * Adding window hooks to callback into this object from Ninja. + */ + templateDidLoad: { + value: function(){ + var self = this; + // + window.addComponent = function(element, data, callback) { + var component; + + component = require.async(data.path) + .then(function(component) { + var componentRequire = component[data.name]; + var componentInstance = componentRequire.create(); + + componentInstance.element = element; + + componentInstance.needsDraw = true; + componentInstance.ownerComponent = self; + + callback(componentInstance, element); + }) + .end(); + + }; + // + window.mjsTemplateCreator = TemplateCreator; + // + window.mjsTemplate = Template; + // + var templateEvent = document.createEvent("CustomEvent"); + templateEvent.initCustomEvent("mjsTemplateReady", false, true); + document.body.dispatchEvent(templateEvent); + + + // Dispatch event when this template has loaded. + /* + var newEvent = document.createEvent( "CustomEvent" ); + newEvent.initCustomEvent( "userTemplateDidLoad", false, true ); + document.body.dispatchEvent( newEvent ); + */ + + } + } +}); \ No newline at end of file diff --git a/js/document/templates/app/package.json b/js/document/templates/app/package.json new file mode 100755 index 00000000..4f36090a --- /dev/null +++ b/js/document/templates/app/package.json @@ -0,0 +1,10 @@ +{ + "directories": { + "lib": "" + }, + "mappings": { + "montage": "../../../../node_modules/montage/", + "tools": "../../../../node_modules/tools/", + "montage-google": "../../../../node_modules/montage-google/" + } +} \ No newline at end of file diff --git a/js/document/templates/banner/index.html b/js/document/templates/banner/index.html index 91ef06de..f1ee3d98 100755 --- a/js/document/templates/banner/index.html +++ b/js/document/templates/banner/index.html @@ -81,7 +81,7 @@ - + - +