-
Notifications
You must be signed in to change notification settings - Fork 0
/
icon.js.map
1 lines (1 loc) · 13.4 KB
/
icon.js.map
1
{"version":3,"file":"icon.js","sourceRoot":"","sources":["../../Users/jelbourn/material2/tmp/broccoli_type_script_compiler-input_base_path-YqXGOpVN.tmp/0/src/demo-app/components/icon/icon.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,qBAWO,eAAe,CAAC,CAAA;AACvB,sBAAsB,sCAAsC,CAAC,CAAA;AAC7D,8BAA6B,iBAAiB,CAAC,CAAA;AAC/C,8BAA6B,iBAAiB,CAAC;AAAvC,wDAAuC;AAG/C,oFAAoF;AACpF;IAA4C,0CAAO;IACjD,gCAAY,QAAgB;QACxB,kBAAM,0BAAuB,QAAQ,OAAG,CAAC,CAAC;IAC9C,CAAC;IACH,6BAAC;AAAD,CAAC,AAJD,CAA4C,eAAO,GAIlD;AAJY,8BAAsB,yBAIlC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAYH;IAYE,gBACY,QAAoB,EACpB,SAAmB,EACnB,eAA+B;QAF/B,aAAQ,GAAR,QAAQ,CAAY;QACpB,cAAS,GAAT,SAAS,CAAU;QACnB,oBAAe,GAAf,eAAe,CAAgB;QARtB,kBAAa,GAAW,EAAE,CAAC;IAQD,CAAC;IAEhD;;;;;;;;;;;;OAYG;IACK,+BAAc,GAAtB,UAAuB,QAAgB;QACrC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;YACd,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAClB,CAAC;QACD,IAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAClC,MAAM,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;YACrB,KAAK,CAAC;gBACJ,yBAAyB;gBACzB,MAAM,CAAC,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YACxB,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\n OnInit,\n Renderer,\n SimpleChange,\n ViewEncapsulation,\n AfterViewChecked\n} from '@angular/core';\nimport {MdError} from '@angular2-material/core/errors/error';\nimport {MdIconRegistry} from './icon-registry';\nexport {MdIconRegistry} from './icon-registry';\n\n\n/** Exception thrown when an invalid icon name is passed to an md-icon component. */\nexport class MdIconInvalidNameError extends MdError {\n constructor(iconName: string) {\n super(`Invalid icon name: \"${iconName}\"`);\n }\n}\n\n/**\n * Component to display an icon. It can be used in the following ways:\n * - Specify the svgSrc input to load an SVG icon from a URL. The SVG content is directly inlined\n * as a child of the <md-icon> component, so that CSS styles can easily be applied to it.\n * The URL is loaded via an XMLHttpRequest, so it must be on the same domain as the page or its\n * server must be configured to allow cross-domain requests.\n * Example:\n * <md-icon svgSrc=\"assets/arrow.svg\"></md-icon>\n *\n * - Specify the svgIcon input to load an SVG icon from a URL previously registered with the\n * addSvgIcon, addSvgIconInNamespace, addSvgIconSet, or addSvgIconSetInNamespace methods of\n * MdIconRegistry. If the svgIcon value contains a colon it is assumed to be in the format\n * \"[namespace]:[name]\", if not the value will be the name of an icon in the default namespace.\n * Examples:\n * <md-icon svgIcon=\"left-arrow\"></md-icon>\n * <md-icon svgIcon=\"animals:cat\"></md-icon>\n *\n * - Use a font ligature as an icon by putting the ligature text in the content of the <md-icon>\n * component. By default the Material icons font is used as described at\n * http://google.github.io/material-design-icons/#icon-font-for-the-web. You can specify an\n * alternate font by setting the fontSet input to either the CSS class to apply to use the\n * desired font, or to an alias previously registered with MdIconRegistry.registerFontClassAlias.\n * Examples:\n * <md-icon>home</md-icon>\n * <md-icon fontSet=\"myfont\">sun</md-icon>\n *\n * - Specify a font glyph to be included via CSS rules by setting the fontSet input to specify the\n * font, and the fontIcon input to specify the icon. Typically the fontIcon will specify a\n * CSS class which causes the glyph to be displayed via a :before selector, as in\n * https://fortawesome.github.io/Font-Awesome/examples/\n * Example:\n * <md-icon fontSet=\"fa\" fontIcon=\"alarm\"></md-icon>\n */\n@Component({\n moduleId: module.id,\n template: '<ng-content></ng-content>',\n selector: 'md-icon',\n styleUrls: ['icon.css'],\n host: {\n 'role': 'img',\n },\n encapsulation: ViewEncapsulation.None,\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class MdIcon implements OnChanges, OnInit, AfterViewChecked {\n @Input() svgSrc: string;\n @Input() svgIcon: string;\n @Input() fontSet: string;\n @Input() fontIcon: string;\n @Input() alt: string;\n\n @Input('aria-label') hostAriaLabel: string = '';\n\n private _previousFontSetClass: string;\n private _previousFontIconClass: string;\n\n constructor(\n private _element: ElementRef,\n private _renderer: Renderer,\n private _mdIconRegistry: MdIconRegistry) { }\n\n /**\n * Splits an svgIcon binding value into its icon set and icon name components.\n * Returns a 2-element array of [(icon set), (icon name)].\n * The separator for the two fields is ':'. If there is no separator, an empty\n * string is returned for the icon set and the entire value is returned for\n * the icon name. If the argument is falsy, returns an array of two empty strings.\n * Throws a MdIconInvalidNameError if the name contains two or more ':' separators.\n * Examples:\n * 'social:cake' -> ['social', 'cake']\n * 'penguin' -> ['', 'penguin']\n * null -> ['', '']\n * 'a:b:c' -> (throws MdIconInvalidNameError)\n */\n private _splitIconName(iconName: string): [string, string] {\n if (!iconName) {\n return ['', ''];\n }\n const parts = iconName.split(':');\n switch (parts.length) {\n case 1:\n // Use default namespace.\n return ['', parts[0]];\n case 2:\n return <[string, string]>parts;\n default:\n throw new MdIconInvalidNameError(iconName);\n }\n }\n\n /** TODO: internal */\n ngOnChanges(changes: { [propertyName: string]: SimpleChange }) {\n const changedInputs = Object.keys(changes);\n // Only update the inline SVG icon if the inputs changed, to avoid unnecessary DOM operations.\n if (changedInputs.indexOf('svgIcon') != -1 || changedInputs.indexOf('svgSrc') != -1) {\n if (this.svgIcon) {\n const [namespace, iconName] = this._splitIconName(this.svgIcon);\n this._mdIconRegistry.getNamedSvgIcon(iconName, namespace).subscribe(\n svg => this._setSvgElement(svg),\n (err: any) => console.log(`Error retrieving icon: ${err}`));\n } else if (this.svgSrc) {\n this._mdIconRegistry.getSvgIconFromUrl(this.svgSrc).subscribe(\n svg => this._setSvgElement(svg),\n (err: any) => console.log(`Error retrieving icon: ${err}`));\n }\n }\n if (this._usingFontIcon()) {\n this._updateFontIconClasses();\n }\n this._updateAriaLabel();\n }\n\n /** TODO: internal */\n ngOnInit() {\n // Update font classes because ngOnChanges won't be called if none of the inputs are present,\n // e.g. <md-icon>arrow</md-icon>. In this case we need to add a CSS class for the default font.\n if (this._usingFontIcon()) {\n this._updateFontIconClasses();\n }\n }\n\n /** TODO: internal */\n ngAfterViewChecked() {\n // Update aria label here because it may depend on the projected text content.\n // (e.g. <md-icon>home</md-icon> should use 'home').\n this._updateAriaLabel();\n }\n\n private _updateAriaLabel() {\n const ariaLabel = this._getAriaLabel();\n if (ariaLabel) {\n this._renderer.setElementAttribute(this._element.nativeElement, 'aria-label', ariaLabel);\n }\n }\n\n private _getAriaLabel() {\n // If the parent provided an aria-label attribute value, use it as-is. Otherwise look for a\n // reasonable value from the alt attribute, font icon name, SVG icon name, or (for ligatures)\n // the text content of the directive.\n const label =\n this.hostAriaLabel ||\n this.alt ||\n this.fontIcon ||\n this._splitIconName(this.svgIcon)[1];\n if (label) {\n return label;\n }\n // The \"content\" of an SVG icon is not a useful label.\n if (this._usingFontIcon()) {\n const text = this._element.nativeElement.textContent;\n if (text) {\n return text;\n }\n }\n // TODO: Warn here in dev mode.\n return null;\n }\n\n private _usingFontIcon(): boolean {\n return !(this.svgIcon || this.svgSrc);\n }\n\n private _setSvgElement(svg: SVGElement) {\n const layoutElement = this._element.nativeElement;\n // Remove existing child nodes and add the new SVG element.\n // We would use renderer.detachView(Array.from(layoutElement.childNodes)) here,\n // but it fails in IE11: https://github.com/angular/angular/issues/6327\n layoutElement.innerHTML = '';\n this._renderer.projectNodes(layoutElement, [svg]);\n }\n\n private _updateFontIconClasses() {\n if (!this._usingFontIcon()) {\n return;\n }\n const elem = this._element.nativeElement;\n const fontSetClass = this.fontSet ?\n this._mdIconRegistry.classNameForFontAlias(this.fontSet) :\n this._mdIconRegistry.getDefaultFontSetClass();\n if (fontSetClass != this._previousFontSetClass) {\n if (this._previousFontSetClass) {\n this._renderer.setElementClass(elem, this._previousFontSetClass, false);\n }\n if (fontSetClass) {\n this._renderer.setElementClass(elem, fontSetClass, true);\n }\n this._previousFontSetClass = fontSetClass;\n }\n\n if (this.fontIcon != this._previousFontIconClass) {\n if (this._previousFontIconClass) {\n this._renderer.setElementClass(elem, this._previousFontIconClass, false);\n }\n if (this.fontIcon) {\n this._renderer.setElementClass(elem, this.fontIcon, true);\n }\n this._previousFontIconClass = this.fontIcon;\n }\n }\n}\n\nexport const MD_ICON_DIRECTIVES = [MdIcon];\n"]}