@lidorsystems/integralui-web
Version:
IntegralUI Web - Advanced UI Components for Angular
15 lines (12 loc) • 28.8 kB
JavaScript
/*
filename: integralui.toolitem.js
version : 20.2.0
Copyright © 2016-2020 Lidor Systems. All rights reserved.
This file is part of the "IntegralUI Web" Library.
The contents of this file are subject to the IntegralUI Web License, and may not be used except in compliance with the License.
A copy of the License should have been installed in the product's root installation directory or it can be found at
http://www.lidorsystems.com/products/web/studio/license-agreement.aspx.
This SOFTWARE is provided "AS IS", WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language
governing rights and limitations under the License. Any infringement will be prosecuted under applicable laws.
*/
"use strict";var __extends=this&&this.__extends||function(){var e=function(t,i){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)if(t.hasOwnProperty(i))e[i]=t[i]})(t,i)};return function(t,i){e(t,i);function n(){this.constructor=t}t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}();Object.defineProperty(exports,"__esModule",{value:!0});var core_1=require("@angular/core"),integralui_core_1=require("./integralui.core"),integralui_datepicker_1=require("./integralui.datepicker"),integralui_common_service_1=require("../services/integralui.common.service"),i0=require("@angular/core"),i1=require("../services/integralui.common.service"),i2=require("./integralui.core"),i3=require("@angular/common"),i4=require("./integralui.checkbox"),i5=require("@angular/forms"),i6=require("./integralui.listscroller"),i7=require("./integralui.progressbar"),i8=require("./integralui.rating"),i9=require("./integralui.slider"),_c0=["content"];function IntegralUIToolItem_div_1_div_2_span_1_Template(e,t){if(1&e)i0.ɵɵelement(0,"span",19);if(2&e){var i=i0.ɵɵnextContext(3);i0.ɵɵproperty("ngClass",i.data.icon)}}function IntegralUIToolItem_div_1_div_2_span_2_Template(e,t){if(1&e){i0.ɵɵelementStart(0,"span",20);i0.ɵɵtext(1);i0.ɵɵelementEnd()}if(2&e){var i=i0.ɵɵnextContext(3);i0.ɵɵadvance(1);i0.ɵɵtextInterpolate(i.data.text)}}var _c1=function(e){return{"iui-toolitem-button-leave":e}};function IntegralUIToolItem_div_1_div_2_Template(e,t){if(1&e){i0.ɵɵelementStart(0,"div",16);i0.ɵɵtemplate(1,IntegralUIToolItem_div_1_div_2_span_1_Template,1,1,"span",17);i0.ɵɵtemplate(2,IntegralUIToolItem_div_1_div_2_span_2_Template,2,1,"span",18);i0.ɵɵelementEnd()}if(2&e){var i=i0.ɵɵnextContext(2);i0.ɵɵproperty("ngClass",i0.ɵɵpureFunction1(3,_c1,i.isLeaving));i0.ɵɵadvance(1);i0.ɵɵproperty("ngIf",i.data.icon);i0.ɵɵadvance(1);i0.ɵɵproperty("ngIf",i.data.text)}}function IntegralUIToolItem_div_1_div_3_Template(e,t){if(1&e){var i=i0.ɵɵgetCurrentView();i0.ɵɵelementStart(0,"div",21);i0.ɵɵelementStart(1,"iui-checkbox",22);i0.ɵɵlistener("ngModelChange",function(e){i0.ɵɵrestoreView(i);var t=i0.ɵɵnextContext(2);return t.data[t.getDataField("value")]=e})("checkedChanged",function(e){i0.ɵɵrestoreView(i);return i0.ɵɵnextContext(2).itemCheckedChanged(e)})("checkStateChanged",function(e){i0.ɵɵrestoreView(i);return i0.ɵɵnextContext(2).itemCheckStateChanged(e)});i0.ɵɵtext(2);i0.ɵɵelementEnd();i0.ɵɵelementEnd()}if(2&e){var n=i0.ɵɵnextContext(2);i0.ɵɵadvance(1);i0.ɵɵproperty("allowAnimation",!0)("controlStyle",n.getToolItemStyle())("threeState",n.currentSettings&&void 0!=n.currentSettings.threeState?n.currentSettings.threeState:!1)("ngModel",n.data[n.getDataField("value")]);i0.ɵɵadvance(1);i0.ɵɵtextInterpolate(n.data.text)}}var _c2=function(e){return{"iui-toolitem-datepicker-button-hover":e}};function IntegralUIToolItem_div_1_div_4_Template(e,t){if(1&e){i0.ɵɵelementStart(0,"div",23);i0.ɵɵelementStart(1,"div",24);i0.ɵɵelement(2,"span");i0.ɵɵelementEnd();i0.ɵɵelementStart(3,"span",20);i0.ɵɵtext(4);i0.ɵɵelementEnd();i0.ɵɵelementEnd()}if(2&e){var i=i0.ɵɵnextContext(2);i0.ɵɵadvance(1);i0.ɵɵproperty("ngClass",i0.ɵɵpureFunction1(2,_c2,i.isHovered()));i0.ɵɵadvance(3);i0.ɵɵtextInterpolate(i.getValue())}}var _c3=function(e){return{"iui-toolitem-dropdown-button-hover":e}},_c4=function(e,t){return{height:e,opacity:t}};function IntegralUIToolItem_div_1_div_5_Template(e,t){if(1&e){i0.ɵɵelementStart(0,"div",25);i0.ɵɵelementStart(1,"div",26);i0.ɵɵelement(2,"span");i0.ɵɵelementEnd();i0.ɵɵelementStart(3,"span",27);i0.ɵɵtext(4);i0.ɵɵelementEnd();i0.ɵɵelementEnd()}if(2&e){var i=i0.ɵɵnextContext(2);i0.ɵɵadvance(1);i0.ɵɵproperty("ngClass",i0.ɵɵpureFunction1(3,_c3,i.isHovered()));i0.ɵɵadvance(2);i0.ɵɵproperty("ngStyle",i0.ɵɵpureFunction2(5,_c4,i.toolItemHeight,i.toolItemStyleOpacity));i0.ɵɵadvance(1);i0.ɵɵtextInterpolate(i.value)}}function IntegralUIToolItem_div_1_div_6_img_1_Template(e,t){if(1&e)i0.ɵɵelement(0,"img",30);if(2&e){var i=t.$implicit;i0.ɵɵproperty("src",i.src,i0.ɵɵsanitizeUrl)}}function IntegralUIToolItem_div_1_div_6_Template(e,t){if(1&e){i0.ɵɵelementStart(0,"div",28);i0.ɵɵtemplate(1,IntegralUIToolItem_div_1_div_6_img_1_Template,1,1,"img",29);i0.ɵɵelementEnd()}if(2&e){var i=i0.ɵɵnextContext(2);i0.ɵɵadvance(1);i0.ɵɵproperty("ngForOf",i.data[i.getDataField("value")])}}function IntegralUIToolItem_div_1_div_7_Template(e,t){if(1&e){i0.ɵɵelementStart(0,"div");i0.ɵɵelementStart(1,"span",20);i0.ɵɵtext(2);i0.ɵɵelementEnd();i0.ɵɵelementEnd()}if(2&e){var i=i0.ɵɵnextContext(2);i0.ɵɵadvance(2);i0.ɵɵtextInterpolate(i.data.text)}}function IntegralUIToolItem_div_1_div_8_ng_template_2_Template(e,t){if(1&e){i0.ɵɵelementStart(0,"div",32);i0.ɵɵelement(1,"div",19);i0.ɵɵelementEnd()}if(2&e){var i=t.$implicit,n=i0.ɵɵnextContext(3);i0.ɵɵadvance(1);i0.ɵɵproperty("ngClass",n.getListScrollItemIcon(i))}}var _c5=function(){return[]},_c6=function(){return{}};function IntegralUIToolItem_div_1_div_8_Template(e,t){if(1&e){var i=i0.ɵɵgetCurrentView();i0.ɵɵelementStart(0,"div");i0.ɵɵelementStart(1,"iui-listscroller",31);i0.ɵɵlistener("selectionChanged",function(e){i0.ɵɵrestoreView(i);return i0.ɵɵnextContext(2).listScrollerItemChanged(e)});i0.ɵɵtemplate(2,IntegralUIToolItem_div_1_div_8_ng_template_2_Template,2,1,"ng-template");i0.ɵɵelementEnd();i0.ɵɵelementEnd()}if(2&e){var n=i0.ɵɵnextContext(2);i0.ɵɵadvance(1);i0.ɵɵproperty("controlStyle",n.getToolItemStyle())("enabled",n.enabled)("items",n.currentSettings&&n.currentSettings.items?n.currentSettings.items:i0.ɵɵpureFunction0(4,_c5))("itemSize",n.currentSettings&&n.currentSettings.itemSize?n.currentSettings.itemSize:i0.ɵɵpureFunction0(5,_c6))}}function IntegralUIToolItem_div_1_input_9_Template(e,t){if(1&e){var i=i0.ɵɵgetCurrentView();i0.ɵɵelementStart(0,"input",33);i0.ɵɵlistener("ngModelChange",function(e){i0.ɵɵrestoreView(i);var t=i0.ɵɵnextContext(2);return t.data[t.getDataField("value")]=e})("change",function(e){i0.ɵɵrestoreView(i);return i0.ɵɵnextContext(2).numericValueChange(e.target.value)})("DOMMouseScroll",function(e){i0.ɵɵrestoreView(i);return i0.ɵɵnextContext(2).editorMouseWheel(e)})("mousewheel",function(e){i0.ɵɵrestoreView(i);return i0.ɵɵnextContext(2).editorMouseWheel(e)})("dragstart",function(e){i0.ɵɵrestoreView(i);return i0.ɵɵnextContext(2).editorPreventDragStart(e)});i0.ɵɵelementEnd()}if(2&e){var n=i0.ɵɵnextContext(2);i0.ɵɵproperty("ngModel",n.data[n.getDataField("value")])}}function IntegralUIToolItem_div_1_div_10_Template(e,t){if(1&e){i0.ɵɵelementStart(0,"div",34);i0.ɵɵelement(1,"iui-progressbar",35);i0.ɵɵelementEnd()}if(2&e){var i=i0.ɵɵnextContext(2);i0.ɵɵadvance(1);i0.ɵɵproperty("allowAnimation",!0)("controlStyle",i.getToolItemStyle())("value",i.data[i.getDataField("value")])}}function IntegralUIToolItem_div_1_div_11_Template(e,t){if(1&e){var i=i0.ɵɵgetCurrentView();i0.ɵɵelementStart(0,"div",36);i0.ɵɵelementStart(1,"iui-rating",37);i0.ɵɵlistener("ngModelChange",function(e){i0.ɵɵrestoreView(i);var t=i0.ɵɵnextContext(2);return t.data[t.getDataField("value")]=e})("valueChanged",function(){i0.ɵɵrestoreView(i);return i0.ɵɵnextContext(2).callValueChanged()});i0.ɵɵelementEnd();i0.ɵɵelementEnd()}if(2&e){var n=i0.ɵɵnextContext(2);i0.ɵɵadvance(1);i0.ɵɵproperty("controlStyle",n.getToolItemStyle())("enabled",n.enabled)("ngModel",n.data[n.getDataField("value")])("division",n.currentSettings?n.currentSettings.division:1)("increment",n.currentSettings?n.currentSettings.increment:0)("max",n.currentSettings?n.currentSettings.max:5)("stepSize",n.currentSettings?n.currentSettings.stepSize:16)}}var _c7=function(e){return{"iui-toolitem-separator-vertical":e}};function IntegralUIToolItem_div_1_div_12_Template(e,t){if(1&e)i0.ɵɵelement(0,"div",38);if(2&e){var i=i0.ɵɵnextContext(2);i0.ɵɵproperty("ngClass",i0.ɵɵpureFunction1(1,_c7,i.currentSettings&&1==i.currentSettings.orientation))}}function IntegralUIToolItem_div_1_div_13_Template(e,t){if(1&e){var i=i0.ɵɵgetCurrentView();i0.ɵɵelementStart(0,"div",39);i0.ɵɵelementStart(1,"iui-slider",40);i0.ɵɵlistener("ngModelChange",function(e){i0.ɵɵrestoreView(i);var t=i0.ɵɵnextContext(2);return t.data[t.getDataField("value")]=e})("valueChanged",function(){i0.ɵɵrestoreView(i);return i0.ɵɵnextContext(2).callValueChanged()});i0.ɵɵelementEnd();i0.ɵɵelementEnd()}if(2&e){var n=i0.ɵɵnextContext(2);i0.ɵɵadvance(1);i0.ɵɵproperty("allowAnimation",!0)("enabled",n.enabled)("controlStyle",n.getToolItemStyle())("ngModel",n.data[n.getDataField("value")])}}function IntegralUIToolItem_div_1_div_14_Template(e,t){if(1&e){var i=i0.ɵɵgetCurrentView();i0.ɵɵelementStart(0,"div");i0.ɵɵelementStart(1,"input",41);i0.ɵɵlistener("ngModelChange",function(e){i0.ɵɵrestoreView(i);var t=i0.ɵɵnextContext(2);return t.data[t.getDataField("text")]=e})("change",function(e){i0.ɵɵrestoreView(i);return i0.ɵɵnextContext(2).itemTextChanged(e)});i0.ɵɵelementEnd();i0.ɵɵelementEnd()}if(2&e){var n=i0.ɵɵnextContext(2);i0.ɵɵadvance(1);i0.ɵɵproperty("ngModel",n.data[n.getDataField("text")])}}function IntegralUIToolItem_div_1_div_15_Template(e,t){if(1&e){i0.ɵɵelementStart(0,"div");i0.ɵɵprojection(1);i0.ɵɵelementEnd()}}var _c8=function(e){return{"margin-top":e,height:"100%"}};function IntegralUIToolItem_div_1_Template(e,t){if(1&e){i0.ɵɵelementStart(0,"div",2,3);i0.ɵɵtemplate(2,IntegralUIToolItem_div_1_div_2_Template,3,5,"div",4);i0.ɵɵtemplate(3,IntegralUIToolItem_div_1_div_3_Template,3,5,"div",5);i0.ɵɵtemplate(4,IntegralUIToolItem_div_1_div_4_Template,5,4,"div",6);i0.ɵɵtemplate(5,IntegralUIToolItem_div_1_div_5_Template,5,8,"div",7);i0.ɵɵtemplate(6,IntegralUIToolItem_div_1_div_6_Template,2,1,"div",8);i0.ɵɵtemplate(7,IntegralUIToolItem_div_1_div_7_Template,3,1,"div",9);i0.ɵɵtemplate(8,IntegralUIToolItem_div_1_div_8_Template,3,6,"div",9);i0.ɵɵtemplate(9,IntegralUIToolItem_div_1_input_9_Template,1,1,"input",10);i0.ɵɵtemplate(10,IntegralUIToolItem_div_1_div_10_Template,2,3,"div",11);i0.ɵɵtemplate(11,IntegralUIToolItem_div_1_div_11_Template,2,7,"div",12);i0.ɵɵtemplate(12,IntegralUIToolItem_div_1_div_12_Template,1,3,"div",13);i0.ɵɵtemplate(13,IntegralUIToolItem_div_1_div_13_Template,2,4,"div",14);i0.ɵɵtemplate(14,IntegralUIToolItem_div_1_div_14_Template,2,1,"div",9);i0.ɵɵtemplate(15,IntegralUIToolItem_div_1_div_15_Template,2,0,"div",15);i0.ɵɵelementEnd()}if(2&e){var i=i0.ɵɵnextContext();i0.ɵɵproperty("ngSwitch",i.type)("ngStyle",i0.ɵɵpureFunction1(15,_c8,i.contentMargin.top+"px"));i0.ɵɵadvance(2);i0.ɵɵproperty("ngSwitchCase",0);i0.ɵɵadvance(1);i0.ɵɵproperty("ngSwitchCase",1);i0.ɵɵadvance(1);i0.ɵɵproperty("ngSwitchCase",2);i0.ɵɵadvance(1);i0.ɵɵproperty("ngSwitchCase",3);i0.ɵɵadvance(1);i0.ɵɵproperty("ngSwitchCase",4);i0.ɵɵadvance(1);i0.ɵɵproperty("ngSwitchCase",5);i0.ɵɵadvance(1);i0.ɵɵproperty("ngSwitchCase",6);i0.ɵɵadvance(1);i0.ɵɵproperty("ngSwitchCase",7);i0.ɵɵadvance(1);i0.ɵɵproperty("ngSwitchCase",8);i0.ɵɵadvance(1);i0.ɵɵproperty("ngSwitchCase",9);i0.ɵɵadvance(1);i0.ɵɵproperty("ngSwitchCase",10);i0.ɵɵadvance(1);i0.ɵɵproperty("ngSwitchCase",11);i0.ɵɵadvance(1);i0.ɵɵproperty("ngSwitchCase",12)}}var _c9=["*"],IntegralUIToolItem=function(e){__extends(t,e);function t(t,i,n,a){var r=e.call(this,t,i)||this;r.elemRef=t;r.commonService=i;r.baseService=n;r.cmpResolver=a;r.dataFields={};r.currentSettings={};r.contentMargin={top:0,left:0};r.isPopupDelayed=!1;r.updateTimer=null;r.calendarRef=null;r.calendar=null;r.dropListRef=null;r.dropList=null;r.parentCtrl=null;r.isLeaving=!1;r.toolItemHeight="auto";r.toolItemStyleOpacity=1;r.type=integralui_core_1.IntegralUIToolItemType.Label;r.itemClick=new core_1.EventEmitter;r.valueChanging=new core_1.EventEmitter;r.valueChanged=new core_1.EventEmitter;return r}Object.defineProperty(t.prototype,"settings",{get:function(){return this.currentSettings},set:function(e){if(this.currentSettings!=e)this.currentSettings=e},enumerable:!0,configurable:!0});t.prototype.ngOnInit=function(){this.parentCtrl=this.baseService.getComponent();this.dataFields=this.parentCtrl?this.parentCtrl.getDataFields():{};this.generalClassName="iui-toolitem";this.contentClassName=this.generalClassName+"-content";this.initStyle()};t.prototype.ngAfterViewInit=function(){var e=this,t=setTimeout(function(){e.value=e.getValue();clearTimeout(t)},1);e.updateLayout()};t.prototype.ngOnDestroy=function(){this.removeCalendar();this.removeDropList();this.resetLayoutTimer()};t.prototype.ngAfterContentChecked=function(){this.clientRect={width:this.elemRef.nativeElement.firstElementChild.clientWidth,height:this.elemRef.nativeElement.firstElementChild.clientHeight};if(this.clientRect.width!=this.prevClientRect.width){this.updateLayout();this.prevClientRect.width=this.clientRect.width}else if(this.clientRect.height!=this.prevClientRect.height){this.updateLayout();this.prevClientRect.height=this.clientRect.height}};t.prototype.getProgressValue=function(){if(this.data){var e=void 0!=this.data.min?this.data.min:0,t=void 0!=this.data.max?this.data.max:100,i=this.data[this.dataFields.value];if(i&&!isNaN(i)&&!isNaN(t)&&t>0){return 100*Math.min(Math.max(i,e),t)/t}}return 0};t.prototype.getItemClass=function(){var e="";if(this.data){var t=this.data.settings||{};switch(this.type){case integralui_core_1.IntegralUIToolItemType.CheckBox:e="iui-toolitem-checkbox";e+=t.general?" "+t.general:"";switch(this.getValue()){case"checked":e+=t.checked?" "+t.checked:" iui-toolitem-checkbox-checked";break;case"indeterminate":e+=t.indeterminate?" "+t.indeterminate:" iui-toolitem-checkbox-indeterminate";break;default:e+=t.unchecked?" "+t.unchecked:" iui-toolitem-checkbox-unchecked"}}}return e};t.prototype.getValue=function(){var e=null;if(this.data){e=void 0!=this.data[this.dataFields.value]?this.data[this.dataFields.value]:null;switch(this.type){case integralui_core_1.IntegralUIToolItemType.Button:e=void 0!=this.data[this.dataFields.text]?this.data[this.dataFields.text]:"";break;case integralui_core_1.IntegralUIToolItemType.CheckBox:if(this.data.settings)if("checked"==e||1==e)e="checked";else if(this.data.settings.threeState&&"indeterminate"==e)e="indeterminate";else e="unchecked";break;case integralui_core_1.IntegralUIToolItemType.Date:var t="en-US",i={year:"numeric",month:"numeric",day:"numeric"};if(this.data.settings){t=this.data.settings.locales?this.data.settings.locales:"en-US";switch(this.data.settings.format){case integralui_core_1.IntegralUIDateFormat.Long:i.weekday="long";break;case integralui_core_1.IntegralUIDateFormat.Custom:i=this.data.settings.formatOptions}}e=e?e.toLocaleString(t,i):"";break;case integralui_core_1.IntegralUIToolItemType.DropList:if(this.commonService.isObject(e))e=e?e.text:"";else e=void 0!=e&&this.currentSettings?this.findItemByValue(e,this.currentSettings.items||[]):"";e=!e||""==e?this.currentSettings.placeHolder:e;this.toolItemHeight=!e||""==e?"20px":"auto";this.toolItemStyleOpacity=this.currentSettings&&(""==e||e==this.currentSettings.placeHolder)?.5:1;break;case integralui_core_1.IntegralUIToolItemType.Image:e=Array.isArray(e)?e:[{src:e}];break;case integralui_core_1.IntegralUIToolItemType.Numeric:e=void 0!=this.data[this.dataFields.value]?this.data[this.dataFields.value]:"";break;case integralui_core_1.IntegralUIToolItemType.Progress:e=this.getProgressValue();break;case integralui_core_1.IntegralUIToolItemType.TextBox:e=void 0!=this.data[this.dataFields.text]?this.data[this.dataFields.text]:""}}return e};t.prototype.findItemByValue=function(e,t){for(var i="",n=0;n<t.length;n++)if(void 0!=t[n].value&&t[n].value==e){i=void 0!=t[n].text&&""!=t[n].text?t[n].text:t[n].value.toString();break}return i};t.prototype.callValueChanging=function(e){var t={cancel:!1,data:this.data,text:this.data[this.dataFields.text],value:void 0!=e?e:this.data[this.dataFields.value]};this.valueChanging.emit(t);return t.cancel};t.prototype.callValueChanged=function(){var e={data:this.data,text:this.data[this.dataFields.text],value:this.data[this.dataFields.value]};this.valueChanged.emit(e)};t.prototype.itemCheckedChanged=function(e){var t={data:this.data,text:this.data[this.dataFields.text],value:e.checked};this.valueChanged.emit(t)};t.prototype.itemCheckStateChanged=function(e){var t={data:this.data,text:this.data[this.dataFields.text],value:e.checkState};this.valueChanged.emit(t)};t.prototype.itemTextChanged=function(e){var t={data:this.data,text:this.data[this.dataFields.text],value:this.data[this.dataFields.text]};this.valueChanged.emit(t)};t.prototype.numericValueChange=function(e){if(e&&!isNaN(e)){var t=Number(e),i=this.currentSettings&&void 0!=this.currentSettings.min?this.currentSettings.min:-9999999,n=this.currentSettings&&void 0!=this.currentSettings.max?this.currentSettings.max:9999999;this.data[this.dataFields.value]=Math.min(Math.max(t,i),n);this.callValueChanged()}};t.prototype.editorMouseWheel=function(e){e.stopPropagation()};t.prototype.editorPreventDragStart=function(e){e.preventDefault();e.stopPropagation()};t.prototype.onItemClicked=function(e){if(this.type!=integralui_core_1.IntegralUIToolItemType.Separator)this.itemClick.emit({data:this.data});e.stopPropagation()};t.prototype.onMouseEnter=function(e){if(this.isEnabled){this.state|=integralui_core_1.IntegralUIObjectState.hovered;this.mouseEnter.emit(e)}this.isLeaving=!1;e.stopPropagation()};t.prototype.onMouseLeave=function(e){var t=this;if(t.isEnabled){t.state&=~integralui_core_1.IntegralUIObjectState.hovered;t.mouseLeave.emit(e);if(t.type==integralui_core_1.IntegralUIToolItemType.Button){t.isLeaving=!0;setTimeout(function(){t.isLeaving=!1},250)}}e.stopPropagation()};t.prototype.listScrollerItemChanged=function(e){if(this.data&&e.item){this.data[this.dataFields.text]=e.item.text;this.data[this.dataFields.value]=e.item.value;this.callValueChanged()}};t.prototype.itemMouseUp=function(e){if(1==e.which)switch(this.type){case integralui_core_1.IntegralUIToolItemType.Date:case integralui_core_1.IntegralUIToolItemType.DropList:this.openDropDown(e);break;case integralui_core_1.IntegralUIToolItemType.Numeric:case integralui_core_1.IntegralUIToolItemType.TextBox:}};t.prototype.openDropDown=function(e){if(!this.isPopupDelayed)switch(this.type){case integralui_core_1.IntegralUIToolItemType.Date:case integralui_core_1.IntegralUIToolItemType.DropList:this.showPopup(e)}e.stopPropagation()};t.prototype.addCalendar=function(){var e=this,t=this.parentCtrl?this.parentCtrl.appRef:null;if(t){e.removeCalendar();var i=e.cmpResolver.resolveComponentFactory(integralui_datepicker_1.IntegralUICalendarPopup);if(i){e.calendarRef=t.createComponent(i);if(e.calendarRef.instance)e.calendar=e.calendarRef.instance;if(e.calendar){e.calendar.closed.subscribe(function(t){e.removeCalendar()});e.calendar.dateChanged.subscribe(function(t){if(1!=e.callValueChanging(t.date)){e.data.value=t.date;e.callValueChanged()}e.isPopupDelayed=!0;setTimeout(function(){e.isPopupDelayed=!1;e.removeCalendar()},250)})}}}};t.prototype.addDropList=function(){var e=this,t=this.parentCtrl?this.parentCtrl.appRef:null;if(t){e.removeDropList();var i=e.cmpResolver.resolveComponentFactory(integralui_core_1.IntegralUIListPopup);if(i){e.dropListRef=t.createComponent(i);if(e.dropListRef.instance)e.dropList=e.dropListRef.instance;e.hideDropList();if(e.dropList){e.dropList.closed.subscribe(function(t){e.removeDropList()});e.dropList.selectionChanged.subscribe(function(t){if(t.item&&1!=e.callValueChanging(t.item.value)){e.data.value=t.item.value;e.value=e.getValue();e.callValueChanged()}e.isPopupDelayed=!0;setTimeout(function(){e.isPopupDelayed=!1;e.removeDropList()},250)})}}}};t.prototype.removeCalendar=function(){if(this.calendar){if(this.calendar.closed)this.calendar.closed.unsubscribe();if(this.calendar.dateChanged)this.calendar.dateChanged.unsubscribe()}if(this.calendarRef)this.calendarRef.destroy();this.calendar=null};t.prototype.removeDropList=function(){if(this.dropList){if(this.dropList.closed)this.dropList.closed.unsubscribe();if(this.dropList.selectionChanged)this.dropList.selectionChanged.unsubscribe()}if(this.dropListRef)this.dropListRef.destroy();this.dropList=null};t.prototype.hideCalendar=function(){if(this.calendar)this.calendar.display="none"};t.prototype.hideDropList=function(){if(this.dropList)this.dropList.display="none"};t.prototype.showPopup=function(e){if(this.data){var t=this.commonService.getShiftPos(),i=this.commonService.getPageRect(this.elemRef.nativeElement.firstElementChild);switch(this.type){case integralui_core_1.IntegralUIToolItemType.Date:this.addCalendar();if(this.calendar){this.calendar.allowAnimation=!1;this.calendar.calendarStyle=this.data.settings&&this.data.settings.style&&this.data.settings.style.calendar?this.data.settings.style.calendar:null;this.calendar.date=this.data.value;this.calendar.display="block";this.calendar.firstDayOfWeek=this.data.settings&&void 0!=this.data.settings.firstDayOfWeek?this.data.settings.firstDayOfWeek:integralui_core_1.IntegralUIWeekDays.Sunday;this.calendar.position={x:i.left+t.x+2,y:i.bottom+t.y};this.calendar.size=this.data.settings&&this.data.settings.calendarSize?this.data.settings.calendarSize:{width:250,height:200};if(this.allowAnimation)this.calendar.position.y-=2;this.calendar.refresh();this.calendar.open();this.calendar.focus()}break;case integralui_core_1.IntegralUIToolItemType.DropList:this.addDropList();if(this.dropList){this.dropList.allowAnimation=!1;this.dropList.display="block";this.dropList.items=this.data.settings&&this.data.settings.items?this.data.settings.items:[];this.dropList.listStyle=this.data.settings&&this.data.settings.style&&this.data.settings.style.list?this.data.settings.style.list:null;this.dropList.minWidth=this.data.settings&&this.data.settings.minWidth?this.data.settings.minWidth:i.width;this.dropList.maxVisibleItems=this.data.settings&&this.data.settings.maxVisibleItems?this.data.settings.maxVisibleItems:5;this.dropList.position={x:i.left+t.x+1,y:i.bottom+t.y};this.dropList.size={width:Math.max(i.width,this.dropList.minWidth)-2,height:0};this.dropList.refresh();this.dropList.open();this.dropList.focus()}}}};t.prototype.getDataField=function(e){switch(e){case"text":return this.dataFields.text;case"value":return this.dataFields.value}};t.prototype.isHovered=function(){return this.state&integralui_core_1.IntegralUIObjectState.hovered?!0:!1};t.prototype.resetLayoutTimer=function(){if(this.updateTimer)clearTimeout(this.updateTimer);this.updateTimer=null};t.prototype.updateLayout=function(){var e=this;e.resetLayoutTimer();e.updateTimer=setTimeout(function(){e.contentMargin.top=(e.clientRect.height-e.contentElem.nativeElement.firstElementChild.offsetHeight)/2;e.value=e.getValue();clearTimeout(e.updateTimer)},100)};t.prototype.getControlStyle=function(){var e={};if(this.data&&this.parentCtrl){var t=this.parentCtrl.getDataFields();e=this.data[t.style]||{}}if(this.ctrlSize.width>0)e.width=this.ctrlSize.width+"px";if(this.ctrlSize.height>0)e.height=this.ctrlSize.height+"px";return e};t.prototype.getProgressStyle=function(){return{width:this.getProgressValue()+"%","z-index":2}};t.prototype.getListScrollItemIcon=function(e){return this.currentSettings&&this.currentSettings.iconClass?this.currentSettings.iconClass+" "+e.icon:e.icon};t.prototype.getToolItemStyle=function(){var e={};if(this.data&&this.data.settings){var t=this.data.settings.style||{};switch(this.type){case integralui_core_1.IntegralUIToolItemType.Button:case integralui_core_1.IntegralUIToolItemType.CheckBox:case integralui_core_1.IntegralUIToolItemType.Progress:case integralui_core_1.IntegralUIToolItemType.Rating:case integralui_core_1.IntegralUIToolItemType.Slider:e=t}}return e};t.ɵfac=function(e){return new(e||t)(i0.ɵɵdirectiveInject(i0.ElementRef),i0.ɵɵdirectiveInject(i1.IntegralUICommonService),i0.ɵɵdirectiveInject(i2.IntegralUIBaseService),i0.ɵɵdirectiveInject(i0.ComponentFactoryResolver))};t.ɵcmp=i0.ɵɵdefineComponent({type:t,selectors:[["iui-toolitem"]],viewQuery:function(e,t){if(1&e)i0.ɵɵviewQuery(_c0,!0,core_1.ElementRef);if(2&e){var i;i0.ɵɵqueryRefresh(i=i0.ɵɵloadQuery())&&(t.contentElem=i.first)}},inputs:{controlStyle:"controlStyle",data:"data",enabled:"enabled",icon:"icon",name:"name",size:"size",state:"state",text:"text",type:"type",settings:"settings"},outputs:{click:"click",mouseDown:"mouseDown",mouseEnter:"mouseEnter",mouseLeave:"mouseLeave",mouseMove:"mouseMove",mouseUp:"mouseUp",itemClick:"itemClick",valueChanging:"valueChanging",valueChanged:"valueChanged"},features:[i0.ɵɵInheritDefinitionFeature],ngContentSelectors:_c9,decls:2,vars:3,consts:[[3,"ngClass","ngStyle","click","mouseup","mouseenter","mouseleave"],[3,"ngSwitch","ngStyle",4,"ngIf"],[3,"ngSwitch","ngStyle"],["content",""],["class","iui-toolitem-button",3,"ngClass",4,"ngSwitchCase"],["class","iui-toolitem-checkbox",4,"ngSwitchCase"],["class","iui-toolitem-datepicker",4,"ngSwitchCase"],["class","iui-toolitem-droplist",4,"ngSwitchCase"],["class","iui-toolitem-image",4,"ngSwitchCase"],[4,"ngSwitchCase"],["class","iui-toolitem-numeric","type","number","draggable","true",3,"ngModel","ngModelChange","change","DOMMouseScroll","mousewheel","dragstart",4,"ngSwitchCase"],["class","iui-toolitem-progress",4,"ngSwitchCase"],["class","iui-toolitem-rating","align","center",4,"ngSwitchCase"],["class","iui-toolitem-separator",3,"ngClass",4,"ngSwitchCase"],["class","iui-toolitem-slider","align","center",4,"ngSwitchCase"],[4,"ngSwitchDefault"],[1,"iui-toolitem-button",3,"ngClass"],[3,"ngClass",4,"ngIf"],["class","iui-toolitem-label",4,"ngIf"],[3,"ngClass"],[1,"iui-toolitem-label"],[1,"iui-toolitem-checkbox"],[3,"allowAnimation","controlStyle","threeState","ngModel","ngModelChange","checkedChanged","checkStateChanged"],[1,"iui-toolitem-datepicker"],[1,"iui-toolitem-datepicker-button",3,"ngClass"],[1,"iui-toolitem-droplist"],[1,"iui-toolitem-dropdown-button",3,"ngClass"],[1,"iui-toolitem-droplist-label",3,"ngStyle"],[1,"iui-toolitem-image"],[3,"src",4,"ngFor","ngForOf"],[3,"src"],[3,"controlStyle","enabled","items","itemSize","selectionChanged"],["align","center"],["type","number","draggable","true",1,"iui-toolitem-numeric",3,"ngModel","ngModelChange","change","DOMMouseScroll","mousewheel","dragstart"],[1,"iui-toolitem-progress"],[3,"allowAnimation","controlStyle","value"],["align","center",1,"iui-toolitem-rating"],[3,"controlStyle","enabled","ngModel","division","increment","max","stepSize","ngModelChange","valueChanged"],[1,"iui-toolitem-separator",3,"ngClass"],["align","center",1,"iui-toolitem-slider"],[3,"allowAnimation","enabled","controlStyle","ngModel","ngModelChange","valueChanged"],["type","text",1,"iui-toolitem-textbox",3,"ngModel","ngModelChange","change"]],template:function(e,t){if(1&e){i0.ɵɵprojectionDef();i0.ɵɵelementStart(0,"div",0);i0.ɵɵlistener("click",function(e){return t.onItemClicked(e)})("mouseup",function(e){return t.itemMouseUp(e)})("mouseenter",function(e){return t.onMouseEnter(e)})("mouseleave",function(e){return t.onMouseLeave(e)});i0.ɵɵtemplate(1,IntegralUIToolItem_div_1_Template,16,17,"div",1);i0.ɵɵelementEnd()}if(2&e){i0.ɵɵproperty("ngClass",t.getControlClass())("ngStyle",t.getControlStyle());i0.ɵɵadvance(1);i0.ɵɵproperty("ngIf",t.data)}},directives:[i3.NgClass,i3.NgStyle,i3.NgIf,i3.NgSwitch,i3.NgSwitchCase,i3.NgSwitchDefault,i4.IntegralUICheckBox,i5.NgControlStatus,i5.NgModel,i3.NgForOf,i6.IntegralUIListScroller,i5.NumberValueAccessor,i5.DefaultValueAccessor,i7.IntegralUIProgressBar,i8.IntegralUIRating,i9.IntegralUISlider],encapsulation:2});return t}(integralui_core_1.IntegralUIItem);exports.IntegralUIToolItem=IntegralUIToolItem;