OLD | NEW |
1 'use strict'; | 1 'use strict'; |
2 | 2 |
3 | 3 |
4 /** | 4 /** |
5 * Browser SubApp Sidebar View handler. | 5 * Browser SubApp Sidebar View handler. |
6 * | 6 * |
7 * @module juju.browser | 7 * @module juju.browser |
8 * @submodule views | 8 * @submodule views |
9 * | 9 * |
10 */ | 10 */ |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 105 |
106 container.setHTML(tplNode); | 106 container.setHTML(tplNode); |
107 | 107 |
108 // By default we grab the editorial content from the api to use for | 108 // By default we grab the editorial content from the api to use for |
109 // display. | 109 // display. |
110 this.get('store').sidebarEditorial({ | 110 this.get('store').sidebarEditorial({ |
111 'success': function(data) { | 111 'success': function(data) { |
112 var sliderCharms = this.get('store').resultsToCharmlist( | 112 var sliderCharms = this.get('store').resultsToCharmlist( |
113 data.result.slider); | 113 data.result.slider); |
114 var sliderContainer = container.one('.bws-left .slider'); | 114 var sliderContainer = container.one('.bws-left .slider'); |
115 this.slider = this._generateSliderWidget(sliderCharms); | 115 var sliderCharmContainer = new Y.juju.widgets.browser.CharmContainer({ |
116 if (this.slider) { | 116 name: 'Featured Charms', |
117 this.slider.render(sliderContainer); | 117 cutoff: 1, |
118 } | 118 children: sliderCharms.map(function(charm) { |
| 119 return charm.getAttrs(); }) |
| 120 }); |
| 121 sliderCharmContainer.render(sliderContainer); |
119 | 122 |
120 // Add in the charm tokens for the new as well. | 123 // Add in the charm tokens for the new as well. |
121 var newContainer = container.one('.bws-left .new'); | 124 var newContainer = container.one('.bws-left .new'); |
122 var newCharms = this.get('store').resultsToCharmlist( | 125 var newCharms = this.get('store').resultsToCharmlist( |
123 data.result['new']); | 126 data.result['new']); |
124 newCharms.map(function(charm) { | 127 var newCharmContainer = new Y.juju.widgets.browser.CharmContainer({ |
125 var node = Y.Node.create('<div>'), | 128 name: 'New Charms', |
126 widget = new Y.juju.widgets.browser.CharmToken( | 129 cutoff: 2, |
127 charm.getAttrs()); | 130 children: newCharms.map(function(charm) { |
128 widget.render(node); | 131 return charm.getAttrs(); }) |
129 newContainer.append(node); | |
130 }); | 132 }); |
| 133 newCharmContainer.render(newContainer); |
131 | 134 |
132 // Add the charms to the cache for use in other views. | 135 // Add the charms to the cache for use in other views. |
133 // Start with a reset to empty any current cached models. | 136 // Start with a reset to empty any current cached models. |
134 this._cacheCharms.reset(newCharms); | 137 this._cacheCharms.reset(newCharms); |
135 this._cacheCharms.add(sliderCharms); | 138 this._cacheCharms.add(sliderCharms); |
136 }, | 139 }, |
137 | 140 |
138 'failure': function(data, request) { | 141 'failure': function(data, request) { |
139 var message; | 142 var message; |
140 if (data && data.type) { | 143 if (data && data.type) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 // Bind our view to the events from the search widget used for controls. | 183 // Bind our view to the events from the search widget used for controls. |
181 this._bindSearchWidgetEvents(); | 184 this._bindSearchWidgetEvents(); |
182 } | 185 } |
183 | 186 |
184 }, { | 187 }, { |
185 ATTRS: {} | 188 ATTRS: {} |
186 }); | 189 }); |
187 | 190 |
188 }, '0.1.0', { | 191 }, '0.1.0', { |
189 requires: [ | 192 requires: [ |
| 193 'browser-charm-container', |
190 'browser-charm-slider', | 194 'browser-charm-slider', |
191 'browser-charm-token', | 195 'browser-charm-token', |
192 'browser-search-widget', | 196 'browser-search-widget', |
193 'juju-charm-store', | 197 'juju-charm-store', |
194 'juju-models', | 198 'juju-models', |
195 'juju-templates', | 199 'juju-templates', |
196 'subapp-browser-charmview', | 200 'subapp-browser-charmview', |
197 'subapp-browser-mainview', | 201 'subapp-browser-mainview', |
198 'view' | 202 'view' |
199 ] | 203 ] |
200 }); | 204 }); |
OLD | NEW |