UNPKG

@lidorsystems/integralui-web

Version:

IntegralUI Web - Advanced UI Components for Angular

15 lines (12 loc) 10.4 kB
/* filename: integralui.listitem.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 t=function(e,i){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)if(e.hasOwnProperty(i))t[i]=e[i]})(e,i)};return function(e,i){t(e,i);function n(){this.constructor=e}e.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_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"),_c0=["content"],_c1=["dragElem"];function IntegralUIListItem_span_5_Template(t,e){if(1&t)i0.ɵɵelement(0,"span",8);if(2&t){var i=i0.ɵɵnextContext();i0.ɵɵstyleProp("display",i.getIconStatus());i0.ɵɵproperty("ngClass",i.icon)}}function IntegralUIListItem_span_6_Template(t,e){if(1&t){i0.ɵɵelementStart(0,"span",9);i0.ɵɵtext(1);i0.ɵɵelementEnd()}if(2&t){var i=i0.ɵɵnextContext();i0.ɵɵadvance(1);i0.ɵɵtextInterpolate(i.text)}}var _c2=function(t,e){return{height:t,width:e}},_c3=function(t){return{"iui-listitem-animate-select iui-listitem-animate-select-left":t}},_c4=function(t){return{height:t}};function IntegralUIListItem_span_8_Template(t,e){if(1&t){i0.ɵɵelementStart(0,"span",10);i0.ɵɵelement(1,"span",11);i0.ɵɵelementEnd()}if(2&t){var i=i0.ɵɵnextContext();i0.ɵɵproperty("ngStyle",i0.ɵɵpureFunction2(3,_c2,i.getSize().height+"px",i.clickPos.x+"px"));i0.ɵɵadvance(1);i0.ɵɵproperty("ngClass",i0.ɵɵpureFunction1(6,_c3,i.isClicked))("ngStyle",i0.ɵɵpureFunction1(8,_c4,i.getSize().height+"px"))}}var _c5=function(t,e,i){return{left:t,height:e,width:i}},_c6=function(t){return{"iui-listitem-animate-select iui-listitem-animate-select-right":t}};function IntegralUIListItem_span_9_Template(t,e){if(1&t){i0.ɵɵelementStart(0,"span",10);i0.ɵɵelement(1,"span",11);i0.ɵɵelementEnd()}if(2&t){var i=i0.ɵɵnextContext();i0.ɵɵproperty("ngStyle",i0.ɵɵpureFunction3(3,_c5,i.clickPos.x+"px",i.getSize().height+"px",i.getSize().width-i.clickPos.x+"px"));i0.ɵɵadvance(1);i0.ɵɵproperty("ngClass",i0.ɵɵpureFunction1(7,_c6,i.isClicked))("ngStyle",i0.ɵɵpureFunction1(9,_c4,i.getSize().height+"px"))}}var _c7=function(t,e,i){return{"iui-listitem-general":t,"iui-listitem-animate":e,"iui-listitem-animate-enter-suspended":i}},_c8=["*"],IntegralUIListItem=function(t){__extends(e,t);function e(e,i,n){var r=t.call(this,e,i)||this;r.elemRef=e;r.commonService=i;r.baseService=n;r.clickPos={x:0,y:0};r.isClicked=!1;r.isHovered=!1;r.parentCtrl=null;r.spacing=0;r.itemClick=new core_1.EventEmitter;r.itemDblClick=new core_1.EventEmitter;r.itemRightClick=new core_1.EventEmitter;r.allowSelection=!0;return r}e.prototype.ngOnInit=function(){this.parentCtrl=this.baseService.getComponent();this.generalClassName="iui-listitem";this.contentClassName=this.generalClassName+"-content";this.initStyle()};e.prototype.onClick=function(t){if(this.isEnabled&&1==t.which){var e={event:t,item:this.data};if(this.parentCtrl)this.parentCtrl.itemClick.emit(e);else this.itemClick.emit(e)}};e.prototype.onDblClick=function(t){if(this.isEnabled&&1==t.which){var e={cancel:!1,event:t,item:this.data};if(this.parentCtrl)this.parentCtrl.itemDblClick.emit(e);else this.itemDblClick.emit(e)}};e.prototype.onRightClick=function(t){if(this.isEnabled){var e={event:t,item:this.data};if(this.parentCtrl)this.parentCtrl.itemRightClick.emit(e);else this.itemRightClick.emit(e)}};e.prototype.itemDragStart=function(t){if(this.isEnabled&&this.parentCtrl){var e=this.parentCtrl.getItemFromComponent(this);this.parentCtrl.processDragStart(t,e)}};e.prototype.itemDragOver=function(t,e){if(this.isEnabled&&this.parentCtrl){var i=this.parentCtrl.getItemFromComponent(this),n=this.getPageRect(),r=this.getContentSize(),o={x:n.left,y:n.top,width:n.right-n.left,height:r.height},a="none";if(this.parentCtrl.isDropPosHorizontal)a=this.parentCtrl.isDropPosHorizontal()?"horizontal":"vertical";this.parentCtrl.processDragOver(t,i,o,e,a)}t.stopPropagation()};e.prototype.itemDragDrop=function(t){if(this.isEnabled&&this.parentCtrl){var e=this.parentCtrl.getItemFromComponent(this);this.parentCtrl.processDragDrop(t,e)}t.stopPropagation()};e.prototype.onMouseEnter=function(t){if(this.isEnabled){this.state|=integralui_core_1.IntegralUIObjectState.hovered;this.mouseEnter.emit(t);if(this.data&&this.parentCtrl)this.parentCtrl.invokeEvent("ITEM_HOVER",this.data);this.isHovered=!0}t.stopPropagation()};e.prototype.onMouseDown=function(t){var e=this;if(e.isEnabled){if(e.parentCtrl){var i=e.parentCtrl.getItemFromComponent(e);e.allowSelection=e.parentCtrl.invokeMethod("SELECT_ITEM",{event:t,item:i});e.isClicked=!0;e.clickPos=e.commonService.getClientPos(t,e.elemRef.nativeElement.firstElementChild);var n=setTimeout(function(){e.isClicked=!1;clearTimeout(n)},500)}e.mouseDown.emit(t)}t.stopPropagation()};e.prototype.onMouseUp=function(t){if(this.isEnabled){if(this.parentCtrl&&this.allowSelection)this.parentCtrl.invokeMethod("UPDATE_SELECTION",{event:t,item:this.parentCtrl.getItemFromComponent(this)});this.mouseUp.emit(t)}t.stopPropagation()};e.prototype.onMouseLeave=function(t){if(this.isEnabled){this.state&=~integralui_core_1.IntegralUIObjectState.hovered;this.mouseLeave.emit(t)}this.isHovered=!1;t.stopPropagation()};e.prototype.selectItem=function(){this.state|=integralui_core_1.IntegralUIObjectState.selected};e.prototype.onTouchStart=function(t){if(this.isEnabled)if(this.parentCtrl)this.allowSelection=this.parentCtrl.invokeMethod("SELECT_ITEM",{event:t,item:this.parentCtrl.getItemFromComponent(this)});t.stopPropagation()};e.prototype.getControlStyle=function(){var t={};if(this.data&&this.parentCtrl){var e=this.parentCtrl.getDataFields();t=this.data[e.style]||{}}t.position=this.positionType;t.top=this.itemPos.top+"px";t.left=this.itemPos.left+"px";if(this.ctrlSize.width>0)t.width=this.ctrlSize.width+"px";if(this.ctrlSize.height>0)t.height=this.ctrlSize.height+"px";return t};e.ɵfac=function(t){return new(t||e)(i0.ɵɵdirectiveInject(i0.ElementRef),i0.ɵɵdirectiveInject(i1.IntegralUICommonService),i0.ɵɵdirectiveInject(i2.IntegralUIBaseService))};e.ɵcmp=i0.ɵɵdefineComponent({type:e,selectors:[["iui-listitem"]],viewQuery:function(t,e){if(1&t){i0.ɵɵviewQuery(_c0,!0,core_1.ElementRef);i0.ɵɵviewQuery(_c1,!0,core_1.ElementRef)}if(2&t){var i;i0.ɵɵqueryRefresh(i=i0.ɵɵloadQuery())&&(e.contentElem=i.first);i0.ɵɵqueryRefresh(i=i0.ɵɵloadQuery())&&(e.dragElem=i.first)}},inputs:{controlStyle:"controlStyle",data:"data",enabled:"enabled",icon:"icon",name:"name",size:"size",state:"state",text:"text",spacing:"spacing"},outputs:{click:"click",mouseDown:"mouseDown",mouseEnter:"mouseEnter",mouseLeave:"mouseLeave",mouseMove:"mouseMove",mouseUp:"mouseUp",itemClick:"itemClick",itemDblClick:"itemDblClick",itemRightClick:"itemRightClick"},features:[i0.ɵɵInheritDefinitionFeature],ngContentSelectors:_c8,decls:10,vars:12,consts:[[3,"ngClass","ngStyle","mouseenter","mousemove","mouseleave"],["draggable","true",2,"position","relative",3,"ngClass","dragstart","dragover","drop"],["dragElem",""],[3,"ngClass","click","dblclick","contextmenu","mousedown","mouseup","touchstart"],["content",""],["class","iui-item-icon",3,"ngClass","display",4,"ngIf"],["class","iui-item-label",4,"ngIf"],["class","iui-listitem-animate-select-block",3,"ngStyle",4,"ngIf"],[1,"iui-item-icon",3,"ngClass"],[1,"iui-item-label"],[1,"iui-listitem-animate-select-block",3,"ngStyle"],[3,"ngClass","ngStyle"]],template:function(t,e){if(1&t){i0.ɵɵprojectionDef();i0.ɵɵelementStart(0,"li",0);i0.ɵɵlistener("mouseenter",function(t){return e.onMouseEnter(t)})("mousemove",function(t){return e.onMouseMove(t)})("mouseleave",function(t){return e.onMouseLeave(t)});i0.ɵɵelementStart(1,"div",1,2);i0.ɵɵlistener("dragstart",function(t){return e.itemDragStart(t)})("dragover",function(t){return e.itemDragOver(t,!0)})("drop",function(t){return e.itemDragDrop(t)});i0.ɵɵelementStart(3,"div",3,4);i0.ɵɵlistener("click",function(t){return e.onClick(t)})("dblclick",function(t){return e.onDblClick(t)})("contextmenu",function(t){return e.onRightClick(t)})("mousedown",function(t){return e.onMouseDown(t)})("mouseup",function(t){return e.onMouseUp(t)})("touchstart",function(t){return e.onTouchStart(t)});i0.ɵɵtemplate(5,IntegralUIListItem_span_5_Template,1,3,"span",5);i0.ɵɵtemplate(6,IntegralUIListItem_span_6_Template,2,1,"span",6);i0.ɵɵprojection(7);i0.ɵɵelementEnd();i0.ɵɵtemplate(8,IntegralUIListItem_span_8_Template,2,10,"span",7);i0.ɵɵtemplate(9,IntegralUIListItem_span_9_Template,2,11,"span",7);i0.ɵɵelementEnd();i0.ɵɵelementEnd()}if(2&t){i0.ɵɵproperty("ngClass",i0.ɵɵpureFunction3(8,_c7,!e.allowAnimation,e.allowAnimation,e.allowAnimation&&e.isHovered))("ngStyle",e.getControlStyle());i0.ɵɵadvance(1);i0.ɵɵproperty("ngClass",e.getControlClass());i0.ɵɵadvance(2);i0.ɵɵproperty("ngClass",e.getContentClass());i0.ɵɵadvance(2);i0.ɵɵproperty("ngIf",e.icon);i0.ɵɵadvance(1);i0.ɵɵproperty("ngIf",e.text);i0.ɵɵadvance(2);i0.ɵɵproperty("ngIf",e.allowAnimation&&e.isClicked);i0.ɵɵadvance(1);i0.ɵɵproperty("ngIf",e.allowAnimation&&e.isClicked)}},directives:[i3.NgClass,i3.NgStyle,i3.NgIf],encapsulation:2});return e}(integralui_core_1.IntegralUIItem);exports.IntegralUIListItem=IntegralUIListItem;