aboutsummaryrefslogtreecommitdiff
path: root/js/document/html-document.js
diff options
context:
space:
mode:
authorJose Antonio Marquez2012-02-15 19:07:31 -0800
committerJose Antonio Marquez2012-02-15 19:07:31 -0800
commitcdd36ed6c789886657c967e72ec2dcd49c6c5a76 (patch)
treeb044208c38770c0c4edce03379071dbf2eb29b83 /js/document/html-document.js
parentc7ef6951baff283266df7567e30c8074dda4ad01 (diff)
parentd366c0bd1af6471511217ed574083e15059519b5 (diff)
downloadninja-cdd36ed6c789886657c967e72ec2dcd49c6c5a76.tar.gz
Merge branch 'refs/heads/NinjaInternal' into FileIO
Conflicts: js/document/html-document.js
Diffstat (limited to 'js/document/html-document.js')
-rwxr-xr-xjs/document/html-document.js70
1 files changed, 39 insertions, 31 deletions
diff --git a/js/document/html-document.js b/js/document/html-document.js
index d0b63dcc..bf9bba76 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -31,6 +31,7 @@ exports.HTMLDocument = Montage.create(TextDocument, {
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(TextDocument, {
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(TextDocument, {
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(TextDocument, {
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(TextDocument, {
356 } 368 }
357 }, 369 },
358*/ 370*/
359 371
360 372
361 373
362 //////////////////////////////////////////////////////////////////// 374 ////////////////////////////////////////////////////////////////////
@@ -368,7 +380,7 @@ exports.HTMLDocument = Montage.create(TextDocument, {
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(TextDocument, {
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(TextDocument, {
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(TextDocument, {
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(TextDocument, {
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 ////////////////////////////////////////////////////////////////////