aboutsummaryrefslogtreecommitdiff
path: root/node_modules/montage/ui/template.js
diff options
context:
space:
mode:
authorValerio Virgillito2012-02-02 00:11:51 -0800
committerValerio Virgillito2012-02-02 15:33:42 -0800
commita3024011a91d3941f81481dd4d600e9684eb0fd4 (patch)
tree084b4856910f1db53973dd11617f7ffa03a6dd46 /node_modules/montage/ui/template.js
parent97255032921178bdfbc25512ddf3e0867e353f7a (diff)
downloadninja-a3024011a91d3941f81481dd4d600e9684eb0fd4.tar.gz
upgrading to Montage v0.6
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'node_modules/montage/ui/template.js')
-rwxr-xr-xnode_modules/montage/ui/template.js47
1 files changed, 27 insertions, 20 deletions
diff --git a/node_modules/montage/ui/template.js b/node_modules/montage/ui/template.js
index 219fbc5f..509e3406 100755
--- a/node_modules/montage/ui/template.js
+++ b/node_modules/montage/ui/template.js
@@ -18,7 +18,7 @@ var Serializer = require("core/serializer").Serializer;
18var Deserializer = require("core/deserializer").Deserializer; 18var Deserializer = require("core/deserializer").Deserializer;
19var logger = require("core/logger").logger("template"); 19var logger = require("core/logger").logger("template");
20var defaultEventManager = require("core/event/event-manager").defaultEventManager; 20var defaultEventManager = require("core/event/event-manager").defaultEventManager;
21var defaultApplication = require("ui/application").application; 21var applicationExports = require("ui/application");
22 22
23/** 23/**
24 @class module:montage/ui/template.Template 24 @class module:montage/ui/template.Template
@@ -48,7 +48,7 @@ var Template = exports.Template = Montage.create(Montage, /** @lends module:mont
48 @private 48 @private
49*/ 49*/
50 _isLoaded: {value: false}, 50 _isLoaded: {value: false},
51 51
52 /** 52 /**
53 Creates a new Template instance from an HTML document element. 53 Creates a new Template instance from an HTML document element.
54 @function 54 @function
@@ -59,7 +59,7 @@ var Template = exports.Template = Montage.create(Montage, /** @lends module:mont
59 59
60 return this; 60 return this;
61 }}, 61 }},
62 62
63 __templatesById: {value: {}}, 63 __templatesById: {value: {}},
64 __templateCallbacksByModuleId: {value: {}}, 64 __templateCallbacksByModuleId: {value: {}},
65 65
@@ -123,7 +123,7 @@ var Template = exports.Template = Montage.create(Montage, /** @lends module:mont
123 @private 123 @private
124 */ 124 */
125 _deserializer: {value:null}, 125 _deserializer: {value:null},
126 126
127 /** 127 /**
128 The deserializer object used by the template. 128 The deserializer object used by the template.
129 @type {module:montage/core/deserializer.Deserializer} 129 @type {module:montage/core/deserializer.Deserializer}
@@ -224,10 +224,16 @@ var Template = exports.Template = Montage.create(Montage, /** @lends module:mont
224 } 224 }
225 // make sure we use the same require used to create this component to instantiate this reel 225 // make sure we use the same require used to create this component to instantiate this reel
226 this._deserializer = this._createDeserializer(this._ownerSerialization); 226 this._deserializer = this._createDeserializer(this._ownerSerialization);
227 227
228 return this; 228 return this;
229 }}, 229 }},
230 230
231 optimize: {
232 value: function() {
233 this.deserializer.optimizeForDocument(this._document);
234 }
235 },
236
231 /** 237 /**
232 Instantiates the Template by specifying an object as the owner and a document where the elements referenced in the serialization should be found. 238 Instantiates the Template by specifying an object as the owner and a document where the elements referenced in the serialization should be found.
233 @function 239 @function
@@ -237,7 +243,8 @@ var Template = exports.Template = Montage.create(Montage, /** @lends module:mont
237 */ 243 */
238 instantiateWithOwnerAndDocument: { 244 instantiateWithOwnerAndDocument: {
239 value: function(owner, document, callback) { 245 value: function(owner, document, callback) {
240 var self = this; 246 var self = this,
247 defaultApplication = applicationExports.application;
241 this.getDeserializer(function(deserializer) { 248 this.getDeserializer(function(deserializer) {
242 function invokeTemplateDidLoad(objects) { 249 function invokeTemplateDidLoad(objects) {
243 owner = objects.owner; 250 owner = objects.owner;
@@ -351,7 +358,7 @@ var Template = exports.Template = Montage.create(Montage, /** @lends module:mont
351 this.insertStylesInDocumentIfNeeded(doc); 358 this.insertStylesInDocumentIfNeeded(doc);
352 this.insertScriptsInDocumentIfNeeded(doc); 359 this.insertScriptsInDocumentIfNeeded(doc);
353 }}, 360 }},
354 361
355 /** 362 /**
356 @private 363 @private
357 */ 364 */
@@ -359,7 +366,7 @@ var Template = exports.Template = Montage.create(Montage, /** @lends module:mont
359 enumerable: false, 366 enumerable: false,
360 value: null 367 value: null
361 }, 368 },
362 369
363 /** 370 /**
364 @private 371 @private
365 */ 372 */
@@ -367,7 +374,7 @@ var Template = exports.Template = Montage.create(Montage, /** @lends module:mont
367 enumerable: false, 374 enumerable: false,
368 value: null 375 value: null
369 }, 376 },
370 377
371 /** 378 /**
372 @private 379 @private
373 */ 380 */
@@ -375,10 +382,10 @@ var Template = exports.Template = Montage.create(Montage, /** @lends module:mont
375 enumerable: false, 382 enumerable: false,
376 value: null 383 value: null
377 }, 384 },
378 385
379 /** 386 /**
380 Inserts all styles found in the Template object into the document given. 387 Inserts all styles found in the Template object into the document given.
381 This function is idempotent, it will not insert styles that are already in the document. 388 This function is idempotent, it will not insert styles that are already in the document.
382 @function 389 @function
383 @param {HTMLDocument} doc The document to insert the styles. 390 @param {HTMLDocument} doc The document to insert the styles.
384 */ 391 */
@@ -490,7 +497,7 @@ var Template = exports.Template = Montage.create(Montage, /** @lends module:mont
490 497
491 /** 498 /**
492 Inserts all scripts found in the Template object into the document given. 499 Inserts all scripts found in the Template object into the document given.
493 This function is idempotent, it will not insert scripts that are already in the document. 500 This function is idempotent, it will not insert scripts that are already in the document.
494 @function 501 @function
495 @param {HTMLDocument} doc The document to insert the scripts. 502 @param {HTMLDocument} doc The document to insert the scripts.
496 */ 503 */
@@ -548,7 +555,7 @@ var Template = exports.Template = Montage.create(Montage, /** @lends module:mont
548 555
549 documentHead.appendChild(container); 556 documentHead.appendChild(container);
550 }}, 557 }},
551 558
552 /** 559 /**
553 <i>This function is meant to work with insertScriptsInDocumentIfNeeded, insertStylesInDocumentIfNeeded and setupDocument</i>. 560 <i>This function is meant to work with insertScriptsInDocumentIfNeeded, insertStylesInDocumentIfNeeded and setupDocument</i>.
554 This function informs the caller when the Template styles have been loaded into the document. 561 This function informs the caller when the Template styles have been loaded into the document.
@@ -612,7 +619,7 @@ var Template = exports.Template = Montage.create(Montage, /** @lends module:mont
612 619
613 return htmlDocument; 620 return htmlDocument;
614 }}, 621 }},
615 622
616 // indexed by module id 623 // indexed by module id
617 /** 624 /**
618 @private 625 @private
@@ -621,7 +628,7 @@ var Template = exports.Template = Montage.create(Montage, /** @lends module:mont
621 enumerable: false, 628 enumerable: false,
622 value: {} 629 value: {}
623 }, 630 },
624 631
625 /** 632 /**
626 Creates an HTMLDocument from an HTML file at the given module id. 633 Creates an HTMLDocument from an HTML file at the given module id.
627 @function 634 @function
@@ -644,7 +651,7 @@ var Template = exports.Template = Montage.create(Montage, /** @lends module:mont
644 }); 651 });
645 } 652 }
646 }}, 653 }},
647 654
648 /** 655 /**
649 Searches for an inline serialization in a document and returns it if found. 656 Searches for an inline serialization in a document and returns it if found.
650 @function 657 @function
@@ -662,7 +669,7 @@ var Template = exports.Template = Montage.create(Montage, /** @lends module:mont
662 return null; 669 return null;
663 } 670 }
664 }}, 671 }},
665 672
666 /** 673 /**
667 Searches for an external serialization in a document and returns its content if found. 674 Searches for an external serialization in a document and returns its content if found.
668 @function 675 @function
@@ -703,7 +710,7 @@ var Template = exports.Template = Montage.create(Montage, /** @lends module:mont
703 callback(null); 710 callback(null);
704 } 711 }
705 }}, 712 }},
706 713
707 /** 714 /**
708 Gets the configured Deserializer object ready to deserialize the Template serialization if any. 715 Gets the configured Deserializer object ready to deserialize the Template serialization if any.
709 @function 716 @function
@@ -729,7 +736,7 @@ var Template = exports.Template = Montage.create(Montage, /** @lends module:mont
729 } 736 }
730 } 737 }
731 }}, 738 }},
732 739
733 /** 740 /**
734 @private 741 @private
735 */ 742 */
@@ -780,7 +787,7 @@ var Template = exports.Template = Montage.create(Montage, /** @lends module:mont
780 serializer.set("owner", this._ownerSerialization); 787 serializer.set("owner", this._ownerSerialization);
781 serializer.set("markup", this._document.body.innerHTML); 788 serializer.set("markup", this._document.body.innerHTML);
782 }}, 789 }},
783 790
784 /** 791 /**
785 @private 792 @private
786 */ 793 */