Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 'use strict'; | 1 'use strict'; |
2 | 2 |
3 YUI.add('app-subapp-extension', function(Y) { | 3 YUI.add('app-subapp-extension', function(Y) { |
4 | 4 |
5 /** | 5 /** |
6 Adds the ability to register sub applications with a parent Y.App instance by | 6 Adds the ability to register sub applications with a parent Y.App instance by |
7 recording all instances in a subApps attribute and augmenting the parent | 7 recording all instances in a subApps attribute and augmenting the parent |
8 routes with the sub applications. | 8 routes with the sub applications. |
9 | 9 |
10 @class SubAppRegistration | 10 @class SubAppRegistration |
11 @extension App | 11 @extension App |
12 */ | 12 */ |
13 function SubAppRegistration() {} | 13 function SubAppRegistration() {} |
14 | 14 |
15 SubAppRegistration.ATTRS = { | 15 SubAppRegistration.ATTRS = { |
16 subApps: { | 16 subApps: { |
17 value: {} | 17 value: {} |
18 } | 18 } |
19 }; | 19 }; |
20 | 20 |
21 SubAppRegistration.prototype = { | 21 SubAppRegistration.prototype = { |
22 _blacklisted_config: [ | 22 _blacklistedConfig: [ |
jeff.pihach
2013/03/14 19:48:43
camelCase :) _blacklistedConfig
| |
23 'container', | 23 'container', |
24 'html5', | 24 'html5', |
25 'serverRouting', | 25 'serverRouting', |
26 'transitions', | 26 'transitions', |
27 'viewContainer' | 27 'viewContainer' |
28 ], | 28 ], |
29 | 29 |
30 /** | 30 /** |
31 A list of sub applications to be instantiated after initialization | 31 A list of sub applications to be instantiated after initialization |
32 of the parent app. | 32 of the parent app. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 */ | 89 */ |
90 addSubApps: function(subApps, cfg) { | 90 addSubApps: function(subApps, cfg) { |
91 if (cfg === undefined) { | 91 if (cfg === undefined) { |
92 cfg = {}; | 92 cfg = {}; |
93 } | 93 } |
94 | 94 |
95 Y.Array.each(subApps, function(subApp) { | 95 Y.Array.each(subApps, function(subApp) { |
96 // Merge the shared application config data with the hard coded config | 96 // Merge the shared application config data with the hard coded config |
97 // so that the hard coded values maintain precedence. | 97 // so that the hard coded values maintain precedence. |
98 // Note that black listed attributes are not passed into SubApps. | 98 // Note that black listed attributes are not passed into SubApps. |
99 Y.each(this._blacklisted_config, function(blacklist) { | 99 Y.each(this._blacklistedConfig, function(blacklist) { |
jeff.pihach
2013/03/14 19:48:43
trivial, maybe blacklist should be renamed blackli
| |
100 if (cfg[blacklist]) { | 100 if (cfg[blacklist]) { |
101 delete cfg[blacklist]; | 101 delete cfg[blacklist]; |
102 } | 102 } |
103 }); | 103 }); |
104 | 104 |
105 var merged_cfg = Y.merge(cfg, subApp.config); | 105 var mergedCfg = Y.merge(cfg, subApp.config); |
jeff.pihach
2013/03/14 19:48:43
camelCase
| |
106 this.addSubApp(subApp.type, merged_cfg); | 106 this.addSubApp(subApp.type, mergedCfg); |
107 }, this); | 107 }, this); |
108 }, | 108 }, |
109 | 109 |
110 /** | 110 /** |
111 Extract the routes out of the sub apps. | 111 Extract the routes out of the sub apps. |
112 | 112 |
113 @method _extractRoutes | 113 @method _extractRoutes |
114 @protected | 114 @protected |
115 @param {object | integer | undefined} subApp will extract the routes | 115 @param {object | integer | undefined} subApp will extract the routes |
116 out of the supplied subApp, index, or all subApps if undefined. | 116 out of the supplied subApp, index, or all subApps if undefined. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
164 Array.prototype.splice.apply(parentRoutes, routes); | 164 Array.prototype.splice.apply(parentRoutes, routes); |
165 | 165 |
166 this.set('routes', parentRoutes); | 166 this.set('routes', parentRoutes); |
167 return parentRoutes; | 167 return parentRoutes; |
168 } | 168 } |
169 }; | 169 }; |
170 | 170 |
171 Y.namespace('juju').SubAppRegistration = SubAppRegistration; | 171 Y.namespace('juju').SubAppRegistration = SubAppRegistration; |
172 | 172 |
173 }, '0.1.0'); | 173 }, '0.1.0'); |
LEFT | RIGHT |