all files / actions/ touch.js

100% Statements 67/67
87.5% Branches 21/24
100% Functions 13/13
100% Lines 67/67
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112                                                     15× 15× 15×     15×   17×   15× 15× 14×                   22×   22× 22×          
define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-popups", "@syncfusion/ej2-buttons", "../base/css-constant"], function (require, exports, ej2_base_1, ej2_popups_1, ej2_buttons_1, cls) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var KanbanTouch = (function () {
        function KanbanTouch(parent) {
            this.parent = parent;
            this.tabHold = false;
        }
        KanbanTouch.prototype.wireTouchEvents = function () {
            this.element = this.parent.element.querySelector('.' + cls.CONTENT_CLASS);
            this.touchObj = new ej2_base_1.Touch(this.element, { tapHold: this.tapHoldHandler.bind(this) });
        };
        KanbanTouch.prototype.tapHoldHandler = function (e) {
            this.tabHold = true;
            var target = ej2_base_1.closest(e.originalEvent.target, '.' + cls.CARD_CLASS);
            Eif (target && this.parent.cardSettings.selectionType === 'Multiple') {
                this.parent.actionModule.cardSelection(target, true, false);
                if (!this.mobilePopup) {
                    this.renderMobilePopup();
                    this.mobilePopup.show();
                }
                this.updatePopupContent();
            }
        };
        KanbanTouch.prototype.renderMobilePopup = function () {
            Eif (this.parent.cardSettings.selectionType === 'Multiple') {
                var mobilePopupWrapper = ej2_base_1.createElement('div', {
                    className: cls.POPUP_WRAPPER_CLASS + ' e-popup-close',
                    innerHTML: "<div class=\"" + cls.POPUP_HEADER_CLASS + "\"><button class=\"" + cls.CLOSE_CLASS + "\"></button></div>" +
                        ("<div class=\"" + cls.POPUP_CONTENT_CLASS + "\"></div>")
                });
                document.body.appendChild(mobilePopupWrapper);
                ej2_base_1.addClass([mobilePopupWrapper], cls.DEVICE_CLASS);
                this.mobilePopup = new ej2_popups_1.Popup(mobilePopupWrapper, {
                    targetType: 'container',
                    enableRtl: this.parent.enableRtl,
                    hideAnimation: { name: 'ZoomOut' },
                    showAnimation: { name: 'ZoomIn' },
                    collision: { X: 'fit', Y: 'fit' },
                    position: { X: 'left', Y: 'top' },
                    viewPortElement: document.body,
                    zIndex: 1004,
                    close: this.popupClose.bind(this)
                });
                var closeIcon = this.mobilePopup.element.querySelector('.' + cls.CLOSE_CLASS);
                var buttonObj = new ej2_buttons_1.Button({
                    cssClass: 'e-flat e-round e-small',
                    enableRtl: this.parent.enableRtl,
                    iconCss: cls.ICON_CLASS + ' ' + cls.CLOSE_ICON_CLASS
                });
                buttonObj.appendTo(closeIcon);
                buttonObj.isStringTemplate = true;
                ej2_base_1.EventHandler.add(closeIcon, 'click', this.closeClick, this);
            }
        };
        KanbanTouch.prototype.getPopupContent = function () {
            var popupContent;
            var selectedCards = this.parent.getSelectedCards();
            if (selectedCards.length > 1) {
                popupContent = '(' + selectedCards.length + ') ' + this.parent.localeObj.getConstant('cardsSelected');
            }
            else if (selectedCards.length === 1) {
                popupContent = ' ' + this.parent.getCardDetails(selectedCards[0])[this.parent.cardSettings.headerField];
            }
            return popupContent;
        };
        KanbanTouch.prototype.updatePopupContent = function () {
            if (!this.mobilePopup) {
                return;
            }
            var popupContent = this.getPopupContent();
            if (popupContent) {
                this.mobilePopup.element.querySelector('.' + cls.POPUP_CONTENT_CLASS).textContent = popupContent;
            }
            else {
                this.mobilePopup.hide();
            }
        };
        KanbanTouch.prototype.closeClick = function () {
            this.parent.touchModule.mobilePopup.hide();
        };
        KanbanTouch.prototype.popupClose = function () {
            this.popupDestroy();
        };
        KanbanTouch.prototype.popupDestroy = function () {
            if (this.mobilePopup && this.mobilePopup.element) {
                var instance = this.mobilePopup.element.querySelector('.e-control.e-btn').ej2_instances[0];
                Eif (instance) {
                    instance.destroy();
                }
                this.mobilePopup.destroy();
                ej2_base_1.remove(this.mobilePopup.element);
                this.mobilePopup = null;
            }
        };
        KanbanTouch.prototype.unWireTouchEvents = function () {
            if (this.touchObj) {
                this.touchObj.destroy();
            }
            this.touchObj = null;
            this.element = null;
        };
        KanbanTouch.prototype.destroy = function () {
            this.popupDestroy();
            this.unWireTouchEvents();
            this.tabHold = false;
        };
        return KanbanTouch;
    }());
    exports.KanbanTouch = KanbanTouch;
});