From d0af21d80441cb7ffe3a92ed00f8dc9b90867098 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Mon, 23 Apr 2012 13:41:16 -0700 Subject: adjusting the bread crumb to work with the new template Initial container get setup in ninja now. Signed-off-by: Valerio Virgillito --- .../layout/bread-crumb.reel/bread-crumb.js | 25 ++++++++++++++++------ js/document/document-html.js | 8 +++---- js/document/html-document.js | 2 +- .../templates/montage-web/main.reel/main.js | 3 ++- js/ninja.reel/ninja.js | 7 ++++++ js/stage/stage.reel/stage.js | 4 +++- 6 files changed, 35 insertions(+), 14 deletions(-) (limited to 'js') diff --git a/js/components/layout/bread-crumb.reel/bread-crumb.js b/js/components/layout/bread-crumb.reel/bread-crumb.js index f35972b6..597577f1 100755 --- a/js/components/layout/bread-crumb.reel/bread-crumb.js +++ b/js/components/layout/bread-crumb.reel/bread-crumb.js @@ -63,16 +63,27 @@ exports.Breadcrumb = Montage.create(Component, { parentNode = this.container; - while(parentNode.id !== "UserContent") { + // This is for the old template support. + // TODO: Remove marker for old template: NINJA-STAGE-REWORK + if(this.application.ninja.currentDocument.documentRoot.id === "UserContent") { + while(parentNode.id !== "UserContent") { + this.containerElements.unshift({"node": parentNode, "nodeUuid":parentNode.uuid, "label": parentNode.nodeName}); + parentNode = parentNode.parentNode; + } + + // This is always the top container which is now hardcoded to body + this.containerElements.unshift({"node": parentNode, "nodeUuid":parentNode.uuid, "label": "Body"}); + } else { + while(parentNode !== this.application.ninja.currentDocument.documentRoot) { + this.containerElements.unshift({"node": parentNode, "nodeUuid":parentNode.uuid, "label": parentNode.nodeName}); + parentNode = parentNode.parentNode; + } + + // This is always the top container which is now hardcoded to body this.containerElements.unshift({"node": parentNode, "nodeUuid":parentNode.uuid, "label": parentNode.nodeName}); - parentNode = parentNode.parentNode; + console.log("this works!"); } - // This is always the top container which is now hardcoded to body - this.containerElements.unshift({"node": parentNode, "nodeUuid":parentNode.uuid, "label": "Body"}); - - - } }, diff --git a/js/document/document-html.js b/js/document/document-html.js index 841e66ed..8cb88516 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js @@ -67,8 +67,8 @@ exports.HtmlDocument = Montage.create(Component, { // this.init(file.name, file.uri, file.extension, iframe, uuid, callback); + this.iframe = this.createView(); - this.iframe.addEventListener("load", this.handleWebTemplateLoad.bind(this), true); //this.selectionExclude = ["HTML", "BODY", "Viewport", "UserContent", "stageBG"]; //this.currentView = "design"; @@ -96,6 +96,7 @@ exports.HtmlDocument = Montage.create(Component, { // ifr.style.opacity = 0; ifr.src = "js/document/templates/montage-web/index.html"; + ifr.addEventListener("load", this.handleWebTemplateLoad.bind(this), true); return document.getElementById("iframeContainer").appendChild(ifr); } @@ -124,8 +125,7 @@ exports.HtmlDocument = Montage.create(Component, { // TODO: We don't need this anymore -> need to setup the main container still //Adding a handler for the main user document reel to finish loading - //this._document.body.addEventListener("userTemplateDidLoad", this.userTemplateDidLoad.bind(this), false); - this.documentRoot.addEventListener("userTemplateDidLoad", this.userTemplateDidLoad.bind(this), false); +// this.documentRoot.addEventListener("userTemplateDidLoad", this.userTemplateDidLoad.bind(this), false); // Live node list of the current loaded document this._liveNodeList = this.documentRoot.getElementsByTagName('*'); @@ -314,7 +314,7 @@ exports.HtmlDocument = Montage.create(Component, { // Setting up the currentSelectedContainer to the document body. userTemplateDidLoad: { value: function(){ - this.application.ninja.currentSelectedContainer = this.documentRoot; +// this.application.ninja.currentSelectedContainer = this.documentRoot; } } }); diff --git a/js/document/html-document.js b/js/document/html-document.js index 9873fdd1..54db9eaa 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -826,7 +826,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { // Setting up the currentSelectedContainer to the document body. userTemplateDidLoad: { value: function(){ - this.application.ninja.currentSelectedContainer = this.documentRoot; + //this.application.ninja.currentSelectedContainer = this.documentRoot; } }, diff --git a/js/document/templates/montage-web/main.reel/main.js b/js/document/templates/montage-web/main.reel/main.js index 019c675e..d5ac88d5 100644 --- a/js/document/templates/montage-web/main.reel/main.js +++ b/js/document/templates/montage-web/main.reel/main.js @@ -38,10 +38,11 @@ exports.Main = Montage.create(Component, { }; // Dispatch event when this template has loaded. + /* var newEvent = document.createEvent( "CustomEvent" ); newEvent.initCustomEvent( "userTemplateDidLoad", false, true ); - document.body.dispatchEvent( newEvent ); + */ } } diff --git a/js/ninja.reel/ninja.js b/js/ninja.reel/ninja.js index 2fedd71d..d2d45410 100755 --- a/js/ninja.reel/ninja.js +++ b/js/ninja.reel/ninja.js @@ -269,6 +269,13 @@ exports.Ninja = Montage.create(Component, { value: function(event) { this.currentDocument = event.detail; + if(this.currentDocument.documentRoot) { + this.application.ninja.currentSelectedContainer = this.currentDocument.documentRoot; + } else { + alert("The current document has not loaded yet"); + return; + } + this.appModel.show3dGrid = this.currentDocument.draw3DGrid; NJevent("openDocument"); } diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index ec8c0e55..8382135d 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -252,7 +252,9 @@ exports.Stage = Montage.create(Component, { this.application.ninja.currentDocument.savedLeftScroll = this._iframeContainer.scrollLeft; this.application.ninja.currentDocument.savedTopScroll = this._iframeContainer.scrollTop; - this.userContentBorder = parseInt(this._documentRoot.elementModel.controller.getProperty(this._documentRoot, "border")); + // Hardcode this value so that it does not fail for the new stage architecture + // TODO: Remove marker for old template: NINJA-STAGE-REWORK + this.userContentBorder = 1; //parseInt(this._documentRoot.elementModel.controller.getProperty(this._documentRoot, "border")); this._userContentLeft = this._documentOffsetLeft - this._scrollLeft + this._userContentBorder; this._userContentTop = this._documentOffsetTop - this._scrollTop + this._userContentBorder; -- cgit v1.2.3