diff options
author | hwc487 | 2012-02-08 14:47:31 -0800 |
---|---|---|
committer | hwc487 | 2012-02-08 14:47:31 -0800 |
commit | 468d324f8e9a5f018bc7609b58254ae468075ce9 (patch) | |
tree | c55cebc2cefc959251bcaca0fce139b4b1fc0fc7 /node_modules/montage/ui/component.js | |
parent | ab4b753907bc80a969b0d4104d0b0731597e3bf0 (diff) | |
parent | 0537f8f29e7b8dd48fd08f20b1533fbe92a54c4b (diff) | |
download | ninja-468d324f8e9a5f018bc7609b58254ae468075ce9.tar.gz |
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into working
Diffstat (limited to 'node_modules/montage/ui/component.js')
-rwxr-xr-x | node_modules/montage/ui/component.js | 48 |
1 files changed, 39 insertions, 9 deletions
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 @@ | |||
7 | @module montage/ui/component | 7 | @module montage/ui/component |
8 | @requires montage/core/core | 8 | @requires montage/core/core |
9 | @requires montage/core/event/mutable-event | 9 | @requires montage/core/event/mutable-event |
10 | @requires montage/core/bitfield | ||
11 | @requires montage/ui/reel | 10 | @requires montage/ui/reel |
12 | @requires montage/core/gate | 11 | @requires montage/core/gate |
13 | @requires montage/core/logger | component | 12 | @requires montage/core/logger | component |
@@ -16,7 +15,6 @@ | |||
16 | */ | 15 | */ |
17 | var Montage = require("montage").Montage, | 16 | var Montage = require("montage").Montage, |
18 | MutableEvent = require("core/event/mutable-event").MutableEvent, | 17 | MutableEvent = require("core/event/mutable-event").MutableEvent, |
19 | BitField = require("core/bitfield").BitField, | ||
20 | Template = require("ui/template").Template, | 18 | Template = require("ui/template").Template, |
21 | Gate = require("core/gate").Gate, | 19 | Gate = require("core/gate").Gate, |
22 | logger = require("core/logger").logger("component"), | 20 | logger = require("core/logger").logger("component"), |
@@ -525,7 +523,11 @@ var Component = exports.Component = Montage.create(Montage,/** @lends module:mon | |||
525 | 523 | ||
526 | content: { | 524 | content: { |
527 | get: function() { | 525 | get: function() { |
528 | return Array.prototype.slice.call(this._element.childNodes, 0); | 526 | if (this._element) { |
527 | return Array.prototype.slice.call(this._element.childNodes, 0); | ||
528 | } else { | ||
529 | return null; | ||
530 | } | ||
529 | }, | 531 | }, |
530 | set: function(value) { | 532 | set: function(value) { |
531 | var components = [], | 533 | var components = [], |
@@ -891,11 +893,11 @@ var Component = exports.Component = Montage.create(Montage,/** @lends module:mon | |||
891 | Template.templateWithModuleId(info.require, templateModuleId, onTemplateLoad); | 893 | Template.templateWithModuleId(info.require, templateModuleId, onTemplateLoad); |
892 | }}, | 894 | }}, |
893 | /** | 895 | /** |
894 | Callback for the <code>_canDrawBitField</code>.<br> | 896 | Callback for the <code>_canDrawGate</code>.<br> |
895 | Propagates to the parent and adds the component to the draw list. | 897 | Propagates to the parent and adds the component to the draw list. |
896 | @function | 898 | @function |
897 | @param {Property} gate | 899 | @param {Property} gate |
898 | @see _canDrawBitField | 900 | @see _canDrawGate |
899 | */ | 901 | */ |
900 | gateDidBecomeTrue: { | 902 | gateDidBecomeTrue: { |
901 | value: function(gate) { | 903 | value: function(gate) { |
@@ -1047,6 +1049,27 @@ var Component = exports.Component = Montage.create(Montage,/** @lends module:mon | |||
1047 | enumerable: false, | 1049 | enumerable: false, |
1048 | value: null | 1050 | value: null |
1049 | }, | 1051 | }, |
1052 | |||
1053 | /** | ||
1054 | * Called to add event listeners on demand | ||
1055 | * @type function | ||
1056 | * @private | ||
1057 | */ | ||
1058 | _prepareForActivationEvents: { | ||
1059 | value: function() { | ||
1060 | var i = this.composerList.length, composer; | ||
1061 | for (i = 0; i < this.composerList.length; i++) { | ||
1062 | composer = this.composerList[i]; | ||
1063 | if (composer.lazyLoad) { | ||
1064 | composer._load(); | ||
1065 | } | ||
1066 | } | ||
1067 | if (typeof this.prepareForActivationEvents === "function") { | ||
1068 | this.prepareForActivationEvents(); | ||
1069 | } | ||
1070 | } | ||
1071 | }, | ||
1072 | |||
1050 | /** | 1073 | /** |
1051 | Description TODO | 1074 | Description TODO |
1052 | @private | 1075 | @private |
@@ -1297,7 +1320,11 @@ var Component = exports.Component = Montage.create(Montage,/** @lends module:mon | |||
1297 | this.composerList.push(composer); | 1320 | this.composerList.push(composer); |
1298 | 1321 | ||
1299 | if (!this._firstDraw) { // prepareForDraw has already happened so do the loading here | 1322 | if (!this._firstDraw) { // prepareForDraw has already happened so do the loading here |
1300 | composer._load(); | 1323 | if (!composer.lazyLoad) { |
1324 | composer._load(); | ||
1325 | } else if (this._preparedForActivationEvents) { // even though it's lazyLoad prepareForActivationEvents has already happened | ||
1326 | composer._load(); | ||
1327 | } | ||
1301 | } | 1328 | } |
1302 | } | 1329 | } |
1303 | }, | 1330 | }, |
@@ -1671,7 +1698,7 @@ var rootComponent = Montage.create(Component, /** @lends module:montage/ui/compo | |||
1671 | */ | 1698 | */ |
1672 | addToDrawCycle: { | 1699 | addToDrawCycle: { |
1673 | value: function(component) { | 1700 | value: function(component) { |
1674 | var needsDrawListIndex = this._readyToDrawListIndex, length; | 1701 | var needsDrawListIndex = this._readyToDrawListIndex, length, composer; |
1675 | 1702 | ||
1676 | if (needsDrawListIndex.hasOwnProperty(component.uuid)) { | 1703 | if (needsDrawListIndex.hasOwnProperty(component.uuid)) { |
1677 | // Requesting a draw of a component that has already been drawn in the current cycle | 1704 | // 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 | |||
1694 | component.prepareForDraw(); | 1721 | component.prepareForDraw(); |
1695 | } | 1722 | } |
1696 | 1723 | ||
1697 | // Load any composers that have been added | 1724 | // Load any non lazyLoad composers that have been added |
1698 | length = component.composerList.length; | 1725 | length = component.composerList.length; |
1699 | for (i = 0; i < length; i++) { | 1726 | for (i = 0; i < length; i++) { |
1700 | component.composerList[i]._load(); | 1727 | composer = component.composerList[i]; |
1728 | if (!composer.lazyLoad) { | ||
1729 | composer._load(); | ||
1730 | } | ||
1701 | } | 1731 | } |
1702 | 1732 | ||
1703 | // Will we expose a different property, firstDraw, for components to check | 1733 | // Will we expose a different property, firstDraw, for components to check |