Left: | ||
Right: |
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 */ |
11 YUI.add('subapp-browser-searchview', function(Y) { | 11 YUI.add('subapp-browser-searchview', function(Y) { |
12 var ns = Y.namespace('juju.browser.views'), | 12 var ns = Y.namespace('juju.browser.views'), |
13 views = Y.namespace('juju.views'), | 13 views = Y.namespace('juju.views'), |
14 widgets = Y.namespace('juju.widgets'), | 14 widgets = Y.namespace('juju.widgets'), |
15 models = Y.namespace('juju.models'); | 15 models = Y.namespace('juju.models'); |
16 | 16 |
17 ns.BrowserSearchView = Y.Base.create('browser-view-searchview', Y.View, [ | 17 ns.BrowserSearchView = Y.Base.create('browser-view-searchview', Y.View, [ |
18 Y.Event.EventTracker | 18 views.utils.apiFailingView |
19 ], { | 19 ], { |
20 template: views.Templates.search, | 20 template: views.Templates.search, |
21 /** | 21 /** |
22 * Renders the search results from the the store query. | 22 * Renders the search results from the the store query. |
23 * | 23 * |
24 * @method _renderSearchResults | 24 * @method _renderSearchResults |
25 * @param {Y.Node} container Optional container to render results to. | 25 * @param {Y.Node} container Optional container to render results to. |
26 */ | 26 */ |
27 _renderSearchResults: function(results) { | 27 _renderSearchResults: function(results) { |
28 var target = this.get('renderTo'), | 28 var target = this.get('renderTo'), |
29 tpl = this.template({count: results.size()}), | 29 tpl = this.template({count: results.size()}), |
30 tplNode = Y.Node.create(tpl), | 30 tplNode = Y.Node.create(tpl), |
31 container = tplNode.one('.search-results'); | 31 container = tplNode.one('.search-results'); |
32 | 32 |
33 results.map(function(charm) { | 33 results.map(function(charm) { |
rharding
2013/04/22 14:08:15
does it make sense to use a charm-container here w
j.c.sackett
2013/04/22 20:54:45
I don't think so; the container header &c will loo
| |
34 var ct = new widgets.browser.CharmToken(charm.getAttrs()); | 34 var ct = new widgets.browser.CharmToken(charm.getAttrs()); |
35 ct.render(container); | 35 ct.render(container); |
36 }); | 36 }); |
37 target.setHTML(tplNode); | 37 target.setHTML(tplNode); |
38 }, | 38 }, |
39 | 39 |
40 /** | 40 /** |
41 * Generates a message to the user based on a bad api call. | 41 * Generates a message to the user based on a bad api call. |
42 * | 42 * |
43 * @method apiFailure | 43 * @method apiFailure |
44 * @param {Object} data the json decoded response text. | 44 * @param {Object} data the json decoded response text. |
45 * @param {Object} request the original io_request object for debugging. | 45 * @param {Object} request the original io_request object for debugging. |
46 * | 46 * |
47 */ | 47 */ |
48 apiFailure: function(data, request) { | 48 apiFailure: function(data, request) { |
rharding
2013/04/22 14:08:15
yea, so this is where an extension would remove th
j.c.sackett
2013/04/22 20:54:45
Yup, extension implemented.
| |
49 Y.juju.browser.views.utils.apiFailure(data, request, this); | 49 this._apiFailure(data, request, 'Failed to load search results.'); |
50 }, | 50 }, |
51 | 51 |
52 /** | 52 /** |
53 * Renders the searchview, rendering search results for the view's search | 53 * Renders the searchview, rendering search results for the view's search |
54 * text. | 54 * text. |
55 * | 55 * |
56 * @method render | 56 * @method render |
57 */ | 57 */ |
58 render: function() { | 58 render: function() { |
59 var text = this.get('text'); | 59 var text = this.get('text'); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
93 * @attribute text | 93 * @attribute text |
94 * @default '' | 94 * @default '' |
95 * @type {String} | 95 * @type {String} |
96 */ | 96 */ |
97 text: {} | 97 text: {} |
98 } | 98 } |
99 }); | 99 }); |
100 | 100 |
101 }, '0.1.0', { | 101 }, '0.1.0', { |
102 requires: [ | 102 requires: [ |
103 'event-tracker', | |
104 'browser-overlay-indicator', | |
105 'base-build', | 103 'base-build', |
106 'browser-charm-token', | 104 'browser-charm-token', |
107 'subapp-browser-view-utils', | 105 'browser-overlay-indicator', |
106 'event-tracker', | |
107 'juju-view-utils', | |
108 'view' | 108 'view' |
109 ] | 109 ] |
110 }); | 110 }); |
LEFT | RIGHT |