ionic-angular
Version:
A powerful framework for building mobile and progressive web apps with JavaScript and Angular 2
178 lines • 4.39 kB
JavaScript
import { Input } from '@angular/core';
/**
* @hidden
*/
export class Ion {
/**
* @param {?} config
* @param {?} elementRef
* @param {?} renderer
* @param {?=} componentName
*/
constructor(config, elementRef, renderer, componentName) {
this._config = config;
this._elementRef = elementRef;
this._renderer = renderer;
this._componentName = componentName;
if (componentName) {
this._setComponentName();
this._setMode(config.get('mode'));
}
}
/**
* \@input {string} The color to use from your Sass `$colors` map.
* Default options are: `"primary"`, `"secondary"`, `"danger"`, `"light"`, and `"dark"`.
* For more information, see [Theming your App](/docs/theming/theming-your-app).
* @param {?} val
* @return {?}
*/
set color(val) {
this._setColor(val);
}
/**
* @return {?}
*/
get color() {
return this._color;
}
/**
* \@input {string} The mode determines which platform styles to use.
* Possible values are: `"ios"`, `"md"`, or `"wp"`.
* For more information, see [Platform Styles](/docs/theming/platform-specific-styles).
* @param {?} val
* @return {?}
*/
set mode(val) {
this._setMode(val);
}
/**
* @return {?}
*/
get mode() {
return this._mode;
}
/**
* @hidden
* @param {?} className
* @param {?} isAdd
* @return {?}
*/
setElementClass(className, isAdd) {
this._renderer.setElementClass(this._elementRef.nativeElement, className, isAdd);
}
/**
* @hidden
* @param {?} attributeName
* @param {?} attributeValue
* @return {?}
*/
setElementAttribute(attributeName, attributeValue) {
this._renderer.setElementAttribute(this._elementRef.nativeElement, attributeName, attributeValue);
}
/**
* @hidden
* @param {?} property
* @param {?} value
* @return {?}
*/
setElementStyle(property, value) {
this._renderer.setElementStyle(this._elementRef.nativeElement, property, value);
}
/**
* @hidden
* @param {?} newColor
* @param {?=} componentName
* @return {?}
*/
_setColor(newColor, componentName) {
if (componentName) {
// This is needed for the item-radio
this._componentName = componentName;
}
if (this._color) {
this.setElementClass(`${this._componentName}-${this._mode}-${this._color}`, false);
}
if (newColor) {
this.setElementClass(`${this._componentName}-${this._mode}-${newColor}`, true);
this._color = newColor;
}
}
/**
* @hidden
* @param {?} newMode
* @return {?}
*/
_setMode(newMode) {
if (this._mode) {
this.setElementClass(`${this._componentName}-${this._mode}`, false);
}
if (newMode) {
this.setElementClass(`${this._componentName}-${newMode}`, true);
// Remove the color class associated with the previous mode,
// change the mode, then add the new color class
this._setColor(null);
this._mode = newMode;
this._setColor(this._color);
}
}
/**
* @hidden
* @return {?}
*/
_setComponentName() {
this.setElementClass(this._componentName, true);
}
/**
* @hidden
* @return {?}
*/
getElementRef() {
return this._elementRef;
}
/**
* @hidden
* @return {?}
*/
getNativeElement() {
return this._elementRef.nativeElement;
}
}
Ion.propDecorators = {
'color': [{ type: Input },],
'mode': [{ type: Input },],
};
function Ion_tsickle_Closure_declarations() {
/** @type {?} */
Ion.propDecorators;
/**
* @hidden
* @type {?}
*/
Ion.prototype._config;
/**
* @hidden
* @type {?}
*/
Ion.prototype._elementRef;
/**
* @hidden
* @type {?}
*/
Ion.prototype._renderer;
/**
* @hidden
* @type {?}
*/
Ion.prototype._color;
/**
* @hidden
* @type {?}
*/
Ion.prototype._mode;
/**
* @hidden
* @type {?}
*/
Ion.prototype._componentName;
}
//# sourceMappingURL=ion.js.map