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AAC;QAC5B,KAAK,CAAC,UAAU,CAAC;;4CAAA;IAlCpB;QAAC,SAAS,CAAC;YACT,QAAQ,EAAE,MAAM,CAAC,EAAE;YACnB,QAAQ,EAAE,iFAAiF;YAC3F,MAAM,EAAE,CAAC,OAAO,CAAC;YACjB,IAAI,EAAE;gBACJ,yBAAyB,EAAE,oBAAoB;gBAC/C,aAAa,EAAE,iBAAiB;gBAChC,SAAS,EAAE,qBAAqB;gBAChC,QAAQ,EAAE,wBAAwB;gBAClC,SAAS,EAAE,6BAA6B;aACzC;YACD,WAAW,EAAE,aAAa;YAC1B,SAAS,EAAE,CAAC,YAAY,CAAC;YACzB,aAAa,EAAE,iBAAiB,CAAC,IAAI;SACtC,CAAC;;gBAAA;IAmCF,eAAC;AAAD,CAlCA,AAkCC,CAlC6B,QAAQ,GAkCrC;AAQD;IAAA;IAOA,CAAC;IANQ,sBAAO,GAAd;QACE,MAAM,CAAC;YACL,QAAQ,EAAE,cAAc;YACxB,SAAS,EAAE,EAAE;SACd,CAAC;IACJ,CAAC;IAXH;QAAC,QAAQ,CAAC;YACR,OAAO,EAAE,CAAC,YAAY,EAAE,cAAc,CAAC;YACvC,OAAO,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC;YAC7B,YAAY,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC;SACnC,CAAC;;sBAAA;IAQF,qBAAC;AAAD,CAPA,AAOC,IAAA","file":"button/button.js","sourcesContent":["import {\n Component,\n ViewEncapsulation,\n Input,\n HostBinding,\n ChangeDetectionStrategy,\n ElementRef,\n Renderer,\n NgModule,\n ModuleWithProviders,\n} from '@angular/core';\nimport {CommonModule} from '@angular/common';\nimport {BooleanFieldValue} from '@angular2-material/core';\nimport {MdRippleModule} from '@angular2-material/core';\n\n// TODO(jelbourn): Make the `isMouseDown` stuff done with one global listener.\n// TODO(kara): Convert attribute selectors to classes when attr maps become available\n\n\n@Component({\n moduleId: module.id,\n selector: 'button[md-button], button[md-raised-button], button[md-icon-button], ' +\n 'button[md-fab], button[md-mini-fab]',\n inputs: ['color'],\n host: {\n '[class.md-button-focus]': '_isKeyboardFocused',\n '(mousedown)': '_setMousedown()',\n '(focus)': '_setKeyboardFocus()',\n '(blur)': '_removeKeyboardFocus()',\n },\n templateUrl: 'button.html',\n styleUrls: ['button.css'],\n encapsulation: ViewEncapsulation.None,\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class MdButton {\n private _color: string;\n\n /** Whether the button has focus from the keyboard (not the mouse). Used for class binding. */\n _isKeyboardFocused: boolean = false;\n\n /** Whether a mousedown has occurred on this element in the last 100ms. */\n _isMouseDown: boolean = false;\n\n /** Whether the ripple effect on click should be disabled. */\n @Input() @BooleanFieldValue() disableRipple: boolean = false;\n\n constructor(private _elementRef: ElementRef, private _renderer: Renderer) { }\n\n get color(): string {\n return this._color;\n }\n\n set color(value: string) {\n this._updateColor(value);\n }\n\n _setMousedown() {\n // We only *show* the focus style when focus has come to the button via the keyboard.\n // The Material Design spec is silent on this topic, and without doing this, the\n // button continues to look :active after clicking.\n // @see http://marcysutton.com/button-focus-hell/\n this._isMouseDown = true;\n setTimeout(() => { this._isMouseDown = false; }, 100);\n }\n\n _updateColor(newColor: string) {\n this._setElementColor(this._color, false);\n this._setElementColor(newColor, true);\n this._color = newColor;\n }\n\n _setElementColor(color: string, isAdd: boolean) {\n if (color != null && color != '') {\n this._renderer.setElementClass(this._elementRef.nativeElement, `md-${color}`, isAdd);\n }\n }\n\n _setKeyboardFocus() {\n this._isKeyboardFocused = !this._isMouseDown;\n }\n\n _removeKeyboardFocus() {\n this._isKeyboardFocused = false;\n }\n\n /** TODO(hansl): e2e test this function. */\n focus() {\n this._elementRef.nativeElement.focus();\n }\n\n getHostElement() {\n return this._elementRef.nativeElement;\n }\n\n isRoundButton() {\n const el = this._elementRef.nativeElement;\n return el.hasAttribute('md-icon-button') ||\n el.hasAttribute('md-fab') ||\n el.hasAttribute('md-mini-fab');\n }\n\n isRippleEnabled() {\n return !this.disableRipple;\n }\n}\n\n@Component({\n moduleId: module.id,\n selector: 'a[md-button], a[md-raised-button], a[md-icon-button], a[md-fab], a[md-mini-fab]',\n inputs: ['color'],\n host: {\n '[class.md-button-focus]': '_isKeyboardFocused',\n '(mousedown)': '_setMousedown()',\n '(focus)': '_setKeyboardFocus()',\n '(blur)': '_removeKeyboardFocus()',\n '(click)': '_haltDisabledEvents($event)',\n },\n templateUrl: 'button.html',\n styleUrls: ['button.css'],\n encapsulation: ViewEncapsulation.None\n})\nexport class MdAnchor extends MdButton {\n _disabled: boolean = null;\n\n constructor(elementRef: ElementRef, renderer: Renderer) {\n super(elementRef, renderer);\n }\n\n @HostBinding('tabIndex')\n get tabIndex(): number {\n return this.disabled ? -1 : 0;\n }\n\n @HostBinding('attr.aria-disabled')\n /** Gets the aria-disabled value for the component, which must be a string for Dart. */\n get isAriaDisabled(): string {\n return this.disabled ? 'true' : 'false';\n }\n\n @HostBinding('attr.disabled')\n @Input('disabled')\n get disabled() { return this._disabled; }\n\n set disabled(value: boolean) {\n // The presence of *any* disabled value makes the component disabled, *except* for false.\n this._disabled = (value != null && value != false) ? true : null;\n }\n\n _haltDisabledEvents(event: Event) {\n // A disabled button shouldn't apply any actions\n if (this.disabled) {\n event.preventDefault();\n event.stopImmediatePropagation();\n }\n }\n}\n\n\n@NgModule({\n imports: [CommonModule, MdRippleModule],\n exports: [MdButton, MdAnchor],\n declarations: [MdButton, MdAnchor],\n})\nexport class MdButtonModule {\n static forRoot(): ModuleWithProviders {\n return {\n ngModule: MdButtonModule,\n providers: []\n };\n }\n}\n"],"sourceRoot":"/source/"}
\No newline at end of file