jqwidgets-ng
Version:
[](https://jqwidgets.com/license/)
250 lines (245 loc) • 9.89 kB
JavaScript
import '../jqwidgets/modules/jqxbuttongroup';
import * as i0 from '@angular/core';
import { EventEmitter, Component, Input, Output, NgModule } from '@angular/core';
/// <reference path="../../jqwidgets.d.ts" />
class jqxButtonGroupComponent {
constructor(containerElement) {
this.autoCreate = true;
this.properties = ['disabled', 'enableHover', 'mode', 'rtl', 'template', 'theme'];
// jqxButtonGroupComponent events
this.onButtonclick = new EventEmitter();
this.onSelected = new EventEmitter();
this.onUnselected = 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.jqxButtonGroup(this.properties[i]));
}
if (areEqual) {
return false;
}
this.host.jqxButtonGroup(this.properties[i], this[attrName]);
continue;
}
if (this[attrName] !== this.host.jqxButtonGroup(this.properties[i])) {
this.host.jqxButtonGroup(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.host[0].style.marginLeft = '1px';
this.__wireEvents__();
this.widgetObject = jqwidgets.createInstance(this.host, 'jqxButtonGroup', options);
}
createWidget(options) {
this.createComponent(options);
}
__updateRect__() {
if (this.host)
this.host.css({ width: this.attrWidth, height: this.attrHeight });
}
setOptions(options) {
this.host.jqxButtonGroup('setOptions', options);
}
// jqxButtonGroupComponent properties
disabled(arg) {
if (arg !== undefined) {
this.host.jqxButtonGroup('disabled', arg);
}
else {
return this.host.jqxButtonGroup('disabled');
}
}
enableHover(arg) {
if (arg !== undefined) {
this.host.jqxButtonGroup('enableHover', arg);
}
else {
return this.host.jqxButtonGroup('enableHover');
}
}
mode(arg) {
if (arg !== undefined) {
this.host.jqxButtonGroup('mode', arg);
}
else {
return this.host.jqxButtonGroup('mode');
}
}
rtl(arg) {
if (arg !== undefined) {
this.host.jqxButtonGroup('rtl', arg);
}
else {
return this.host.jqxButtonGroup('rtl');
}
}
template(arg) {
if (arg !== undefined) {
this.host.jqxButtonGroup('template', arg);
}
else {
return this.host.jqxButtonGroup('template');
}
}
theme(arg) {
if (arg !== undefined) {
this.host.jqxButtonGroup('theme', arg);
}
else {
return this.host.jqxButtonGroup('theme');
}
}
// jqxButtonGroupComponent functions
disableAt(index) {
this.host.jqxButtonGroup('disableAt', index);
}
disable() {
this.host.jqxButtonGroup('disable');
}
destroy() {
this.host.jqxButtonGroup('destroy');
}
enable() {
this.host.jqxButtonGroup('enable');
}
enableAt(index) {
this.host.jqxButtonGroup('enableAt', index);
}
getSelection() {
return this.host.jqxButtonGroup('getSelection');
}
render() {
this.host.jqxButtonGroup('render');
}
setSelection(index) {
this.host.jqxButtonGroup('setSelection', index);
}
__wireEvents__() {
this.host.on('buttonclick', (eventData) => { this.onButtonclick.emit(eventData); });
this.host.on('selected', (eventData) => { this.onSelected.emit(eventData); });
this.host.on('unselected', (eventData) => { this.onUnselected.emit(eventData); });
}
} //jqxButtonGroupComponent
jqxButtonGroupComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: jqxButtonGroupComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
jqxButtonGroupComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: jqxButtonGroupComponent, selector: "jqxButtonGroup", inputs: { attrDisabled: ["disabled", "attrDisabled"], attrEnableHover: ["enableHover", "attrEnableHover"], attrMode: ["mode", "attrMode"], attrRtl: ["rtl", "attrRtl"], attrTemplate: ["template", "attrTemplate"], attrTheme: ["theme", "attrTheme"], attrWidth: ["width", "attrWidth"], attrHeight: ["height", "attrHeight"], autoCreate: ["auto-create", "autoCreate"] }, outputs: { onButtonclick: "onButtonclick", onSelected: "onSelected", onUnselected: "onUnselected" }, usesOnChanges: true, ngImport: i0, template: '<div><ng-content></ng-content></div>', isInline: true });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: jqxButtonGroupComponent, decorators: [{
type: Component,
args: [{
selector: 'jqxButtonGroup',
template: '<div><ng-content></ng-content></div>'
}]
}], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { attrDisabled: [{
type: Input,
args: ['disabled']
}], attrEnableHover: [{
type: Input,
args: ['enableHover']
}], attrMode: [{
type: Input,
args: ['mode']
}], attrRtl: [{
type: Input,
args: ['rtl']
}], attrTemplate: [{
type: Input,
args: ['template']
}], attrTheme: [{
type: Input,
args: ['theme']
}], attrWidth: [{
type: Input,
args: ['width']
}], attrHeight: [{
type: Input,
args: ['height']
}], autoCreate: [{
type: Input,
args: ['auto-create']
}], onButtonclick: [{
type: Output
}], onSelected: [{
type: Output
}], onUnselected: [{
type: Output
}] } });
class jqxButtonGroupModule {
}
jqxButtonGroupModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: jqxButtonGroupModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
jqxButtonGroupModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: jqxButtonGroupModule, declarations: [jqxButtonGroupComponent], exports: [jqxButtonGroupComponent] });
jqxButtonGroupModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: jqxButtonGroupModule, imports: [[]] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: jqxButtonGroupModule, decorators: [{
type: NgModule,
args: [{
imports: [],
declarations: [jqxButtonGroupComponent],
exports: [jqxButtonGroupComponent]
}]
}] });
/**
* Generated bundle index. Do not edit.
*/
export { jqxButtonGroupComponent, jqxButtonGroupModule };