From e5579374ff39b80b8c0c69faba37f6f581758fe0 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 7 Feb 2012 13:28:17 -0800 Subject: updated montage v.0.6 to the latest changes. Signed-off-by: Valerio Virgillito --- node_modules/montage/ui/component.js | 48 +++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 9 deletions(-) (limited to 'node_modules/montage/ui/component.js') diff --git a/node_modules/montage/ui/component.js b/node_modules/montage/ui/component.js index 90612f83..e41a1958 100755 --- a/node_modules/montage/ui/component.js +++ b/node_modules/montage/ui/component.js @@ -7,7 +7,6 @@ @module montage/ui/component @requires montage/core/core @requires montage/core/event/mutable-event - @requires montage/core/bitfield @requires montage/ui/reel @requires montage/core/gate @requires montage/core/logger | component @@ -16,7 +15,6 @@ */ var Montage = require("montage").Montage, MutableEvent = require("core/event/mutable-event").MutableEvent, - BitField = require("core/bitfield").BitField, Template = require("ui/template").Template, Gate = require("core/gate").Gate, logger = require("core/logger").logger("component"), @@ -525,7 +523,11 @@ var Component = exports.Component = Montage.create(Montage,/** @lends module:mon content: { get: function() { - return Array.prototype.slice.call(this._element.childNodes, 0); + if (this._element) { + return Array.prototype.slice.call(this._element.childNodes, 0); + } else { + return null; + } }, set: function(value) { var components = [], @@ -891,11 +893,11 @@ var Component = exports.Component = Montage.create(Montage,/** @lends module:mon Template.templateWithModuleId(info.require, templateModuleId, onTemplateLoad); }}, /** - Callback for the _canDrawBitField.
+ Callback for the _canDrawGate.
Propagates to the parent and adds the component to the draw list. @function @param {Property} gate - @see _canDrawBitField + @see _canDrawGate */ gateDidBecomeTrue: { value: function(gate) { @@ -1047,6 +1049,27 @@ var Component = exports.Component = Montage.create(Montage,/** @lends module:mon enumerable: false, value: null }, + + /** + * Called to add event listeners on demand + * @type function + * @private + */ + _prepareForActivationEvents: { + value: function() { + var i = this.composerList.length, composer; + for (i = 0; i < this.composerList.length; i++) { + composer = this.composerList[i]; + if (composer.lazyLoad) { + composer._load(); + } + } + if (typeof this.prepareForActivationEvents === "function") { + this.prepareForActivationEvents(); + } + } + }, + /** Description TODO @private @@ -1297,7 +1320,11 @@ var Component = exports.Component = Montage.create(Montage,/** @lends module:mon this.composerList.push(composer); if (!this._firstDraw) { // prepareForDraw has already happened so do the loading here - composer._load(); + if (!composer.lazyLoad) { + composer._load(); + } else if (this._preparedForActivationEvents) { // even though it's lazyLoad prepareForActivationEvents has already happened + composer._load(); + } } } }, @@ -1671,7 +1698,7 @@ var rootComponent = Montage.create(Component, /** @lends module:montage/ui/compo */ addToDrawCycle: { value: function(component) { - var needsDrawListIndex = this._readyToDrawListIndex, length; + var needsDrawListIndex = this._readyToDrawListIndex, length, composer; if (needsDrawListIndex.hasOwnProperty(component.uuid)) { // Requesting a draw of a component that has already been drawn in the current cycle @@ -1694,10 +1721,13 @@ var rootComponent = Montage.create(Component, /** @lends module:montage/ui/compo component.prepareForDraw(); } - // Load any composers that have been added + // Load any non lazyLoad composers that have been added length = component.composerList.length; for (i = 0; i < length; i++) { - component.composerList[i]._load(); + composer = component.composerList[i]; + if (!composer.lazyLoad) { + composer._load(); + } } // Will we expose a different property, firstDraw, for components to check -- cgit v1.2.3