OLD | NEW |
1 'use strict'; | 1 'use strict'; |
2 | 2 |
3 | 3 |
4 YUI.add('subapp-browser-charmview', function(Y) { | 4 YUI.add('subapp-browser-charmview', function(Y) { |
5 var ns = Y.namespace('juju.browser.views'), | 5 var ns = Y.namespace('juju.browser.views'), |
6 views = Y.namespace('juju.views'), | 6 views = Y.namespace('juju.views'), |
7 widgets = Y.namespace('juju.widgets'); | 7 widgets = Y.namespace('juju.widgets'); |
8 | 8 |
9 | 9 |
10 /** | 10 /** |
11 * View for the Charm details UI. | 11 * View for the Charm details UI. |
12 * | 12 * |
13 * @class CharmView | 13 * @class CharmView |
14 * @extends {Y.View} | 14 * @extends {Y.View} |
15 * | 15 * |
16 */ | 16 */ |
17 ns.BrowserCharmView = Y.Base.create('browser-view-charmview', Y.View, [], { | 17 ns.BrowserCharmView = Y.Base.create('browser-view-charmview', Y.View, [ |
| 18 widgets.browser.IndicatorManager], { |
| 19 |
18 template: views.Templates.browser_charm, | 20 template: views.Templates.browser_charm, |
19 | 21 |
20 /** | 22 /** |
21 * List the DOM based events to watch for in the container. | 23 * List the DOM based events to watch for in the container. |
22 * @attribute events | 24 * @attribute events |
23 * | 25 * |
24 */ | 26 */ |
25 events: { | 27 events: { |
26 '.changelog .toggle': { | 28 '.changelog .toggle': { |
27 click: '_toggleLog' | 29 click: '_toggleLog' |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 /** | 148 /** |
147 * Clean up after ourselves. | 149 * Clean up after ourselves. |
148 * | 150 * |
149 * @method destructor | 151 * @method destructor |
150 * | 152 * |
151 */ | 153 */ |
152 destructor: function() { | 154 destructor: function() { |
153 if (this.tabview) { | 155 if (this.tabview) { |
154 this.tabview.destroy(); | 156 this.tabview.destroy(); |
155 } | 157 } |
156 | |
157 Y.Object.each(this._indicators, function(ind, key) { | |
158 ind.destroy(); | |
159 }); | |
160 }, | |
161 | |
162 /** | |
163 * Helper to make sure we can hide an indicator correctly. | |
164 * | |
165 * @method hideIndicator | |
166 * @param {Node} node the container the indicator is currently over. | |
167 * | |
168 */ | |
169 hideIndicator: function(node) { | |
170 var id = node._yuid; | |
171 if (this.indicators[id]) { | |
172 this.indicators[id].success(); | |
173 } | |
174 }, | 158 }, |
175 | 159 |
176 /** | 160 /** |
177 * Generic YUI initializer. Make sure we track indicators for cleanup. | 161 * Generic YUI initializer. Make sure we track indicators for cleanup. |
178 * | 162 * |
179 * @method initializer | 163 * @method initializer |
180 * @param {Object} cfg configuration object. | 164 * @param {Object} cfg configuration object. |
181 * | 165 * |
182 */ | 166 */ |
183 initializer: function(cfg) { | 167 initializer: function(cfg) { |
(...skipping 29 matching lines...) Expand all Loading... |
213 // Start loading the readme so it's ready to go. | 197 // Start loading the readme so it's ready to go. |
214 var readme = this._locateReadme(); | 198 var readme = this._locateReadme(); |
215 | 199 |
216 if (readme) { | 200 if (readme) { |
217 this._loadFile(tplNode.one('#bws_readme'), | 201 this._loadFile(tplNode.one('#bws_readme'), |
218 readme | 202 readme |
219 ); | 203 ); |
220 } else { | 204 } else { |
221 this._noReadme(tplNode.one('#bws_readme')); | 205 this._noReadme(tplNode.one('#bws_readme')); |
222 } | 206 } |
223 }, | |
224 | |
225 /** | |
226 * Show/setBusy an indicator for a given node. If an indicator is already | |
227 * attached then just show it, else create a new indicator instance on the | |
228 * node. | |
229 * | |
230 * @method showIndicator | |
231 * @param {Node} node the node to cover with the indicator. | |
232 * | |
233 */ | |
234 showIndicator: function(node) { | |
235 var id = node._yuid; | |
236 | |
237 if (this.indicators[id]) { | |
238 this.indicators[id].setBusy(); | |
239 } else { | |
240 this.indicators[id] = new widgets.browser.OverlayIndicator({ | |
241 target: node | |
242 }); | |
243 | |
244 this.indicators[id].render(); | |
245 this.indicators[id].setBusy(); | |
246 } | |
247 } | 207 } |
248 | |
249 }, { | 208 }, { |
250 ATTRS: { | 209 ATTRS: { |
251 /** | 210 /** |
252 * The charm we're viewing the details of. | 211 * The charm we're viewing the details of. |
253 * | 212 * |
254 * @attribute charm | 213 * @attribute charm |
255 * @default undefined | 214 * @default undefined |
256 * @type {juju.models.BrowserCharm} | 215 * @type {juju.models.BrowserCharm} |
257 * | 216 * |
258 */ | 217 */ |
(...skipping 16 matching lines...) Expand all Loading... |
275 requires: [ | 234 requires: [ |
276 'browser-overlay-indicator', | 235 'browser-overlay-indicator', |
277 'browser-tabview', | 236 'browser-tabview', |
278 'gallery-markdown', | 237 'gallery-markdown', |
279 'juju-templates', | 238 'juju-templates', |
280 'juju-views', | 239 'juju-views', |
281 'prettify', | 240 'prettify', |
282 'view' | 241 'view' |
283 ] | 242 ] |
284 }); | 243 }); |
OLD | NEW |