diff --git a/src/components/icon/iconService.js b/src/components/icon/iconService.js index 4cae6b7fc17..6f1a69fd835 100644 --- a/src/components/icon/iconService.js +++ b/src/components/icon/iconService.js @@ -71,8 +71,8 @@ * @param {string} id Icon name/id used to register the icon * @param {string} url specifies the external location for the data file. Used internally by `$http` to load the * data or as part of the lookup in `$templateCache` if pre-loading was configured. - * @param {string=} iconSize Number indicating the width and height of the icons in the set. All icons - * in the icon set must be the same size. Default size is 24. + * @param {number=} viewBoxSize Sets the width and height the icon's viewBox. + * It is ignored for icons with an existing viewBox. Default size is 24. * * @returns {obj} an `$mdIconProvider` reference; used to support method call chains for the API * @@ -101,8 +101,9 @@ * @param {string} id Icon name/id used to register the iconset * @param {string} url specifies the external location for the data file. Used internally by `$http` to load the * data or as part of the lookup in `$templateCache` if pre-loading was configured. - * @param {string=} iconSize Number indicating the width and height of the icons in the set. All icons - * in the icon set must be the same size. Default size is 24. + * @param {number=} viewBoxSize Sets the width and height of the viewBox of all icons in the set. + * It is ignored for icons with an existing viewBox. All icons in the icon set should be the same size. + * Default value is 24. * * @returns {obj} an `$mdIconProvider` reference; used to support method call chains for the API * @@ -130,8 +131,9 @@ * * @param {string} url specifies the external location for the data file. Used internally by `$http` to load the * data or as part of the lookup in `$templateCache` if pre-loading was configured. - * @param {string=} iconSize Number indicating the width and height of the icons in the set. All icons - * in the icon set must be the same size. Default size is 24. + * @param {number=} viewBoxSize Sets the width and height of the viewBox of all icons in the set. + * It is ignored for icons with an existing viewBox. All icons in the icon set should be the same size. + * Default value is 24. * * @returns {obj} an `$mdIconProvider` reference; used to support method call chains for the API * @@ -149,15 +151,14 @@ */ /** * @ngdoc method - * @name $mdIconProvider#defaultIconSize + * @name $mdIconProvider#defaultViewBoxSize * * @description * While `` markup can also be style with sizing CSS, this method configures * the default width **and** height used for all icons; unless overridden by specific CSS. * The default sizing is (24px, 24px). - * - * @param {string} iconSize Number indicating the width and height of the icons in the set. All icons - * in the icon set must be the same size. Default size is 24. + * @param {number=} viewBoxSize Sets the width and height of the viewBox for an icon or an icon set. + * All icons in a set should be the same size. The default value is 24. * * @returns {obj} an `$mdIconProvider` reference; used to support method call chains for the API * @@ -168,45 +169,45 @@ * // Configure URLs for icons specified by [set:]id. * * $mdIconProvider - * .defaultIconSize(36) // Register a default icon size (width == height) + * .defaultViewBoxSize(36) // Register a default icon size (width == height) * }); * * */ var config = { - defaultIconSize: 24 + defaultViewBoxSize: 24 }; function MdIconProvider() { } MdIconProvider.prototype = { - icon : function icon(id, url, iconSize) { + icon : function (id, url, viewBoxSize) { if ( id.indexOf(':') == -1 ) id = '$default:' + id; - config[id] = new ConfigurationItem(url, iconSize ); + config[id] = new ConfigurationItem(url, viewBoxSize ); return this; }, - iconSet : function iconSet(id, url, iconSize) { - config[id] = new ConfigurationItem(url, iconSize ); + iconSet : function (id, url, viewBoxSize) { + config[id] = new ConfigurationItem(url, viewBoxSize ); return this; }, - defaultIconSet : function defaultIconSet(url, iconSize) { + defaultIconSet : function (url, viewBoxSize) { var setName = '$default'; if ( !config[setName] ) { - config[setName] = new ConfigurationItem(url, iconSize ); + config[setName] = new ConfigurationItem(url, viewBoxSize ); } - config[setName].iconSize = iconSize || config.defaultIconSize; + config[setName].viewBoxSize = viewBoxSize || config.defaultViewBoxSize; return this; }, - defaultIconSize : function defaultIconSize(iconSize) { - config.defaultIconSize = iconSize; + defaultViewBoxSize : function (viewBoxSize) { + config.defaultViewBoxSize = viewBoxSize; return this; }, @@ -257,9 +258,9 @@ * Configuration item stored in the Icon registry; used for lookups * to load if not already cached in the `loaded` cache */ - function ConfigurationItem(url, iconSize) { + function ConfigurationItem(url, viewBoxSize) { this.url = url; - this.iconSize = iconSize || config.defaultIconSize; + this.viewBoxSize = viewBoxSize || config.defaultViewBoxSize; } /** @@ -434,13 +435,13 @@ * loaded iconCache store. */ function prepareAndStyle() { - var iconSize = this.config ? this.config.iconSize : config.defaultIconSize; + var viewBoxSize = this.config ? this.config.viewBoxSize : config.defaultViewBoxSize; angular.forEach({ 'fit' : '', 'height': '100%', 'width' : '100%', 'preserveAspectRatio': 'xMidYMid meet', - 'viewBox' : this.element.getAttribute('viewBox') || ('0 0 ' + iconSize + ' ' + iconSize) + 'viewBox' : this.element.getAttribute('viewBox') || ('0 0 ' + viewBoxSize + ' ' + viewBoxSize) }, function(val, attr) { this.element.setAttribute(attr, val); }, this);