1 | import { Component, Input, ElementRef, forwardRef, Renderer, Inject, ViewEncapsulation } from '@angular/core';
|
2 | import { MdlMenuComponent } from './mdl-menu.component';
|
3 | import { toBoolean } from '../common/boolean-property';
|
4 | export var MdlMenuItemComponent = (function () {
|
5 |
|
6 | function MdlMenuItemComponent(elementRef, renderer, mdlMenu) {
|
7 | this.elementRef = elementRef;
|
8 | this.renderer = renderer;
|
9 | this.mdlMenu = mdlMenu;
|
10 | this._disabled = false;
|
11 | this.element = elementRef.nativeElement;
|
12 | }
|
13 | Object.defineProperty(MdlMenuItemComponent.prototype, "disabled", {
|
14 | get: function () { return this._disabled; },
|
15 | set: function (value) { this._disabled = toBoolean(value); },
|
16 | enumerable: true,
|
17 | configurable: true
|
18 | });
|
19 | MdlMenuItemComponent.prototype.onClick = function ($event) {
|
20 | $event.stopPropagation();
|
21 | if (this.disabled) {
|
22 | this.mdlMenu.hide();
|
23 | return;
|
24 | }
|
25 | this.mdlMenu.hideOnItemClicked();
|
26 | };
|
27 |
|
28 |
|
29 |
|
30 |
|
31 | MdlMenuItemComponent.prototype.onTouch = function ($event) {
|
32 |
|
33 | $event.stopPropagation();
|
34 | $event.preventDefault();
|
35 | var event = new MouseEvent('click', { bubbles: true });
|
36 | this.renderer.invokeElementMethod(this.element, 'dispatchEvent', [event]);
|
37 | };
|
38 | MdlMenuItemComponent.decorators = [
|
39 | { type: Component, args: [{
|
40 | selector: 'mdl-menu-item',
|
41 | host: {
|
42 | '[class.mdl-menu__item]': 'true',
|
43 | 'tabindex': '-1',
|
44 | '(click)': 'onClick($event)',
|
45 | '(touchstart)': 'onTouch($event)'
|
46 | },
|
47 | template: '<ng-content></ng-content>',
|
48 | encapsulation: ViewEncapsulation.None
|
49 | },] },
|
50 | ];
|
51 |
|
52 | MdlMenuItemComponent.ctorParameters = function () { return [
|
53 | { type: ElementRef, },
|
54 | { type: Renderer, },
|
55 | { type: MdlMenuComponent, decorators: [{ type: Inject, args: [forwardRef(function () { return MdlMenuComponent; }),] },] },
|
56 | ]; };
|
57 | MdlMenuItemComponent.propDecorators = {
|
58 | 'disabled': [{ type: Input },],
|
59 | };
|
60 | return MdlMenuItemComponent;
|
61 | }());
|
62 |
|
\ | No newline at end of file |