UNPKG

5.04 kBJavaScriptView Raw
1import { Input } from '@angular/core';
2/**
3 * @hidden
4 */
5var Ion = (function () {
6 /**
7 * @param {?} config
8 * @param {?} elementRef
9 * @param {?} renderer
10 * @param {?=} componentName
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 * @return {?}
25 */
26 get: function () {
27 return this._color;
28 },
29 /**
30 * \@input {string} The color to use from your Sass `$colors` map.
31 * Default options are: `"primary"`, `"secondary"`, `"danger"`, `"light"`, and `"dark"`.
32 * For more information, see [Theming your App](/docs/theming/theming-your-app).
33 * @param {?} val
34 * @return {?}
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 * @return {?}
45 */
46 get: function () {
47 return this._mode;
48 },
49 /**
50 * \@input {string} The mode determines which platform styles to use.
51 * Possible values are: `"ios"`, `"md"`, or `"wp"`.
52 * For more information, see [Platform Styles](/docs/theming/platform-specific-styles).
53 * @param {?} val
54 * @return {?}
55 */
56 set: function (val) {
57 this._setMode(val);
58 },
59 enumerable: true,
60 configurable: true
61 });
62 /**
63 * @hidden
64 * @param {?} className
65 * @param {?} isAdd
66 * @return {?}
67 */
68 Ion.prototype.setElementClass = function (className, isAdd) {
69 this._renderer.setElementClass(this._elementRef.nativeElement, className, isAdd);
70 };
71 /**
72 * @hidden
73 * @param {?} attributeName
74 * @param {?} attributeValue
75 * @return {?}
76 */
77 Ion.prototype.setElementAttribute = function (attributeName, attributeValue) {
78 this._renderer.setElementAttribute(this._elementRef.nativeElement, attributeName, attributeValue);
79 };
80 /**
81 * @hidden
82 * @param {?} property
83 * @param {?} value
84 * @return {?}
85 */
86 Ion.prototype.setElementStyle = function (property, value) {
87 this._renderer.setElementStyle(this._elementRef.nativeElement, property, value);
88 };
89 /**
90 * @hidden
91 * @param {?} newColor
92 * @param {?=} componentName
93 * @return {?}
94 */
95 Ion.prototype._setColor = function (newColor, componentName) {
96 if (componentName) {
97 // This is needed for the item-radio
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 * @hidden
110 * @param {?} newMode
111 * @return {?}
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 // Remove the color class associated with the previous mode,
120 // change the mode, then add the new color class
121 this._setColor(null);
122 this._mode = newMode;
123 this._setColor(this._color);
124 }
125 };
126 /**
127 * @hidden
128 * @return {?}
129 */
130 Ion.prototype._setComponentName = function () {
131 this.setElementClass(this._componentName, true);
132 };
133 /**
134 * @hidden
135 * @return {?}
136 */
137 Ion.prototype.getElementRef = function () {
138 return this._elementRef;
139 };
140 /**
141 * @hidden
142 * @return {?}
143 */
144 Ion.prototype.getNativeElement = function () {
145 return this._elementRef.nativeElement;
146 };
147 return Ion;
148}());
149export { Ion };
150Ion.propDecorators = {
151 'color': [{ type: Input },],
152 'mode': [{ type: Input },],
153};
154function Ion_tsickle_Closure_declarations() {
155 /** @type {?} */
156 Ion.propDecorators;
157 /**
158 * @hidden
159 * @type {?}
160 */
161 Ion.prototype._config;
162 /**
163 * @hidden
164 * @type {?}
165 */
166 Ion.prototype._elementRef;
167 /**
168 * @hidden
169 * @type {?}
170 */
171 Ion.prototype._renderer;
172 /**
173 * @hidden
174 * @type {?}
175 */
176 Ion.prototype._color;
177 /**
178 * @hidden
179 * @type {?}
180 */
181 Ion.prototype._mode;
182 /**
183 * @hidden
184 * @type {?}
185 */
186 Ion.prototype._componentName;
187}
188//# sourceMappingURL=ion.js.map
\No newline at end of file