@lidorsystems/integralui-web
Version:
IntegralUI Web - Advanced UI Components for Angular
15 lines (12 loc) • 64 kB
JavaScript
/*
filename: integralui.base.list.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 o(){this.constructor=t}t.prototype=null===i?Object.create(i):(o.prototype=i.prototype,new o)}}();Object.defineProperty(exports,"__esModule",{value:!0});var core_1=require("@angular/core"),integralui_core_1=require("./integralui.core"),integralui_common_service_1=require("../services/integralui.common.service"),integralui_data_service_1=require("../services/integralui.data.service"),integralui_dragdrop_service_1=require("../services/integralui.dragdrop.service"),integralui_filter_service_1=require("../services/integralui.filter.service"),i0=require("@angular/core"),i1=require("../services/integralui.data.service"),i2=require("../services/integralui.dragdrop.service"),i3=require("../services/integralui.common.service"),i4=require("../services/integralui.filter.service"),IntegralUIBaseList=function(e){__extends(t,e);function t(t,i,o,r,s,l,n){var a=e.call(this,s)||this;a.dataService=t;a.dragDropService=i;a.elemRef=o;a.elemRenderer=r;a.commonService=s;a.filterService=l;a.cmpResolver=n;a.animateItemSize={width:0,height:0};a.prevClickedObj=null;a.itemData=[];a.itemHoverData=[];a.itemSelectData=[];a.templateList=[];a.currentList=[];a.fullList=[];a.options={allowDrag:!1,allowDrop:!0,dataFields:null,selectedItem:null,sorting:integralui_core_1.IntegralUISortOrder.None};a.dataItems=[];a.scrollItemList=[];a.dropMarkElem=null;a.dragCmpRef=null;a.dragCmp=null;a.dragHandleElem=null;a.dragHandleCmpRef=null;a.dragHandleCmp=null;a.cloneElem=null;a.cloneElemStartPos={x:0,y:0};a.isCtrlDragEntered=!1;a.isDragActive=!1;a.filterParams=null;a.ctrlCursor="default";a.hoverItem=null;a.blockHoverRect={height:0,left:0,top:-9999999,width:0};a.blockSelectRect=[];a.blockSelectHeight=0;a.hoverItemObj={data:{}};a.currentFocusItem=null;a.isKeyboardActive=!1;a.allowUpdate=!0;a.avgItemHeight=0;a.blockSize={width:0,height:0};a.contentSize={width:0,height:0};a.currentIndex=0;a.prevIndex=0;a.isHoverTemplatePresent=!1;a.isSelectedTemplatePresent=!1;a.isUpdateActive=!1;a.prevLongestItemWidth=0;a.longestItemWidth=0;a.longestItemWidthValue="auto";a.virtualization=!1;a.visibleRange=1;a.updateTimer=null;a.currentScrollPos={x:0,y:0};a.maxScrollPos={x:0,y:0};a.accelerator=.5;a.isScrollActive=!1;a.isScrollTimerActive=!1;a.prevScrollPos={x:0,y:0};a.scrollBarSize={width:0,height:0};a.scrollCount=0;a.scrollLargeChange={x:0,y:0};a.scrollSize={width:0,height:0};a.scrollTimerID=null;a.horScrollOrientation=integralui_core_1.IntegralUIOrientation.Horizontal;a.currentSelectionMode=integralui_core_1.IntegralUISelectionMode.One;a.isItemClicked=!1;a.shiftFirstSelectedItem=null;a.removeIndex=-1;a.currentSelectedItems=[];a.sortComparer=null;a.refreshTimer=null;a.touchStartPos={x:0,y:0};a.touchEndPos={x:0,y:0};a.contentVisibility=integralui_core_1.IntegralUIContentVisibility.Both;a.itemSpacing=0;a.mouseWheelSpeed=integralui_core_1.IntegralUISpeedMode.Normal;a.afterSelect=new core_1.EventEmitter;a.beforeEdit=new core_1.EventEmitter;a.beforeSelect=new core_1.EventEmitter;a.change=new core_1.EventEmitter;a.clear=new core_1.EventEmitter;a.dragEnd=new core_1.EventEmitter;a.dragEnter=new core_1.EventEmitter;a.dragDrop=new core_1.EventEmitter;a.dragDropComplete=new core_1.EventEmitter;a.dragLeave=new core_1.EventEmitter;a.dragOver=new core_1.EventEmitter;a.dragStart=new core_1.EventEmitter;a.itemAdding=new core_1.EventEmitter;a.itemAdded=new core_1.EventEmitter;a.itemClick=new core_1.EventEmitter;a.itemDblClick=new core_1.EventEmitter;a.itemHover=new core_1.EventEmitter;a.itemRemoving=new core_1.EventEmitter;a.itemRemoved=new core_1.EventEmitter;a.itemRightClick=new core_1.EventEmitter;a.keyDown=new core_1.EventEmitter;a.keyPress=new core_1.EventEmitter;a.keyUp=new core_1.EventEmitter;a.loadComplete=new core_1.EventEmitter;a.scrollPosChanged=new core_1.EventEmitter;a.selectionChanged=new core_1.EventEmitter;a.updateComplete=new core_1.EventEmitter;a.updateOptions();return a}Object.defineProperty(t.prototype,"allowDrag",{set:function(e){this.options.allowDrag=e},enumerable:!0,configurable:!0});Object.defineProperty(t.prototype,"allowDrop",{set:function(e){this.options.allowDrop=e},enumerable:!0,configurable:!0});Object.defineProperty(t.prototype,"allowFilter",{set:function(e){this.options.allowFilter=e},enumerable:!0,configurable:!0});Object.defineProperty(t.prototype,"allowFocus",{set:function(e){this.options.allowFocus=e;if(!e)this.currentFocusItem=null;this.refresh()},enumerable:!0,configurable:!0});Object.defineProperty(t.prototype,"dataFields",{set:function(e){this.updateDataFields(e)},enumerable:!0,configurable:!0});Object.defineProperty(t.prototype,"focusedItem",{get:function(){return this.currentFocusItem},set:function(e){if(this.currentFocusItem!=e)this.currentFocusItem=e},enumerable:!0,configurable:!0});Object.defineProperty(t.prototype,"items",{get:function(){return this.dataItems},set:function(e){this.dataItems=e;this.updateData()},enumerable:!0,configurable:!0});Object.defineProperty(t.prototype,"showScroll",{get:function(){return this.options.showScroll},set:function(e){this.updateShowScroll(e)},enumerable:!0,configurable:!0});Object.defineProperty(t.prototype,"selectedItem",{get:function(){return this.currentSelection},set:function(e){if(this.currentSelection!=e)var t=this,i=setTimeout(function(){t.processSelection(null,e);t.updateSelectContentPos();clearTimeout(i)},1)},enumerable:!0,configurable:!0});Object.defineProperty(t.prototype,"selectionMode",{get:function(){return this.currentSelectionMode},set:function(e){if(this.currentSelectionMode!=e){this.currentSelectionMode=e;this.clearPrevSelection(this.currentSelectionMode!=integralui_core_1.IntegralUISelectionMode.None?this.currentSelection:null);var t=this,i=setTimeout(function(){t.refresh();if(t.currentSelectionMode==integralui_core_1.IntegralUISelectionMode.None){t.currentSelection=null;t.selectionChanged.emit({item:null})}clearTimeout(i)},1)}},enumerable:!0,configurable:!0});Object.defineProperty(t.prototype,"sorting",{set:function(e){this.options.sorting=e},enumerable:!0,configurable:!0});Object.defineProperty(t.prototype,"virtualMode",{get:function(){return this.virtualization},set:function(e){this.virtualization=e;this.updateLayout()},enumerable:!0,configurable:!0});t.prototype.ngOnInit=function(){this.dataService.init([{data:this.items}]);this.itemClassName="iui-list";this.itemContentClassName=this.itemClassName+"-content"};t.prototype.initStyle=function(){this.defaultStyle={general:{disabled:this.generalClassName+"-disabled",focused:this.generalClassName+"-focused",normal:this.generalClassName,hovered:this.generalClassName+"-hovered",selected:this.generalClassName+"-selected"},item:{general:{disabled:this.itemClassName+"-disabled",focused:this.itemClassName+"-focused",normal:this.itemClassName,hovered:this.itemClassName+"-hovered",selected:this.itemClassName+"-selected"},content:{disabled:this.itemContentClassName+"-disabled",focused:this.itemContentClassName+"-focused",normal:this.itemContentClassName,hovered:this.itemContentClassName+"-hovered",selected:this.itemContentClassName+"-selected"}}};this.updateStyle(this.controlStyle);this.updateControlClass();this.refresh()};t.prototype.addItem=function(e,t){this.callEventAdd("add",e,-1,t)};t.prototype.clearItems=function(e){if(!e){this.currentSelectedItems.length=0;this.currentSelection=null}this.dataService.clear(e);this.clear.emit({parent:e});this.updateLayout()};t.prototype.insertItemAt=function(e,t,i){this.callEventAdd("at",e,t,i)};t.prototype.insertItemBefore=function(e,t){this.callEventAdd("ref",e,-1,null,t)};t.prototype.insertItemAfter=function(e,t){this.callEventAdd("ref",e,-1,null,t,!0)};t.prototype.removeItem=function(e){return this.callEventRemove(e)};t.prototype.removeItemAt=function(e,t){return this.callEventRemove(null,e,t)};t.prototype.callEventAdd=function(e,t,i,o,r,s){var l={cancel:!1,item:t};this.itemAdding.emit(l);if(1!=l.cancel){switch(e){case"at":this.dataService.insert(t,i,o);break;case"ref":this.dataService.insertByRef(t,r,s);break;default:this.dataService.insert(t,-1,o)}this.processItemAdd(t,o);this.updateItem(o);this.itemAdded.emit({item:t})}};t.prototype.callEventRemove=function(e,t,i){var o={cancel:!1,item:e};this.itemRemoving.emit(o);if(1!=o.cancel){this.removeIndex=this.items?this.items.indexOf(e):-1;var r=this.dataService.removeAt(e,t,i);if(r.result){this.processItemRemoval(e,i);if(e&&e[this.options.dataFields.selected]){e[this.options.dataFields.selected]=!1;this.currentSelectedItems=this.currentSelectedItems.filter(function(t){return t!=e});if(this.currentSelection&&this.commonService.isEqual(this.currentSelection[this.options.dataFields.id],e[this.options.dataFields.id]))this.currentSelection=null;this.selectionChanged.emit({item:this.currentSelection})}this.itemRemoved.emit({item:r.obj});return!0}}return!1};t.prototype.processItemAdd=function(e,t){};t.prototype.processItemRemoval=function(e,t){};t.prototype.itemClickEvent=function(e,t){if(this.isEnabled&&1==e.which)this.itemClick.emit({event:e,item:t.data})};t.prototype.itemDblClickEvent=function(e,t){if(this.isEnabled&&1==e.which){var i={event:e,item:t.data};this.itemDblClick.emit(i)}};t.prototype.itemRightClickEvent=function(e,t){if(this.isEnabled){var i={event:e,item:t.data};this.itemRightClick.emit(i)}};t.prototype.getDataFields=function(){return this.options.dataFields};t.prototype.updateCurrentList=function(){};t.prototype.updateData=function(){};t.prototype.updateOptions=function(e){if(e){this.options={allowDrag:this.commonService.isFieldAvailable(e.allowDrag,!1),allowDrop:this.commonService.isFieldAvailable(e.allowDrop,!0),allowFilter:this.commonService.isFieldAvailable(e.allowFilter,!1),allowFocus:this.commonService.isFieldAvailable(e.allowFocus,!1),dataFields:null,selectedItem:this.commonService.isFieldAvailable(e.selectedItem,this.options.selectedItem?this.options.selectedItem:null)};this.updateShowScroll(e.showScroll)}else{this.options={allowDrag:!1,allowDrop:!0,allowFilter:!1,allowFocus:!1,dataFields:null,selectedItem:null};this.updateDataFields();this.updateShowScroll()}};t.prototype.updateDataFields=function(e){if(e)this.options.dataFields={allowDrag:e.allowDrag?e.allowDrag:"allowDrag",allowDrop:e.allowDrop?e.allowDrop:"allowDrop",allowEdit:e.allowEdit?e.allowEdit:"allowEdit",allowFocus:e.allowFocus?e.allowFocus:"allowFocus",autoCheck:e.autoCheck?e.autoCheck:"autoCheck",canSelect:e.canSelect?e.canSelect:"canSelect",checkBoxSettings:e.checkBoxSettings?e.checkBoxSettings:"checkBoxSettings",checked:e.checked?e.checked:"checked",checkState:e.checkState?e.checkState:"checkState",content:e.content?e.content:"content",contentVisibility:e.contentVisibility?e.contentVisibility:"contentVisibility",contextMenu:e.contextMenu?e.contextMenu:"contextMenu",enabled:e.enabled?e.enabled:"enabled",expanded:e.expanded?e.expanded:"expanded",hasChildren:e.hasChildren?e.hasChildren:"hasChildren",icon:e.icon?e.icon:"icon",id:e.id?e.id:"id",items:e.items?e.items:"items",pid:e.pid?e.pid:"pid",selected:e.selected?e.selected:"selected",statusIcon:e.statusIcon?e.statusIcon:"statusIcon",style:e.style?e.style:"style",templateObj:e.templateObj?e.templateObj:"templateObj",text:e.text?e.text:"text",tooltip:e.tooltip?e.tooltip:"tooltip",value:e.value?e.value:"value",visible:e.visible?e.visible:"visible"};else this.options.dataFields={allowDrag:"allowDrag",allowDrop:"allowDrop",allowEdit:"allowEdit",allowFocus:"allowFocus",autoCheck:"autoCheck",canSelect:"canSelect",checkBoxSettings:"checkBoxSettings",checked:"checked",checkState:"checkState",content:"content",contentVisibility:"contentVisibility",contextMenu:"contextMenu",enabled:"enabled",expanded:"expanded",hasChildren:"hasChildren",icon:"icon",id:"id",items:"items",pid:"pid",selected:"selected",statusIcon:"statusIcon",style:"style",templateObj:"templateObj",text:"text",tooltip:"tooltip",value:"value",visible:"visible"};if(this.dataService)this.dataService.updateDataFields(this.options.dataFields)};t.prototype.updateShowScroll=function(e){if(e)this.options.showScroll={horizontal:this.commonService.isFieldAvailable(e.horizontal,!0),vertical:this.commonService.isFieldAvailable(e.vertical,!0)};else this.options.showScroll={horizontal:!0,vertical:!0}};t.prototype.processLoadData=function(e,t,i,o){var r=this;r.clearItems(t);r.updateDataFields(i);var s=[];if(e)if(o||void 0==o){var l=[];e.forEach(function(e,t){e[r.options.dataFields.items]=[];var i=e[r.options.dataFields.pid];if(l[i]){if(!l[i][r.options.dataFields.items])l[i][r.options.dataFields.items]=[];l[e[r.options.dataFields.id]]=e;l[i][r.options.dataFields.items].push(e)}else{l[e[r.options.dataFields.id]]=e;s.push(e)}});l.length=0}else s=e;if(t){t[r.options.dataFields.items]=s;for(var n=0;n<t[r.options.dataFields.items].length;n++)t[r.options.dataFields.items][n][r.options.dataFields.pid]=t[r.options.dataFields.id]}else if(r.items){r.items.length=0;for(n=0;n<s.length;n++)r.items.push(s[n])}r.updateItem(t);r.loadComplete.emit(null);this.updateLayout()};t.prototype.updateItem=function(e){};t.prototype.updateScrollItemList=function(){this.scrollItemList.length=0};t.prototype.addDropMark=function(e){if(this.appRef){this.removeDropMark();var t=this.cmpResolver.resolveComponentFactory(integralui_core_1.IntegralUIDragWindow);if(t){this.dragCmpRef=this.appRef.createComponent(t);if(this.dragCmpRef.instance)this.dragCmp=this.dragCmpRef.instance}}};t.prototype.removeDropMark=function(){if(this.dragCmpRef)this.dragCmpRef.destroy();this.dragCmp=null};t.prototype.callDragDropEvent=function(e,t,i){var o={action:t.action,cancel:!1,dragItem:t.source,dropPos:t.dropPos,event:e,isDropAllowed:t.allow,mousePos:this.commonService.getMousePos(e),sourceCtrl:t.sourceCtrl,targetCtrl:t.targetCtrl,targetItem:t.target};if(i)this.dragDrop.emit(o);else this.dragOver.emit(o);return o};t.prototype.checkEmptySpace=function(e){var t=this.getContentSize(),i=this.commonService.getPageRect(this.elemRef.nativeElement.firstElementChild),o=i.top+t.height,r=i.bottom,s=this.commonService.getMousePos(e),l=this.commonService.getShiftPos();s.x-=l.x;s.y-=l.y;return s.y>=o&&s.y<=r};t.prototype.ctrlDragEnd=function(e){this.removeDropMark();var t=this.dragDropService.getData();if(t.targetCtrl&&t.targetCtrl.removeDropMark)t.targetCtrl.removeDropMark();this.itemDragEnd(e,null)};t.prototype.ctrlDragEnter=function(e){if(this.isEnabled)this.processDragEnter(e)};t.prototype.ctrlDragDrop=function(e){if(this.isEnabled)this.processDragDrop(e);this.removeDropMark();e.stopPropagation()};t.prototype.ctrlDragLeave=function(e){if(this.isEnabled)this.processDragLeave(e)};t.prototype.ctrlDragOver=function(e){if(this.isEnabled)this.processDragOver(e);e.stopPropagation()};t.prototype.dropMark=function(e,t){if(!this.dragCmp&&!this.isScrollTimerActive)this.addDropMark({x:e.pageX,y:e.pageY});if(this.dragCmp){var i="none";if(this.options.allowDrop)i=t?"block":"none";this.dragCmp.display=i}};t.prototype.updateDragComponent=function(e){if(this.dragCmp)this.dragCmp.updatePos(e)};t.prototype.isDragAllowed=function(e){return this.options.allowDrag?e&&(e[this.options.dataFields.allowDrag]||void 0===e[this.options.dataFields.allowDrag])?!0:!1:!1};t.prototype.isDropAllowed=function(e,t,i){var o=this.options.allowDrop;if(o&&e&&t)if(o=t[this.options.dataFields.allowDrop]||void 0===t[this.options.dataFields.allowDrop]?!0:!1)if(Array.isArray(e))for(var r=0;r<e.length;r++){if(this.commonService.isEqual(e[r][this.options.dataFields.id],t[this.options.dataFields.id])||0===i&&this.isParentOf(t,e[r])||this.isChildOf(t,e[r])){o=!1;break}if(!o)break}else if(this.commonService.isEqual(e[this.options.dataFields.id],t[this.options.dataFields.id])||0===i&&this.isParentOf(t,e)||this.isChildOf(t,e))o=!1;return o};t.prototype.processDragStart=function(e,t){this.dragDropService.clearData();if(this.isDragAllowed(t)){if(t)if(!this.isDragAllowed(t)){if(e.dataTransfer)e.dataTransfer.effectAllowed="none";else if(e.originalEvent&&e.originalEvent.dataTransfer)e.originalEvent.dataTransfer.effectAllowed="none"}else{var i={clone:this.cloneItem(t),source:t,sourceCtrl:this,sourceData:this.items};switch(this.selectionMode){case integralui_core_1.IntegralUISelectionMode.MultiSimple:case integralui_core_1.IntegralUISelectionMode.MultiExtended:i.clone=this.createCloneList(this.currentSelectedItems);i.source=this.currentSelectedItems}var o={action:e.shiftKey?"copy":"move",cancel:!1,dragItem:i.source,dropPos:-1,event:e,isDropAllowed:this.options.allowDrop,mousePos:this.commonService.getMousePos(e),sourceCtrl:i.sourceCtrl,targetCtrl:this,targetItem:null};this.dragStart.emit(o);if(1==o.cancel){e.preventDefault();return}else{this.isDragActive=!0;this.addDropMark({x:e.pageX,y:e.pageY});this.dropMark(e);if(e.dataTransfer){e.dataTransfer.effectAllowed="move";e.dataTransfer.setData("text",t[this.options.dataFields.id]?t[this.options.dataFields.id].toString():"")}else if(e.originalEvent&&e.originalEvent.dataTransfer){e.originalEvent.dataTransfer.effectAllowed="move";e.originalEvent.dataTransfer.setData("text",t[this.options.dataFields.id]?t[this.options.dataFields.id].toString():"")}this.dragDropService.setData(i)}}}else e.preventDefault()};t.prototype.processDragEnter=function(e){if(!this.isCtrlDragEntered){this.isCtrlDragEntered=!0;var t=this.dragDropService.getData(),i={action:e.shiftKey?"copy":"move",dragItem:t.source,dropPos:-1,event:e,isDropAllowed:this.options.allowDrop,mousePos:this.commonService.getMousePos(e),sourceCtrl:t.sourceCtrl,targetCtrl:this,targetItem:null};this.dragEnter.emit(i)}};t.prototype.processDragLeave=function(e){if(this.isCtrlDragEntered){var t=this.commonService.getPageRect(this.elemRef.nativeElement.firstElementChild),i=this.commonService.getMousePos(e),o=this.commonService.getShiftPos();i.x-=o.x;i.y-=o.y;if(i.x<t.left||i.x>t.right||i.y<t.top||i.y>t.bottom){this.isCtrlDragEntered=!1;this.stopScrollTimer();var r=this.dragDropService.getData(),s={action:e.shiftKey?"copy":"move",dragItem:r.source,dropPos:-1,event:e,isDropAllowed:!1,mousePos:this.commonService.getMousePos(e),sourceCtrl:r.sourceCtrl,targetCtrl:null,targetItem:null};this.dragLeave.emit(s)}this.dropMark(e)}};t.prototype.processDragOver=function(e,t,i,o,r){e.preventDefault();this.processDragEnter(e);var s=!0;if(e.dataTransfer)s="none"===e.dataTransfer.effectAllowed?!1:!0;else if(e.originalEvent&&e.originalEvent.dataTransfer)s="none"===e.originalEvent.dataTransfer.effectAllowed?!1:!0;if(s){var l=this.dragDropService.getData(),n=this.commonService.getShiftPos();if(t){(f=this.commonService.getMousePos(e)).x-=n.x;f.y-=n.y;var a=this.dragDropService.getDropPos(f,i,o,r);s=this.isDropAllowed(l.source,t,a);var c={action:e.shiftKey?"copy":"move",source:l.source,dropPos:a,allow:s,sourceCtrl:l.sourceCtrl,target:t,targetCtrl:this},h=this.callDragDropEvent(e,c);if(!s||1==h.cancel){if(e.dataTransfer)e.dataTransfer.dropEffect="none";else if(e.originalEvent&&e.originalEvent.dataTransfer)e.originalEvent.dataTransfer.dropEffect="none";this.dropMark(e)}else{var d=this.commonService.getMousePos(e),u=d.y+16,p=d.x+20,m="iui-dragwin-icon";switch(h.dropPos){case 0:m+=" iui-dragwin-move-in";break;case 1:if("horizontal"==r)m+=" iui-dragwin-move-left";else m+=" iui-dragwin-move-up";break;case 2:if("horizontal"==r)m+=" iui-dragwin-move-right";else m+=" iui-dragwin-move-down"}if("copy"==h.action)m+="-copy";this.updateDragComponent({class:m,top:u,left:p,text:t[this.options.dataFields.text]});this.dropMark(e,s);this.dragDropService.setData({action:h.action,clone:l.clone,source:l.source,sourceCtrl:l.sourceCtrl,sourceData:l.sourceData,target:t,targetCtrl:this,dropPos:h.dropPos})}}else if(!this.options.allowDrop){if(e.dataTransfer)e.dataTransfer.dropEffect="none";else if(e.originalEvent&&e.originalEvent.dataTransfer)e.originalEvent.dataTransfer.dropEffect="none";this.dropMark(e)}else{s=this.checkEmptySpace(e);c={action:e.shiftKey?"copy":"move",source:l.source,dropPos:-1,allow:s,sourceCtrl:l.sourceCtrl,target:null,targetCtrl:this},h=this.callDragDropEvent(e,c);if(!s||1==h.cancel){if(e.dataTransfer)e.dataTransfer.dropEffect="none";else if(e.originalEvent&&e.originalEvent.dataTransfer)e.originalEvent.dataTransfer.dropEffect="none";this.dropMark(e)}else{var f;u=(f=this.commonService.getMousePos(e)).y+16,p=f.x+20,m="iui-dragwin-icon iui-dragwin-move-end";if("copy"==h.action)m+="-copy";this.updateDragComponent({class:m,top:u,left:p,text:this.name?this.name:"Component"});this.dropMark(e,s);this.dragDropService.setData({action:h.action,clone:l.clone,source:l.source,sourceCtrl:l.sourceCtrl,sourceData:l.sourceData,target:null,targetCtrl:this,dropPos:h.dropPos})}}}};t.prototype.processDragDrop=function(e,t){e.preventDefault();this.dropMark(e);var i=!0;if(e.dataTransfer)i="none"===e.dataTransfer.effectAllowed?!1:!0;else if(e.originalEvent&&e.originalEvent.dataTransfer)i="none"===e.originalEvent.dataTransfer.effectAllowed?!1:!0;var o=this.dragDropService.getData();if(i){if(t)i=this.isDropAllowed(o.source,t,o.dropPos);else i=this.checkEmptySpace(e);if(i&&o.source){var r={action:o.action,source:o.source,dropPos:o.dropPos,allow:i,sourceCtrl:o.sourceCtrl,target:o.target,targetCtrl:this},s=this.callDragDropEvent(e,r,!0);this.dragDropService.setData({action:s.action,clone:o.clone,dropPos:s.dropPos,source:o.source,sourceCtrl:o.sourceCtrl,sourceData:o.sourceData,target:o.target,targetCtrl:this});if(!s.cancel)this.drop(e,this.dragDropService.getData())}if(o.sourceCtrl&&o.sourceCtrl.removeDropMark)o.sourceCtrl.removeDropMark()}var l=this,n=setTimeout(function(){if(i){var t=l.dragDropService.getData(),o={action:t.action,dragItem:t.source,dropPos:t.dropPos,event:e,isDropAllowed:!0,mousePos:l.commonService.getMousePos(e),sourceCtrl:t.sourceCtrl,targetCtrl:l,targetItem:t.target};l.dragDropComplete.emit(o)}l.isDragActive=!1;l.dragDropService.clearData();l.clearHoverItem();clearTimeout(n)},150)};t.prototype.drop=function(e,t){if(t&&t.sourceCtrl){var i="copy"==t.action&&t.clone?t.clone:t.source;if(Array.isArray(i)){for(var o=[],r=0;r<i.length;r++)o.push(i[r]);if(o.length>0){for(r=0;r<o.length;r++)this.processDataDrop(e,o[r],t);this.clearPrevSelection()}}else{this.processDataDrop(e,i,t);this.clearPrevSelection()}if(t.sourceCtrl!=t.targetCtrl&&t.sourceCtrl.updateLayout)t.sourceCtrl.updateLayout();this.updateLayout()}this.isCtrlDragEntered=!1};t.prototype.processDataDrop=function(e,t,i){var o="copy"==i.action;if("copy"!=i.action&&i.sourceCtrl&&i.sourceCtrl.removeItem)o=i.sourceCtrl.removeItem(t);if(o)switch(i.dropPos){case 0:this.insertItemAt(t,-1,i.target);break;case 1:this.insertItemBefore(t,i.target);break;case 2:this.insertItemAfter(t,i.target);break;default:this.addItem(t)}};t.prototype.callAfterSelectEvent=function(e){var t={item:e};this.afterSelect.emit(t);this.selectionChanged.emit(t)};t.prototype.itemDragStart=function(e,t){this.processDragStart(e,t.data);e.stopPropagation()};t.prototype.itemDragOver=function(e,t,i,o){if(this.isEnabled){var r=this.getItemElemList();if(r&&i>=0&&i<r.length){var s=this.commonService.getPageRect(r[i].nativeElement),l={x:s.left,y:s.top,width:s.right-s.left,height:s.bottom-s.top};this.processScroll(e);if(!this.isScrollTimerActive)this.processDragOver(e,t.data,l,o)}}e.stopPropagation()};t.prototype.itemDragDrop=function(e,t){if(this.isEnabled)this.processDragDrop(e,t.data);e.stopPropagation()};t.prototype.itemDragEnd=function(e,t){var i=this.dragDropService.getData(),o={action:e.shiftKey?"copy":"move",dragItem:i.source,dropPos:i.dropPos,event:e,mousePos:this.commonService.getMousePos(e),sourceCtrl:i.sourceCtrl,targetCtrl:this,targetItem:i.target};this.dragEnd.emit(o)};t.prototype.exportToJSON=function(e,t){t=t?t:null;var i=this.items,o=e?e:[this.options.dataFields.allowDrag,this.options.dataFields.allowDrop,this.options.dataFields.allowEdit,this.options.dataFields.allowFocus,this.options.dataFields.autoCheck,this.options.dataFields.canSelect,this.options.dataFields.checkBoxSettings,this.options.dataFields.checked,this.options.dataFields.checkState,this.options.dataFields.content,this.options.dataFields.contentVisibility,this.options.dataFields.contextMenu,this.options.dataFields.enabled,this.options.dataFields.fixed,this.options.dataFields.fixChildren,this.options.dataFields.hasChildren,this.options.dataFields.icon,this.options.dataFields.id,this.options.dataFields.selected,this.options.dataFields.showCheckBox,this.options.dataFields.statusIcon,this.options.dataFields.style,this.options.dataFields.templateObj,this.options.dataFields.text,this.options.dataFields.tooltip,this.options.dataFields.value,this.options.dataFields.visible];return JSON.stringify(i,o,t)};t.prototype.filter=function(e){this.filterParams=e;this.updateLayout();this.change.emit({type:"filtering"})};t.prototype.clearHoverItem=function(){var e=this;if(e.hoverItem)var t=setTimeout(function(){var i=e.getObjFromScrollItem(e.hoverItem);e.hoverItem=null;e.updateItemStyle(i);clearTimeout(t)},25)};t.prototype.cloneItem=function(e){return this.dataService.clone(e)};t.prototype.createCloneList=function(e){for(var t=[],i=0;i<e.length;i++)t.push(this.cloneItem(e[i]));return t};t.prototype.getFilterTree=function(e){return e?this.filterService.createTree(e.conditions,e.formula):null};t.prototype.getObjFromItem=function(e){for(var t=null,i=0;i<this.currentList.length;i++)if(this.currentList[i].data==e){t=this.currentList[i];break}return t};t.prototype.getObjFromScrollItem=function(e){for(var t=null,i=0;i<this.scrollItemList.length;i++){var o=this.scrollItemList[i];if(o.data==e){t=o;break}}return t};t.prototype.getItemCurrentIndex=function(e){if(e){var t=this.getObjFromItem(e);return t&&this.currentList?this.currentList.indexOf(t):-1}};t.prototype.getItemScrollIndex=function(e){return e&&this.scrollItemList?this.scrollItemList.indexOf(e):-1};t.prototype.getItemElem=function(e){var t=this.getObjFromScrollItem(e);if(t){var i=this.getItemElemList(),o=this.getItemScrollIndex(t);if(o>=0&&o<i.length)return i[o]}return null};t.prototype.getItemElemList=function(){return null};t.prototype.getItemFromComponent=function(e){return null};t.prototype.getList=function(e){switch(e){case"current":return this.currentList;case"selected":return this.currentSelectedItems}return this.dataService.getList()};t.prototype.getFullList=function(){return this.fullList};t.prototype.updateFullList=function(){this.fullList.length=0;return this.fullList};t.prototype.getTopItem=function(){return 0!=this.virtualMode?this.scrollItemList.length>0?this.scrollItemList[0].data:null:null};t.prototype.invokeMethod=function(e,t){var i=!0;if(this.isEnabled)switch(e){case"REMOVE_DROPMARK":this.removeDropMark();break;case"SELECT_ITEM":this.isItemClicked=!0;if(t)i=this.processSelection(t.event,t.item);break;case"UPDATE_SELECTION":if(t&&this.isItemClicked)this.updateSelection(t.event,t.item);this.isItemClicked=!1}return i};t.prototype.isChildOf=function(e,t){return!1};t.prototype.isContentAllowed=function(e,t){var i=this.contentVisibility==integralui_core_1.IntegralUIContentVisibility.Both;switch(t){case"hover":i=(i&&(!this.isSelectedTemplatePresent||!e[this.options.dataFields.selected])||this.contentVisibility==integralui_core_1.IntegralUIContentVisibility.Hover)&&(void 0==e[this.options.dataFields.contentVisibility]||e[this.options.dataFields.contentVisibility]==integralui_core_1.IntegralUIContentVisibility.Hover||e[this.options.dataFields.contentVisibility]==integralui_core_1.IntegralUIContentVisibility.Both);break;case"select":i=(i||this.contentVisibility==integralui_core_1.IntegralUIContentVisibility.Select)&&(void 0==e[this.options.dataFields.contentVisibility]||e[this.options.dataFields.contentVisibility]==integralui_core_1.IntegralUIContentVisibility.Select||e[this.options.dataFields.contentVisibility]==integralui_core_1.IntegralUIContentVisibility.Both)}return i};t.prototype.isComponentIndexInRange=function(e){return this.itemList?e>=0&&e<this.itemList.length:!1};t.prototype.isIndexInRange=function(e){return this.currentList?e>=0&&e<this.currentList.length:!1};t.prototype.isItemAllowed=function(e){if(0==e[this.options.dataFields.visible])return!1;else if(0==this.options.allowFilter)return!0;var t=!0;if(e&&this.filterParams){var i=e[this.options.dataFields.value];i=i?i:e[this.options.dataFields.text];if(this.filterParams.callback)t=this.filterParams.callback(i,e);else if(!(t=this.filterService.match(i,this.filterParams.conditions,this.filterParams.formula,this.getFilterTree(this.filterParams),this.filterParams.caseSensitive))&&this.filterParams.allowParent)t=this.filterIsThereChildren(e)}return t};t.prototype.filterIsThereChildren=function(e){var t=!1,i=e[this.options.dataFields.items];if(i)for(var o=0;o<i.length&&!(t=this.isItemAllowed(i[o]));o++);return t};t.prototype.isItemEnabled=function(e){return!0};t.prototype.isItemHovered=function(e){return!this.isDragActive&&!this.isScrollTimerActive&&e&&e==this.hoverItem?!0:!1};t.prototype.isItemSelected=function(e){return e&&1==e[this.options.dataFields.selected]?!0:!1};t.prototype.isParentOf=function(e,t){return!1};t.prototype.updateItemList=function(){};t.prototype.getLastItemIndex=function(){var e=this.dataService.getList();return e?e.length-1:-1};t.prototype.getPrevItem=function(e){var t=null;if(e){var i=this.dataService.getList(),o=i.indexOf(e);if((o=o>0?o-1:-1)>=0)t=i[o]}return t};t.prototype.getNextItem=function(e){var t=null;if(e){var i=this.dataService.getList(),o=i.indexOf(e);if((o=o<i.length-1?o+1:-1)>=0)t=i[o]}return t};t.prototype.moveItem=function(e,t,i,o){if(e){this.allowUpdate=!1;var r=-1;switch(t){case integralui_core_1.IntegralUIMoveDirection.At:r=o;break;case integralui_core_1.IntegralUIMoveDirection.Down:i=this.getNextItem(e);break;case integralui_core_1.IntegralUIMoveDirection.First:r=0;break;case integralui_core_1.IntegralUIMoveDirection.Last:r=this.getLastItemIndex();break;case integralui_core_1.IntegralUIMoveDirection.Up:i=this.getPrevItem(e)}if(Array.isArray(e)){if(e.length>0){if(this.getItemCurrentIndex(e[0])<=this.getItemCurrentIndex(e[e.length-1]))for(var s=0;s<e.length;s++)this.moveItemAt(e[s],i,t,r);else for(s=e.length-1;s>=0;s--)this.moveItemAt(e[s],i,t,r)}}else this.moveItemAt(e,i,t,r);this.allowUpdate=!0;this.updateLayout();this.change.emit({type:"move-item"})}};t.prototype.moveItemAt=function(e,t,i,o){if(this.removeItem(e))if(i==integralui_core_1.IntegralUIMoveDirection.First||i==integralui_core_1.IntegralUIMoveDirection.Right||i==integralui_core_1.IntegralUIMoveDirection.Last||i==integralui_core_1.IntegralUIMoveDirection.At)this.insertItemAt(e,o,t);else if(i==integralui_core_1.IntegralUIMoveDirection.Before||i==integralui_core_1.IntegralUIMoveDirection.Up)this.insertItemBefore(e,t);else if(i==integralui_core_1.IntegralUIMoveDirection.After||i==integralui_core_1.IntegralUIMoveDirection.Left||i==integralui_core_1.IntegralUIMoveDirection.Down)this.insertItemAfter(e,t)};t.prototype.getSelectBlockRect=function(e){var t={left:0,top:"-9999999px",height:0,width:0};if(e<this.blockSelectRect.length)t={left:this.blockSelectRect[e].left+"px",top:this.blockSelectRect[e].top+"px",height:this.blockSelectRect[e].height+"px",width:this.blockSelectRect[e].width+"px"};return t};t.prototype.hoverBlockMouseMove=function(e){if(this.isEnabled&&!this.isScrollActive&&!this.hoverItem)this.itemMouseEnter(e,this.hoverItemObj)};t.prototype.hoverBlockMouseLeave=function(e){if(this.isEnabled&&!this.isScrollActive)this.itemMouseLeave(e,this.hoverItemObj)};t.prototype.itemMouseEnter=function(e,t){if(this.isEnabled&&!this.isScrollActive){this.hoverItem=t.data;this.hoverItemObj=t;this.updateItemStyle(t);this.itemHover.emit({item:t.data})}};t.prototype.itemMouseMove=function(e,t){if(this.isEnabled&&!this.isScrollActive){this.hoverItem=t.data;this.updateItemStyle(t);var i=this.getItemScrollIndex(t),o=this.getItemElemList();if(o&&i>=0&&i<o.length){var r=this.commonService.getPageRect(this.elemRef.nativeElement.firstElementChild),s=this.commonService.getPageRect(o[i].nativeElement);this.blockHoverRect.top=s.top-r.top-1}this.itemHover.emit({item:t.data})}};t.prototype.itemMouseLeave=function(e,t){if(this.isEnabled&&!this.isScrollActive){this.hoverItem=null;this.updateItemStyle(t)}};t.prototype.itemGotFocus=function(e){this.refresh()};t.prototype.itemLostFocus=function(e){this.refresh()};t.prototype.itemKeyDown=function(e,t){if(this.isEnabled){var i={cancel:!1,item:t.data,event:e};this.keyDown.emit(i);switch(e.keyCode){case 9:break;case 13:this.beforeEdit.emit(i);break;case 27:break;case 33:if(!i.cancel&&this.options.allowFocus){e.preventDefault();this.isKeyboardActive=!0;this.processPageUpKey(t)}break;case 34:if(!i.cancel&&this.options.allowFocus){e.preventDefault();this.isKeyboardActive=!0;this.processPageDownKey(t)}break;case 35:if(!i.cancel&&this.options.allowFocus){e.preventDefault();this.isKeyboardActive=!0;this.processEndKey(t)}break;case 36:if(!i.cancel&&this.options.allowFocus){e.preventDefault();this.isKeyboardActive=!0;this.processHomeKey(t)}break;case 37:if(!i.cancel&&this.options.allowFocus){e.preventDefault();this.isKeyboardActive=!0;this.processLeftArrowKey(t)}break;case 32:break;case 38:if(!i.cancel&&this.options.allowFocus){e.preventDefault();this.isKeyboardActive=!0;this.processUpArrowKey(t)}break;case 39:if(!i.cancel&&this.options.allowFocus){e.preventDefault();this.isKeyboardActive=!0;this.processRightArrowKey(t)}break;case 40:if(!i.cancel&&this.options.allowFocus){e.preventDefault();this.isKeyboardActive=!0;this.processDownArrowKey(t)}}}};t.prototype.itemKeyPress=function(e,t){if(this.isEnabled){var i={cancel:!1,item:t.data,event:e};this.keyPress.emit(i)}};t.prototype.itemKeyUp=function(e,t){if(this.isEnabled){var i={cancel:!1,item:t.data,event:e};this.keyUp.emit(i)}};t.prototype.processDownArrowKey=function(e,t){var i=this.getDownItem(e);if(i){this.currentFocusItem=i.data;var o=this,r=setTimeout(function(){o.processSelection(t,i.data);clearTimeout(r)},1);if(this.isLastItem(i))this.scrollPos({x:this.currentScrollPos.x,y:this.currentScrollPos.y+2*this.avgItemHeight})}return i};t.prototype.processEndKey=function(e,t){var i=null;if(this.scrollItemList.length>0){this.scrollPos({x:this.currentScrollPos.x,y:this.maxScrollPos.y});var o=this;setTimeout(function(){i=o.scrollItemList[o.scrollItemList.length-1];o.currentFocusItem=i.data;var e=setTimeout(function(){o.processSelection(t,i.data);clearTimeout(e)},1)},1)}return i};t.prototype.processHomeKey=function(e,t){var i=null;if(this.scrollItemList.length>0){this.scrollPos({x:this.currentScrollPos.x,y:0});var o=this;setTimeout(function(){i=o.scrollItemList[0];o.currentFocusItem=i.data;var e=setTimeout(function(){o.processSelection(t,i.data);clearTimeout(e)},1)},1)}return i};t.prototype.processLeftArrowKey=function(e,t){return null};t.prototype.processPageDownKey=function(e,t){var i=null;if(this.scrollItemList.length>0){this.scrollPos({x:this.currentScrollPos.x,y:this.currentScrollPos.y+this.avgItemHeight*(this.scrollItemList.length-1)});var o=this;setTimeout(function(){var r=e.index>=0&&e.index<o.scrollItemList.length?e.index:o.scrollItemList.length-1;if(o.currentScrollPos.y==o.maxScrollPos.y)r=o.scrollItemList.length-1;i=o.scrollItemList[r];o.currentFocusItem=i.data;var s=setTimeout(function(){o.processSelection(t,i.data);clearTimeout(s)},1)},1)}return i};t.prototype.processPageUpKey=function(e,t){var i=null;if(this.scrollItemList.length>0){this.scrollPos({x:this.currentScrollPos.x,y:this.currentScrollPos.y-this.avgItemHeight*(this.scrollItemList.length-1)});var o=this;setTimeout(function(){var r=e.index>=0&&e.index<o.scrollItemList.length?e.index:0;if(0==o.currentScrollPos.y)r=0;i=o.scrollItemList[r];o.currentFocusItem=i.data;var s=setTimeout(function(){o.processSelection(t,i.data);clearTimeout(s)},1)},1)}return i};t.prototype.processRightArrowKey=function(e,t){return null};t.prototype.processUpArrowKey=function(e,t){var i=this.getUpItem(e);if(i){this.currentFocusItem=i.data;var o=this,r=setTimeout(function(){o.processSelection(t,i.data);clearTimeout(r)},1);if(this.isFirstItem(i))this.scrollPos({x:this.currentScrollPos.x,y:this.currentScrollPos.y-this.avgItemHeight})}return i};t.prototype.getDownItem=function(e){var t=e.index>=0&&e.index<this.scrollItemList.length-1?e.index+1:-1;return t>=0?this.scrollItemList[t]:null};t.prototype.getUpItem=function(e){var t=e.index>0?e.index-1:-1;return t>=0?this.scrollItemList[t]:null};t.prototype.isFirstItem=function(e){return 0==e.index?!0:!1};t.prototype.isLastItem=function(e){return e.index==this.scrollItemList.length-2?!0:!1};t.prototype.moveFocusFromItem=function(e,t){if(!this.options.allowFocus)return null;var i=null,o=this.getObjFromScrollItem(e);if(o)switch(t){case"down":i=this.processDownArrowKey(o);break;case"end":i=this.processEndKey(o);break;case"home":i=this.processHomeKey(o);break;case"left":i=this.processLeftArrowKey(o);break;case"pagedown":i=this.processPageDownKey(o);break;case"pageup":i=this.processPageUpKey(o);break;case"right":i=this.processRightArrowKey(o);break;case"up":i=this.processUpArrowKey(o)}return i?i.data:null};t.prototype.onWindowKeyDown=function(e){if(this.isEnabled&&this.isKeyboardActive)e.preventDefault()};t.prototype.onWindowKeyUp=function(e){this.isKeyboardActive=!1};t.prototype.checkForSelectionChange=function(){var e=this;if(this.currentSelectedItems.length>0){var t=this.getFullList(),i=[];this.currentSelectedItems.map(function(o){if(0==t.filter(function(t){return e.commonService.isEqual(t[e.options.dataFields.id],o[e.options.dataFields.id])}).length)i.push(o)});if(i.length>0){var o=[];i.map(function(t){t[e.options.dataFields.selected]=!1;o.push(e.currentSelectedItems.indexOf(t))});if(this.currentSelection&&i.filter(function(t){return e.commonService.isEqual(e.currentSelection[e.options.dataFields.id],t[e.options.dataFields.id])}).length>0)this.currentSelection=null;for(var r=o.length-1;r>=0;r--)this.currentSelectedItems.splice(o[r],1);this.selectionChanged.emit({item:this.currentSelection})}}};t.prototype.getContentSize=function(){return{width:0,height:0}};t.prototype.refresh=function(){this.updateItemList();this.clearComponentSelection();for(var e=0;e<this.currentSelectedItems.length;e++){var t=this.getItemCurrentIndex(this.currentSelectedItems[e]);if(this.isComponentIndexInRange(t))this.itemList[t].state|=integralui_core_1.IntegralUIObjectState.selected}};t.prototype.updateBlockSize=function(){this.blockSize={width:0,height:0}};t.prototype.resetLayoutTimer=function(){if(this.updateTimer)clearTimeout(this.updateTimer);this.updateTimer=null};t.prototype.suspendLayout=function(){this.allowUpdate=!1};t.prototype.resumeLayout=function(){this.allowUpdate=!0;this.updateLayout()};t.prototype.updateCurrentLayout=function(e){};t.prototype.updateLayout=function(){var e=this;if(e.allowUpdate){e.resetLayoutTimer();e.updateTimer=setTimeout(function(){e.updateCurrentList();e.updateFullList();e.clientRect={width:e.elemRef.nativeElement.firstElementChild.clientWidth,height:e.elemRef.nativeElement.firstElementChild.clientHeight};if(e.virtualMode)e.updateScrollItemList();var t=setTimeout(function(){e.updateVisibleRange();if(e.virtualMode)e.updateScrollItemList();var i=setTimeout(function(){e.updateBlockSize();e.checkForSelectionChange();var t=e.getItemElemList();e.avgItemHeight=0;if(t&&t.length>0){for(var o=0,r=0;r<t.length;r++)o+=t[r].nativeElement.offsetHeight;e.avgItemHeight=Math.floor(o/t.length)}e.animateItemSize.height=e.avgItemHeight;e.updateScrollSize();e.refresh();var s=setTimeout(function(){e.updateBlockSize();e.updateHoverContentPos();e.updateSelectContentPos();e.updateComplete.emit(null);e.isUpdateActive=!1;clearTimeout(s)},1);clearTimeout(i)},1);clearTimeout(t)},1);clearTimeout(e.updateTimer)},100)}};t.prototype.updateScrollSize=function(){this.contentSize={width:this.clientRect.width-2,height:this.clientRect.height-2};this.scrollSize={width:0,height:this.avgItemHeight*this.currentList.length-this.clientRect.height+this.avgItemHeight};if(this.isVerScrollVisible()){this.contentSize.width-=18;if(this.scrollSize.width>0)this.scrollSize.width+=16}if(this.isHorScrollVisible())this.scrollSize.height+=16;this.scrollSize.width=this.scrollSize.width>0?this.scrollSize.width:0;this.scrollSize.height=this.scrollSize.height>0?this.scrollSize.height:0;this.maxScrollPos={x:this.scrollSize.width,y:this.scrollSize.height};if(this.currentScrollPos.x>this.maxScrollPos.x)this.changeHorizontalScrollPos(this.maxScrollPos.x);if(this.currentScrollPos.y>this.maxScrollPos.y)this.changeVerticalScrollPos(this.maxScrollPos.y);this.scrollBarSize={width:this.isVerScrollVisible()?this.clientRect.width-20:this.clientRect.width-4,height:this.isHorScrollVisible()?this.clientRect.height-20:this.clientRect.height-4};this.scrollLargeChange={x:this.scrollBarSize.width,y:this.scrollBarSize.height};this.blockHoverRect={height:this.avgItemHeight-2,left:0,top:-9999999,width:this.clientRect.width-2};var e={height:this.avgItemHeight-2,left:0,top:-9999999,width:this.clientRect.width-2};if(this.isVerScrollVisible()){this.blockHoverRect.width-=16;e.width-=16}this.blockSelectRect.map(function(t){t.width=e.width;t.height=e.height})};t.prototype.updateHoverContentPos=function(){this.blockHoverRect={height:this.avgItemHeight-2,left:0,top:-9999999,width:this.clientRect.width-2};if(this.hoverItem&&this.isHoverTemplatePresent){var e=this.getObjFromScrollItem(this.hoverItem),t=this.getItemScrollIndex(e),i=this.getItemElemList();if(i&&t>=0&&t<i.length){var o=this.commonService.getPageRect(this.elemRef.nativeElement.firstElementChild),r=this.commonService.getPageRect(i[t].nativeElement);this.blockHoverRect.top=r.top-o.top-1;if(this.isVerScrollVisible())this.blockHoverRect.width-=16}}};t.prototype.updateSelectContentPos=function(){var e=this;e.blockSelectRect.length=0;if(e.isSelectedTemplatePresent){var t=e.commonService.getPageRect(e.elemRef.nativeElement.firstElementChild),i=e.getItemElemList();e.blockSelectHeight=e.avgItemHeight-2;e.currentSelectedItems.map(function(o){var r=e.getObjFromScrollItem(o),s=e.getItemScrollIndex(r),l={height:e.blockSelectHeight,left:0,top:-9999999,width:e.clientRect.width-2};if(e.isVerScrollVisible())l.width-=16;if(i&&s>=0&&s<i.length){var n=e.commonService.getPageRect(i[s].nativeElement);l.top=n.top-t.top-1}else l.top=-9999999;e.blockSelectRect.push(l)})}};t.prototype.updateVisibleRange=function(){this.visibleRange=1;var e=this.getItemElemList();if(e&&e.length>0){for(var t=0,i=0;i<e.length;i++)t+=e[i].nativeElement.offsetHeight;var o=Math.floor(t/e.length);if(o>0)this.visibleRange=Math.floor(this.clientRect.height/o)+1}};t.prototype.updateView=function(){this.currentIndex=this.avgItemHeight>0?Math.floor(this.currentScrollPos.y/this.avgItemHeight):0;if(this.currentIndex!=this.prevIndex){this.updateScrollItemList();this.updateBlockSize();this.updateHoverContentPos();this.updateSelectContentPos();this.prevIndex=this.currentIndex}};t.prototype.updateCloneElemPos=function(e){if(1==e.buttons)if(this.cloneElem){this.cloneElem.style.top=e.pageY-this.cloneElemStartPos.y+"px";this.cloneElem.style.left=e.pageX-this.cloneElemStartPos.x+"px"}};t.prototype.onCtrlMouseEnter=function(e){if(this.isEnabled&&1==e.buttons&&this.cloneElem)this.cloneElem.style.display="block";if(this.isEnabled)this.state|=integralui_core_1.IntegralUIObjectState.hovered;this.elemRenderer.setStyle(this.elemRef.nativeElement,"cursor","default")};t.prototype.onCtrlMouseLeave=function(e){if(this.isEnabled&&1==e.buttons&&this.cloneElem)this.cloneElem.style.display="none";this.state&=~integralui_core_1.IntegralUIObjectState.hovered;this.blockHoverRect.top=-9999999;this.stopScrollTimer()};t.prototype.onCtrlMouseMove=function(e){if(!this.hoverItem)this.blockHoverRect.top=-9999999};t.prototype.itemMouseDown=function(e,t){if(this.isEnabled){this.isItemClicked=!0;if(this.options.allowFocus&&1==e.buttons)this.currentFocusItem=t.data;this.processSelection(e,t.data);if(this.prevClickedObj)this.prevClickedObj.isClicked=!1;t.isClicked=!0;t.clickPos=this.commonService.getClientPos(e,this.elemRef.nativeElement.firstElementChild);this.prevClickedObj=t;this.updateSelectContentPos()}e.stopPropagation()};t.prototype.itemMouseUp=function(e,t){if(this.isEnabled&&this.isItemClicked){this.updateSelection(e,t.data);this.updateSelectContentPos()}this.isItemClicked=!1};t.prototype.onScroll=function(e){if(e.target)if(!this.virtualMode)this.scrollPos({x:e.target.scrollLeft,y:e.target.scrollTop});else{e.target.scrollTop=0;e.target.scrollLeft=0}};t.prototype.scrollPos=function(e){if(0!=this.virtualMode){if(e){this.currentScrollPos={x:Math.max(0,Math.min(e.x,this.maxScrollPos.x)),y:Math.max(0,Math.min(e.y,this.maxScrollPos.y))};this.scrollPosChanged.emit({value:this.currentScrollPos})}return{x:Math.floor(this.currentScrollPos.x),y:Math.floor(this.currentScrollPos.y)}}else{if(this.elemRef){var t={width:this.elemRef.nativeElement.firstElementChild.scrollWidth,height:this.elemRef.nativeElement.firstElementChild.scrollHeight};this.maxScrollPos={x:t.width>this.elemRef.nativeElement.firstElementChild.clientWidth?t.width-this.elemRef.nativeElement.firstElementChild.clientWidth:0,y:t.height>this.elemRef.nativeElement.firstElementChild.clientHeight?t.height-this.elemRef.nativeElement.firstElementChild.clientHeight:0};if(e){this.currentScrollPos.x=Math.max(0,Math.min(e.x,this.maxScrollPos.x));this.currentScrollPos.y=Math.max(0,Math.min(e.y,this.maxScrollPos.y));this.elemRef.nativeElement.firstElementChild.scrollLeft=this.currentScrollPos.x;this.elemRef.nativeElement.firstElementChild.scrollTop=this.currentScrollPos.y;this.scrollPosChanged.emit({value:this.currentScrollPos})}else{this.currentScrollPos.x=Math.max(0,Math.min(this.elemRef.nativeElement.firstElementChild.scrollLeft,this.maxScrollPos.x));this.currentScrollPos.y=Math.max(0,Math.min(this.elemRef.nativeElement.firstElementChild.scrollTop,this.maxScrollPos.y))}}return this.currentScrollPos}};t.prototype.changeHorizontalScrollPos=function(e){this.currentScrollPos.x=Math.max(0,Math.min(e,this.maxScrollPos.x));if(this.currentScrollPos.x!=this.prevScrollPos.x){this.scrollPosChanged.emit({value:this.scrollPos()});this.prevScrollPos.x=this.currentScrollPos.x}};t.prototype.changeVerticalScrollPos=function(e){this.currentScrollPos.y=Math.max(0,Math.min(e,this.maxScrollPos.y));if(this.currentScrollPos.y!=this.prevScrollPos.y){this.updateView();this.scrollPosChanged.emit({value:this.scrollPos()});this.prevScrollPos.y=this.currentScrollPos.y}};t.prototype.processMouseWheel=function(e,t){if(this.isEnabled){this.hoverItem=null;var i=Math.max(-1,Math.min(1,e.wheelDelta||-e.detail)),o=5;switch(this.mouseWheelSpeed){case integralui_core_1.IntegralUISpeedMode.VerySlow:o=15;break;case integralui_core_1.IntegralUISpeedMode.Slow:o=9;break;case integralui_core_1.IntegralUISpeedMode.Fast:o=3;break;case integralui_core_1.IntegralUISpeedMode.VeryFast:o=1}if(0!=this.virtualMode){e.preventDefault();if(this.isVerScrollVisible()){var r=Math.floor(this.clientRect.height/o);if(this.mouseWheelSpeed==integralui_core_1.IntegralUISpeedMode.VerySlow&&this.avgItemHeight>0)r=this.avgItemHeight;var s=this.currentScrollPos.y+r*i*-1;this.changeVerticalScrollPos(s)}else if(t&&this.isHorScrollVisible()){r=Math.floor(this.clientRect.width/o),s=this.currentScrollPos.x+r*i*-1;this.changeHorizontalScrollPos(s)}e.stopPropagation()}else if(t){e.preventDefault();r=Math.floor(this.clientRect.width/o),s=this.currentScrollPos.x+r*i*-1;this.elemRef.nativeElement.firstElementChild.scrollLeft=s;e.stopPropagation()}}};t.prototype.isVerScrollVisible=function(){return this.isEnabled&&this.options.showScroll.vertical&&this.scrollSize.height>0?!0:!1};t.prototype.isHorScrollVisible=function(){return this.isEnabled&&this.options.showScroll.horizontal&&this.scrollSize.width>0?!0:!1};t.prototype.onVerticalScrollStart=function(e){this.hoverItem=null;this.isScrollActive=!0};t.prototype.onVerticalScrollEnd=function(e){this.isScrollActive=!1};t.prototype.onVerticalScrollChanged=function(e){this.changeVerticalScrollPos(e.value)};t.prototype.onHorizontalScrollStart=function(e){this.hoverItem=null;this.isScrollActive=!0};t.prototype.onHorizontalScrollEnd=function(e){this.isScrollActive=!1};t.prototype.onHorizontalScrollChanged=function(e){this.currentScrollPos.x=e.value;this.scrollPosChanged.emit({value:this.scrollPos()})};t.prototype.scrollMouseEnter=function(e){this.blockHoverRect.top=-9999999};t.prototype.processScroll=function(e){if(this.isVerScrollVisible()){var t=this.commonService.getShiftPos(),i=this.commonService.getMousePos(e);i.x-=t.x;i.y-=t.y;var o=this.commonService.getPageRect(this.elemRef.nativeElement.firstElementChild),r=o.top+25,s=o.bottom-25;if(this.isHorScrollVisible())s-=16;if(i.y<r&&this.currentScrollPos.y>0)this.startScrollTimer(!1);else if(i.y>s&&this.currentScrollPos.y<this.maxScrollPos.y)this.startScrollTimer(!0);else this.stopScrollTimer()}else this.stopScrollTimer()};t.prototype.startScrollTimer=function(e,t){var i=this;i.removeDropMark();if(!i.isScrollTimerActive){i.accelerator=.5;i.scrollCount=0;i.isScro