LEFT | RIGHT |
1 'use strict'; | 1 'use strict'; |
2 | 2 |
3 | 3 |
4 /** | 4 /** |
5 Provides searching functionality for the charm browser. | 5 Provides searching functionality for the charm browser. |
6 | 6 |
7 @namespace juju | 7 @namespace juju |
8 @module browser | 8 @module browser |
9 @submodule views | 9 @submodule views |
10 */ | 10 */ |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 Update the node in the editorial list marked as 'active'. | 99 Update the node in the editorial list marked as 'active'. |
100 @method _updateActive | 100 @method _updateActive |
101 @param {Node} clickTarget the charm-token clicked on to activate. | 101 @param {Node} clickTarget the charm-token clicked on to activate. |
102 | 102 |
103 */ | 103 */ |
104 _updateActive: function(clickTarget) { | 104 _updateActive: function(clickTarget) { |
105 // Remove the active class from any nodes that have it. | 105 // Remove the active class from any nodes that have it. |
106 Y.all('.yui3-charmtoken.active').removeClass('active'); | 106 Y.all('.yui3-charmtoken.active').removeClass('active'); |
107 | 107 |
108 // Add it to the current node. | 108 // Add it to the current node. |
109 clickTarget.ancestor('.yui3-charmtoken').addClass('active'); | 109 if (clickTarget) { |
| 110 clickTarget.ancestor('.yui3-charmtoken').addClass('active'); |
| 111 } |
110 }, | 112 }, |
111 | 113 |
112 /** | 114 /** |
113 Renders the search results from the the store query. | 115 Renders the search results from the the store query. |
114 | 116 |
115 @method _renderSearchResults | 117 @method _renderSearchResults |
116 | 118 |
117 */ | 119 */ |
118 _renderSearchResults: function(results) { | 120 _renderSearchResults: function(results) { |
119 var target = this.get('renderTo'), | 121 var target = this.get('renderTo'), |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 @method apiFailure | 161 @method apiFailure |
160 @param {Object} data the json decoded response text. | 162 @param {Object} data the json decoded response text. |
161 @param {Object} request the original io_request object for debugging. | 163 @param {Object} request the original io_request object for debugging. |
162 | 164 |
163 */ | 165 */ |
164 apiFailure: function(data, request) { | 166 apiFailure: function(data, request) { |
165 this._apiFailure(data, request, 'Failed to load search results.'); | 167 this._apiFailure(data, request, 'Failed to load search results.'); |
166 }, | 168 }, |
167 | 169 |
168 /** | 170 /** |
169 Renders the searchview, rendering search results for the view's search | 171 * General YUI initializer. |
170 text. | 172 * |
171 | 173 * @method initializer |
172 @method render | 174 * @param {Object} cfg configuration object. |
| 175 * |
| 176 */ |
| 177 initializer: function(cfg) { |
| 178 this.on('activeIDChange', function(ev) { |
| 179 var id = ev.newVal; |
| 180 if (id) { |
| 181 id = this.get('container').one( |
| 182 '.charm-token[data-charmid="' + id + '"]'); |
| 183 } |
| 184 this._updateActive(id); |
| 185 }); |
| 186 }, |
| 187 |
| 188 /** |
| 189 * Renders the searchview, rendering search results for the view's search |
| 190 * text. |
| 191 * |
| 192 * @method render |
173 */ | 193 */ |
174 render: function() { | 194 render: function() { |
175 // This is only rendered once from the subapp and so the filters is the | 195 // This is only rendered once from the subapp and so the filters is the |
176 // initial set from the application. All subsequent renders go through | 196 // initial set from the application. All subsequent renders go through |
177 // the subapp so we don't have to keep the filters in sync here. | 197 // the subapp so we don't have to keep the filters in sync here. |
178 // If caching/reusing comes into play though an event to track the | 198 // If caching/reusing comes into play though an event to track the |
179 // change of the filters ATTR would make sense to re-draw. | 199 // change of the filters ATTR would make sense to re-draw. |
180 this.get('store').search(this.get('filters'), { | 200 this.get('store').search(this.get('filters'), { |
181 'success': function(data) { | 201 'success': function(data) { |
182 var results = this.get('store').resultsToCharmlist(data.result); | 202 var results = this.get('store').resultsToCharmlist(data.result); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 'base-build', | 245 'base-build', |
226 'browser-charm-token', | 246 'browser-charm-token', |
227 'browser-filter-widget', | 247 'browser-filter-widget', |
228 'browser-overlay-indicator', | 248 'browser-overlay-indicator', |
229 'event-tracker', | 249 'event-tracker', |
230 'juju-browser-models', | 250 'juju-browser-models', |
231 'juju-view-utils', | 251 'juju-view-utils', |
232 'view' | 252 'view' |
233 ] | 253 ] |
234 }); | 254 }); |
LEFT | RIGHT |