/*! * devextreme-angular-test * Version: 17.2.8 * Build date: Mon Feb 05 2018 * * Copyright (c) 2012 - 2018 Developer Express Inc. ALL RIGHTS RESERVED * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file in the root of the project for details. * * https://github.com/DevExpress/devextreme-angular */ import { Component, NgModule, ElementRef, NgZone, Input, Output, OnDestroy, Injector, EventEmitter, OnChanges, DoCheck, SimpleChanges, ContentChildren, QueryList } from '@angular/core'; import DevExpress from 'devextreme/bundles/dx.all'; import DxResponsiveBox from 'devextreme/ui/responsive_box'; import { DxComponent } from '../core/component'; import { DxTemplateHost } from '../core/template-host'; import { DxTemplateModule } from '../core/template'; import { EventsRegistrator } from '../core/events-strategy'; import { NestedOptionHost } from '../core/nested-option'; import { WatcherHelper } from '../core/watcher-helper'; import { IterableDifferHelper } from '../core/iterable-differ-helper'; import { DxiColModule } from './nested/col-dxi'; import { DxiItemModule } from './nested/item-dxi'; import { DxiLocationModule } from './nested/location-dxi'; import { DxiRowModule } from './nested/row-dxi'; import { DxiColComponent } from './nested/col-dxi'; import { DxiItemComponent } from './nested/item-dxi'; import { DxiRowComponent } from './nested/row-dxi'; /** * The ResponsiveBox widget allows you to create an application or a website with a layout adapted to different screen sizes. */ @Component({ selector: 'dx-responsive-box', template: '', providers: [ DxTemplateHost, WatcherHelper, NestedOptionHost, IterableDifferHelper ] }) export class DxResponsiveBoxComponent extends DxComponent implements OnDestroy, OnChanges, DoCheck { instance: DxResponsiveBox; /** * Specifies the collection of columns for the grid used to position layout elements. */ @Input() get cols(): Array { return this._getOption('cols'); } set cols(value: Array) { this._setOption('cols', value); } /** * A data source used to fetch data to be displayed by the widget. */ @Input() get dataSource(): DevExpress.data.DataSource| DevExpress.data.DataSourceOptions| string| Array { return this._getOption('dataSource'); } set dataSource(value: DevExpress.data.DataSource| DevExpress.data.DataSourceOptions| string| Array) { this._setOption('dataSource', value); } /** * Specifies whether the widget responds to user interaction. */ @Input() get disabled(): boolean { return this._getOption('disabled'); } set disabled(value: boolean) { this._setOption('disabled', value); } /** * Specifies the attributes to be attached to the widget's root element. */ @Input() get elementAttr(): any { return this._getOption('elementAttr'); } set elementAttr(value: any) { this._setOption('elementAttr', value); } /** * Specifies the widget's height. */ @Input() get height(): number| Function| string { return this._getOption('height'); } set height(value: number| Function| string) { this._setOption('height', value); } /** * Specifies whether the widget changes its state when a user pauses on it. */ @Input() get hoverStateEnabled(): boolean { return this._getOption('hoverStateEnabled'); } set hoverStateEnabled(value: boolean) { this._setOption('hoverStateEnabled', value); } /** * The time period in milliseconds before the onItemHold event is raised. */ @Input() get itemHoldTimeout(): number { return this._getOption('itemHoldTimeout'); } set itemHoldTimeout(value: number) { this._setOption('itemHoldTimeout', value); } /** * An array of items displayed by the widget. */ @Input() get items(): Array, template?: any, text?: string, visible?: boolean }> { return this._getOption('items'); } set items(value: Array, template?: any, text?: string, visible?: boolean }>) { this._setOption('items', value); } /** * Specifies a custom template for an item. */ @Input() get itemTemplate(): any { return this._getOption('itemTemplate'); } set itemTemplate(value: any) { this._setOption('itemTemplate', value); } /** * Specifies the collection of rows for the grid used to position layout elements. */ @Input() get rows(): Array { return this._getOption('rows'); } set rows(value: Array) { this._setOption('rows', value); } /** * Switches the widget to a right-to-left representation. */ @Input() get rtlEnabled(): boolean { return this._getOption('rtlEnabled'); } set rtlEnabled(value: boolean) { this._setOption('rtlEnabled', value); } /** * Specifies the function returning the size qualifier depending on the screen's width. */ @Input() get screenByWidth(): Function { return this._getOption('screenByWidth'); } set screenByWidth(value: Function) { this._setOption('screenByWidth', value); } /** * Decides on which screens all layout elements should be arranged in a single column. */ @Input() get singleColumnScreen(): string { return this._getOption('singleColumnScreen'); } set singleColumnScreen(value: string) { this._setOption('singleColumnScreen', value); } /** * Specifies whether the widget is visible. */ @Input() get visible(): boolean { return this._getOption('visible'); } set visible(value: boolean) { this._setOption('visible', value); } /** * Specifies the widget's width. */ @Input() get width(): number| Function| string { return this._getOption('width'); } set width(value: number| Function| string) { this._setOption('width', value); } /** * A handler for the contentReady event. Executed when the widget's content is ready. This handler may be executed multiple times during the widget's lifetime depending on the number of times its content changes. */ @Output() onContentReady: EventEmitter; /** * A handler for the disposing event. Executed when the widget is removed from the DOM using the remove(), empty(), or html() jQuery methods only. */ @Output() onDisposing: EventEmitter; /** * A handler for the initialized event. Executed only once, after the widget is initialized. */ @Output() onInitialized: EventEmitter; /** * A handler for the itemClick event. */ @Output() onItemClick: EventEmitter; /** * A handler for the itemContextMenu event. */ @Output() onItemContextMenu: EventEmitter; /** * A handler for the itemHold event. */ @Output() onItemHold: EventEmitter; /** * A handler for the itemRendered event. */ @Output() onItemRendered: EventEmitter; /** * A handler for the optionChanged event. Executed after an option of the widget is changed. */ @Output() onOptionChanged: EventEmitter; /** * A handler for the colsChange event. */ @Output() colsChange: EventEmitter>; /** * A handler for the dataSourceChange event. */ @Output() dataSourceChange: EventEmitter>; /** * A handler for the disabledChange event. */ @Output() disabledChange: EventEmitter; /** * A handler for the elementAttrChange event. */ @Output() elementAttrChange: EventEmitter; /** * A handler for the heightChange event. */ @Output() heightChange: EventEmitter; /** * A handler for the hoverStateEnabledChange event. */ @Output() hoverStateEnabledChange: EventEmitter; /** * A handler for the itemHoldTimeoutChange event. */ @Output() itemHoldTimeoutChange: EventEmitter; /** * A handler for the itemsChange event. */ @Output() itemsChange: EventEmitter, template?: any, text?: string, visible?: boolean }>>; /** * A handler for the itemTemplateChange event. */ @Output() itemTemplateChange: EventEmitter; /** * A handler for the rowsChange event. */ @Output() rowsChange: EventEmitter>; /** * A handler for the rtlEnabledChange event. */ @Output() rtlEnabledChange: EventEmitter; /** * A handler for the screenByWidthChange event. */ @Output() screenByWidthChange: EventEmitter; /** * A handler for the singleColumnScreenChange event. */ @Output() singleColumnScreenChange: EventEmitter; /** * A handler for the visibleChange event. */ @Output() visibleChange: EventEmitter; /** * A handler for the widthChange event. */ @Output() widthChange: EventEmitter; @ContentChildren(DxiColComponent) get colsChildren(): QueryList { return this._getOption('cols'); } set colsChildren(value) { this.setChildren('cols', value); } @ContentChildren(DxiItemComponent) get itemsChildren(): QueryList { return this._getOption('items'); } set itemsChildren(value) { this.setChildren('items', value); } @ContentChildren(DxiRowComponent) get rowsChildren(): QueryList { return this._getOption('rows'); } set rowsChildren(value) { this.setChildren('rows', value); } constructor(elementRef: ElementRef, ngZone: NgZone, templateHost: DxTemplateHost, injector: Injector, private _watcherHelper: WatcherHelper, private _idh: IterableDifferHelper, optionHost: NestedOptionHost) { super(elementRef, ngZone, templateHost, _watcherHelper); injector.get(EventsRegistrator); this._createEventEmitters([ { subscribe: 'contentReady', emit: 'onContentReady' }, { subscribe: 'disposing', emit: 'onDisposing' }, { subscribe: 'initialized', emit: 'onInitialized' }, { subscribe: 'itemClick', emit: 'onItemClick' }, { subscribe: 'itemContextMenu', emit: 'onItemContextMenu' }, { subscribe: 'itemHold', emit: 'onItemHold' }, { subscribe: 'itemRendered', emit: 'onItemRendered' }, { subscribe: 'optionChanged', emit: 'onOptionChanged' }, { emit: 'colsChange' }, { emit: 'dataSourceChange' }, { emit: 'disabledChange' }, { emit: 'elementAttrChange' }, { emit: 'heightChange' }, { emit: 'hoverStateEnabledChange' }, { emit: 'itemHoldTimeoutChange' }, { emit: 'itemsChange' }, { emit: 'itemTemplateChange' }, { emit: 'rowsChange' }, { emit: 'rtlEnabledChange' }, { emit: 'screenByWidthChange' }, { emit: 'singleColumnScreenChange' }, { emit: 'visibleChange' }, { emit: 'widthChange' } ]); this._idh.setHost(this); optionHost.setHost(this); } protected _createInstance(element, options) { return new DxResponsiveBox(element, options); } ngOnDestroy() { this._destroyWidget(); } ngOnChanges(changes: SimpleChanges) { super.ngOnChanges(changes); this.setupChanges('cols', changes); this.setupChanges('dataSource', changes); this.setupChanges('items', changes); this.setupChanges('rows', changes); } setupChanges(prop: string, changes: SimpleChanges) { if (!(prop in this._optionsToUpdate)) { this._idh.setup(prop, changes); } } ngDoCheck() { this._idh.doCheck('cols'); this._idh.doCheck('dataSource'); this._idh.doCheck('items'); this._idh.doCheck('rows'); this._watcherHelper.checkWatchers(); super.ngDoCheck(); } _setOption(name: string, value: any) { let isSetup = this._idh.setupSingle(name, value); let isChanged = this._idh.getChanges(name, value) !== null; if (isSetup || isChanged) { super._setOption(name, value); } } } @NgModule({ imports: [ DxiColModule, DxiItemModule, DxiLocationModule, DxiRowModule, DxTemplateModule ], declarations: [ DxResponsiveBoxComponent ], exports: [ DxResponsiveBoxComponent, DxiColModule, DxiItemModule, DxiLocationModule, DxiRowModule, DxTemplateModule ], providers: [EventsRegistrator] }) export class DxResponsiveBoxModule { }