jqwidgets-ng
Version:
[](https://jqwidgets.com/license/)
280 lines (275 loc) • 10.5 kB
JavaScript
import '../jqwidgets/modules/jqxtoolbar';
import * as i0 from '@angular/core';
import { EventEmitter, Component, Input, Output, NgModule } from '@angular/core';
/// <reference path="../../jqwidgets.d.ts" />
class jqxToolBarComponent {
constructor(containerElement) {
this.autoCreate = true;
this.properties = ['disabled', 'height', 'initTools', 'minimizeWidth', 'minWidth', 'maxWidth', 'rtl', 'tools', 'theme', 'width'];
// jqxToolBarComponent events
this.onClose = new EventEmitter();
this.onOpen = 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.jqxToolBar(this.properties[i]));
}
if (areEqual) {
return false;
}
this.host.jqxToolBar(this.properties[i], this[attrName]);
continue;
}
if (this[attrName] !== this.host.jqxToolBar(this.properties[i])) {
this.host.jqxToolBar(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, 'jqxToolBar', options);
}
createWidget(options) {
this.createComponent(options);
}
__updateRect__() {
if (this.host)
this.host.css({ width: this.attrWidth, height: this.attrHeight });
}
setOptions(options) {
this.host.jqxToolBar('setOptions', options);
}
// jqxToolBarComponent properties
disabled(arg) {
if (arg !== undefined) {
this.host.jqxToolBar('disabled', arg);
}
else {
return this.host.jqxToolBar('disabled');
}
}
height(arg) {
if (arg !== undefined) {
this.host.jqxToolBar('height', arg);
}
else {
return this.host.jqxToolBar('height');
}
}
initTools(arg) {
if (arg !== undefined) {
this.host.jqxToolBar('initTools', arg);
}
else {
return this.host.jqxToolBar('initTools');
}
}
minimizeWidth(arg) {
if (arg !== undefined) {
this.host.jqxToolBar('minimizeWidth', arg);
}
else {
return this.host.jqxToolBar('minimizeWidth');
}
}
minWidth(arg) {
if (arg !== undefined) {
this.host.jqxToolBar('minWidth', arg);
}
else {
return this.host.jqxToolBar('minWidth');
}
}
maxWidth(arg) {
if (arg !== undefined) {
this.host.jqxToolBar('maxWidth', arg);
}
else {
return this.host.jqxToolBar('maxWidth');
}
}
rtl(arg) {
if (arg !== undefined) {
this.host.jqxToolBar('rtl', arg);
}
else {
return this.host.jqxToolBar('rtl');
}
}
tools(arg) {
if (arg !== undefined) {
this.host.jqxToolBar('tools', arg);
}
else {
return this.host.jqxToolBar('tools');
}
}
theme(arg) {
if (arg !== undefined) {
this.host.jqxToolBar('theme', arg);
}
else {
return this.host.jqxToolBar('theme');
}
}
width(arg) {
if (arg !== undefined) {
this.host.jqxToolBar('width', arg);
}
else {
return this.host.jqxToolBar('width');
}
}
// jqxToolBarComponent functions
addTool(type, position, separator, menuToolIninitialization) {
this.host.jqxToolBar('addTool', type, position, separator, menuToolIninitialization);
}
disableTool(index, disable) {
this.host.jqxToolBar('disableTool', index, disable);
}
destroy() {
this.host.jqxToolBar('destroy');
}
destroyTool(index) {
this.host.jqxToolBar('destroyTool', index);
}
getTools() {
return this.host.jqxToolBar('getTools');
}
render() {
this.host.jqxToolBar('render');
}
refresh() {
this.host.jqxToolBar('refresh');
}
__wireEvents__() {
this.host.on('close', (eventData) => { this.onClose.emit(eventData); });
this.host.on('open', (eventData) => { this.onOpen.emit(eventData); });
}
} //jqxToolBarComponent
jqxToolBarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: jqxToolBarComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
jqxToolBarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: jqxToolBarComponent, selector: "jqxToolbar", inputs: { attrDisabled: ["disabled", "attrDisabled"], attrInitTools: ["initTools", "attrInitTools"], attrMinimizeWidth: ["minimizeWidth", "attrMinimizeWidth"], attrMinWidth: ["minWidth", "attrMinWidth"], attrMaxWidth: ["maxWidth", "attrMaxWidth"], attrRtl: ["rtl", "attrRtl"], attrTools: ["tools", "attrTools"], attrTheme: ["theme", "attrTheme"], attrWidth: ["width", "attrWidth"], attrHeight: ["height", "attrHeight"], autoCreate: ["auto-create", "autoCreate"] }, outputs: { onClose: "onClose", onOpen: "onOpen" }, 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: jqxToolBarComponent, decorators: [{
type: Component,
args: [{
selector: 'jqxToolbar',
template: '<div><ng-content></ng-content></div>'
}]
}], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { attrDisabled: [{
type: Input,
args: ['disabled']
}], attrInitTools: [{
type: Input,
args: ['initTools']
}], attrMinimizeWidth: [{
type: Input,
args: ['minimizeWidth']
}], attrMinWidth: [{
type: Input,
args: ['minWidth']
}], attrMaxWidth: [{
type: Input,
args: ['maxWidth']
}], attrRtl: [{
type: Input,
args: ['rtl']
}], attrTools: [{
type: Input,
args: ['tools']
}], attrTheme: [{
type: Input,
args: ['theme']
}], attrWidth: [{
type: Input,
args: ['width']
}], attrHeight: [{
type: Input,
args: ['height']
}], autoCreate: [{
type: Input,
args: ['auto-create']
}], onClose: [{
type: Output
}], onOpen: [{
type: Output
}] } });
class jqxToolBarModule {
}
jqxToolBarModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: jqxToolBarModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
jqxToolBarModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: jqxToolBarModule, declarations: [jqxToolBarComponent], exports: [jqxToolBarComponent] });
jqxToolBarModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: jqxToolBarModule, imports: [[]] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: jqxToolBarModule, decorators: [{
type: NgModule,
args: [{
imports: [],
declarations: [jqxToolBarComponent],
exports: [jqxToolBarComponent]
}]
}] });
/**
* Generated bundle index. Do not edit.
*/
export { jqxToolBarComponent, jqxToolBarModule };