UNPKG

jqwidgets-scripts-custom

Version:

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

418 lines (417 loc) 11.7 kB
import * as jqxcore from '../../jqwidgets/jqxcore'; import * as jqxrating from '../../jqwidgets/jqxrating'; /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /// <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 {?} */ const noop = () => { }; const ɵ0 = noop; /** @type {?} */ const CUSTOM_INPUT_CONTROL_VALUE_ACCESSOR = { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => jqxRatingComponent), multi: true }; export class jqxRatingComponent { /** * @param {?} containerElement */ constructor(containerElement) { this.autoCreate = true; this.properties = ['count', 'disabled', 'height', 'itemHeight', 'itemWidth', 'precision', 'singleVote', 'value', 'width']; this.onTouchedCallback = noop; this.onChangeCallback = noop; // jqxRatingComponent events this.onChange = new EventEmitter(); this.elementRef = containerElement; } /** * @return {?} */ ngOnInit() { if (this.autoCreate) { this.createComponent(); } } ; /** * @param {?} changes * @return {?} */ ngOnChanges(changes) { if (this.host) { for (let i = 0; i < this.properties.length; i++) { /** @type {?} */ let attrName = 'attr' + this.properties[i].substring(0, 1).toUpperCase() + this.properties[i].substring(1); /** @type {?} */ let areEqual = false; if (this[attrName] !== undefined) { if (typeof this[attrName] === 'object') { if (this[attrName] instanceof Array) { areEqual = this.arraysEqual(this[attrName], this.host.jqxRating(this.properties[i])); } if (areEqual) { return false; } this.host.jqxRating(this.properties[i], this[attrName]); continue; } if (this[attrName] !== this.host.jqxRating(this.properties[i])) { this.host.jqxRating(this.properties[i], this[attrName]); } } } } } /** * @param {?} attrValue * @param {?} hostValue * @return {?} */ 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; } /** * @return {?} */ manageAttributes() { /** @type {?} */ let options = {}; for (let i = 0; i < this.properties.length; i++) { /** @type {?} */ 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; } /** * @param {?} parentEl * @param {?} childEl * @return {?} */ moveClasses(parentEl, childEl) { /** @type {?} */ let classes = parentEl.classList; if (classes.length > 0) { childEl.classList.add(...classes); } parentEl.className = ''; } /** * @param {?} parentEl * @param {?} childEl * @return {?} */ moveStyles(parentEl, childEl) { /** @type {?} */ let style = parentEl.style.cssText; childEl.style.cssText = style; parentEl.style.cssText = ''; } /** * @param {?=} options * @return {?} */ 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, 'jqxRating', options); } /** * @param {?=} options * @return {?} */ createWidget(options) { this.createComponent(options); } /** * @return {?} */ __updateRect__() { if (this.host) this.host.css({ width: this.attrWidth, height: this.attrHeight }); } /** * @param {?} value * @return {?} */ writeValue(value) { if (this.widgetObject) { this.onChangeCallback(this.host.val()); } } /** * @param {?} fn * @return {?} */ registerOnChange(fn) { this.onChangeCallback = fn; } /** * @param {?} fn * @return {?} */ registerOnTouched(fn) { this.onTouchedCallback = fn; } /** * @param {?} options * @return {?} */ setOptions(options) { this.host.jqxRating('setOptions', options); } // jqxRatingComponent properties /** * @param {?=} arg * @return {?} */ count(arg) { if (arg !== undefined) { this.host.jqxRating('count', arg); } else { return this.host.jqxRating('count'); } } /** * @param {?=} arg * @return {?} */ disabled(arg) { if (arg !== undefined) { this.host.jqxRating('disabled', arg); } else { return this.host.jqxRating('disabled'); } } /** * @param {?=} arg * @return {?} */ height(arg) { if (arg !== undefined) { this.host.jqxRating('height', arg); } else { return this.host.jqxRating('height'); } } /** * @param {?=} arg * @return {?} */ itemHeight(arg) { if (arg !== undefined) { this.host.jqxRating('itemHeight', arg); } else { return this.host.jqxRating('itemHeight'); } } /** * @param {?=} arg * @return {?} */ itemWidth(arg) { if (arg !== undefined) { this.host.jqxRating('itemWidth', arg); } else { return this.host.jqxRating('itemWidth'); } } /** * @param {?=} arg * @return {?} */ precision(arg) { if (arg !== undefined) { this.host.jqxRating('precision', arg); } else { return this.host.jqxRating('precision'); } } /** * @param {?=} arg * @return {?} */ singleVote(arg) { if (arg !== undefined) { this.host.jqxRating('singleVote', arg); } else { return this.host.jqxRating('singleVote'); } } /** * @param {?=} arg * @return {?} */ value(arg) { if (arg !== undefined) { this.host.jqxRating('value', arg); } else { return this.host.jqxRating('value'); } } /** * @param {?=} arg * @return {?} */ width(arg) { if (arg !== undefined) { this.host.jqxRating('width', arg); } else { return this.host.jqxRating('width'); } } // jqxRatingComponent functions /** * @return {?} */ disable() { this.host.jqxRating('disable'); } /** * @return {?} */ enable() { this.host.jqxRating('enable'); } /** * @return {?} */ getValue() { return this.host.jqxRating('getValue'); } /** * @param {?} value * @return {?} */ setValue(value) { this.host.jqxRating('setValue', value); } /** * @param {?=} value * @return {?} */ val(value) { if (value !== undefined) { return this.host.jqxRating('val', value); } else { return this.host.jqxRating('val'); } } ; /** * @return {?} */ __wireEvents__() { this.host.on('change', (eventData) => { this.onChange.emit(eventData); this.onChangeCallback(this.host.val()); }); } } //jqxRatingComponent jqxRatingComponent.decorators = [ { type: Component, args: [{ selector: 'jqxRating', template: '<div><ng-content></ng-content></div>', providers: [CUSTOM_INPUT_CONTROL_VALUE_ACCESSOR], changeDetection: ChangeDetectionStrategy.OnPush }] } ]; /** @nocollapse */ jqxRatingComponent.ctorParameters = () => [ { type: ElementRef } ]; jqxRatingComponent.propDecorators = { attrCount: [{ type: Input, args: ['count',] }], attrDisabled: [{ type: Input, args: ['disabled',] }], attrItemHeight: [{ type: Input, args: ['itemHeight',] }], attrItemWidth: [{ type: Input, args: ['itemWidth',] }], attrPrecision: [{ type: Input, args: ['precision',] }], attrSingleVote: [{ type: Input, args: ['singleVote',] }], attrValue: [{ type: Input, args: ['value',] }], attrWidth: [{ type: Input, args: ['width',] }], attrHeight: [{ type: Input, args: ['height',] }], autoCreate: [{ type: Input, args: ['auto-create',] }], onChange: [{ type: Output }] }; if (false) { /** @type {?} */ jqxRatingComponent.prototype.attrCount; /** @type {?} */ jqxRatingComponent.prototype.attrDisabled; /** @type {?} */ jqxRatingComponent.prototype.attrItemHeight; /** @type {?} */ jqxRatingComponent.prototype.attrItemWidth; /** @type {?} */ jqxRatingComponent.prototype.attrPrecision; /** @type {?} */ jqxRatingComponent.prototype.attrSingleVote; /** @type {?} */ jqxRatingComponent.prototype.attrValue; /** @type {?} */ jqxRatingComponent.prototype.attrWidth; /** @type {?} */ jqxRatingComponent.prototype.attrHeight; /** @type {?} */ jqxRatingComponent.prototype.autoCreate; /** @type {?} */ jqxRatingComponent.prototype.properties; /** @type {?} */ jqxRatingComponent.prototype.host; /** @type {?} */ jqxRatingComponent.prototype.elementRef; /** @type {?} */ jqxRatingComponent.prototype.widgetObject; /** * @type {?} * @private */ jqxRatingComponent.prototype.onTouchedCallback; /** * @type {?} * @private */ jqxRatingComponent.prototype.onChangeCallback; /** @type {?} */ jqxRatingComponent.prototype.onChange; /* Skipping unhandled member: ;*/ /* Skipping unhandled member: ;*/ } export { ɵ0 };