UNPKG

jqwidgets-ng

Version:

[![Price](https://img.shields.io/badge/price-COMMERCIAL-0098f7.svg)](https://jqwidgets.com/license/)

337 lines (332 loc) 12.6 kB
import '../jqwidgets/modules/jqxbuttons'; import * as i0 from '@angular/core'; import { EventEmitter, Component, Input, Output, NgModule } from '@angular/core'; /// <reference path="../../jqwidgets.d.ts" /> class jqxToggleButtonComponent { constructor(containerElement) { this.autoCreate = true; this.properties = ['disabled', 'height', 'imgSrc', 'imgWidth', 'imgHeight', 'imgPosition', 'roundedCorners', 'rtl', 'textPosition', 'textImageRelation', 'theme', 'template', 'toggled', 'width', 'value']; // jqxToggleButtonComponent events this.onClick = new EventEmitter(); this.elementRef = containerElement; } ngOnInit() { if (this.autoCreate) { this.createComponent(); } } ; ngOnChanges(changes) { if (this.host) { for (let i = 0; i < this.properties.length; i++) { let attrName = 'attr' + this.properties[i].substring(0, 1).toUpperCase() + this.properties[i].substring(1); let areEqual = false; if (this[attrName] !== undefined) { if (typeof this[attrName] === 'object') { if (this[attrName] instanceof Array) { areEqual = this.arraysEqual(this[attrName], this.host.jqxToggleButton(this.properties[i])); } if (areEqual) { return false; } this.host.jqxToggleButton(this.properties[i], this[attrName]); continue; } if (this[attrName] !== this.host.jqxToggleButton(this.properties[i])) { this.host.jqxToggleButton(this.properties[i], this[attrName]); } } } } } arraysEqual(attrValue, hostValue) { if ((attrValue && !hostValue) || (!attrValue && hostValue)) { return false; } if (attrValue.length != hostValue.length) { return false; } for (let i = 0; i < attrValue.length; i++) { if (attrValue[i] !== hostValue[i]) { return false; } } return true; } manageAttributes() { let options = {}; for (let i = 0; i < this.properties.length; i++) { let 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; } moveClasses(parentEl, childEl) { let classes = parentEl.classList; if (classes.length > 0) { childEl.classList.add(...classes); } parentEl.className = ''; } moveStyles(parentEl, childEl) { let style = parentEl.style.cssText; childEl.style.cssText = style; parentEl.style.cssText = ''; } createComponent(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, 'jqxToggleButton', options); } createWidget(options) { this.createComponent(options); } __updateRect__() { if (this.host) this.host.css({ width: this.attrWidth, height: this.attrHeight }); } setOptions(options) { this.host.jqxToggleButton('setOptions', options); } // jqxToggleButtonComponent properties disabled(arg) { if (arg !== undefined) { this.host.jqxToggleButton('disabled', arg); } else { return this.host.jqxToggleButton('disabled'); } } height(arg) { if (arg !== undefined) { this.host.jqxToggleButton('height', arg); } else { return this.host.jqxToggleButton('height'); } } imgSrc(arg) { if (arg !== undefined) { this.host.jqxToggleButton('imgSrc', arg); } else { return this.host.jqxToggleButton('imgSrc'); } } imgWidth(arg) { if (arg !== undefined) { this.host.jqxToggleButton('imgWidth', arg); } else { return this.host.jqxToggleButton('imgWidth'); } } imgHeight(arg) { if (arg !== undefined) { this.host.jqxToggleButton('imgHeight', arg); } else { return this.host.jqxToggleButton('imgHeight'); } } imgPosition(arg) { if (arg !== undefined) { this.host.jqxToggleButton('imgPosition', arg); } else { return this.host.jqxToggleButton('imgPosition'); } } roundedCorners(arg) { if (arg !== undefined) { this.host.jqxToggleButton('roundedCorners', arg); } else { return this.host.jqxToggleButton('roundedCorners'); } } rtl(arg) { if (arg !== undefined) { this.host.jqxToggleButton('rtl', arg); } else { return this.host.jqxToggleButton('rtl'); } } textPosition(arg) { if (arg !== undefined) { this.host.jqxToggleButton('textPosition', arg); } else { return this.host.jqxToggleButton('textPosition'); } } textImageRelation(arg) { if (arg !== undefined) { this.host.jqxToggleButton('textImageRelation', arg); } else { return this.host.jqxToggleButton('textImageRelation'); } } theme(arg) { if (arg !== undefined) { this.host.jqxToggleButton('theme', arg); } else { return this.host.jqxToggleButton('theme'); } } template(arg) { if (arg !== undefined) { this.host.jqxToggleButton('template', arg); } else { return this.host.jqxToggleButton('template'); } } toggled(arg) { if (arg !== undefined) { this.host.jqxToggleButton('toggled', arg); } else { return this.host.jqxToggleButton('toggled'); } } width(arg) { if (arg !== undefined) { this.host.jqxToggleButton('width', arg); } else { return this.host.jqxToggleButton('width'); } } value(arg) { if (arg !== undefined) { this.host.jqxToggleButton('value', arg); } else { return this.host.jqxToggleButton('value'); } } // jqxToggleButtonComponent functions check() { this.host.jqxToggleButton('check'); } destroy() { this.host.jqxToggleButton('destroy'); } focus() { this.host.jqxToggleButton('focus'); } render() { this.host.jqxToggleButton('render'); } toggle() { this.host.jqxToggleButton('toggle'); } unCheck() { this.host.jqxToggleButton('unCheck'); } val(value) { if (value !== undefined) { return this.host.jqxToggleButton('val', value); } else { return this.host.jqxToggleButton('val'); } } ; __wireEvents__() { this.host.on('click', (eventData) => { this.onClick.emit(eventData); }); } } //jqxToggleButtonComponent jqxToggleButtonComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: jqxToggleButtonComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component }); jqxToggleButtonComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: jqxToggleButtonComponent, selector: "jqxToggleButton", inputs: { attrDisabled: ["disabled", "attrDisabled"], attrImgSrc: ["imgSrc", "attrImgSrc"], attrImgWidth: ["imgWidth", "attrImgWidth"], attrImgHeight: ["imgHeight", "attrImgHeight"], attrImgPosition: ["imgPosition", "attrImgPosition"], attrRoundedCorners: ["roundedCorners", "attrRoundedCorners"], attrRtl: ["rtl", "attrRtl"], attrTextPosition: ["textPosition", "attrTextPosition"], attrTextImageRelation: ["textImageRelation", "attrTextImageRelation"], attrTheme: ["theme", "attrTheme"], attrTemplate: ["template", "attrTemplate"], attrToggled: ["toggled", "attrToggled"], attrValue: ["value", "attrValue"], attrWidth: ["width", "attrWidth"], attrHeight: ["height", "attrHeight"], autoCreate: ["auto-create", "autoCreate"] }, outputs: { onClick: "onClick" }, usesOnChanges: true, ngImport: i0, template: '<button><ng-content></ng-content></button>', isInline: true }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: jqxToggleButtonComponent, decorators: [{ type: Component, args: [{ selector: 'jqxToggleButton', template: '<button><ng-content></ng-content></button>' }] }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { attrDisabled: [{ type: Input, args: ['disabled'] }], attrImgSrc: [{ type: Input, args: ['imgSrc'] }], attrImgWidth: [{ type: Input, args: ['imgWidth'] }], attrImgHeight: [{ type: Input, args: ['imgHeight'] }], attrImgPosition: [{ type: Input, args: ['imgPosition'] }], attrRoundedCorners: [{ type: Input, args: ['roundedCorners'] }], attrRtl: [{ type: Input, args: ['rtl'] }], attrTextPosition: [{ type: Input, args: ['textPosition'] }], attrTextImageRelation: [{ type: Input, args: ['textImageRelation'] }], attrTheme: [{ type: Input, args: ['theme'] }], attrTemplate: [{ type: Input, args: ['template'] }], attrToggled: [{ type: Input, args: ['toggled'] }], attrValue: [{ type: Input, args: ['value'] }], attrWidth: [{ type: Input, args: ['width'] }], attrHeight: [{ type: Input, args: ['height'] }], autoCreate: [{ type: Input, args: ['auto-create'] }], onClick: [{ type: Output }] } }); class jqxToggleButtonModule { } jqxToggleButtonModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: jqxToggleButtonModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); jqxToggleButtonModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: jqxToggleButtonModule, declarations: [jqxToggleButtonComponent], exports: [jqxToggleButtonComponent] }); jqxToggleButtonModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: jqxToggleButtonModule, imports: [[]] }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: jqxToggleButtonModule, decorators: [{ type: NgModule, args: [{ imports: [], declarations: [jqxToggleButtonComponent], exports: [jqxToggleButtonComponent] }] }] }); /** * Generated bundle index. Do not edit. */ export { jqxToggleButtonComponent, jqxToggleButtonModule };