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/document-html.js | 6 ++++++ js/document/models/base.js | 3 +++ js/document/models/html.js | 5 ----- 3 files changed, 9 insertions(+), 5 deletions(-) (limited to 'js/document') diff --git a/js/document/document-html.js b/js/document/document-html.js index 04565753..15f88d09 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js @@ -107,6 +107,12 @@ exports.HtmlDocument = Montage.create(Component, { }, handleViewReady: { value: function() { + // TODO: Find a better way to initialize this property + // Assign the domContainer to be the document root on open + if(typeof this.model.domContainer !== "undefined") { + this.model.domContainer = this.model.documentRoot; + } + //Making callback after view is loaded this.loaded.callback.call(this.loaded.context, this); } 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: { diff --git a/js/document/models/html.js b/js/document/models/html.js index 7064c6e3..4a232ee1 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js @@ -26,11 +26,6 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { // this.libs = {montage: false, canvas: false, montageId: null, canvasId: null}; } - }, - //////////////////////////////////////////////////////////////////// - // - selectionContainer: { - value: [] }, //////////////////////////////////////////////////////////////////// // -- cgit v1.2.3 From 19c77d87df72a85345e527d790878fc65eca189a Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Mon, 11 Jun 2012 15:44:15 -0700 Subject: Adding temp prompt UI component Added a temp prompt component and added on before close logic to ensure user does not lose data if the file needs saving when they close. --- js/document/document-html.js | 6 ++-- js/document/models/base.js | 66 ++++++++++++++++++++++++++++++++------------ 2 files changed, 50 insertions(+), 22 deletions(-) (limited to 'js/document') diff --git a/js/document/document-html.js b/js/document/document-html.js index 04565753..8874c34b 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js @@ -115,10 +115,8 @@ exports.HtmlDocument = Montage.create(Component, { // closeDocument: { value: function (context, callback) { - //Closing document and getting outcome - var closed = this.model.close(null); - //Making callback if specified - if (callback) callback.call(context, this); + //Closing document (sending null to close all views) + this.model.close(null, function () {if (callback) callback.call(context, this);}.bind(this)); } }, //////////////////////////////////////////////////////////////////// diff --git a/js/document/models/base.js b/js/document/models/base.js index 5fa06259..0fd609c3 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -6,8 +6,9 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot //////////////////////////////////////////////////////////////////////// // -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, + NinjaPrompt = require("js/components/prompt.reel").NinjaPrompt; //////////////////////////////////////////////////////////////////////// // exports.BaseDocumentModel = Montage.create(Component, { @@ -264,30 +265,59 @@ exports.BaseDocumentModel = Montage.create(Component, { if (this.callback) this.callback(result); } }, + //////////////////////////////////////////////////////////////////// + // + handleSavePrompt: { + value: function (continueToClose, callback) { + //TODO: Perhaps add logic to save the file is the user wants + if (continueToClose) { + if (callback) callback(); + } else { + //User canceled + //this.saveAll(null, callback); + } + } + }, //////////////////////////////////////////////////////////////////// //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; - // + //Checking if files needs to be saved to avoid losing data if (this.needsSave) { - //TODO: Prompt user to save or lose data + //Creating prompt to ask user to save the file + var prompt = NinjaPrompt.create(); + prompt.initialize('confirm', {message: 'Do you want to save the changes you made in the document '+this.file.name+'?\n\nYour changes will be lost if you do not save them.'}, function (result){this.handleSavePrompt(result, callback);}.bind(this)); + //Showing the prompt, it will make callback with user input + prompt.show(); } 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 = null; + //TODO: Add support for other views + if (!view || view === 'design') { + this.closeView('design'); + } + //Making callback + if (callback) callback(); } - //Returning result of operation - return success; + } - } + }, + //////////////////////////////////////////////////////////////////// + // + closeView: { + value: function (view) { + //Checking for view mode to close + switch (view.toLowerCase()) { + case 'design': + //TODO: Make into clean method in the design view + this.views.design.pauseAndStopVideos(); + this.parentContainer.removeChild(this.views.design.iframe); + this.views.design = null; + break; + default: + //TODO: Error? + break; + } + } + } //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// }); -- cgit v1.2.3 From ac3ceb7b38482d81c58a4ea12291a4559b87fa3d Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 12 Jun 2012 11:49:28 -0700 Subject: fix for the the components not rendering and not selecting Signed-off-by: Valerio Virgillito --- js/document/templates/app/main.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'js/document') diff --git a/js/document/templates/app/main.js b/js/document/templates/app/main.js index 0cdf718c..8dc05ba5 100644 --- a/js/document/templates/app/main.js +++ b/js/document/templates/app/main.js @@ -61,13 +61,15 @@ exports.Main = Montage.create(Component, { var componentRequire = component[data.name]; var componentInstance = componentRequire.create(); - componentInstance.element = element; + componentInstance.addEventListener("firstDraw", self, false); + + componentInstance.element = element; componentInstance.needsDraw = true; componentInstance.ownerComponent = self; self.componentToInsert = componentInstance; - componentInstance.addEventListener("firstDraw", self, false); + callback(componentInstance, element); }) -- cgit v1.2.3 From 9185145b3ab37070c7f32befaec1ab38486745b3 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 14 Jun 2012 16:00:53 -0700 Subject: Save user's html and body styles and inline body styles for 3d so they don't get saved out with the document. This still requires some changes by Jose. Signed-off-by: Nivesh Rajbhandari --- js/document/views/design.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'js/document') diff --git a/js/document/views/design.js b/js/document/views/design.js index 1a5b071e..325259ea 100755 --- a/js/document/views/design.js +++ b/js/document/views/design.js @@ -280,7 +280,10 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { //Removing loading container (should be removed) this.document.body.removeChild(this.document.getElementsByTagName('ninjaloadinghack')[0]); //Getting style and link tags in document - var stags = this.document.getElementsByTagName('style'), + var htags = this.document.getElementsByTagName('html'), + btags = this.document.getElementsByTagName('body'), + userStyles, + stags = this.document.getElementsByTagName('style'), ltags = this.document.getElementsByTagName('link'), i, orgNodes, scripttags = this.document.getElementsByTagName('script'); //Temporarily checking for disabled special case (we must enabled for Ninja to access styles) @@ -319,7 +322,7 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { //Else there is not data to parse if(this._viewCallback) { this._viewCallback.viewCallback.call(this._viewCallback.context); - } + } } //TODO: Verify appropiate location for this operation if (this._template && this._template.type === 'banner') { @@ -335,7 +338,18 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { for (var n in orgNodes) { if (orgNodes[n].getAttribute) orgNodes[n].setAttribute('data-ninja-node', 'true'); } - + + // Save initial HTML and Body style attributes so we don't override them on save + if(htags.length) { + if(userStyles = htags[0].getAttribute('style')) { + htags[0].setAttribute('data-ninja-style', userStyles); + } + } + if(btags.length) { + if(userStyles = btags[0].getAttribute('style')) { + btags[0].setAttribute('data-ninja-style', userStyles); + } + } //Makign callback if specified if (this._callback) this._callback(); } -- cgit v1.2.3 From 0d6693f1a6af1303e99ee72794eb879be8665610 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 14 Jun 2012 16:46:01 -0700 Subject: Adding clean up for ninja style attributes. I/O step in template. --- js/document/mediators/template.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'js/document') diff --git a/js/document/mediators/template.js b/js/document/mediators/template.js index 50fad1c3..0d48355f 100755 --- a/js/document/mediators/template.js +++ b/js/document/mediators/template.js @@ -155,6 +155,7 @@ exports.TemplateDocumentMediator = Montage.create(Component, { //Copying attributes to maintain same properties as the var htmlTagMem = template.document.getElementsByTagName('html')[0], htmlTagDoc = template.file.content.document.getElementsByTagName('html')[0]; wipeAttributes(htmlTagDoc); + // for (var m in htmlTagMem.attributes) { if (htmlTagMem.attributes[m].value) { if (htmlTagMem.attributes[m].value.replace(/montage-app-bootstrapping/gi, '').length>0) { @@ -162,16 +163,33 @@ exports.TemplateDocumentMediator = Montage.create(Component, { } } } + // + if (htmlTagMem && htmlTagMem.getAttribute('data-ninja-style') !== null) { + htmlTagDoc.setAttribute('style', htmlTagMem.getAttribute('data-ninja-style')); + htmlTagDoc.removeAttribute('data-ninja-style'); + } else if (htmlTagMem && htmlTagMem.getAttribute('data-ninja-style') === null) { + htmlTagDoc.removeAttribute('style'); + htmlTagDoc.removeAttribute('data-ninja-style'); + } //Getting list of current nodes (Ninja DOM) presentNodes = template.file.content.document.getElementsByTagName('*'); //Looping through nodes to determine origin and removing if not inserted by Ninja for (var n in presentNodes) { + // if (presentNodes[n].getAttribute && presentNodes[n].getAttribute('data-ninja-node') === null) { toremovetags.push(presentNodes[n]); } else if (presentNodes[n].getAttribute && presentNodes[n].getAttribute('data-ninja-node') !== null) { //Removing attribute presentNodes[n].removeAttribute('data-ninja-node'); } + // + if (presentNodes[n].getAttribute && presentNodes[n].getAttribute('data-ninja-style') !== null) { + presentNodes[n].setAttribute('style', presentNodes[n].getAttribute('data-ninja-style')); + presentNodes[n].removeAttribute('data-ninja-style'); + } else if (presentNodes[n].getAttribute && presentNodes[n].getAttribute('data-ninja-style') === null) { + presentNodes[n].removeAttribute('style'); + presentNodes[n].removeAttribute('data-ninja-style'); + } } //Getting all CSS (style or link) tags var styletags = template.file.content.document.getElementsByTagName('style'), -- cgit v1.2.3 From b39e13b9a53e6c75f4f9364e686dc90df02b09bb Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 14 Jun 2012 16:54:54 -0700 Subject: Moving location to copy body style attribute Fixes issue with removing styles from other elements. This now only applies to HTML and Body tags --- js/document/mediators/template.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'js/document') diff --git a/js/document/mediators/template.js b/js/document/mediators/template.js index 0d48355f..e770e07f 100755 --- a/js/document/mediators/template.js +++ b/js/document/mediators/template.js @@ -145,6 +145,14 @@ exports.TemplateDocumentMediator = Montage.create(Component, { template.file.content.document.body.setAttribute(template.body.attributes[n].name, template.body.attributes[n].value); } } + // + if (template.body && template.body.getAttribute('data-ninja-style') !== null) { + template.file.content.document.body.setAttribute('style', template.body.getAttribute('data-ninja-style')); + template.file.content.document.body.removeAttribute('data-ninja-style'); + } else if (template.body && template.body.getAttribute('data-ninja-style') === null) { + template.file.content.document.body.removeAttribute('style'); + template.file.content.document.body.removeAttribute('data-ninja-style'); + } wipeAttributes(template.file.content.document.head); //Copying attributes to maintain same properties as the for (var m in template.document.head.attributes) { @@ -182,14 +190,6 @@ exports.TemplateDocumentMediator = Montage.create(Component, { //Removing attribute presentNodes[n].removeAttribute('data-ninja-node'); } - // - if (presentNodes[n].getAttribute && presentNodes[n].getAttribute('data-ninja-style') !== null) { - presentNodes[n].setAttribute('style', presentNodes[n].getAttribute('data-ninja-style')); - presentNodes[n].removeAttribute('data-ninja-style'); - } else if (presentNodes[n].getAttribute && presentNodes[n].getAttribute('data-ninja-style') === null) { - presentNodes[n].removeAttribute('style'); - presentNodes[n].removeAttribute('data-ninja-style'); - } } //Getting all CSS (style or link) tags var styletags = template.file.content.document.getElementsByTagName('style'), -- cgit v1.2.3 From 965557ffb8e11918ebc1215738a8a9657a172a84 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 14 Jun 2012 22:11:39 -0700 Subject: Remove ninja's author-time styles for banner and animation templates on publish/save. Missed the banner and animation case in the previous checkin. Signed-off-by: Nivesh Rajbhandari --- js/document/mediators/template.js | 29 ++++++++++++++++++++++------- js/document/views/design.js | 11 +++++------ 2 files changed, 27 insertions(+), 13 deletions(-) (limited to 'js/document') diff --git a/js/document/mediators/template.js b/js/document/mediators/template.js index e770e07f..c5b46c3a 100755 --- a/js/document/mediators/template.js +++ b/js/document/mediators/template.js @@ -146,13 +146,28 @@ exports.TemplateDocumentMediator = Montage.create(Component, { } } // - if (template.body && template.body.getAttribute('data-ninja-style') !== null) { - template.file.content.document.body.setAttribute('style', template.body.getAttribute('data-ninja-style')); - template.file.content.document.body.removeAttribute('data-ninja-style'); - } else if (template.body && template.body.getAttribute('data-ninja-style') === null) { - template.file.content.document.body.removeAttribute('style'); - template.file.content.document.body.removeAttribute('data-ninja-style'); - } + if(template.template) { + // + // TODO - Need to handle banner and animation templates. + //Copying attributes to maintain same properties as + var ninjaContentTagMem = template.document.getElementsByTagName('ninja-content')[0], ninjaContentTagDoc = template.file.content.document.getElementsByTagName('ninja-content')[0]; + if (ninjaContentTagMem && ninjaContentTagMem.getAttribute('data-ninja-style') !== null) { + ninjaContentTagDoc.setAttribute('style', ninjaContentTagMem.getAttribute('data-ninja-style')); + ninjaContentTagDoc.removeAttribute('data-ninja-style'); + } else if (ninjaContentTagMem && ninjaContentTagMem.getAttribute('data-ninja-style') === null) { + ninjaContentTagDoc.removeAttribute('style'); + ninjaContentTagDoc.removeAttribute('data-ninja-style'); + } + } else { + if (template.body && template.body.getAttribute('data-ninja-style') !== null) { + template.file.content.document.body.setAttribute('style', template.body.getAttribute('data-ninja-style')); + template.file.content.document.body.removeAttribute('data-ninja-style'); + } else if (template.body && template.body.getAttribute('data-ninja-style') === null) { + template.file.content.document.body.removeAttribute('style'); + template.file.content.document.body.removeAttribute('data-ninja-style'); + } + } + wipeAttributes(template.file.content.document.head); //Copying attributes to maintain same properties as the for (var m in template.document.head.attributes) { diff --git a/js/document/views/design.js b/js/document/views/design.js index 325259ea..44c61617 100755 --- a/js/document/views/design.js +++ b/js/document/views/design.js @@ -281,7 +281,6 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { this.document.body.removeChild(this.document.getElementsByTagName('ninjaloadinghack')[0]); //Getting style and link tags in document var htags = this.document.getElementsByTagName('html'), - btags = this.document.getElementsByTagName('body'), userStyles, stags = this.document.getElementsByTagName('style'), ltags = this.document.getElementsByTagName('link'), i, orgNodes, @@ -339,18 +338,18 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { if (orgNodes[n].getAttribute) orgNodes[n].setAttribute('data-ninja-node', 'true'); } - // Save initial HTML and Body style attributes so we don't override them on save + // Save initial HTML and Body/ninja-content style attributes so we don't override them on save if(htags.length) { if(userStyles = htags[0].getAttribute('style')) { htags[0].setAttribute('data-ninja-style', userStyles); } } - if(btags.length) { - if(userStyles = btags[0].getAttribute('style')) { - btags[0].setAttribute('data-ninja-style', userStyles); + if(this.documentRoot) { + if(userStyles = this.documentRoot.getAttribute('style')) { + this.documentRoot.setAttribute('data-ninja-style', userStyles); } } - //Makign callback if specified + //Making callback if specified if (this._callback) this._callback(); } }, -- cgit v1.2.3 From 28300cc13e31abd630426325f4293eb8ea279fe4 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 15 Jun 2012 15:27:38 -0700 Subject: IKNINJA-1746 - Can't select items behind the banner templates' viewport. 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 aded9241..b9c8e797 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js @@ -36,7 +36,7 @@ exports.HtmlDocument = Montage.create(Component, { //////////////////////////////////////////////////////////////////// // exclusionList: { - value: ["HTML", "BODY", "NINJA-CONTENT"] + value: ["HTML", "BODY", "NINJA-CONTENT", "NINJA-VIEWPORT"] }, //////////////////////////////////////////////////////////////////// // -- cgit v1.2.3