aboutsummaryrefslogtreecommitdiff
path: root/js/io/document/html-document.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/io/document/html-document.js')
-rwxr-xr-xjs/io/document/html-document.js74
1 files changed, 41 insertions, 33 deletions
diff --git a/js/io/document/html-document.js b/js/io/document/html-document.js
index ac556c2d..88cfec67 100755
--- a/js/io/document/html-document.js
+++ b/js/io/document/html-document.js
@@ -6,9 +6,9 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
6 6
7//////////////////////////////////////////////////////////////////////// 7////////////////////////////////////////////////////////////////////////
8// 8//
9var Montage = require("montage/core/core").Montage, 9var Montage = require("montage/core/core").Montage,
10 BaseDocument = require("js/io/document/base-document").BaseDocument, 10 BaseDocument = require("js/io/document/base-document").BaseDocument,
11 NJUtils = require("js/lib/NJUtils").NJUtils; 11 NJUtils = require("js/lib/NJUtils").NJUtils;
12//////////////////////////////////////////////////////////////////////// 12////////////////////////////////////////////////////////////////////////
13// 13//
14exports.HTMLDocument = Montage.create(BaseDocument, { 14exports.HTMLDocument = Montage.create(BaseDocument, {
@@ -31,6 +31,7 @@ exports.HTMLDocument = Montage.create(BaseDocument, {
31 _userDocument: { value: null, enumerable: false }, 31 _userDocument: { value: null, enumerable: false },
32 _htmlSource: {value: "<html></html>", enumerable: false}, 32 _htmlSource: {value: "<html></html>", enumerable: false},
33 _glData: {value: null, enumerable: false }, 33 _glData: {value: null, enumerable: false },
34 _userComponents: { value: {}, enumarable: false},
34 35
35 _elementCounter: { value: 1, enumerable: false }, 36 _elementCounter: { value: 1, enumerable: false },
36 _snapping : { value: true, enumerable: false }, 37 _snapping : { value: true, enumerable: false },
@@ -137,23 +138,11 @@ exports.HTMLDocument = Montage.create(BaseDocument, {
137 } 138 }
138 }, 139 },
139 140
140 _userComponentSet: { 141 userComponents: {
141 value: {}, 142 get: function() {
142 writable: true, 143 return this._userComponents;
143 enumerable:true 144 }
144 }, 145 },
145
146// userComponentSet:{
147// enumerable: true,
148// get: function() {
149// return this._userComponentSet;
150// },
151// set: function(value) {
152// this._userComponentSet = value;
153// this._drawUserComponentsOnOpen();
154// }
155// },
156//
157// _drawUserComponentsOnOpen:{ 146// _drawUserComponentsOnOpen:{
158// value:function(){ 147// value:function(){
159// for(var i in this._userComponentSet){ 148// for(var i in this._userComponentSet){
@@ -220,22 +209,45 @@ exports.HTMLDocument = Montage.create(BaseDocument, {
220 set: function(value) { this._zoomFactor = value; } 209 set: function(value) { this._zoomFactor = value; }
221 }, 210 },
222 211
212 /**
213 * Add a reference to a component instance to the userComponents hash using the
214 * element UUID
215 */
216 setComponentInstance: {
217 value: function(instance, el) {
218 this.userComponents[el.uuid] = instance;
219 }
220 },
221
222 /**
223 * Returns the component instance obj from the element
224 */
225 getComponentFromElement: {
226 value: function(el) {
227 if(el) {
228 if(el.uuid) return this.userComponents[el.uuid];
229 } else {
230 return null;
231 }
232 }
233 },
234
223 //****************************************// 235 //****************************************//
224 // PUBLIC METHODS 236 // PUBLIC METHODS
225 237
226 238
227 //////////////////////////////////////////////////////////////////// 239 ////////////////////////////////////////////////////////////////////
228 // 240 //
229 initialize: { 241 initialize: {
230 value: function(file, uuid, iframe, callback) { 242 value: function(file, uuid, iframe, callback) {
231 // 243 //
232 this._userDocument = file; 244 this._userDocument = file;
233 // 245 //
234 this.init(file.name, file.uri, file.extension, iframe, uuid, callback); 246 this.init(file.name, file.uri, file.extension, iframe, uuid, callback);
235 // 247 //
236 this.iframe = iframe; 248 this.iframe = iframe;
237 this.selectionExclude = ["HTML", "BODY", "Viewport", "UserContent", "stageBG"]; 249 this.selectionExclude = ["HTML", "BODY", "Viewport", "UserContent", "stageBG"];
238 this.currentView = "design"; 250 this.currentView = "design";
239 // 251 //
240 this.iframe.src = this._htmlTemplateUrl; 252 this.iframe.src = this._htmlTemplateUrl;
241 this.iframe.addEventListener("load", this, true); 253 this.iframe.addEventListener("load", this, true);
@@ -347,7 +359,7 @@ exports.HTMLDocument = Montage.create(BaseDocument, {
347 }, 359 },
348 360
349 /* 361 /*
350// Private 362 // Private
351 _loadDocument: { 363 _loadDocument: {
352 value: function(uri) { 364 value: function(uri) {
353 // Load the document into the Iframe 365 // Load the document into the Iframe
@@ -356,7 +368,7 @@ exports.HTMLDocument = Montage.create(BaseDocument, {
356 } 368 }
357 }, 369 },
358*/ 370*/
359 371
360 372
361 373
362 //////////////////////////////////////////////////////////////////// 374 ////////////////////////////////////////////////////////////////////
@@ -368,7 +380,7 @@ exports.HTMLDocument = Montage.create(BaseDocument, {
368 this._templateDocument.head = this.iframe.contentWindow.document.getElementById("userHead");; 380 this._templateDocument.head = this.iframe.contentWindow.document.getElementById("userHead");;
369 this._templateDocument.body = this.iframe.contentWindow.document.getElementById("UserContent");; 381 this._templateDocument.body = this.iframe.contentWindow.document.getElementById("UserContent");;
370 // 382 //
371 this.documentRoot = this.iframe.contentWindow.document.getElementById("UserContent"); 383 this.documentRoot = this.iframe.contentWindow.document.getElementById("UserContent");
372 this.stageBG = this.iframe.contentWindow.document.getElementById("stageBG"); 384 this.stageBG = this.iframe.contentWindow.document.getElementById("stageBG");
373 this.stageBG.onclick = null; 385 this.stageBG.onclick = null;
374 this._document = this.iframe.contentWindow.document; 386 this._document = this.iframe.contentWindow.document;
@@ -376,10 +388,10 @@ exports.HTMLDocument = Montage.create(BaseDocument, {
376 // 388 //
377 if(!this.documentRoot.Ninja) this.documentRoot.Ninja = {}; 389 if(!this.documentRoot.Ninja) this.documentRoot.Ninja = {};
378 // 390 //
379 391
380 this.documentRoot.innerHTML = this._userDocument.content.body; 392 this.documentRoot.innerHTML = this._userDocument.content.body;
381 this.iframe.contentWindow.document.getElementById("userHead").innerHTML = this._userDocument.content.head; 393 this.iframe.contentWindow.document.getElementById("userHead").innerHTML = this._userDocument.content.head;
382 394
383 395
384 //TODO: Look at code below and clean up 396 //TODO: Look at code below and clean up
385 397
@@ -395,10 +407,6 @@ exports.HTMLDocument = Montage.create(BaseDocument, {
395 this.callback(this); 407 this.callback(this);
396 } 408 }
397 }.bind(this), 50); 409 }.bind(this), 50);
398
399 // TODO - Not sure where this goes
400 this._userComponentSet = {};
401
402 410
403 this._styles = this._document.styleSheets[this._document.styleSheets.length - 1]; 411 this._styles = this._document.styleSheets[this._document.styleSheets.length - 1];
404 this._stylesheets = this._document.styleSheets; // Entire stlyesheets array 412 this._stylesheets = this._document.styleSheets; // Entire stlyesheets array
@@ -449,7 +457,7 @@ exports.HTMLDocument = Montage.create(BaseDocument, {
449 457
450 this.callback(this); 458 this.callback(this);
451 459
452 } 460 }
453 }, 461 },
454 462
455 _setSWFObjectScript: { 463 _setSWFObjectScript: {
@@ -484,7 +492,7 @@ exports.HTMLDocument = Montage.create(BaseDocument, {
484 //TODO: Would this get call when we are in code of HTML? 492 //TODO: Would this get call when we are in code of HTML?
485 } else { 493 } else {
486 //Error 494 //Error
487 } 495 }
488 } 496 }
489 } 497 }
490 //////////////////////////////////////////////////////////////////// 498 ////////////////////////////////////////////////////////////////////