1 | var __extends = (this && this.__extends) || (function () {
|
2 | var extendStatics = Object.setPrototypeOf ||
|
3 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
4 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
5 | return function (d, b) {
|
6 | extendStatics(d, b);
|
7 | function __() { this.constructor = d; }
|
8 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
9 | };
|
10 | })();
|
11 | import { Directive, ElementRef, HostBinding, Input, Renderer } from '@angular/core';
|
12 | import { isTrueProperty } from '../../util/util';
|
13 | import { Config } from '../../config/config';
|
14 | import { Ion } from '../ion';
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 | var Icon = (function (_super) {
|
47 | __extends(Icon, _super);
|
48 | function Icon(config, elementRef, renderer) {
|
49 | var _this = _super.call(this, config, elementRef, renderer, 'icon') || this;
|
50 |
|
51 | _this._isActive = true;
|
52 |
|
53 | _this._name = '';
|
54 |
|
55 | _this._ios = '';
|
56 |
|
57 | _this._md = '';
|
58 |
|
59 | _this._css = '';
|
60 | |
61 |
|
62 |
|
63 | _this._hidden = false;
|
64 | _this._iconMode = config.get('iconMode');
|
65 | return _this;
|
66 | }
|
67 | |
68 |
|
69 |
|
70 | Icon.prototype.ngOnDestroy = function () {
|
71 | if (this._css) {
|
72 | this.setElementClass(this._css, false);
|
73 | }
|
74 | };
|
75 | Object.defineProperty(Icon.prototype, "name", {
|
76 | |
77 |
|
78 |
|
79 |
|
80 | get: function () {
|
81 | return this._name;
|
82 | },
|
83 | set: function (val) {
|
84 | if (!(/^md-|^ios-|^logo-/.test(val))) {
|
85 |
|
86 |
|
87 | this._name = this._iconMode + '-' + val;
|
88 | }
|
89 | else {
|
90 | this._name = val;
|
91 | }
|
92 | this.update();
|
93 | },
|
94 | enumerable: true,
|
95 | configurable: true
|
96 | });
|
97 | Object.defineProperty(Icon.prototype, "ios", {
|
98 | |
99 |
|
100 |
|
101 | get: function () {
|
102 | return this._ios;
|
103 | },
|
104 | set: function (val) {
|
105 | this._ios = val;
|
106 | this.update();
|
107 | },
|
108 | enumerable: true,
|
109 | configurable: true
|
110 | });
|
111 | Object.defineProperty(Icon.prototype, "md", {
|
112 | |
113 |
|
114 |
|
115 | get: function () {
|
116 | return this._md;
|
117 | },
|
118 | set: function (val) {
|
119 | this._md = val;
|
120 | this.update();
|
121 | },
|
122 | enumerable: true,
|
123 | configurable: true
|
124 | });
|
125 | Object.defineProperty(Icon.prototype, "isActive", {
|
126 | |
127 |
|
128 |
|
129 |
|
130 |
|
131 | get: function () {
|
132 | return this._isActive;
|
133 | },
|
134 | set: function (val) {
|
135 | this._isActive = isTrueProperty(val);
|
136 | this.update();
|
137 | },
|
138 | enumerable: true,
|
139 | configurable: true
|
140 | });
|
141 | |
142 |
|
143 |
|
144 | Icon.prototype.update = function () {
|
145 | var iconName;
|
146 | if (this._ios && this._iconMode === 'ios') {
|
147 | iconName = this._ios;
|
148 | }
|
149 | else if (this._md && this._iconMode === 'md') {
|
150 | iconName = this._md;
|
151 | }
|
152 | else {
|
153 | iconName = this._name;
|
154 | }
|
155 | var hidden = this._hidden = (iconName === null);
|
156 | if (hidden) {
|
157 | return;
|
158 | }
|
159 | var iconMode = iconName.split('-', 2)[0];
|
160 | if (iconMode === 'ios' &&
|
161 | !this._isActive &&
|
162 | iconName.indexOf('logo-') < 0 &&
|
163 | iconName.indexOf('-outline') < 0) {
|
164 | iconName += '-outline';
|
165 | }
|
166 | var css = 'ion-' + iconName;
|
167 | if (this._css === css) {
|
168 | return;
|
169 | }
|
170 | if (this._css) {
|
171 | this.setElementClass(this._css, false);
|
172 | }
|
173 | this._css = css;
|
174 | this.setElementClass(css, true);
|
175 | var label = iconName
|
176 | .replace('ios-', '')
|
177 | .replace('md-', '')
|
178 | .replace('-', ' ');
|
179 | this.setElementAttribute('aria-label', label);
|
180 | };
|
181 | Icon.decorators = [
|
182 | { type: Directive, args: [{
|
183 | selector: 'ion-icon',
|
184 | host: {
|
185 | 'role': 'img'
|
186 | }
|
187 | },] },
|
188 | ];
|
189 |
|
190 | Icon.ctorParameters = function () { return [
|
191 | { type: Config, },
|
192 | { type: ElementRef, },
|
193 | { type: Renderer, },
|
194 | ]; };
|
195 | Icon.propDecorators = {
|
196 | 'name': [{ type: Input },],
|
197 | 'ios': [{ type: Input },],
|
198 | 'md': [{ type: Input },],
|
199 | 'isActive': [{ type: Input },],
|
200 | '_hidden': [{ type: HostBinding, args: ['class.hide',] },],
|
201 | };
|
202 | return Icon;
|
203 | }(Ion));
|
204 | export { Icon };
|
205 |
|
\ | No newline at end of file |