jqwidgets-framework
Version:
jQWidgets is an advanced Angular, Vue, Blazor, React, Web Components, jquery, ASP .NET MVC, Custom Elements and HTML5 UI framework.
396 lines (337 loc) • 12 kB
text/typescript
/*
jQWidgets v22.0.0 (2025-Jan)
Copyright (c) 2011-2025 jQWidgets.
License: https://jqwidgets.com/license/
*/
/* eslint-disable */
/// <reference path="jqwidgets.d.ts" />
import '../jqwidgets/jqxcore.js';
import '../jqwidgets/jqxdraw.js';
import '../jqwidgets/jqxknob.js';
import { Component, Input, Output, EventEmitter, ElementRef, OnChanges, SimpleChanges } from '@angular/core';
declare let JQXLite: any;
export class jqxKnobComponent implements OnChanges
{
attrAllowValueChangeOnClick: boolean;
attrAllowValueChangeOnDrag: boolean;
attrAllowValueChangeOnMouseWheel: boolean;
attrChanging: (oldValue: jqwidgets.KnobChanging['oldValue'] | jqwidgets.KnobChanging['oldValue'][], newValue: jqwidgets.KnobChanging['newValue'] | jqwidgets.KnobChanging['newValue'][]) => boolean;
attrDragEndAngle: number;
attrDragStartAngle: number;
attrDisabled: boolean;
attrDial: jqwidgets.KnobDial;
attrEndAngle: number;
attrLabels: jqwidgets.KnobLabels;
attrMarks: jqwidgets.KnobMarks;
attrMin: number;
attrMax: number;
attrProgressBar: jqwidgets.KnobProgressBar;
attrPointer: jqwidgets.KnobPointer | jqwidgets.KnobPointer[];
attrPointerGrabAction: string;
attrRotation: string;
attrStartAngle: number;
attrSpinner: jqwidgets.KnobSpinner;
attrStyles: jqwidgets.KnobStyle;
attrStep: number | string;
attrSnapToStep: boolean;
attrValue: any;
attrWidth: string | number;
attrHeight: string | number;
autoCreate: boolean = true;
properties: string[] = ['allowValueChangeOnClick','allowValueChangeOnDrag','allowValueChangeOnMouseWheel','changing','dragEndAngle','dragStartAngle','disabled','dial','endAngle','height','labels','marks','min','max','progressBar','pointer','pointerGrabAction','rotation','startAngle','spinner','styles','step','snapToStep','value','width'];
host: any;
elementRef: ElementRef;
widgetObject: jqwidgets.jqxKnob;
constructor(containerElement: ElementRef) {
this.elementRef = containerElement;
JQXLite(window).resize(() => {
this.__updateRect__();
});
}
ngOnInit() {
if (this.autoCreate) {
this.createComponent();
}
};
ngOnChanges(changes: SimpleChanges) {
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: boolean = false;
if (this[attrName] !== undefined) {
if (typeof this[attrName] === 'object') {
if (this[attrName] instanceof Array) {
areEqual = this.arraysEqual(this[attrName], this.host.jqxKnob(this.properties[i]));
}
if (areEqual) {
return false;
}
this.host.jqxKnob(this.properties[i], this[attrName]);
continue;
}
if (this[attrName] !== this.host.jqxKnob(this.properties[i])) {
this.host.jqxKnob(this.properties[i], this[attrName]);
}
}
}
}
}
arraysEqual(attrValue: any, hostValue: any): boolean {
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(): any {
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: HTMLElement, childEl: HTMLElement): void {
let classes: any = parentEl.classList;
if (classes.length > 0) {
childEl.classList.add(...classes);
}
parentEl.className = '';
}
moveStyles(parentEl: HTMLElement, childEl: HTMLElement): void {
let style = parentEl.style.cssText;
childEl.style.cssText = style
parentEl.style.cssText = '';
}
createComponent(options?: any): void {
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, 'jqxKnob', options);
this.__updateRect__();
}
createWidget(options?: any): void {
this.createComponent(options);
}
__updateRect__() : void {
if(this.host) this.host.css({ width: this.attrWidth, height: this.attrHeight });
}
setOptions(options: any) : void {
this.host.jqxKnob('setOptions', options);
}
// jqxKnobComponent properties
allowValueChangeOnClick(arg?: boolean): boolean {
if (arg !== undefined) {
this.host.jqxKnob('allowValueChangeOnClick', arg);
} else {
return this.host.jqxKnob('allowValueChangeOnClick');
}
}
allowValueChangeOnDrag(arg?: boolean): boolean {
if (arg !== undefined) {
this.host.jqxKnob('allowValueChangeOnDrag', arg);
} else {
return this.host.jqxKnob('allowValueChangeOnDrag');
}
}
allowValueChangeOnMouseWheel(arg?: boolean): boolean {
if (arg !== undefined) {
this.host.jqxKnob('allowValueChangeOnMouseWheel', arg);
} else {
return this.host.jqxKnob('allowValueChangeOnMouseWheel');
}
}
changing(arg?: (oldValue: jqwidgets.KnobChanging['oldValue'] | jqwidgets.KnobChanging['oldValue'][], newValue: jqwidgets.KnobChanging['newValue'] | jqwidgets.KnobChanging['newValue'][]) => boolean): (oldValue: jqwidgets.KnobChanging['oldValue'] | jqwidgets.KnobChanging['oldValue'][], newValue: jqwidgets.KnobChanging['newValue'] | jqwidgets.KnobChanging['newValue'][]) => boolean {
if (arg !== undefined) {
this.host.jqxKnob('changing', arg);
} else {
return this.host.jqxKnob('changing');
}
}
dragEndAngle(arg?: number): number {
if (arg !== undefined) {
this.host.jqxKnob('dragEndAngle', arg);
} else {
return this.host.jqxKnob('dragEndAngle');
}
}
dragStartAngle(arg?: number): number {
if (arg !== undefined) {
this.host.jqxKnob('dragStartAngle', arg);
} else {
return this.host.jqxKnob('dragStartAngle');
}
}
disabled(arg?: boolean): boolean {
if (arg !== undefined) {
this.host.jqxKnob('disabled', arg);
} else {
return this.host.jqxKnob('disabled');
}
}
dial(arg?: jqwidgets.KnobDial): jqwidgets.KnobDial {
if (arg !== undefined) {
this.host.jqxKnob('dial', arg);
} else {
return this.host.jqxKnob('dial');
}
}
endAngle(arg?: number): number {
if (arg !== undefined) {
this.host.jqxKnob('endAngle', arg);
} else {
return this.host.jqxKnob('endAngle');
}
}
height(arg?: number | string): number | string {
if (arg !== undefined) {
this.host.jqxKnob('height', arg);
} else {
return this.host.jqxKnob('height');
}
}
labels(arg?: jqwidgets.KnobLabels): jqwidgets.KnobLabels {
if (arg !== undefined) {
this.host.jqxKnob('labels', arg);
} else {
return this.host.jqxKnob('labels');
}
}
marks(arg?: jqwidgets.KnobMarks): jqwidgets.KnobMarks {
if (arg !== undefined) {
this.host.jqxKnob('marks', arg);
} else {
return this.host.jqxKnob('marks');
}
}
min(arg?: number): number {
if (arg !== undefined) {
this.host.jqxKnob('min', arg);
} else {
return this.host.jqxKnob('min');
}
}
max(arg?: number): number {
if (arg !== undefined) {
this.host.jqxKnob('max', arg);
} else {
return this.host.jqxKnob('max');
}
}
progressBar(arg?: jqwidgets.KnobProgressBar): jqwidgets.KnobProgressBar {
if (arg !== undefined) {
this.host.jqxKnob('progressBar', arg);
} else {
return this.host.jqxKnob('progressBar');
}
}
pointer(arg?: jqwidgets.KnobPointer | jqwidgets.KnobPointer[]): jqwidgets.KnobPointer | jqwidgets.KnobPointer[] {
if (arg !== undefined) {
this.host.jqxKnob('pointer', arg);
} else {
return this.host.jqxKnob('pointer');
}
}
pointerGrabAction(arg?: string): string {
if (arg !== undefined) {
this.host.jqxKnob('pointerGrabAction', arg);
} else {
return this.host.jqxKnob('pointerGrabAction');
}
}
rotation(arg?: string): string {
if (arg !== undefined) {
this.host.jqxKnob('rotation', arg);
} else {
return this.host.jqxKnob('rotation');
}
}
startAngle(arg?: number): number {
if (arg !== undefined) {
this.host.jqxKnob('startAngle', arg);
} else {
return this.host.jqxKnob('startAngle');
}
}
spinner(arg?: jqwidgets.KnobSpinner): jqwidgets.KnobSpinner {
if (arg !== undefined) {
this.host.jqxKnob('spinner', arg);
} else {
return this.host.jqxKnob('spinner');
}
}
styles(arg?: jqwidgets.KnobStyle): jqwidgets.KnobStyle {
if (arg !== undefined) {
this.host.jqxKnob('styles', arg);
} else {
return this.host.jqxKnob('styles');
}
}
step(arg?: number | string): number | string {
if (arg !== undefined) {
this.host.jqxKnob('step', arg);
} else {
return this.host.jqxKnob('step');
}
}
snapToStep(arg?: boolean): boolean {
if (arg !== undefined) {
this.host.jqxKnob('snapToStep', arg);
} else {
return this.host.jqxKnob('snapToStep');
}
}
value(arg?: any): any {
if (arg !== undefined) {
this.host.jqxKnob('value', arg);
} else {
return this.host.jqxKnob('value');
}
}
width(arg?: number | string): number | string {
if (arg !== undefined) {
this.host.jqxKnob('width', arg);
} else {
return this.host.jqxKnob('width');
}
}
// jqxKnobComponent functions
destroy(): void {
this.host.jqxKnob('destroy');
}
val(value?: number | string): any {
if (value !== undefined) {
return this.host.jqxKnob('val', value);
} else {
return this.host.jqxKnob('val');
}
};
// jqxKnobComponent events
onChange = new EventEmitter();
__wireEvents__(): void {
this.host.on('change', (eventData: any) => { this.onChange.emit(eventData); });
}
} //jqxKnobComponent