From 68ce64a5a2f4a71b54d33916aaf1d57161302425 Mon Sep 17 00:00:00 2001
From: Jose Antonio Marquez
Date: Tue, 14 Feb 2012 20:48:40 -0800
Subject: Reverting text/html document classes and setting up MVC folder
structure
Setting up the folder structure for the proposed set up for documents in Ninja. Reverted to have a temp HTML/Text document class. Tweak some UI for file pickers.
---
js/document/html-document.js | 492 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 492 insertions(+)
create mode 100755 js/document/html-document.js
(limited to 'js/document/html-document.js')
diff --git a/js/document/html-document.js b/js/document/html-document.js
new file mode 100755
index 00000000..d0b63dcc
--- /dev/null
+++ b/js/document/html-document.js
@@ -0,0 +1,492 @@
+/*
+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,
+ TextDocument = require("js/document/text-document").TextDocument,
+ NJUtils = require("js/lib/NJUtils").NJUtils;
+////////////////////////////////////////////////////////////////////////
+//
+exports.HTMLDocument = Montage.create(TextDocument, {
+ // PRIVATE MEMBERS
+ _selectionExclude: { value: null, enumerable: false },
+ _htmlTemplateUrl: { value: "user-document-templates/montage-application-cloud/index.html", enumerable: false},
+ _iframe: { value: null, enumerable: false },
+ _server: { value: null, enumerable: false },
+ _templateDocument: { value: null, enumerable: false },
+ _selectionModel: { value: [], enumerable: false },
+ _undoModel: { value: { "queue" : [], "position" : 0 }, enumerable: false},
+
+ _document: { value: null, enumerable: false },
+ _documentRoot: { value: null, enumerable: false },
+ _stageBG: { value: null, enumerable: false },
+ _window: { value: null, enumerable: false },
+ _styles: { value: null, enumerable: false },
+ _stylesheets: { value: null, enumerable: false },
+ _stageStyleSheetId : { value: 'nj-stage-stylesheet', enumerable: false },
+ _userDocument: { value: null, enumerable: false },
+ _htmlSource: {value: "", enumerable: false},
+ _glData: {value: null, enumerable: false },
+
+ _elementCounter: { value: 1, enumerable: false },
+ _snapping : { value: true, enumerable: false },
+ _layoutMode: { value: "all", enumerable: false },
+ _draw3DGrid: { value: false, writable: true },
+ _swfObject: { value: false, enumerable: false },
+
+ _zoomFactor: { value: 100, enumerable: false },
+
+ // PUBLIC MEMBERS
+ cssLoadInterval: { value: null, enumerable: false },
+
+ _savedLeftScroll: {value:null},
+ _savedTopScroll: {value:null},
+
+ _codeViewDocument:{
+ writable: true,
+ enumerable: true,
+ value:null
+ },
+
+ /*
+ * PUBLIC API
+ */
+
+ // GETTERS / SETTERS
+
+ codeViewDocument:{
+ get: function() { return this._codeViewDocument; },
+ set: function(value) { this._codeViewDocument = value}
+ },
+
+ savedLeftScroll:{
+ get: function() { return this._savedLeftScroll; },
+ set: function(value) { this._savedLeftScroll = value}
+ },
+
+ savedTopScroll:{
+ get: function() { return this._savedTopScroll; },
+ set: function(value) { this._savedTopScroll = value}
+ },
+
+ selectionExclude: {
+ get: function() { return this._selectionExclude; },
+ set: function(value) { this._selectionExclude = value; }
+ },
+
+ iframe: {
+ get: function() { return this._iframe; },
+ set: function(value) { this._iframe = value; }
+ },
+
+ server: {
+ get: function() { return this._server; },
+ set: function(value) { this._server = value; }
+ },
+
+ selectionModel: {
+ get: function() { return this._selectionModel; },
+ set: function(value) { this._selectionModel = value; }
+ },
+
+ undoModel: {
+ get: function() { return this._undoModel; },
+ set: function(value) { this._undoModel.queue = value.queue; this._undoModel.position = value.position; }
+ },
+
+ documentRoot: {
+ get: function() { return this._documentRoot; },
+ set: function(value) { this._documentRoot = value; }
+ },
+
+ stageBG: {
+ get: function() { return this._stageBG; },
+ set: function(value) { this._stageBG = value; }
+ },
+
+ elementCounter: {
+ set: function(value) { this._elementCounter = value; },
+ get: function() { return this._elementCounter; }
+ },
+
+ snapping: {
+ get: function() { return this._snapping; },
+ set: function(value) {
+ if(this._snapping !== value) {
+ this._snapping = value;
+ }
+ }
+ },
+
+ // TODO SEND THE EVENT --> Redraw the desired layout
+ layoutMode: {
+ get: function() { return this._layoutMode; },
+ set: function(mode) { this._layoutMode = mode; }
+ },
+
+ draw3DGrid: {
+ get: function() { return this._draw3DGrid; },
+ set: function(value) {
+ if(this._draw3DGrid !== value) {
+ this._draw3DGrid = value;
+ }
+ }
+ },
+
+ _userComponentSet: {
+ value: {},
+ writable: true,
+ enumerable:true
+ },
+
+// userComponentSet:{
+// enumerable: true,
+// get: function() {
+// return this._userComponentSet;
+// },
+// set: function(value) {
+// this._userComponentSet = value;
+// this._drawUserComponentsOnOpen();
+// }
+// },
+//
+// _drawUserComponentsOnOpen:{
+// value:function(){
+// for(var i in this._userComponentSet){
+// console.log(this._userComponentSet[i].control)
+// this._userComponentSet[i].control.needsDraw = true;
+// }
+// }
+// },
+
+ glData: {
+ get: function()
+ {
+ var elt = this.iframe;
+ var elt = this.iframe.contentWindow.document.getElementById("UserContent");
+ this._glData = null;
+ if (elt)
+ {
+ this._glData = new Array();
+ this.collectGLData( elt, this._glData );
+ }
+
+ return this._glData
+ },
+
+ set: function(value)
+ {
+ var nWorlds = value.length;
+ for (var i=0; i= 0)
+ {
+ var endIndex = importStr.indexOf( "\n", startIndex );
+ if (endIndex > 0)
+ {
+ var id = importStr.substring( startIndex+4, endIndex );
+ var canvas = this.iframe.contentWindow.document.getElementById( id );
+ if (canvas)
+ {
+ if (!canvas.elementModel)
+ {
+ NJUtils.makeElementModel(canvas, "Canvas", "shape", true);
+ }
+
+ if (canvas.elementModel)
+ {
+ if (canvas.elementModel.shapeModel.GLWorld)
+ canvas.elementModel.shapeModel.GLWorld.clearTree();
+
+ var world = new GLWorld( canvas );
+ canvas.elementModel.shapeModel.GLWorld = world;
+ world.import( importStr );
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+
+ zoomFactor: {
+ get: function() { return this._zoomFactor; },
+ set: function(value) { this._zoomFactor = value; }
+ },
+
+ //****************************************//
+ // PUBLIC METHODS
+
+
+ ////////////////////////////////////////////////////////////////////
+ //
+ initialize: {
+ value: function(file, uuid, iframe, callback) {
+ //
+ this._userDocument = file;
+ //
+ this.init(file.name, file.uri, file.extension, iframe, uuid, callback);
+ //
+ this.iframe = iframe;
+ this.selectionExclude = ["HTML", "BODY", "Viewport", "UserContent", "stageBG"];
+ this.currentView = "design";
+ //
+ this.iframe.src = this._htmlTemplateUrl;
+ this.iframe.addEventListener("load", this, true);
+ }
+ },
+ ////////////////////////////////////////////////////////////////////
+
+
+ collectGLData: {
+ value: function( elt, dataArray )
+ {
+ if (elt.elementModel && elt.elementModel.shapeModel && elt.elementModel.shapeModel.GLWorld)
+ {
+ var data = elt.elementModel.shapeModel.GLWorld.export();
+ dataArray.push( data );
+ }
+
+ if (elt.children)
+ {
+ var nKids = elt.children.length;
+ for (var i=0; i 1) {
+ clearInterval(this.cssLoadInterval);
+ this._styles = this._document.styleSheets[this._document.styleSheets.length - 1];
+ this._stylesheets = this._document.styleSheets; // Entire stlyesheets array
+
+ this.callback(this);
+ }
+ }.bind(this), 50);
+
+ // TODO - Not sure where this goes
+ this._userComponentSet = {};
+
+
+ this._styles = this._document.styleSheets[this._document.styleSheets.length - 1];
+ this._stylesheets = this._document.styleSheets; // Entire stlyesheets array
+
+ /* TODO Finish this implementation once we start caching Core Elements */
+ // Assign a model to the UserContent and add the ViewPort reference to it.
+ NJUtils.makeElementModel(this.documentRoot, "Stage", "stage");
+ //this.documentRoot.elementModel.viewPort = this.iframe.contentWindow.document.getElementById("Viewport");
+ NJUtils.makeElementModel(this.stageBG, "Stage", "stage");
+ NJUtils.makeElementModel(this.iframe.contentWindow.document.getElementById("Viewport"), "Stage", "stage");
+
+ for(i = 0; i < this._stylesheets.length; i++) {
+ if(this._stylesheets[i].ownerNode.id === this._stageStyleSheetId) {
+ this.documentRoot.elementModel.defaultRule = this._stylesheets[i];
+ break;
+ }
+ }
+
+ // Temporary create properties for each rule we need to save the index of the rule.
+ var len = this.documentRoot.elementModel.defaultRule.cssRules.length;
+ for(var j = 0; j < len; j++) {
+// console.log(this.documentRoot.elementModel.defaultRule.cssRules[j].selectorText);
+ if(this.documentRoot.elementModel.defaultRule.cssRules[j].selectorText === "*") {
+
+ this.documentRoot.elementModel.transitionStopRule = this.documentRoot.elementModel.defaultRule.cssRules[j];
+
+ } else if(this.documentRoot.elementModel.defaultRule.cssRules[j].selectorText === "body") {
+
+ this.documentRoot.elementModel.body = this.documentRoot.elementModel.defaultRule.cssRules[j];
+
+ } else if(this.documentRoot.elementModel.defaultRule.cssRules[j].selectorText === "#Viewport") {
+
+ this.documentRoot.elementModel.viewPort = this.documentRoot.elementModel.defaultRule.cssRules[j];
+
+ } else if(this.documentRoot.elementModel.defaultRule.cssRules[j].selectorText === ".stageDimension") {
+
+ this.documentRoot.elementModel.stageDimension = this.documentRoot.elementModel.defaultRule.cssRules[j];
+
+ } else if(this.documentRoot.elementModel.defaultRule.cssRules[j].selectorText === ".stageView") {
+
+ this.documentRoot.elementModel.stageView = this.documentRoot.elementModel.defaultRule.cssRules[j];
+
+ } else if(this.documentRoot.elementModel.defaultRule.cssRules[j].selectorText === "#stageBG") {
+
+ this.documentRoot.elementModel.stageBackground = this.documentRoot.elementModel.defaultRule.cssRules[j];
+ }
+ }
+
+ this.callback(this);
+
+ }
+ },
+
+ _setSWFObjectScript: {
+ value: function() {
+ if(!this._swfObject) {
+ /*
+ var swfObj = document.createElement("script");
+ swfObj.type = "text/javascript";
+ swfObj.src = "../../user-document-templates/external-libs/swf-object/swfobject.js";
+ swfObj.id = "swfObject";
+ var head= this._document.getElementsByTagName('head')[0];
+ head.appendChild(swfObj);
+ this._swfObject = true;
+ */
+ }
+ }
+ },
+
+ /**
+ * public method
+ *
+ */
+ ////////////////////////////////////////////////////////////////////
+ //
+ save: {
+ enumerable: false,
+ value: function () {
+ //TODO: Add code view logic and also styles for HTML
+ if (this.currentView === 'design') {
+ return {mode: 'html', document: this._userDocument, style: this._styles, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML};
+ } else if (this.currentView === "code"){
+ //TODO: Would this get call when we are in code of HTML?
+ } else {
+ //Error
+ }
+ }
+ }
+ ////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////
+});
\ No newline at end of file
--
cgit v1.2.3
From 075252ad893452df446566f01d0b26eeab08be3d Mon Sep 17 00:00:00 2001
From: Jose Antonio Marquez
Date: Wed, 15 Feb 2012 23:07:00 -0800
Subject: Setting up webGL library copy on save
---
js/document/html-document.js | 36 ++++++++----------------------------
1 file changed, 8 insertions(+), 28 deletions(-)
(limited to 'js/document/html-document.js')
diff --git a/js/document/html-document.js b/js/document/html-document.js
index bf9bba76..ad5417a9 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -12,7 +12,7 @@ var Montage = require("montage/core/core").Montage,
////////////////////////////////////////////////////////////////////////
//
exports.HTMLDocument = Montage.create(TextDocument, {
- // PRIVATE MEMBERS
+
_selectionExclude: { value: null, enumerable: false },
_htmlTemplateUrl: { value: "user-document-templates/montage-application-cloud/index.html", enumerable: false},
_iframe: { value: null, enumerable: false },
@@ -41,7 +41,6 @@ exports.HTMLDocument = Montage.create(TextDocument, {
_zoomFactor: { value: 100, enumerable: false },
- // PUBLIC MEMBERS
cssLoadInterval: { value: null, enumerable: false },
_savedLeftScroll: {value:null},
@@ -53,9 +52,7 @@ exports.HTMLDocument = Montage.create(TextDocument, {
value:null
},
- /*
- * PUBLIC API
- */
+
// GETTERS / SETTERS
@@ -231,9 +228,7 @@ exports.HTMLDocument = Montage.create(TextDocument, {
}
}
},
-
- //****************************************//
- // PUBLIC METHODS
+
////////////////////////////////////////////////////////////////////
@@ -357,19 +352,8 @@ exports.HTMLDocument = Montage.create(TextDocument, {
return this._window.getElement(x,y);
}
},
-
- /*
- // Private
- _loadDocument: {
- value: function(uri) {
- // Load the document into the Iframe
- this.iframe.src = uri;
- this.iframe.addEventListener("load", this, true);
- }
- },
-*/
-
-
+
+
////////////////////////////////////////////////////////////////////
//
@@ -475,11 +459,7 @@ exports.HTMLDocument = Montage.create(TextDocument, {
}
}
},
-
- /**
- * public method
- *
- */
+
////////////////////////////////////////////////////////////////////
//
save: {
@@ -487,12 +467,12 @@ exports.HTMLDocument = Montage.create(TextDocument, {
value: function () {
//TODO: Add code view logic and also styles for HTML
if (this.currentView === 'design') {
- return {mode: 'html', document: this._userDocument, style: this._styles, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML};
+ return {mode: 'html', document: this._userDocument, webgl: this.glData, style: this._styles, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML};
} else if (this.currentView === "code"){
//TODO: Would this get call when we are in code of HTML?
} else {
//Error
- }
+ }
}
}
////////////////////////////////////////////////////////////////////
--
cgit v1.2.3
From cfc2a432323d4620b1f4ca2061bbe57f46e7eaf7 Mon Sep 17 00:00:00 2001
From: Jose Antonio Marquez
Date: Thu, 16 Feb 2012 23:10:15 -0800
Subject: Moving Ninja iFrame templates
---
js/document/html-document.js | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
(limited to 'js/document/html-document.js')
diff --git a/js/document/html-document.js b/js/document/html-document.js
index 0c8695fb..a5483f40 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -14,7 +14,7 @@ var Montage = require("montage/core/core").Montage,
exports.HTMLDocument = Montage.create(TextDocument, {
_selectionExclude: { value: null, enumerable: false },
- _htmlTemplateUrl: { value: "user-document-templates/montage-application-cloud/index.html", enumerable: false},
+ _htmlTemplateUrl: { value: "js/document/templates/montage-html/index.html", enumerable: false},
_iframe: { value: null, enumerable: false },
_server: { value: null, enumerable: false },
_templateDocument: { value: null, enumerable: false },
@@ -235,6 +235,7 @@ exports.HTMLDocument = Montage.create(TextDocument, {
//
initialize: {
value: function(file, uuid, iframe, callback) {
+ //console.log('allow');
//
this._userDocument = file;
//
@@ -359,6 +360,8 @@ exports.HTMLDocument = Montage.create(TextDocument, {
//
handleEvent: {
value: function(event){
+ //console.log('end');
+ //console.log('file content start');
//TODO: Clean up, using for prototyping save
this._templateDocument = {};
this._templateDocument.head = this.iframe.contentWindow.document.getElementById("userHead");;
@@ -389,6 +392,8 @@ exports.HTMLDocument = Montage.create(TextDocument, {
this._stylesheets = this._document.styleSheets; // Entire stlyesheets array
this.callback(this);
+
+ //console.log('file content end');
}
}.bind(this), 50);
@@ -440,7 +445,9 @@ exports.HTMLDocument = Montage.create(TextDocument, {
}
// Remving this callback and using the callback from the css load
- // this.callback(this);
+ //this.callback(this);
+
+
}
},
--
cgit v1.2.3
From 66af1dd3e5aa80b257ba711600d112752ecaf655 Mon Sep 17 00:00:00 2001
From: Jose Antonio Marquez
Date: Fri, 17 Feb 2012 00:19:48 -0800
Subject: Adding Chrome webRequest intercept
Need to add logic to resolve file's actual URL dynamically.
---
js/document/html-document.js | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
(limited to 'js/document/html-document.js')
diff --git a/js/document/html-document.js b/js/document/html-document.js
index a5483f40..16595d14 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -355,13 +355,15 @@ exports.HTMLDocument = Montage.create(TextDocument, {
},
+
+
+
////////////////////////////////////////////////////////////////////
//
handleEvent: {
value: function(event){
- //console.log('end');
- //console.log('file content start');
+
//TODO: Clean up, using for prototyping save
this._templateDocument = {};
this._templateDocument.head = this.iframe.contentWindow.document.getElementById("userHead");;
--
cgit v1.2.3
From a42c536c2b3209afc058eabd31167bd0aa6f71c8 Mon Sep 17 00:00:00 2001
From: Jose Antonio Marquez
Date: Fri, 17 Feb 2012 13:40:38 -0800
Subject: Adding webRequest redirects for iFrame templates
---
js/document/html-document.js | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
(limited to 'js/document/html-document.js')
diff --git a/js/document/html-document.js b/js/document/html-document.js
index 16595d14..ae2b4600 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -235,7 +235,7 @@ exports.HTMLDocument = Montage.create(TextDocument, {
//
initialize: {
value: function(file, uuid, iframe, callback) {
- //console.log('allow');
+ this.application.ninja.documentController._hackRootFlag = false;
//
this._userDocument = file;
//
@@ -363,7 +363,8 @@ exports.HTMLDocument = Montage.create(TextDocument, {
//
handleEvent: {
value: function(event){
-
+ this.application.ninja.documentController._hackRootFlag = true;
+ //console.log(this._userDocument.root, this);
//TODO: Clean up, using for prototyping save
this._templateDocument = {};
this._templateDocument.head = this.iframe.contentWindow.document.getElementById("userHead");;
--
cgit v1.2.3
From d47c4c0f6053fb8390526f32c2ee08dee0bdec20 Mon Sep 17 00:00:00 2001
From: Jose Antonio Marquez
Date: Fri, 17 Feb 2012 15:22:23 -0800
Subject: Chrome Preview
---
js/document/html-document.js | 45 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
(limited to 'js/document/html-document.js')
diff --git a/js/document/html-document.js b/js/document/html-document.js
index ae2b4600..77cc711d 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -363,6 +363,9 @@ exports.HTMLDocument = Montage.create(TextDocument, {
//
handleEvent: {
value: function(event){
+ //TODO: Remove
+ window.hackPreview = this.livePreview.bind(this);
+
this.application.ninja.documentController._hackRootFlag = true;
//console.log(this._userDocument.root, this);
//TODO: Clean up, using for prototyping save
@@ -471,6 +474,48 @@ exports.HTMLDocument = Montage.create(TextDocument, {
}
},
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ////////////////////////////////////////////////////////////////////
+ //
+ livePreview: {
+ enumerable: false,
+ value: function () {
+ //this.application.ninja.documentController
+ //console.log(this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController._activeDocument.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]);
+ chrome.tabs.create({url: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController._activeDocument.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]});
+ }
+ },
+ ////////////////////////////////////////////////////////////////////
+
+
+
+
+
+
+
+
+
////////////////////////////////////////////////////////////////////
//
save: {
--
cgit v1.2.3
From 6787b29cfaa723c5c181baeb05160cfd4aadfe0f Mon Sep 17 00:00:00 2001
From: Jose Antonio Marquez
Date: Sun, 19 Feb 2012 17:27:09 -0800
Subject: Clean up and repairing manifest
---
js/document/html-document.js | 222 ++++++++++++++++++++++---------------------
1 file changed, 112 insertions(+), 110 deletions(-)
(limited to 'js/document/html-document.js')
diff --git a/js/document/html-document.js b/js/document/html-document.js
index 77cc711d..28818774 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -358,22 +358,40 @@ exports.HTMLDocument = Montage.create(TextDocument, {
-
+
+
+
+ /*
+ DOM Mutation Events:
+
+ DOMActivate, DOMFocusIn, DOMFocusOut, DOMAttrModified,
+ DOMCharacterDataModified, DOMNodeInserted, DOMNodeInsertedIntoDocument,
+ DOMNodeRemoved, DOMNodeRemovedFromDocument, DOMSubtreeModified, DOMContentLoaded
+
+ */
+
+
+
+ /*
+//TODO: Remove and clean up event listener (DOMSubtreeModified)
+ _hackCount: {
+ value: 0
+ },
+*/
+
+
////////////////////////////////////////////////////////////////////
//
handleEvent: {
value: function(event){
- //TODO: Remove
- window.hackPreview = this.livePreview.bind(this);
-
- this.application.ninja.documentController._hackRootFlag = true;
- //console.log(this._userDocument.root, this);
//TODO: Clean up, using for prototyping save
this._templateDocument = {};
- this._templateDocument.head = this.iframe.contentWindow.document.getElementById("userHead");;
- this._templateDocument.body = this.iframe.contentWindow.document.getElementById("UserContent");;
+ this._templateDocument.head = this.iframe.contentWindow.document.getElementById("userHead");
+ this._templateDocument.body = this.documentRoot = this.iframe.contentWindow.document.getElementById("UserContent");
+ //TODO: Remove, also for prototyping
+ this.application.ninja.documentController._hackRootFlag = true;
//
- this.documentRoot = this.iframe.contentWindow.document.getElementById("UserContent");
+ //this.documentRoot = this.iframe.contentWindow.document.getElementById("UserContent");
this.stageBG = this.iframe.contentWindow.document.getElementById("stageBG");
this.stageBG.onclick = null;
this._document = this.iframe.contentWindow.document;
@@ -381,82 +399,93 @@ exports.HTMLDocument = Montage.create(TextDocument, {
//
if(!this.documentRoot.Ninja) this.documentRoot.Ninja = {};
//
+ this._templateDocument.head.innerHTML = this._userDocument.content.head;
+ this._templateDocument.body.innerHTML = this._userDocument.content.body;
+
+
+
+
+ /* this.iframe.contentWindow.document.addEventListener('DOMSubtreeModified', function (e) { */ //TODO: Remove events upon loading once
- this.documentRoot.innerHTML = this._userDocument.content.body;
- this.iframe.contentWindow.document.getElementById("userHead").innerHTML = this._userDocument.content.head;
-
-
- //TODO: Look at code below and clean up
+ //TODO: When written, the best way to initialize the document is to listen for the DOM tree being modified
+ setTimeout(function () {
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ if(this._document.styleSheets.length > 1) {
+ this._styles = this._document.styleSheets[this._document.styleSheets.length - 1];
+ this._stylesheets = this._document.styleSheets; // Entire stlyesheets array
+
+ //TODO Finish this implementation once we start caching Core Elements
+ // Assign a model to the UserContent and add the ViewPort reference to it.
+ NJUtils.makeElementModel(this.documentRoot, "Stage", "stage");
+ //this.documentRoot.elementModel.viewPort = this.iframe.contentWindow.document.getElementById("Viewport");
+ NJUtils.makeElementModel(this.stageBG, "Stage", "stage");
+ NJUtils.makeElementModel(this.iframe.contentWindow.document.getElementById("Viewport"), "Stage", "stage");
+
+ for(i = 0; i < this._stylesheets.length; i++) {
+ if(this._stylesheets[i].ownerNode.id === this._stageStyleSheetId) {
+ this.documentRoot.elementModel.defaultRule = this._stylesheets[i];
+ break;
+ }
+ }
+
+ //Temporary create properties for each rule we need to save the index of the rule
+ var len = this.documentRoot.elementModel.defaultRule.cssRules.length;
+ for(var j = 0; j < len; j++) {
+ //console.log(this.documentRoot.elementModel.defaultRule.cssRules[j].selectorText);
+ if(this.documentRoot.elementModel.defaultRule.cssRules[j].selectorText === "*") {
+
+ this.documentRoot.elementModel.transitionStopRule = this.documentRoot.elementModel.defaultRule.cssRules[j];
+
+ } else if(this.documentRoot.elementModel.defaultRule.cssRules[j].selectorText === "body") {
+
+ this.documentRoot.elementModel.body = this.documentRoot.elementModel.defaultRule.cssRules[j];
+
+ } else if(this.documentRoot.elementModel.defaultRule.cssRules[j].selectorText === "#Viewport") {
+
+ this.documentRoot.elementModel.viewPort = this.documentRoot.elementModel.defaultRule.cssRules[j];
+
+ } else if(this.documentRoot.elementModel.defaultRule.cssRules[j].selectorText === ".stageDimension") {
+
+ this.documentRoot.elementModel.stageDimension = this.documentRoot.elementModel.defaultRule.cssRules[j];
+
+ } else if(this.documentRoot.elementModel.defaultRule.cssRules[j].selectorText === ".stageView") {
+
+ this.documentRoot.elementModel.stageView = this.documentRoot.elementModel.defaultRule.cssRules[j];
+
+ } else if(this.documentRoot.elementModel.defaultRule.cssRules[j].selectorText === "#stageBG") {
+
+ this.documentRoot.elementModel.stageBackground = this.documentRoot.elementModel.defaultRule.cssRules[j];
+ }
+ }
+
+ this.callback(this);
+
+ }
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+
+
+
+
+ }.bind(this), 1000);
+
+
-
- this.cssLoadInterval = setInterval(function() {
- if(this._document.styleSheets.length > 1) {
- clearInterval(this.cssLoadInterval);
- this._styles = this._document.styleSheets[this._document.styleSheets.length - 1];
- this._stylesheets = this._document.styleSheets; // Entire stlyesheets array
-
- this.callback(this);
-
- //console.log('file content end');
- }
- }.bind(this), 50);
- this._styles = this._document.styleSheets[this._document.styleSheets.length - 1];
- this._stylesheets = this._document.styleSheets; // Entire stlyesheets array
-
- /* TODO Finish this implementation once we start caching Core Elements */
- // Assign a model to the UserContent and add the ViewPort reference to it.
- NJUtils.makeElementModel(this.documentRoot, "Stage", "stage");
- //this.documentRoot.elementModel.viewPort = this.iframe.contentWindow.document.getElementById("Viewport");
- NJUtils.makeElementModel(this.stageBG, "Stage", "stage");
- NJUtils.makeElementModel(this.iframe.contentWindow.document.getElementById("Viewport"), "Stage", "stage");
-
- for(i = 0; i < this._stylesheets.length; i++) {
- if(this._stylesheets[i].ownerNode.id === this._stageStyleSheetId) {
- this.documentRoot.elementModel.defaultRule = this._stylesheets[i];
- break;
- }
- }
-
- // Temporary create properties for each rule we need to save the index of the rule.
- var len = this.documentRoot.elementModel.defaultRule.cssRules.length;
- for(var j = 0; j < len; j++) {
-// console.log(this.documentRoot.elementModel.defaultRule.cssRules[j].selectorText);
- if(this.documentRoot.elementModel.defaultRule.cssRules[j].selectorText === "*") {
-
- this.documentRoot.elementModel.transitionStopRule = this.documentRoot.elementModel.defaultRule.cssRules[j];
-
- } else if(this.documentRoot.elementModel.defaultRule.cssRules[j].selectorText === "body") {
-
- this.documentRoot.elementModel.body = this.documentRoot.elementModel.defaultRule.cssRules[j];
-
- } else if(this.documentRoot.elementModel.defaultRule.cssRules[j].selectorText === "#Viewport") {
-
- this.documentRoot.elementModel.viewPort = this.documentRoot.elementModel.defaultRule.cssRules[j];
-
- } else if(this.documentRoot.elementModel.defaultRule.cssRules[j].selectorText === ".stageDimension") {
-
- this.documentRoot.elementModel.stageDimension = this.documentRoot.elementModel.defaultRule.cssRules[j];
-
- } else if(this.documentRoot.elementModel.defaultRule.cssRules[j].selectorText === ".stageView") {
-
- this.documentRoot.elementModel.stageView = this.documentRoot.elementModel.defaultRule.cssRules[j];
-
- } else if(this.documentRoot.elementModel.defaultRule.cssRules[j].selectorText === "#stageBG") {
-
- this.documentRoot.elementModel.stageBackground = this.documentRoot.elementModel.defaultRule.cssRules[j];
- }
- }
-
- // Remving this callback and using the callback from the css load
- //this.callback(this);
-
-
-
- }
+ }
},
+ ////////////////////////////////////////////////////////////////////
+
+
+
+
_setSWFObjectScript: {
value: function() {
@@ -475,24 +504,6 @@ exports.HTMLDocument = Montage.create(TextDocument, {
},
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -501,21 +512,12 @@ exports.HTMLDocument = Montage.create(TextDocument, {
livePreview: {
enumerable: false,
value: function () {
- //this.application.ninja.documentController
- //console.log(this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController._activeDocument.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]);
- chrome.tabs.create({url: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController._activeDocument.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]});
+ //TODO: Add logic to handle save before preview
+ this.save();
+ //Launching 'blank' tab for testing movie
+ chrome.tabs.create({url: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController._activeDocument.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]});
}
},
- ////////////////////////////////////////////////////////////////////
-
-
-
-
-
-
-
-
-
////////////////////////////////////////////////////////////////////
//
save: {
--
cgit v1.2.3
From b1daf0b285a4a96bfd0086709c20e3682d75551a Mon Sep 17 00:00:00 2001
From: Valerio Virgillito
Date: Tue, 21 Feb 2012 14:32:17 -0800
Subject: fixing the dirty flag and removing sass changes
Signed-off-by: Valerio Virgillito
---
js/document/html-document.js | 9 ---------
1 file changed, 9 deletions(-)
(limited to 'js/document/html-document.js')
diff --git a/js/document/html-document.js b/js/document/html-document.js
index 28818774..01d042d6 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -290,15 +290,6 @@ exports.HTMLDocument = Montage.create(TextDocument, {
}
},
-
-
- AppendElement: {
- value: function(element, parent) {
- this.dirtyFlag = true;
- }
- },
-
-
/**
* Return the specified inline attribute from the element.
*/
--
cgit v1.2.3
From 2f24dafec79583547fe663d5a387d8ef15aae3bf Mon Sep 17 00:00:00 2001
From: Valerio Virgillito
Date: Tue, 21 Feb 2012 17:33:11 -0800
Subject: user document main reel listener moved to the html-document class.
Signed-off-by: Valerio Virgillito
---
js/document/html-document.js | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
(limited to 'js/document/html-document.js')
diff --git a/js/document/html-document.js b/js/document/html-document.js
index 01d042d6..9a7755e6 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -392,9 +392,10 @@ exports.HTMLDocument = Montage.create(TextDocument, {
//
this._templateDocument.head.innerHTML = this._userDocument.content.head;
this._templateDocument.body.innerHTML = this._userDocument.content.body;
-
-
-
+
+ // Adding a handler for the main user document reel to finish loading.
+ this._document.body.addEventListener("userTemplateDidLoad", this.userTemplateDidLoad.bind(this), false);
+
/* this.iframe.contentWindow.document.addEventListener('DOMSubtreeModified', function (e) { */ //TODO: Remove events upon loading once
@@ -472,12 +473,20 @@ exports.HTMLDocument = Montage.create(TextDocument, {
}
},
+
////////////////////////////////////////////////////////////////////
+
+ // Handler for user content main reel. Gets called once the main reel of the template
+ // gets deserialized.
+ // Setting up the currentSelectedContainer to the document body.
+ userTemplateDidLoad: {
+ value: function(){
+ this.application.ninja.currentSelectedContainer = this.documentRoot;
+ }
+ },
-
-
-
+ ////////////////////////////////////////////////////////////////////
_setSWFObjectScript: {
value: function() {
if(!this._swfObject) {
--
cgit v1.2.3