1 | import { Input } from '@angular/core';
|
2 |
|
3 |
|
4 |
|
5 | var Ion = (function () {
|
6 | |
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | function Ion(config, elementRef, renderer, componentName) {
|
13 | this._config = config;
|
14 | this._elementRef = elementRef;
|
15 | this._renderer = renderer;
|
16 | this._componentName = componentName;
|
17 | if (componentName) {
|
18 | this._setComponentName();
|
19 | this._setMode(config.get('mode'));
|
20 | }
|
21 | }
|
22 | Object.defineProperty(Ion.prototype, "color", {
|
23 | |
24 |
|
25 |
|
26 | get: function () {
|
27 | return this._color;
|
28 | },
|
29 | |
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 | set: function (val) {
|
37 | this._setColor(val);
|
38 | },
|
39 | enumerable: true,
|
40 | configurable: true
|
41 | });
|
42 | Object.defineProperty(Ion.prototype, "mode", {
|
43 | |
44 |
|
45 |
|
46 | get: function () {
|
47 | return this._mode;
|
48 | },
|
49 | |
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 | set: function (val) {
|
57 | this._setMode(val);
|
58 | },
|
59 | enumerable: true,
|
60 | configurable: true
|
61 | });
|
62 | |
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 | Ion.prototype.setElementClass = function (className, isAdd) {
|
69 | this._renderer.setElementClass(this._elementRef.nativeElement, className, isAdd);
|
70 | };
|
71 | |
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 | Ion.prototype.setElementAttribute = function (attributeName, attributeValue) {
|
78 | this._renderer.setElementAttribute(this._elementRef.nativeElement, attributeName, attributeValue);
|
79 | };
|
80 | |
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 | Ion.prototype.setElementStyle = function (property, value) {
|
87 | this._renderer.setElementStyle(this._elementRef.nativeElement, property, value);
|
88 | };
|
89 | |
90 |
|
91 |
|
92 |
|
93 |
|
94 |
|
95 | Ion.prototype._setColor = function (newColor, componentName) {
|
96 | if (componentName) {
|
97 |
|
98 | this._componentName = componentName;
|
99 | }
|
100 | if (this._color) {
|
101 | this.setElementClass(this._componentName + "-" + this._mode + "-" + this._color, false);
|
102 | }
|
103 | if (newColor) {
|
104 | this.setElementClass(this._componentName + "-" + this._mode + "-" + newColor, true);
|
105 | this._color = newColor;
|
106 | }
|
107 | };
|
108 | |
109 |
|
110 |
|
111 |
|
112 |
|
113 | Ion.prototype._setMode = function (newMode) {
|
114 | if (this._mode) {
|
115 | this.setElementClass(this._componentName + "-" + this._mode, false);
|
116 | }
|
117 | if (newMode) {
|
118 | this.setElementClass(this._componentName + "-" + newMode, true);
|
119 |
|
120 |
|
121 | this._setColor(null);
|
122 | this._mode = newMode;
|
123 | this._setColor(this._color);
|
124 | }
|
125 | };
|
126 | |
127 |
|
128 |
|
129 |
|
130 | Ion.prototype._setComponentName = function () {
|
131 | this.setElementClass(this._componentName, true);
|
132 | };
|
133 | |
134 |
|
135 |
|
136 |
|
137 | Ion.prototype.getElementRef = function () {
|
138 | return this._elementRef;
|
139 | };
|
140 | |
141 |
|
142 |
|
143 |
|
144 | Ion.prototype.getNativeElement = function () {
|
145 | return this._elementRef.nativeElement;
|
146 | };
|
147 | return Ion;
|
148 | }());
|
149 | export { Ion };
|
150 | Ion.propDecorators = {
|
151 | 'color': [{ type: Input },],
|
152 | 'mode': [{ type: Input },],
|
153 | };
|
154 | function Ion_tsickle_Closure_declarations() {
|
155 |
|
156 | Ion.propDecorators;
|
157 | |
158 |
|
159 |
|
160 |
|
161 | Ion.prototype._config;
|
162 | |
163 |
|
164 |
|
165 |
|
166 | Ion.prototype._elementRef;
|
167 | |
168 |
|
169 |
|
170 |
|
171 | Ion.prototype._renderer;
|
172 | |
173 |
|
174 |
|
175 |
|
176 | Ion.prototype._color;
|
177 | |
178 |
|
179 |
|
180 |
|
181 | Ion.prototype._mode;
|
182 | |
183 |
|
184 |
|
185 |
|
186 | Ion.prototype._componentName;
|
187 | }
|
188 |
|
\ | No newline at end of file |