@angular2-material/icon
Version:
Angular 2 Material icon
622 lines (617 loc) • 30.9 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/http'), require('@angular2-material/core'), require('rxjs/Observable'), require('rxjs/add/observable/forkJoin'), require('rxjs/add/observable/of'), require('rxjs/add/operator/map'), require('rxjs/add/operator/filter'), require('rxjs/add/operator/do'), require('rxjs/add/operator/share'), require('rxjs/add/operator/finally'), require('rxjs/add/operator/catch')) :
typeof define === 'function' && define.amd ? define(['exports', '@angular/core', '@angular/http', '@angular2-material/core', 'rxjs/Observable', 'rxjs/add/observable/forkJoin', 'rxjs/add/observable/of', 'rxjs/add/operator/map', 'rxjs/add/operator/filter', 'rxjs/add/operator/do', 'rxjs/add/operator/share', 'rxjs/add/operator/finally', 'rxjs/add/operator/catch'], factory) :
(factory((global.md = global.md || {}, global.md.icon = global.md.icon || {}),global.ng.core,global.ng.http,global.md.core,global.Rx,global.Rx.Observable,global.Rx.Observable,global.Rx.Observable.prototype,global.Rx.Observable.prototype,global.Rx.Observable.prototype,global.Rx.Observable.prototype,global.Rx.Observable.prototype,global.Rx.Observable.prototype));
}(this, (function (exports,_angular_core,_angular_http,_angular2Material_core,rxjs_Observable,rxjs_add_observable_forkJoin,rxjs_add_observable_of,rxjs_add_operator_map,rxjs_add_operator_filter,rxjs_add_operator_do,rxjs_add_operator_share,rxjs_add_operator_finally,rxjs_add_operator_catch) { 'use strict';
var __extends$1 = (window && window.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var __decorate$1 = (window && window.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata$1 = (window && window.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
/** Exception thrown when attempting to load an icon with a name that cannot be found. */
var MdIconNameNotFoundError = (function (_super) {
__extends$1(MdIconNameNotFoundError, _super);
function MdIconNameNotFoundError(iconName) {
_super.call(this, "Unable to find icon with the name \"" + iconName + "\"");
}
return MdIconNameNotFoundError;
}(_angular2Material_core.MdError));
/**
* Exception thrown when attempting to load SVG content that does not contain the expected
* <svg> tag.
*/
var MdIconSvgTagNotFoundError = (function (_super) {
__extends$1(MdIconSvgTagNotFoundError, _super);
function MdIconSvgTagNotFoundError() {
_super.call(this, '<svg> tag not found');
}
return MdIconSvgTagNotFoundError;
}(_angular2Material_core.MdError));
/** Configuration for an icon, including the URL and possibly the cached SVG element. */
var SvgIconConfig = (function () {
function SvgIconConfig(url) {
this.url = url;
this.svgElement = null;
}
return SvgIconConfig;
}());
/** Returns the cache key to use for an icon namespace and name. */
var iconKey = function (namespace, name) { return namespace + ':' + name; };
/**
* Service to register and display icons used by the <md-icon> component.
* - Registers icon URLs by namespace and name.
* - Registers icon set URLs by namespace.
* - Registers aliases for CSS classes, for use with icon fonts.
* - Loads icons from URLs and extracts individual icons from icon sets.
*/
var MdIconRegistry = (function () {
function MdIconRegistry(_http) {
this._http = _http;
/**
* URLs and cached SVG elements for individual icons. Keys are of the format "[namespace]:[icon]".
*/
this._svgIconConfigs = new Map();
/**
* SvgIconConfig objects and cached SVG elements for icon sets, keyed by namespace.
* Multiple icon sets can be registered under the same namespace.
*/
this._iconSetConfigs = new Map();
/** Cache for icons loaded by direct URLs. */
this._cachedIconsByUrl = new Map();
/** In-progress icon fetches. Used to coalesce multiple requests to the same URL. */
this._inProgressUrlFetches = new Map();
/** Map from font identifiers to their CSS class names. Used for icon fonts. */
this._fontCssClassesByAlias = new Map();
/**
* The CSS class to apply when an <md-icon> component has no icon name, url, or font specified.
* The default 'material-icons' value assumes that the material icon font has been loaded as
* described at http://google.github.io/material-design-icons/#icon-font-for-the-web
*/
this._defaultFontSetClass = 'material-icons';
}
/** Registers an icon by URL in the default namespace. */
MdIconRegistry.prototype.addSvgIcon = function (iconName, url) {
return this.addSvgIconInNamespace('', iconName, url);
};
/** Registers an icon by URL in the specified namespace. */
MdIconRegistry.prototype.addSvgIconInNamespace = function (namespace, iconName, url) {
var key = iconKey(namespace, iconName);
this._svgIconConfigs.set(key, new SvgIconConfig(url));
return this;
};
/** Registers an icon set by URL in the default namespace. */
MdIconRegistry.prototype.addSvgIconSet = function (url) {
return this.addSvgIconSetInNamespace('', url);
};
/** Registers an icon set by URL in the specified namespace. */
MdIconRegistry.prototype.addSvgIconSetInNamespace = function (namespace, url) {
var config = new SvgIconConfig(url);
if (this._iconSetConfigs.has(namespace)) {
this._iconSetConfigs.get(namespace).push(config);
}
else {
this._iconSetConfigs.set(namespace, [config]);
}
return this;
};
/**
* Defines an alias for a CSS class name to be used for icon fonts. Creating an mdIcon
* component with the alias as the fontSet input will cause the class name to be applied
* to the <md-icon> element.
*/
MdIconRegistry.prototype.registerFontClassAlias = function (alias, className) {
if (className === void 0) { className = alias; }
this._fontCssClassesByAlias.set(alias, className);
return this;
};
/**
* Returns the CSS class name associated with the alias by a previous call to
* registerFontClassAlias. If no CSS class has been associated, returns the alias unmodified.
*/
MdIconRegistry.prototype.classNameForFontAlias = function (alias) {
return this._fontCssClassesByAlias.get(alias) || alias;
};
/**
* Sets the CSS class name to be used for icon fonts when an <md-icon> component does not
* have a fontSet input value, and is not loading an icon by name or URL.
*/
MdIconRegistry.prototype.setDefaultFontSetClass = function (className) {
this._defaultFontSetClass = className;
return this;
};
/**
* Returns the CSS class name to be used for icon fonts when an <md-icon> component does not
* have a fontSet input value, and is not loading an icon by name or URL.
*/
MdIconRegistry.prototype.getDefaultFontSetClass = function () {
return this._defaultFontSetClass;
};
/**
* Returns an Observable that produces the icon (as an <svg> DOM element) from the given URL.
* The response from the URL may be cached so this will not always cause an HTTP request, but
* the produced element will always be a new copy of the originally fetched icon. (That is,
* it will not contain any modifications made to elements previously returned).
*/
MdIconRegistry.prototype.getSvgIconFromUrl = function (url) {
var _this = this;
if (this._cachedIconsByUrl.has(url)) {
return rxjs_Observable.Observable.of(cloneSvg(this._cachedIconsByUrl.get(url)));
}
return this._loadSvgIconFromConfig(new SvgIconConfig(url))
.do(function (svg) { return _this._cachedIconsByUrl.set(url, svg); })
.map(function (svg) { return cloneSvg(svg); });
};
/**
* Returns an Observable that produces the icon (as an <svg> DOM element) with the given name
* and namespace. The icon must have been previously registered with addIcon or addIconSet;
* if not, the Observable will throw an MdIconNameNotFoundError.
*/
MdIconRegistry.prototype.getNamedSvgIcon = function (name, namespace) {
if (namespace === void 0) { namespace = ''; }
// Return (copy of) cached icon if possible.
var key = iconKey(namespace, name);
if (this._svgIconConfigs.has(key)) {
return this._getSvgFromConfig(this._svgIconConfigs.get(key));
}
// See if we have any icon sets registered for the namespace.
var iconSetConfigs = this._iconSetConfigs.get(namespace);
if (iconSetConfigs) {
return this._getSvgFromIconSetConfigs(name, iconSetConfigs);
}
return rxjs_Observable.Observable.throw(new MdIconNameNotFoundError(key));
};
/**
* Returns the cached icon for a SvgIconConfig if available, or fetches it from its URL if not.
*/
MdIconRegistry.prototype._getSvgFromConfig = function (config) {
if (config.svgElement) {
// We already have the SVG element for this icon, return a copy.
return rxjs_Observable.Observable.of(cloneSvg(config.svgElement));
}
else {
// Fetch the icon from the config's URL, cache it, and return a copy.
return this._loadSvgIconFromConfig(config)
.do(function (svg) { return config.svgElement = svg; })
.map(function (svg) { return cloneSvg(svg); });
}
};
/**
* Attempts to find an icon with the specified name in any of the SVG icon sets.
* First searches the available cached icons for a nested element with a matching name, and
* if found copies the element to a new <svg> element. If not found, fetches all icon sets
* that have not been cached, and searches again after all fetches are completed.
* The returned Observable produces the SVG element if possible, and throws
* MdIconNameNotFoundError if no icon with the specified name can be found.
*/
MdIconRegistry.prototype._getSvgFromIconSetConfigs = function (name, iconSetConfigs) {
var _this = this;
// For all the icon set SVG elements we've fetched, see if any contain an icon with the
// requested name.
var namedIcon = this._extractIconWithNameFromAnySet(name, iconSetConfigs);
if (namedIcon) {
// We could cache namedIcon in _svgIconConfigs, but since we have to make a copy every
// time anyway, there's probably not much advantage compared to just always extracting
// it from the icon set.
return rxjs_Observable.Observable.of(namedIcon);
}
// Not found in any cached icon sets. If there are icon sets with URLs that we haven't
// fetched, fetch them now and look for iconName in the results.
var iconSetFetchRequests = iconSetConfigs
.filter(function (iconSetConfig) { return !iconSetConfig.svgElement; })
.map(function (iconSetConfig) {
return _this._loadSvgIconSetFromConfig(iconSetConfig)
.catch(function (err, caught) {
// Swallow errors fetching individual URLs so the combined Observable won't
// necessarily fail.
console.log("Loading icon set URL: " + iconSetConfig.url + " failed: " + err);
return rxjs_Observable.Observable.of(null);
})
.do(function (svg) {
// Cache SVG element.
if (svg) {
iconSetConfig.svgElement = svg;
}
});
});
// Fetch all the icon set URLs. When the requests complete, every IconSet should have a
// cached SVG element (unless the request failed), and we can check again for the icon.
return rxjs_Observable.Observable.forkJoin(iconSetFetchRequests)
.map(function (ignoredResults) {
var foundIcon = _this._extractIconWithNameFromAnySet(name, iconSetConfigs);
if (!foundIcon) {
throw new MdIconNameNotFoundError(name);
}
return foundIcon;
});
};
/**
* Searches the cached SVG elements for the given icon sets for a nested icon element whose "id"
* tag matches the specified name. If found, copies the nested element to a new SVG element and
* returns it. Returns null if no matching element is found.
*/
MdIconRegistry.prototype._extractIconWithNameFromAnySet = function (iconName, iconSetConfigs) {
// Iterate backwards, so icon sets added later have precedence.
for (var i = iconSetConfigs.length - 1; i >= 0; i--) {
var config = iconSetConfigs[i];
if (config.svgElement) {
var foundIcon = this._extractSvgIconFromSet(config.svgElement, iconName, config);
if (foundIcon) {
return foundIcon;
}
}
}
return null;
};
/**
* Loads the content of the icon URL specified in the SvgIconConfig and creates an SVG element
* from it.
*/
MdIconRegistry.prototype._loadSvgIconFromConfig = function (config) {
var _this = this;
return this._fetchUrl(config.url)
.map(function (svgText) { return _this._createSvgElementForSingleIcon(svgText, config); });
};
/**
* Loads the content of the icon set URL specified in the SvgIconConfig and creates an SVG element
* from it.
*/
MdIconRegistry.prototype._loadSvgIconSetFromConfig = function (config) {
var _this = this;
// TODO: Document that icons should only be loaded from trusted sources.
return this._fetchUrl(config.url)
.map(function (svgText) { return _this._svgElementFromString(svgText); });
};
/**
* Creates a DOM element from the given SVG string, and adds default attributes.
*/
MdIconRegistry.prototype._createSvgElementForSingleIcon = function (responseText, config) {
var svg = this._svgElementFromString(responseText);
this._setSvgAttributes(svg, config);
return svg;
};
/**
* Searches the cached element of the given SvgIconConfig for a nested icon element whose "id"
* tag matches the specified name. If found, copies the nested element to a new SVG element and
* returns it. Returns null if no matching element is found.
*/
MdIconRegistry.prototype._extractSvgIconFromSet = function (iconSet, iconName, config) {
var iconNode = iconSet.querySelector('#' + iconName);
if (!iconNode) {
return null;
}
// If the icon node is itself an <svg> node, clone and return it directly. If not, set it as
// the content of a new <svg> node.
if (iconNode.tagName.toLowerCase() == 'svg') {
return this._setSvgAttributes(iconNode.cloneNode(true), config);
}
// createElement('SVG') doesn't work as expected; the DOM ends up with
// the correct nodes, but the SVG content doesn't render. Instead we
// have to create an empty SVG node using innerHTML and append its content.
// Elements created using DOMParser.parseFromString have the same problem.
// http://stackoverflow.com/questions/23003278/svg-innerhtml-in-firefox-can-not-display
var svg = this._svgElementFromString('<svg></svg>');
// Clone the node so we don't remove it from the parent icon set element.
svg.appendChild(iconNode.cloneNode(true));
return this._setSvgAttributes(svg, config);
};
/**
* Creates a DOM element from the given SVG string.
*/
MdIconRegistry.prototype._svgElementFromString = function (str) {
// TODO: Is there a better way than innerHTML? Renderer doesn't appear to have a method for
// creating an element from an HTML string.
var div = document.createElement('DIV');
div.innerHTML = str;
var svg = div.querySelector('svg');
if (!svg) {
throw new MdIconSvgTagNotFoundError();
}
return svg;
};
/**
* Sets the default attributes for an SVG element to be used as an icon.
*/
MdIconRegistry.prototype._setSvgAttributes = function (svg, config) {
if (!svg.getAttribute('xmlns')) {
svg.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
}
svg.setAttribute('fit', '');
svg.setAttribute('height', '100%');
svg.setAttribute('width', '100%');
svg.setAttribute('preserveAspectRatio', 'xMidYMid meet');
svg.setAttribute('focusable', 'false'); // Disable IE11 default behavior to make SVGs focusable.
return svg;
};
/**
* Returns an Observable which produces the string contents of the given URL. Results may be
* cached, so future calls with the same URL may not cause another HTTP request.
*/
MdIconRegistry.prototype._fetchUrl = function (url) {
var _this = this;
// Store in-progress fetches to avoid sending a duplicate request for a URL when there is
// already a request in progress for that URL. It's necessary to call share() on the
// Observable returned by http.get() so that multiple subscribers don't cause multiple XHRs.
if (this._inProgressUrlFetches.has(url)) {
return this._inProgressUrlFetches.get(url);
}
// TODO(jelbourn): for some reason, the `finally` operator "loses" the generic type on the
// Observable. Figure out why and fix it.
var req = this._http.get(url)
.map(function (response) { return response.text(); })
.finally(function () {
_this._inProgressUrlFetches.delete(url);
})
.share();
this._inProgressUrlFetches.set(url, req);
return req;
};
MdIconRegistry = __decorate$1([
_angular_core.Injectable(),
__metadata$1('design:paramtypes', [_angular_http.Http])
], MdIconRegistry);
return MdIconRegistry;
}());
/** Clones an SVGElement while preserving type information. */
function cloneSvg(svg) {
return svg.cloneNode(true);
}
var __extends = (window && window.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var __decorate = (window && window.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (window && window.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
/** Exception thrown when an invalid icon name is passed to an md-icon component. */
var MdIconInvalidNameError = (function (_super) {
__extends(MdIconInvalidNameError, _super);
function MdIconInvalidNameError(iconName) {
_super.call(this, "Invalid icon name: \"" + iconName + "\"");
}
return MdIconInvalidNameError;
}(_angular2Material_core.MdError));
/**
* Component to display an icon. It can be used in the following ways:
* - Specify the svgSrc input to load an SVG icon from a URL. The SVG content is directly inlined
* as a child of the <md-icon> component, so that CSS styles can easily be applied to it.
* The URL is loaded via an XMLHttpRequest, so it must be on the same domain as the page or its
* server must be configured to allow cross-domain requests.
* Example:
* <md-icon svgSrc="assets/arrow.svg"></md-icon>
*
* - Specify the svgIcon input to load an SVG icon from a URL previously registered with the
* addSvgIcon, addSvgIconInNamespace, addSvgIconSet, or addSvgIconSetInNamespace methods of
* MdIconRegistry. If the svgIcon value contains a colon it is assumed to be in the format
* "[namespace]:[name]", if not the value will be the name of an icon in the default namespace.
* Examples:
* <md-icon svgIcon="left-arrow"></md-icon>
* <md-icon svgIcon="animals:cat"></md-icon>
*
* - Use a font ligature as an icon by putting the ligature text in the content of the <md-icon>
* component. By default the Material icons font is used as described at
* http://google.github.io/material-design-icons/#icon-font-for-the-web. You can specify an
* alternate font by setting the fontSet input to either the CSS class to apply to use the
* desired font, or to an alias previously registered with MdIconRegistry.registerFontClassAlias.
* Examples:
* <md-icon>home</md-icon>
* <md-icon fontSet="myfont">sun</md-icon>
*
* - Specify a font glyph to be included via CSS rules by setting the fontSet input to specify the
* font, and the fontIcon input to specify the icon. Typically the fontIcon will specify a
* CSS class which causes the glyph to be displayed via a :before selector, as in
* https://fortawesome.github.io/Font-Awesome/examples/
* Example:
* <md-icon fontSet="fa" fontIcon="alarm"></md-icon>
*/
var MdIcon = (function () {
function MdIcon(_element, _renderer, _mdIconRegistry) {
this._element = _element;
this._renderer = _renderer;
this._mdIconRegistry = _mdIconRegistry;
this.hostAriaLabel = '';
}
/**
* Splits an svgIcon binding value into its icon set and icon name components.
* Returns a 2-element array of [(icon set), (icon name)].
* The separator for the two fields is ':'. If there is no separator, an empty
* string is returned for the icon set and the entire value is returned for
* the icon name. If the argument is falsy, returns an array of two empty strings.
* Throws a MdIconInvalidNameError if the name contains two or more ':' separators.
* Examples:
* 'social:cake' -> ['social', 'cake']
* 'penguin' -> ['', 'penguin']
* null -> ['', '']
* 'a:b:c' -> (throws MdIconInvalidNameError)
*/
MdIcon.prototype._splitIconName = function (iconName) {
if (!iconName) {
return ['', ''];
}
var parts = iconName.split(':');
switch (parts.length) {
case 1:
// Use default namespace.
return ['', parts[0]];
case 2:
return parts;
default:
throw new MdIconInvalidNameError(iconName);
}
};
/** TODO: internal */
MdIcon.prototype.ngOnChanges = function (changes) {
var _this = this;
var changedInputs = Object.keys(changes);
// Only update the inline SVG icon if the inputs changed, to avoid unnecessary DOM operations.
if (changedInputs.indexOf('svgIcon') != -1 || changedInputs.indexOf('svgSrc') != -1) {
if (this.svgIcon) {
var _a = this._splitIconName(this.svgIcon), namespace = _a[0], iconName = _a[1];
this._mdIconRegistry.getNamedSvgIcon(iconName, namespace).subscribe(function (svg) { return _this._setSvgElement(svg); }, function (err) { return console.log("Error retrieving icon: " + err); });
}
else if (this.svgSrc) {
this._mdIconRegistry.getSvgIconFromUrl(this.svgSrc).subscribe(function (svg) { return _this._setSvgElement(svg); }, function (err) { return console.log("Error retrieving icon: " + err); });
}
}
if (this._usingFontIcon()) {
this._updateFontIconClasses();
}
this._updateAriaLabel();
};
/** TODO: internal */
MdIcon.prototype.ngOnInit = function () {
// Update font classes because ngOnChanges won't be called if none of the inputs are present,
// e.g. <md-icon>arrow</md-icon>. In this case we need to add a CSS class for the default font.
if (this._usingFontIcon()) {
this._updateFontIconClasses();
}
};
/** TODO: internal */
MdIcon.prototype.ngAfterViewChecked = function () {
// Update aria label here because it may depend on the projected text content.
// (e.g. <md-icon>home</md-icon> should use 'home').
this._updateAriaLabel();
};
MdIcon.prototype._updateAriaLabel = function () {
var ariaLabel = this._getAriaLabel();
if (ariaLabel) {
this._renderer.setElementAttribute(this._element.nativeElement, 'aria-label', ariaLabel);
}
};
MdIcon.prototype._getAriaLabel = function () {
// If the parent provided an aria-label attribute value, use it as-is. Otherwise look for a
// reasonable value from the alt attribute, font icon name, SVG icon name, or (for ligatures)
// the text content of the directive.
var label = this.hostAriaLabel ||
this.alt ||
this.fontIcon ||
this._splitIconName(this.svgIcon)[1];
if (label) {
return label;
}
// The "content" of an SVG icon is not a useful label.
if (this._usingFontIcon()) {
var text = this._element.nativeElement.textContent;
if (text) {
return text;
}
}
// TODO: Warn here in dev mode.
return null;
};
MdIcon.prototype._usingFontIcon = function () {
return !(this.svgIcon || this.svgSrc);
};
MdIcon.prototype._setSvgElement = function (svg) {
var layoutElement = this._element.nativeElement;
// Remove existing child nodes and add the new SVG element.
// We would use renderer.detachView(Array.from(layoutElement.childNodes)) here,
// but it fails in IE11: https://github.com/angular/angular/issues/6327
layoutElement.innerHTML = '';
this._renderer.projectNodes(layoutElement, [svg]);
};
MdIcon.prototype._updateFontIconClasses = function () {
if (!this._usingFontIcon()) {
return;
}
var elem = this._element.nativeElement;
var fontSetClass = this.fontSet ?
this._mdIconRegistry.classNameForFontAlias(this.fontSet) :
this._mdIconRegistry.getDefaultFontSetClass();
if (fontSetClass != this._previousFontSetClass) {
if (this._previousFontSetClass) {
this._renderer.setElementClass(elem, this._previousFontSetClass, false);
}
if (fontSetClass) {
this._renderer.setElementClass(elem, fontSetClass, true);
}
this._previousFontSetClass = fontSetClass;
}
if (this.fontIcon != this._previousFontIconClass) {
if (this._previousFontIconClass) {
this._renderer.setElementClass(elem, this._previousFontIconClass, false);
}
if (this.fontIcon) {
this._renderer.setElementClass(elem, this.fontIcon, true);
}
this._previousFontIconClass = this.fontIcon;
}
};
__decorate([
_angular_core.Input(),
__metadata('design:type', String)
], MdIcon.prototype, "svgSrc", void 0);
__decorate([
_angular_core.Input(),
__metadata('design:type', String)
], MdIcon.prototype, "svgIcon", void 0);
__decorate([
_angular_core.Input(),
__metadata('design:type', String)
], MdIcon.prototype, "fontSet", void 0);
__decorate([
_angular_core.Input(),
__metadata('design:type', String)
], MdIcon.prototype, "fontIcon", void 0);
__decorate([
_angular_core.Input(),
__metadata('design:type', String)
], MdIcon.prototype, "alt", void 0);
__decorate([
_angular_core.Input('aria-label'),
__metadata('design:type', String)
], MdIcon.prototype, "hostAriaLabel", void 0);
MdIcon = __decorate([
_angular_core.Component({template: '<ng-content></ng-content>',
selector: 'md-icon',
styles: ["/** The width/height of the icon element. */ /** This works because we're using ViewEncapsulation.None. If we used the default encapsulation, the selector would need to be \":host\". */ md-icon { background-repeat: no-repeat; display: inline-block; fill: currentColor; height: 24px; width: 24px; } /*# sourceMappingURL=icon.css.map */ "],
host: {
'role': 'img',
},
encapsulation: _angular_core.ViewEncapsulation.None,
changeDetection: _angular_core.ChangeDetectionStrategy.OnPush,
}),
__metadata('design:paramtypes', [_angular_core.ElementRef, _angular_core.Renderer, MdIconRegistry])
], MdIcon);
return MdIcon;
}());
var MdIconModule = (function () {
function MdIconModule() {
}
MdIconModule.forRoot = function () {
return {
ngModule: MdIconModule,
providers: [MdIconRegistry],
};
};
MdIconModule = __decorate([
_angular_core.NgModule({
imports: [_angular_http.HttpModule],
exports: [MdIcon],
declarations: [MdIcon],
}),
__metadata('design:paramtypes', [])
], MdIconModule);
return MdIconModule;
}());
exports.MdIconInvalidNameError = MdIconInvalidNameError;
exports.MdIcon = MdIcon;
exports.MdIconModule = MdIconModule;
exports.MdIconRegistry = MdIconRegistry;
Object.defineProperty(exports, '__esModule', { value: true });
})));