|
18 | 18 | *
|
19 | 19 | * @description
|
20 | 20 | * `$mdIconProvider` is used only to register icon IDs with URLs. These configuration features allow
|
21 |
| - * icons and icon sets to be pre-registered and associated with source URLs **before** the `<md-icon />` |
22 |
| - * directives are compiled. |
| 21 | + * icons and icon sets to be pre-registered and associated with source URLs **before** the |
| 22 | + * `<md-icon />` directives are compiled. |
23 | 23 | *
|
24 | 24 | * If using font-icons, the developer is responsible for loading the fonts.
|
25 | 25 | *
|
|
29 | 29 | * that URL is used to on-demand load and parse the SVG dynamically.
|
30 | 30 | *
|
31 | 31 | * The `$templateRequest` service expects the icons source to be loaded over trusted URLs.<br/>
|
32 |
| - * This means, when loading icons from an external URL, you have to trust the URL in the `$sceDelegateProvider`. |
| 32 | + * This means, when loading icons from an external URL, you have to trust the URL in the |
| 33 | + * `$sceDelegateProvider`. |
33 | 34 | *
|
34 | 35 | * <hljs lang="js">
|
35 | 36 | * app.config(function($sceDelegateProvider) {
|
36 | 37 | * $sceDelegateProvider.resourceUrlWhitelist([
|
37 |
| - * // Adding 'self' to the whitelist, will allow requests from the current origin. |
| 38 | + * // Adding 'self' to the allow-list, will allow requests from the current origin. |
38 | 39 | * 'self',
|
39 | 40 | * // Using double asterisks here, will allow all URLs to load.
|
40 |
| - * // We recommend to only specify the given domain you want to allow. |
| 41 | + * // However, we recommend only specifying the given domain you want to allow. |
41 | 42 | * '**'
|
42 | 43 | * ]);
|
43 | 44 | * });
|
44 | 45 | * </hljs>
|
45 | 46 | *
|
46 | 47 | * Read more about the [$sceDelegateProvider](https://docs.angularjs.org/api/ng/provider/$sceDelegateProvider).
|
47 | 48 | *
|
48 |
| - * **Notice:** Most font-icons libraries do not support ligatures (for example `fontawesome`).<br/> |
| 49 | + * **Notice:** Most font-icon libraries do not support ligatures (for example `fontawesome`).<br/> |
49 | 50 | * In such cases you are not able to use the icon's ligature name - Like so:
|
50 | 51 | *
|
51 | 52 | * <hljs lang="html">
|
|
64 | 65 | * @usage
|
65 | 66 | * <hljs lang="js">
|
66 | 67 | * app.config(function($mdIconProvider) {
|
67 |
| - * |
68 |
| - * // Configure URLs for icons specified by [set:]id. |
69 |
| - * |
70 |
| - * $mdIconProvider |
71 |
| - * .defaultFontSet( 'fa' ) // This sets our default fontset className. |
72 |
| - * .defaultIconSet('my/app/icons.svg') // Register a default set of SVG icons |
73 |
| - * .iconSet('social', 'my/app/social.svg') // Register a named icon set of SVGs |
74 |
| - * .icon('android', 'my/app/android.svg') // Register a specific icon (by name) |
75 |
| - * .icon('work:chair', 'my/app/chair.svg'); // Register icon in a specific set |
76 |
| - * }); |
| 68 | + * |
| 69 | + * // Configure URLs for icons specified by [set:]id. |
| 70 | + * $mdIconProvider |
| 71 | + * .defaultFontSet( 'fa' ) // This sets our default fontset className. |
| 72 | + * .defaultIconSet('my/app/icons.svg') // Register a default set of SVG icons |
| 73 | + * .iconSet('social', 'my/app/social.svg') // Register a named icon set of SVGs |
| 74 | + * .icon('android', 'my/app/android.svg') // Register a specific icon (by name) |
| 75 | + * .icon('work:chair', 'my/app/chair.svg'); // Register icon in a specific set |
| 76 | + * }); |
77 | 77 | * </hljs>
|
78 | 78 | *
|
79 |
| - * SVG icons and icon sets can be easily pre-loaded and cached using either (a) a build process or (b) a runtime |
80 |
| - * **startup** process (shown below): |
| 79 | + * SVG icons and icon sets can be easily pre-loaded and cached using either (a) a build process or |
| 80 | + * (b) a runtime **startup** process (shown below): |
81 | 81 | *
|
82 | 82 | * <hljs lang="js">
|
83 | 83 | * app.config(function($mdIconProvider) {
|
84 |
| - * |
85 |
| - * // Register a default set of SVG icon definitions |
86 |
| - * $mdIconProvider.defaultIconSet('my/app/icons.svg') |
87 |
| - * |
88 |
| - * }) |
89 |
| - * .run(function($templateRequest){ |
90 |
| - * |
91 |
| - * // Pre-fetch icons sources by URL and cache in the $templateCache... |
92 |
| - * // subsequent $templateRequest calls will look there first. |
93 |
| - * |
94 |
| - * var urls = [ 'imy/app/icons.svg', 'img/icons/android.svg']; |
95 |
| - * |
96 |
| - * angular.forEach(urls, function(url) { |
97 |
| - * $templateRequest(url); |
98 |
| - * }); |
99 |
| - * |
100 |
| - * }); |
| 84 | + * |
| 85 | + * // Register a default set of SVG icon definitions |
| 86 | + * $mdIconProvider.defaultIconSet('my/app/icons.svg') |
| 87 | + * }) |
| 88 | + * .run(function($templateRequest) { |
| 89 | + * |
| 90 | + * // Pre-fetch icons sources by URL and cache in the $templateCache... |
| 91 | + * // subsequent $templateRequest calls will look there first. |
| 92 | + * var urls = [ 'imy/app/icons.svg', 'img/icons/android.svg']; |
| 93 | + * |
| 94 | + * angular.forEach(urls, function(url) { |
| 95 | + * $templateRequest(url); |
| 96 | + * }); |
| 97 | + * }); |
101 | 98 | *
|
102 | 99 | * </hljs>
|
103 | 100 | *
|
104 | 101 | * > <b>Note:</b> The loaded SVG data is subsequently cached internally for future requests.
|
105 |
| - * |
106 | 102 | */
|
107 | 103 |
|
108 | 104 | /**
|
109 | 105 | * @ngdoc method
|
110 | 106 | * @name $mdIconProvider#icon
|
111 | 107 | *
|
112 | 108 | * @description
|
113 |
| - * Register a source URL for a specific icon name; the name may include optional 'icon set' name prefix. |
114 |
| - * These icons will later be retrieved from the cache using `$mdIcon( <icon name> )` |
| 109 | + * Register a source URL for a specific icon name; the name may include optional 'icon set' name |
| 110 | + * prefix. These icons will later be retrieved from the cache using `$mdIcon(<icon name>)`. |
115 | 111 | *
|
116 | 112 | * @param {string} id Icon name/id used to register the icon
|
117 | 113 | * @param {string} url specifies the external location for the data file. Used internally by
|
118 |
| - * `$templateRequest` to load the data or as part of the lookup in `$templateCache` if pre-loading |
119 |
| - * was configured. |
| 114 | + * `$templateRequest` to load the data or as part of the lookup in `$templateCache` if pre-loading |
| 115 | + * was configured. |
120 | 116 | * @param {number=} viewBoxSize Sets the width and height the icon's viewBox.
|
121 |
| - * It is ignored for icons with an existing viewBox. Default size is 24. |
| 117 | + * It is ignored for icons with an existing viewBox. Default size is 24. |
122 | 118 | *
|
123 | 119 | * @returns {obj} an `$mdIconProvider` reference; used to support method call chains for the API
|
124 | 120 | *
|
125 | 121 | * @usage
|
126 | 122 | * <hljs lang="js">
|
127 | 123 | * app.config(function($mdIconProvider) {
|
128 |
| - * |
129 |
| - * // Configure URLs for icons specified by [set:]id. |
130 |
| - * |
131 |
| - * $mdIconProvider |
132 |
| - * .icon('android', 'my/app/android.svg') // Register a specific icon (by name) |
133 |
| - * .icon('work:chair', 'my/app/chair.svg'); // Register icon in a specific set |
134 |
| - * }); |
135 |
| - * </hljs> |
136 | 124 | *
|
| 125 | + * // Configure URLs for icons specified by [set:]id. |
| 126 | + * $mdIconProvider |
| 127 | + * .icon('android', 'my/app/android.svg') // Register a specific icon (by name) |
| 128 | + * .icon('work:chair', 'my/app/chair.svg'); // Register icon in a specific set |
| 129 | + * }); |
| 130 | + * </hljs> |
137 | 131 | */
|
| 132 | + |
138 | 133 | /**
|
139 | 134 | * @ngdoc method
|
140 | 135 | * @name $mdIconProvider#iconSet
|
|
154 | 149 | *
|
155 | 150 | * @returns {obj} an `$mdIconProvider` reference; used to support method call chains for the API
|
156 | 151 | *
|
157 |
| - * |
158 | 152 | * @usage
|
159 | 153 | * <hljs lang="js">
|
160 | 154 | * app.config(function($mdIconProvider) {
|
161 |
| - * |
162 |
| - * // Configure URLs for icons specified by [set:]id. |
163 |
| - * |
164 |
| - * $mdIconProvider |
165 |
| - * .iconSet('social', 'my/app/social.svg') // Register a named icon set |
166 |
| - * }); |
167 |
| - * </hljs> |
168 | 155 | *
|
| 156 | + * // Configure URLs for icons specified by [set:]id. |
| 157 | + * $mdIconProvider |
| 158 | + * .iconSet('social', 'my/app/social.svg'); // Register a named icon set |
| 159 | + * }); |
| 160 | + * </hljs> |
169 | 161 | */
|
| 162 | + |
170 | 163 | /**
|
171 | 164 | * @ngdoc method
|
172 | 165 | * @name $mdIconProvider#defaultIconSet
|
173 | 166 | *
|
174 | 167 | * @description
|
175 | 168 | * Register a source URL for the default 'named' set of icons. Unless explicitly registered,
|
176 |
| - * subsequent lookups of icons will failover to search this 'default' icon set. |
| 169 | + * subsequent lookups of icons will fail over to search this 'default' icon set. |
177 | 170 | * Icon can be retrieved from this cached, default set using `$mdIcon(<name>)`
|
178 | 171 | *
|
179 | 172 | * @param {string} url specifies the external location for the data file. Used internally by
|
180 | 173 | * `$templateRequest` to load the data or as part of the lookup in `$templateCache` if pre-loading
|
181 | 174 | * was configured.
|
182 | 175 | * @param {number=} viewBoxSize Sets the width and height of the viewBox of all icons in the set.
|
183 |
| - * It is ignored for icons with an existing viewBox. All icons in the icon set should be the same size. |
184 |
| - * Default value is 24. |
| 176 | + * It is ignored for icons with an existing viewBox. All icons in the icon set should be the same |
| 177 | + * size. Default value is 24. |
185 | 178 | *
|
186 |
| - * @returns {obj} an `$mdIconProvider` reference; used to support method call chains for the API |
| 179 | + * @returns {Object} an `$mdIconProvider` reference; used to support method call chains for the API |
187 | 180 | *
|
188 | 181 | * @usage
|
189 | 182 | * <hljs lang="js">
|
190 | 183 | * app.config(function($mdIconProvider) {
|
191 |
| - * |
192 |
| - * // Configure URLs for icons specified by [set:]id. |
193 |
| - * |
194 |
| - * $mdIconProvider |
195 |
| - * .defaultIconSet( 'my/app/social.svg' ) // Register a default icon set |
196 |
| - * }); |
197 |
| - * </hljs> |
198 | 184 | *
|
| 185 | + * // Configure URLs for icons specified by [set:]id. |
| 186 | + * $mdIconProvider |
| 187 | + * .defaultIconSet('my/app/social.svg'); // Register a default icon set |
| 188 | + * }); |
| 189 | + * </hljs> |
199 | 190 | */
|
| 191 | + |
200 | 192 | /**
|
201 | 193 | * @ngdoc method
|
202 | 194 | * @name $mdIconProvider#defaultFontSet
|
203 | 195 | *
|
204 | 196 | * @description
|
205 |
| - * When using Font-Icons, AngularJS Material assumes the the Material Design icons will be used and automatically |
206 |
| - * configures the default font-set == 'material-icons'. Note that the font-set references the font-icon library |
207 |
| - * class style that should be applied to the `<md-icon>`. |
| 197 | + * When using Font-Icons, AngularJS Material assumes the the Material Design icons will be used and |
| 198 | + * automatically configures the default `font-set == 'material-icons'`. Note that the font-set |
| 199 | + * references the font-icon library class style that should be applied to the `<md-icon>`. |
208 | 200 | *
|
209 | 201 | * Configuring the default means that the attributes
|
210 |
| - * `md-font-set="material-icons"` or `class="material-icons"` do not need to be explicitly declared on the |
211 |
| - * `<md-icon>` markup. For example: |
212 |
| - * |
213 |
| - * `<md-icon> face </md-icon>` |
214 |
| - * will render as |
215 |
| - * `<span class="material-icons"> face </span>`, and |
| 202 | + * `md-font-set="material-icons"` or `class="material-icons"` do not need to be explicitly declared |
| 203 | + * on the `<md-icon>` markup. |
216 | 204 | *
|
217 |
| - * `<md-icon md-font-set="fa"> face </md-icon>` |
218 |
| - * will render as |
219 |
| - * `<span class="fa"> face </span>` |
| 205 | + * For example:<br/> |
| 206 | + * `<md-icon>face</md-icon>` will render as `<span class="material-icons">face</span>`,<br/> |
| 207 | + * and<br/> |
| 208 | + * `<md-icon md-font-set="fa">face</md-icon>` will render as `<span class="fa">face</span>` |
220 | 209 | *
|
221 |
| - * @param {string} name of the font-library style that should be applied to the md-icon DOM element |
| 210 | + * @param {string} name Name of the font-library style that should be applied to the md-icon DOM |
| 211 | + * element. |
222 | 212 | *
|
223 | 213 | * @usage
|
224 | 214 | * <hljs lang="js">
|
225 | 215 | * app.config(function($mdIconProvider) {
|
226 |
| - * $mdIconProvider.defaultFontSet( 'fa' ); |
227 |
| - * }); |
| 216 | + * $mdIconProvider.defaultFontSet('fa'); |
| 217 | + * }); |
228 | 218 | * </hljs>
|
229 |
| - * |
230 | 219 | */
|
231 | 220 |
|
232 | 221 | /**
|
233 | 222 | * @ngdoc method
|
234 | 223 | * @name $mdIconProvider#fontSet
|
235 | 224 | *
|
236 | 225 | * @description
|
237 |
| - * When using a font set for `<md-icon>` you must specify the correct font classname in the `md-font-set` |
238 |
| - * attribute. If the fonset className is really long, your markup may become cluttered... an easy |
239 |
| - * solution is to define an `alias` for your fontset: |
| 226 | + * When using a font-set for `<md-icon>` you must specify the correct font classname in the |
| 227 | + * `md-font-set` attribute. If the font-set className is really long, your markup may become |
| 228 | + * cluttered... an easy solution is to define an `alias` for your font-set: |
240 | 229 | *
|
241 |
| - * @param {string} alias of the specified fontset. |
242 |
| - * @param {string} className of the fontset. |
| 230 | + * @param {string} alias Alias name of the specified font-set. |
| 231 | + * @param {string} className Name of the class for the font-set. |
243 | 232 | *
|
244 | 233 | * @usage
|
245 | 234 | * <hljs lang="js">
|
246 | 235 | * app.config(function($mdIconProvider) {
|
247 |
| - * // In this case, we set an alias for the `material-icons` fontset. |
248 |
| - * $mdIconProvider.fontSet('md', 'material-icons'); |
249 |
| - * }); |
| 236 | + * // In this case, we set an alias for the `material-icons` font-set. |
| 237 | + * $mdIconProvider.fontSet('md', 'material-icons'); |
| 238 | + * }); |
250 | 239 | * </hljs>
|
251 |
| - * |
252 | 240 | */
|
253 | 241 |
|
254 | 242 | /**
|
255 | 243 | * @ngdoc method
|
256 | 244 | * @name $mdIconProvider#defaultViewBoxSize
|
257 | 245 | *
|
258 | 246 | * @description
|
259 |
| - * While `<md-icon />` markup can also be style with sizing CSS, this method configures |
| 247 | + * While `<md-icon>` markup can also be styled with sizing CSS, this method configures |
260 | 248 | * the default width **and** height used for all icons; unless overridden by specific CSS.
|
261 |
| - * The default sizing is (24px, 24px). |
| 249 | + * The default sizing is (`24px`, `24px`). |
262 | 250 | * @param {number=} viewBoxSize Sets the width and height of the viewBox for an icon or an icon set.
|
263 | 251 | * All icons in a set should be the same size. The default value is 24.
|
264 | 252 | *
|
265 |
| - * @returns {obj} an `$mdIconProvider` reference; used to support method call chains for the API |
| 253 | + * @returns {Object} an `$mdIconProvider` reference; used to support method call chains for the API |
266 | 254 | *
|
267 | 255 | * @usage
|
268 | 256 | * <hljs lang="js">
|
269 | 257 | * app.config(function($mdIconProvider) {
|
270 |
| - * |
271 |
| - * // Configure URLs for icons specified by [set:]id. |
272 |
| - * |
273 |
| - * $mdIconProvider |
274 |
| - * .defaultViewBoxSize(36) // Register a default icon size (width == height) |
275 |
| - * }); |
276 |
| - * </hljs> |
277 | 258 | *
|
| 259 | + * // Configure URLs for icons specified by [set:]id. |
| 260 | + * $mdIconProvider |
| 261 | + * .defaultViewBoxSize(36); // Register a default icon size (width == height) |
| 262 | + * }); |
| 263 | + * </hljs> |
278 | 264 | */
|
279 | 265 |
|
280 | 266 | var config = {
|
@@ -381,21 +367,18 @@ MdIconProvider.prototype = {
|
381 | 367 | * @usage
|
382 | 368 | * <hljs lang="js">
|
383 | 369 | * function SomeDirective($mdIcon) {
|
384 |
| - * |
385 |
| - * // See if the icon has already been loaded, if not |
386 |
| - * // then lookup the icon from the registry cache, load and cache |
387 |
| - * // it for future requests. |
388 |
| - * // NOTE: ID queries require configuration with $mdIconProvider |
389 |
| - * |
390 |
| - * $mdIcon('android').then(function(iconEl) { element.append(iconEl); }); |
391 |
| - * $mdIcon('work:chair').then(function(iconEl) { element.append(iconEl); }); |
392 |
| - * |
393 |
| - * // Load and cache the external SVG using a URL |
394 |
| - * |
395 |
| - * $mdIcon('img/icons/android.svg').then(function(iconEl) { |
396 |
| - * element.append(iconEl); |
397 |
| - * }); |
398 |
| - * }; |
| 370 | + * |
| 371 | + * // See if the icon has already been loaded, if not then lookup the icon from the |
| 372 | + * // registry cache, load and cache it for future requests. |
| 373 | + * // NOTE: Non-URL queries require configuration with $mdIconProvider. |
| 374 | + * $mdIcon('android').then(function(iconEl) { element.append(iconEl); }); |
| 375 | + * $mdIcon('work:chair').then(function(iconEl) { element.append(iconEl); }); |
| 376 | + * |
| 377 | + * // Load and cache the external SVG using a URL. |
| 378 | + * $mdIcon('img/icons/android.svg').then(function(iconEl) { |
| 379 | + * element.append(iconEl); |
| 380 | + * }); |
| 381 | + * }; |
399 | 382 | * </hljs>
|
400 | 383 | *
|
401 | 384 | * > <b>Note:</b> The `<md-icon>` directive internally uses the `$mdIcon` service to query, load,
|
|
0 commit comments