|
74 | 74 | * @param {string} id Icon name/id used to register the icon
|
75 | 75 | * @param {string} url specifies the external location for the data file. Used internally by `$http` to load the
|
76 | 76 | * data or as part of the lookup in `$templateCache` if pre-loading was configured.
|
77 |
| - * @param {string=} iconSize Number indicating the width and height of the icons in the set. All icons |
78 |
| - * in the icon set must be the same size. Default size is 24. |
| 77 | + * @param {number=} viewBoxSize Sets the width and height the icon's viewBox. |
| 78 | + * It is ignored for icons with an existing viewBox. Default size is 24. |
79 | 79 | *
|
80 | 80 | * @returns {obj} an `$mdIconProvider` reference; used to support method call chains for the API
|
81 | 81 | *
|
|
104 | 104 | * @param {string} id Icon name/id used to register the iconset
|
105 | 105 | * @param {string} url specifies the external location for the data file. Used internally by `$http` to load the
|
106 | 106 | * data or as part of the lookup in `$templateCache` if pre-loading was configured.
|
107 |
| - * @param {string=} iconSize Number indicating the width and height of the icons in the set. All icons |
108 |
| - * in the icon set must be the same size. Default size is 24. |
| 107 | + * @param {number=} viewBoxSize Sets the width and height of the viewBox of all icons in the set. |
| 108 | + * It is ignored for icons with an existing viewBox. All icons in the icon set should be the same size. |
| 109 | + * Default value is 24. |
109 | 110 | *
|
110 | 111 | * @returns {obj} an `$mdIconProvider` reference; used to support method call chains for the API
|
111 | 112 | *
|
|
133 | 134 | *
|
134 | 135 | * @param {string} url specifies the external location for the data file. Used internally by `$http` to load the
|
135 | 136 | * data or as part of the lookup in `$templateCache` if pre-loading was configured.
|
136 |
| - * @param {string=} iconSize Number indicating the width and height of the icons in the set. All icons |
137 |
| - * in the icon set must be the same size. Default size is 24. |
| 137 | + * @param {number=} viewBoxSize Sets the width and height of the viewBox of all icons in the set. |
| 138 | + * It is ignored for icons with an existing viewBox. All icons in the icon set should be the same size. |
| 139 | + * Default value is 24. |
138 | 140 | *
|
139 | 141 | * @returns {obj} an `$mdIconProvider` reference; used to support method call chains for the API
|
140 | 142 | *
|
|
184 | 186 |
|
185 | 187 | /**
|
186 | 188 | * @ngdoc method
|
187 |
| - * @name $mdIconProvider#defaultIconSize |
| 189 | + * @name $mdIconProvider#defaultViewBoxSize |
188 | 190 | *
|
189 | 191 | * @description
|
190 | 192 | * While `<md-icon />` markup can also be style with sizing CSS, this method configures
|
191 | 193 | * the default width **and** height used for all icons; unless overridden by specific CSS.
|
192 | 194 | * The default sizing is (24px, 24px).
|
193 |
| - * |
194 |
| - * @param {string} iconSize Number indicating the width and height of the icons in the set. All icons |
195 |
| - * in the icon set must be the same size. Default size is 24. |
| 195 | + * @param {number=} viewBoxSize Sets the width and height of the viewBox for an icon or an icon set. |
| 196 | + * All icons in a set should be the same size. The default value is 24. |
196 | 197 | *
|
197 | 198 | * @returns {obj} an `$mdIconProvider` reference; used to support method call chains for the API
|
198 | 199 | *
|
|
203 | 204 | * // Configure URLs for icons specified by [set:]id.
|
204 | 205 | *
|
205 | 206 | * $mdIconProvider
|
206 |
| - * .defaultIconSize(36) // Register a default icon size (width == height) |
| 207 | + * .defaultViewBoxSize(36) // Register a default icon size (width == height) |
207 | 208 | * });
|
208 | 209 | * </hljs>
|
209 | 210 | *
|
210 | 211 | */
|
211 | 212 |
|
212 | 213 | var config = {
|
213 |
| - defaultIconSize: 24, |
| 214 | + defaultViewBoxSize: 24, |
214 | 215 | defaultFontSet: 'material-icons',
|
215 | 216 | fontSets : [ ]
|
216 | 217 | };
|
217 | 218 |
|
218 | 219 | function MdIconProvider() { }
|
219 | 220 |
|
220 | 221 | MdIconProvider.prototype = {
|
221 |
| - |
222 |
| - icon : function icon(id, url, iconSize) { |
| 222 | + icon : function (id, url, viewBoxSize) { |
223 | 223 | if ( id.indexOf(':') == -1 ) id = '$default:' + id;
|
224 | 224 |
|
225 |
| - config[id] = new ConfigurationItem(url, iconSize ); |
| 225 | + config[id] = new ConfigurationItem(url, viewBoxSize ); |
226 | 226 | return this;
|
227 | 227 | },
|
228 |
| - iconSet : function iconSet(id, url, iconSize) { |
229 |
| - config[id] = new ConfigurationItem(url, iconSize ); |
| 228 | + |
| 229 | + iconSet : function (id, url, viewBoxSize) { |
| 230 | + config[id] = new ConfigurationItem(url, viewBoxSize ); |
230 | 231 | return this;
|
231 | 232 | },
|
232 |
| - defaultIconSet : function defaultIconSet(url, iconSize) { |
| 233 | + |
| 234 | + defaultIconSet : function (url, viewBoxSize) { |
233 | 235 | var setName = '$default';
|
234 | 236 |
|
235 | 237 | if ( !config[setName] ) {
|
236 |
| - config[setName] = new ConfigurationItem(url, iconSize ); |
| 238 | + config[setName] = new ConfigurationItem(url, viewBoxSize ); |
237 | 239 | }
|
238 | 240 |
|
239 |
| - config[setName].iconSize = iconSize || config.defaultIconSize; |
| 241 | + config[setName].viewBoxSize = viewBoxSize || config.defaultViewBoxSize; |
| 242 | + |
240 | 243 | return this;
|
241 | 244 | },
|
242 | 245 |
|
| 246 | + defaultViewBoxSize : function (viewBoxSize) { |
| 247 | + config.defaultViewBoxSize = viewBoxSize; |
| 248 | + return this; |
| 249 | + }, |
| 250 | + |
243 | 251 | /**
|
244 | 252 | * Register an alias name associated with a font-icon library style ;
|
245 | 253 | */
|
|
312 | 320 | * Configuration item stored in the Icon registry; used for lookups
|
313 | 321 | * to load if not already cached in the `loaded` cache
|
314 | 322 | */
|
315 |
| - function ConfigurationItem(url, iconSize) { |
| 323 | + function ConfigurationItem(url, viewBoxSize) { |
316 | 324 | this.url = url;
|
317 |
| - this.iconSize = iconSize || config.defaultIconSize; |
| 325 | + this.viewBoxSize = viewBoxSize || config.defaultViewBoxSize; |
318 | 326 | }
|
319 | 327 |
|
320 | 328 | /**
|
|
512 | 520 | * loaded iconCache store.
|
513 | 521 | */
|
514 | 522 | function prepareAndStyle() {
|
515 |
| - var iconSize = this.config ? this.config.iconSize : config.defaultIconSize; |
| 523 | + var viewBoxSize = this.config ? this.config.viewBoxSize : config.defaultViewBoxSize; |
516 | 524 | angular.forEach({
|
517 | 525 | 'fit' : '',
|
518 | 526 | 'height': '100%',
|
519 | 527 | 'width' : '100%',
|
520 | 528 | 'preserveAspectRatio': 'xMidYMid meet',
|
521 |
| - 'viewBox' : this.element.getAttribute('viewBox') || ('0 0 ' + iconSize + ' ' + iconSize) |
| 529 | + 'viewBox' : this.element.getAttribute('viewBox') || ('0 0 ' + viewBoxSize + ' ' + viewBoxSize) |
522 | 530 | }, function(val, attr) {
|
523 | 531 | this.element.setAttribute(attr, val);
|
524 | 532 | }, this);
|
|
0 commit comments