UNPKG

jqwidgets-scripts-custom

Version:

jQWidgets is an advanced jQuery, Angular 7, Vue, React, ASP .NET MVC, Custom Elements and HTML5 UI framework.

551 lines (550 loc) 16.2 kB
import * as jqxcore from '../../jqwidgets/jqxcore'; import * as jqxswitchbutton from '../../jqwidgets/jqxswitchbutton'; /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ import * as tslib_1 from "tslib"; /// <reference path="../../jqwidgets.d.ts" /> /// <reference path="../../jqwidgets.d.ts" /> import { Component, Input, Output, EventEmitter, ElementRef, forwardRef, ChangeDetectionStrategy } from '@angular/core'; import { NG_VALUE_ACCESSOR } from '@angular/forms'; /** @type {?} */ var noop = function () { }; var ɵ0 = noop; /** @type {?} */ var CUSTOM_INPUT_CONTROL_VALUE_ACCESSOR = { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(function () { return jqxSwitchButtonComponent; }), multi: true }; var jqxSwitchButtonComponent = /** @class */ (function () { function jqxSwitchButtonComponent(containerElement) { this.autoCreate = true; this.properties = ['checked', 'disabled', 'height', 'orientation', 'onLabel', 'offLabel', 'thumbSize', 'rtl', 'width']; this.onTouchedCallback = noop; this.onChangeCallback = noop; // jqxSwitchButtonComponent events this.onChecked = new EventEmitter(); this.onChange = new EventEmitter(); this.onUnchecked = new EventEmitter(); this.elementRef = containerElement; } /** * @return {?} */ jqxSwitchButtonComponent.prototype.ngOnInit = /** * @return {?} */ function () { if (this.autoCreate) { this.createComponent(); } }; ; /** * @param {?} changes * @return {?} */ jqxSwitchButtonComponent.prototype.ngOnChanges = /** * @param {?} changes * @return {?} */ function (changes) { if (this.host) { for (var i = 0; i < this.properties.length; i++) { /** @type {?} */ var attrName = 'attr' + this.properties[i].substring(0, 1).toUpperCase() + this.properties[i].substring(1); /** @type {?} */ var areEqual = false; if (this[attrName] !== undefined) { if (typeof this[attrName] === 'object') { if (this[attrName] instanceof Array) { areEqual = this.arraysEqual(this[attrName], this.host.jqxSwitchButton(this.properties[i])); } if (areEqual) { return false; } this.host.jqxSwitchButton(this.properties[i], this[attrName]); continue; } if (this[attrName] !== this.host.jqxSwitchButton(this.properties[i])) { this.host.jqxSwitchButton(this.properties[i], this[attrName]); } } } } }; /** * @param {?} attrValue * @param {?} hostValue * @return {?} */ jqxSwitchButtonComponent.prototype.arraysEqual = /** * @param {?} attrValue * @param {?} hostValue * @return {?} */ function (attrValue, hostValue) { if ((attrValue && !hostValue) || (!attrValue && hostValue)) { return false; } if (attrValue.length != hostValue.length) { return false; } for (var i = 0; i < attrValue.length; i++) { if (attrValue[i] !== hostValue[i]) { return false; } } return true; }; /** * @return {?} */ jqxSwitchButtonComponent.prototype.manageAttributes = /** * @return {?} */ function () { /** @type {?} */ var options = {}; for (var i = 0; i < this.properties.length; i++) { /** @type {?} */ var attrName = 'attr' + this.properties[i].substring(0, 1).toUpperCase() + this.properties[i].substring(1); if (this[attrName] !== undefined) { options[this.properties[i]] = this[attrName]; } } return options; }; /** * @param {?} parentEl * @param {?} childEl * @return {?} */ jqxSwitchButtonComponent.prototype.moveClasses = /** * @param {?} parentEl * @param {?} childEl * @return {?} */ function (parentEl, childEl) { var _a; /** @type {?} */ var classes = parentEl.classList; if (classes.length > 0) { (_a = childEl.classList).add.apply(_a, tslib_1.__spread(classes)); } parentEl.className = ''; }; /** * @param {?} parentEl * @param {?} childEl * @return {?} */ jqxSwitchButtonComponent.prototype.moveStyles = /** * @param {?} parentEl * @param {?} childEl * @return {?} */ function (parentEl, childEl) { /** @type {?} */ var style = parentEl.style.cssText; childEl.style.cssText = style; parentEl.style.cssText = ''; }; /** * @param {?=} options * @return {?} */ jqxSwitchButtonComponent.prototype.createComponent = /** * @param {?=} options * @return {?} */ function (options) { if (this.host) { return; } if (options) { JQXLite.extend(options, this.manageAttributes()); } else { options = this.manageAttributes(); } this.host = JQXLite(this.elementRef.nativeElement.firstChild); this.moveClasses(this.elementRef.nativeElement, this.host[0]); this.moveStyles(this.elementRef.nativeElement, this.host[0]); this.__wireEvents__(); this.widgetObject = jqwidgets.createInstance(this.host, 'jqxSwitchButton', options); }; /** * @param {?=} options * @return {?} */ jqxSwitchButtonComponent.prototype.createWidget = /** * @param {?=} options * @return {?} */ function (options) { this.createComponent(options); }; /** * @return {?} */ jqxSwitchButtonComponent.prototype.__updateRect__ = /** * @return {?} */ function () { if (this.host) this.host.css({ width: this.attrWidth, height: this.attrHeight }); }; /** * @param {?} value * @return {?} */ jqxSwitchButtonComponent.prototype.writeValue = /** * @param {?} value * @return {?} */ function (value) { if (this.widgetObject) { this.onChangeCallback(this.host.val()); } }; /** * @param {?} fn * @return {?} */ jqxSwitchButtonComponent.prototype.registerOnChange = /** * @param {?} fn * @return {?} */ function (fn) { this.onChangeCallback = fn; }; /** * @param {?} fn * @return {?} */ jqxSwitchButtonComponent.prototype.registerOnTouched = /** * @param {?} fn * @return {?} */ function (fn) { this.onTouchedCallback = fn; }; /** * @param {?} options * @return {?} */ jqxSwitchButtonComponent.prototype.setOptions = /** * @param {?} options * @return {?} */ function (options) { this.host.jqxSwitchButton('setOptions', options); }; // jqxSwitchButtonComponent properties // jqxSwitchButtonComponent properties /** * @param {?=} arg * @return {?} */ jqxSwitchButtonComponent.prototype.checked = // jqxSwitchButtonComponent properties /** * @param {?=} arg * @return {?} */ function (arg) { if (arg !== undefined) { this.host.jqxSwitchButton('checked', arg); } else { return this.host.jqxSwitchButton('checked'); } }; /** * @param {?=} arg * @return {?} */ jqxSwitchButtonComponent.prototype.disabled = /** * @param {?=} arg * @return {?} */ function (arg) { if (arg !== undefined) { this.host.jqxSwitchButton('disabled', arg); } else { return this.host.jqxSwitchButton('disabled'); } }; /** * @param {?=} arg * @return {?} */ jqxSwitchButtonComponent.prototype.height = /** * @param {?=} arg * @return {?} */ function (arg) { if (arg !== undefined) { this.host.jqxSwitchButton('height', arg); } else { return this.host.jqxSwitchButton('height'); } }; /** * @param {?=} arg * @return {?} */ jqxSwitchButtonComponent.prototype.orientation = /** * @param {?=} arg * @return {?} */ function (arg) { if (arg !== undefined) { this.host.jqxSwitchButton('orientation', arg); } else { return this.host.jqxSwitchButton('orientation'); } }; /** * @param {?=} arg * @return {?} */ jqxSwitchButtonComponent.prototype.onLabel = /** * @param {?=} arg * @return {?} */ function (arg) { if (arg !== undefined) { this.host.jqxSwitchButton('onLabel', arg); } else { return this.host.jqxSwitchButton('onLabel'); } }; /** * @param {?=} arg * @return {?} */ jqxSwitchButtonComponent.prototype.offLabel = /** * @param {?=} arg * @return {?} */ function (arg) { if (arg !== undefined) { this.host.jqxSwitchButton('offLabel', arg); } else { return this.host.jqxSwitchButton('offLabel'); } }; /** * @param {?=} arg * @return {?} */ jqxSwitchButtonComponent.prototype.thumbSize = /** * @param {?=} arg * @return {?} */ function (arg) { if (arg !== undefined) { this.host.jqxSwitchButton('thumbSize', arg); } else { return this.host.jqxSwitchButton('thumbSize'); } }; /** * @param {?=} arg * @return {?} */ jqxSwitchButtonComponent.prototype.rtl = /** * @param {?=} arg * @return {?} */ function (arg) { if (arg !== undefined) { this.host.jqxSwitchButton('rtl', arg); } else { return this.host.jqxSwitchButton('rtl'); } }; /** * @param {?=} arg * @return {?} */ jqxSwitchButtonComponent.prototype.width = /** * @param {?=} arg * @return {?} */ function (arg) { if (arg !== undefined) { this.host.jqxSwitchButton('width', arg); } else { return this.host.jqxSwitchButton('width'); } }; // jqxSwitchButtonComponent functions // jqxSwitchButtonComponent functions /** * @return {?} */ jqxSwitchButtonComponent.prototype.check = // jqxSwitchButtonComponent functions /** * @return {?} */ function () { this.host.jqxSwitchButton('check'); }; /** * @return {?} */ jqxSwitchButtonComponent.prototype.disable = /** * @return {?} */ function () { this.host.jqxSwitchButton('disable'); }; /** * @return {?} */ jqxSwitchButtonComponent.prototype.enable = /** * @return {?} */ function () { this.host.jqxSwitchButton('enable'); }; /** * @return {?} */ jqxSwitchButtonComponent.prototype.toggle = /** * @return {?} */ function () { this.host.jqxSwitchButton('toggle'); }; /** * @return {?} */ jqxSwitchButtonComponent.prototype.uncheck = /** * @return {?} */ function () { this.host.jqxSwitchButton('uncheck'); }; /** * @param {?=} value * @return {?} */ jqxSwitchButtonComponent.prototype.val = /** * @param {?=} value * @return {?} */ function (value) { if (value !== undefined) { return this.host.jqxSwitchButton('val', value); } else { return this.host.jqxSwitchButton('val'); } }; ; /** * @return {?} */ jqxSwitchButtonComponent.prototype.__wireEvents__ = /** * @return {?} */ function () { var _this = this; this.host.on('checked', function (eventData) { _this.onChecked.emit(eventData); }); this.host.on('change', function (eventData) { _this.onChange.emit(eventData); _this.onChangeCallback(_this.host.val()); }); this.host.on('unchecked', function (eventData) { _this.onUnchecked.emit(eventData); }); }; jqxSwitchButtonComponent.decorators = [ { type: Component, args: [{ selector: 'jqxSwitchButton', template: '<div><ng-content></ng-content></div>', providers: [CUSTOM_INPUT_CONTROL_VALUE_ACCESSOR], changeDetection: ChangeDetectionStrategy.OnPush }] } ]; /** @nocollapse */ jqxSwitchButtonComponent.ctorParameters = function () { return [ { type: ElementRef } ]; }; jqxSwitchButtonComponent.propDecorators = { attrChecked: [{ type: Input, args: ['checked',] }], attrDisabled: [{ type: Input, args: ['disabled',] }], attrOrientation: [{ type: Input, args: ['orientation',] }], attrOnLabel: [{ type: Input, args: ['onLabel',] }], attrOffLabel: [{ type: Input, args: ['offLabel',] }], attrThumbSize: [{ type: Input, args: ['thumbSize',] }], attrRtl: [{ type: Input, args: ['rtl',] }], attrWidth: [{ type: Input, args: ['width',] }], attrHeight: [{ type: Input, args: ['height',] }], autoCreate: [{ type: Input, args: ['auto-create',] }], onChecked: [{ type: Output }], onChange: [{ type: Output }], onUnchecked: [{ type: Output }] }; return jqxSwitchButtonComponent; }()); //jqxSwitchButtonComponent export { jqxSwitchButtonComponent }; if (false) { /** @type {?} */ jqxSwitchButtonComponent.prototype.attrChecked; /** @type {?} */ jqxSwitchButtonComponent.prototype.attrDisabled; /** @type {?} */ jqxSwitchButtonComponent.prototype.attrOrientation; /** @type {?} */ jqxSwitchButtonComponent.prototype.attrOnLabel; /** @type {?} */ jqxSwitchButtonComponent.prototype.attrOffLabel; /** @type {?} */ jqxSwitchButtonComponent.prototype.attrThumbSize; /** @type {?} */ jqxSwitchButtonComponent.prototype.attrRtl; /** @type {?} */ jqxSwitchButtonComponent.prototype.attrWidth; /** @type {?} */ jqxSwitchButtonComponent.prototype.attrHeight; /** @type {?} */ jqxSwitchButtonComponent.prototype.autoCreate; /** @type {?} */ jqxSwitchButtonComponent.prototype.properties; /** @type {?} */ jqxSwitchButtonComponent.prototype.host; /** @type {?} */ jqxSwitchButtonComponent.prototype.elementRef; /** @type {?} */ jqxSwitchButtonComponent.prototype.widgetObject; /** * @type {?} * @private */ jqxSwitchButtonComponent.prototype.onTouchedCallback; /** * @type {?} * @private */ jqxSwitchButtonComponent.prototype.onChangeCallback; /** @type {?} */ jqxSwitchButtonComponent.prototype.onChecked; /** @type {?} */ jqxSwitchButtonComponent.prototype.onChange; /** @type {?} */ jqxSwitchButtonComponent.prototype.onUnchecked; /* Skipping unhandled member: ;*/ /* Skipping unhandled member: ;*/ } export { ɵ0 };