LEFT | RIGHT |
1 'use strict'; | 1 'use strict'; |
2 | 2 |
3 | 3 |
4 /** | 4 /** |
5 * Provide data models used for the charm browser. | 5 * Provide data models used for the charm browser. |
6 * | 6 * |
7 * @module models | 7 * @module models |
8 * @submodule models.browser | 8 * @submodule models.browser |
9 */ | 9 */ |
10 YUI.add('juju-browser-models', function(Y) { | 10 YUI.add('juju-browser-models', function(Y) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 _setDefaults: function() { | 65 _setDefaults: function() { |
66 this.set('series', ['precise']); | 66 this.set('series', ['precise']); |
67 this.set('type', ['approved']); | 67 this.set('type', ['approved']); |
68 }, | 68 }, |
69 | 69 |
70 /** | 70 /** |
71 Given the current filters, generate a query string to use for api | 71 Given the current filters, generate a query string to use for api |
72 calls. | 72 calls. |
73 | 73 |
74 @method genQueryString | 74 @method genQueryString |
| 75 @return {String} generated query string. |
75 | 76 |
76 */ | 77 */ |
77 genQueryString: function() { | 78 genQueryString: function() { |
78 return Y.QueryString.stringify(this.getFilterData()); | 79 return Y.QueryString.stringify(this.getFilterData()); |
79 }, | 80 }, |
80 | 81 |
81 /** | 82 /** |
82 Helper to generate a nice object from all of the properties we track as | 83 Helper to generate a nice object from all of the properties we track as |
83 filters. | 84 filters. |
84 | 85 |
(...skipping 21 matching lines...) Expand all Loading... |
106 } | 107 } |
107 }); | 108 }); |
108 return res; | 109 return res; |
109 }, | 110 }, |
110 | 111 |
111 /** | 112 /** |
112 * Model initialization method. | 113 * Model initialization method. |
113 * | 114 * |
114 * @method initializer | 115 * @method initializer |
115 * @param {Object} cfg object attrs override. | 116 * @param {Object} cfg object attrs override. |
| 117 * @return {undefined} nadda. |
116 * | 118 * |
117 */ | 119 */ |
118 initializer: function(cfg) { | 120 initializer: function(cfg) { |
119 this._setDefaults(); | 121 this._setDefaults(); |
120 | 122 |
121 if (cfg) { | 123 if (cfg) { |
122 // we've got initial data we need to load into proper arrays and | 124 // we've got initial data we need to load into proper arrays and |
123 // such. We use this update because it turns strings from the query | 125 // such. We use this update because it turns strings from the query |
124 // string into a proper array when there is only one selection from | 126 // string into a proper array when there is only one selection from |
125 // the filter group. | 127 // the filter group. |
126 this.update(cfg); | 128 this.update(cfg); |
127 } | 129 } |
128 }, | 130 }, |
129 | 131 |
130 /** | 132 /** |
131 Update the current filters given an update object that's keyed on the | 133 Update the current filters given an update object that's keyed on the |
132 property and the new values to use for it. | 134 property and the new values to use for it. |
133 | 135 |
134 This is used to help pre-populate the filters from the url on an | 136 This is used to help pre-populate the filters from the url on an |
135 initial url load (a shared searc link) as well as updates from the | 137 initial url load (a shared searc link) as well as updates from the |
136 widgets that turn into change events that make sure we update the | 138 widgets that turn into change events that make sure we update the |
137 current set of filters based on the changes detected in widgets lower | 139 current set of filters based on the changes detected in widgets lower |
138 in the stack. | 140 in the stack. |
139 | 141 |
140 @method update | 142 @method update |
141 @param {Object} data the properties to update. | 143 @param {Object} data the properties to update. |
| 144 @return {undefined} nadda. |
142 | 145 |
143 */ | 146 */ |
144 update: function(data) { | 147 update: function(data) { |
145 // If you don't give a real object then pass. | 148 // If you don't give a real object then pass. |
146 if (!data || typeof data !== 'object') { | 149 if (!data || typeof data !== 'object') { |
147 return; | 150 return; |
148 } | 151 } |
149 | 152 |
150 // Update each manually as we might get an Array or a single value from | 153 // Update each manually as we might get an Array or a single value from |
151 // the query string update. | 154 // the query string update. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 } | 191 } |
189 }); | 192 }); |
190 | 193 |
191 | 194 |
192 }, '0.1.0', { | 195 }, '0.1.0', { |
193 requires: [ | 196 requires: [ |
194 'model', | 197 'model', |
195 'querystring-stringify' | 198 'querystring-stringify' |
196 ] | 199 ] |
197 }); | 200 }); |
LEFT | RIGHT |