all files / multi-select/ checkbox-selection.js

98.11% Statements 363/370
88.89% Branches 216/243
100% Functions 33/33
98.11% Lines 363/370
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 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542   212× 212× 212× 212× 205×   337×   205×   204× 204× 204× 204× 204× 204× 204× 204× 204× 204× 204× 204× 204× 204× 204× 204×   369× 155×   207× 207× 207× 207× 207× 207× 207× 207× 207× 207× 207× 207× 207× 207× 207×   253× 253× 242× 3672×       11× 11× 47× 47×         3851× 3851× 3744×     107×   3851×   3767× 3767× 3767× 3767× 3767× 545×   3767×     84×     451× 358× 107×     107×     107× 107× 107× 107× 107×         107× 102×     98×     107×   358×     26×     332×   358×   93×     155× 155× 155× 155× 155× 155× 155× 155×   2214× 2214× 1946× 1946×               268× 268×   2214× 115×   2214× 2214×   2214× 2214× 2214× 2214×     2241×   27× 27×   25×       27× 27× 27× 27× 27×   27×   2570× 2570× 2570× 2067× 2067× 2067× 2067× 19× 19×     503× 217× 217× 217×     286×           187× 176×     176×       176× 176× 176× 21× 21×   176×         176×       176× 176× 176×                   176× 176× 155× 155×   176× 176× 176× 176× 176× 176× 176×                 23× 23× 23× 23× 23× 23× 23× 23× 23× 23×   23× 23× 23× 23× 23× 14×   23×     23×     23× 23× 23× 23× 23× 23× 23×   23× 15× 15× 15× 15×     526× 526× 526×   526×   74× 74× 74×   70× 23×   70× 47×   70×     69×   67×   15× 15× 15×   67×   15× 15× 15× 15×   67×   14×       147× 138× 138×     138×   47× 14× 14× 14× 14× 14×       91×     138×           138×         178× 178×       178× 92× 92× 92×   178× 86× 86×     329× 64× 64×   329× 251× 251×   329× 14× 14×     464× 19× 19× 19× 19× 19× 19× 19×       445× 445× 445× 445×   445× 445×       2361× 2175×     186×     130× 66× 66× 66×     66× 53× 53× 398×   53× 53× 53×     47×     66×          
define(["require", "exports", "@syncfusion/ej2-buttons", "@syncfusion/ej2-inputs", "@syncfusion/ej2-base", "@syncfusion/ej2-base", "../drop-down-base/drop-down-base"], function (require, exports, ej2_buttons_1, ej2_inputs_1, ej2_base_1, ej2_base_2, drop_down_base_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var ICON = 'e-icons';
    var CHECKBOXFRAME = 'e-frame';
    var CHECK = 'e-check';
    var CHECKBOXWRAP = 'e-checkbox-wrapper';
    var INDETERMINATE = 'e-stop';
    var checkAllParent = 'e-selectall-parent';
    var searchBackIcon = 'e-input-group-icon e-back-icon e-icons';
    var filterBarClearIcon = 'e-input-group-icon e-clear-icon e-icons';
    var filterInput = 'e-input-filter';
    var filterParent = 'e-filter-parent';
    var mobileFilter = 'e-ddl-device-filter';
    var clearIcon = 'e-clear-icon';
    var popupFullScreen = 'e-popup-full-page';
    var device = 'e-ddl-device';
    var FOCUS = 'e-input-focus';
    var CheckBoxSelection = (function () {
        function CheckBoxSelection(parent) {
            this.activeLi = [];
            this.activeEle = [];
            this.parent = parent;
            this.removeEventListener();
            this.addEventListener();
        }
        CheckBoxSelection.prototype.getModuleName = function () {
            return 'CheckBoxSelection';
        };
        CheckBoxSelection.prototype.addEventListener = function () {
            if (this.parent.isDestroyed) {
                return;
            }
            this.parent.on('updatelist', this.listSelection, this);
            this.parent.on('listoption', this.listOption, this);
            this.parent.on('selectAll', this.setSelectAll, this);
            this.parent.on('checkSelectAll', this.checkSelectAll, this);
            this.parent.on('searchBox', this.setSearchBox, this);
            this.parent.on('blur', this.onBlurHandler, this);
            this.parent.on('targetElement', this.targetElement, this);
            this.parent.on('deviceSearchBox', this.setDeviceSearchBox, this);
            this.parent.on('inputFocus', this.getFocus, this);
            this.parent.on('reOrder', this.setReorder, this);
            this.parent.on('activeList', this.getActiveList, this);
            this.parent.on('selectAllText', this.setLocale, this);
            this.parent.on('filterBarPlaceholder', this.setPlaceholder, this);
            ej2_base_1.EventHandler.add(document, 'mousedown', this.onDocumentClick, this);
            this.parent.on('addItem', this.checboxCreate, this);
            this.parent.on('popupFullScreen', this.setPopupFullScreen, this);
        };
        CheckBoxSelection.prototype.removeEventListener = function () {
            if (this.parent.isDestroyed) {
                return;
            }
            this.parent.off('updatelist', this.listSelection);
            this.parent.off('listoption', this.listOption);
            this.parent.off('selectAll', this.setSelectAll);
            this.parent.off('checkSelectAll', this.checkSelectAll);
            this.parent.off('searchBox', this.setSearchBox);
            this.parent.off('blur', this.onBlurHandler);
            this.parent.off('targetElement', this.targetElement);
            this.parent.off('deviceSearchBox', this.setDeviceSearchBox);
            this.parent.off('inputFocus', this.getFocus);
            this.parent.off('reOrder', this.setReorder);
            this.parent.off('activeList', this.getActiveList);
            this.parent.off('selectAllText', this.setLocale);
            this.parent.off('filterBarPlaceholder', this.setPlaceholder);
            this.parent.off('addItem', this.checboxCreate);
            this.parent.off('popupFullScreen', this.setPopupFullScreen);
        };
        CheckBoxSelection.prototype.listOption = function (args) {
            var _this = this;
            if (ej2_base_2.isNullOrUndefined(this.parent.listCurrentOptions.itemCreated)) {
                this.parent.listCurrentOptions.itemCreated = function (e) {
                    _this.checboxCreate(e);
                };
            }
            else {
                var itemCreated_1 = this.parent.listCurrentOptions.itemCreated;
                this.parent.listCurrentOptions.itemCreated = function (e) {
                    _this.checboxCreate(e);
                    itemCreated_1.apply(_this, [e]);
                };
            }
        };
        CheckBoxSelection.prototype.setPlaceholder = function (props) {
            ej2_inputs_1.Input.setPlaceholder(props.filterBarPlaceholder, this.filterInput);
        };
        CheckBoxSelection.prototype.checboxCreate = function (e) {
            var item;
            if (!ej2_base_2.isNullOrUndefined(e.item)) {
                item = e.item;
            }
            else {
                item = e;
            }
            if (this.parent.enableGroupCheckBox || (item.className !== 'e-list-group-item '
                && item.className !== 'e-list-group-item')) {
                var checkboxEle = ej2_buttons_1.createCheckBox(this.parent.createElement, true);
                var icon = ej2_base_1.select('div.' + ICON, item);
                item.insertBefore(checkboxEle, item.childNodes[ej2_base_2.isNullOrUndefined(icon) ? 0 : 1]);
                ej2_base_1.select('.' + CHECKBOXFRAME, checkboxEle);
                if (this.parent.enableGroupCheckBox) {
                    this.parent.popupWrapper.classList.add('e-multiselect-group');
                }
                return item;
            }
            else {
                return item;
            }
        };
        CheckBoxSelection.prototype.setSelectAll = function () {
            if (this.parent.showSelectAll) {
                if (ej2_base_2.isNullOrUndefined(this.checkAllParent)) {
                    this.checkAllParent = this.parent.createElement('div', {
                        className: checkAllParent
                    });
                    this.selectAllSpan = this.parent.createElement('span', {
                        className: 'e-all-text'
                    });
                    this.selectAllSpan.textContent = '';
                    this.checkAllParent.appendChild(this.selectAllSpan);
                    this.setLocale();
                    this.checboxCreate(this.checkAllParent);
                    if (this.parent.headerTemplate) {
                        if (!ej2_base_2.isNullOrUndefined(this.parent.filterParent)) {
                            ej2_base_2.append([this.checkAllParent], this.parent.filterParent);
                        }
                        else {
                            ej2_base_2.append([this.checkAllParent], this.parent.popupWrapper);
                        }
                    }
                    if (!this.parent.headerTemplate) {
                        if (!ej2_base_2.isNullOrUndefined(this.parent.filterParent)) {
                            this.parent.filterParent.parentNode.insertBefore(this.checkAllParent, this.parent.filterParent.nextSibling);
                        }
                        else {
                            ej2_base_2.prepend([this.checkAllParent], this.parent.popupWrapper);
                        }
                    }
                    ej2_base_1.EventHandler.add(this.checkAllParent, 'mousedown', this.clickHandler, this);
                }
                if (this.parent.list.classList.contains('e-nodata') || (this.parent.listData && this.parent.listData.length <= 1 && !this.parent.enableVirtualization &&
                    !(this.parent.isDynamicDataChange)) || (this.parent.isDynamicDataChange &&
                    this.parent.listData && this.parent.listData.length <= 1)) {
                    this.checkAllParent.style.display = 'none';
                }
                else {
                    this.checkAllParent.style.display = 'block';
                }
                this.parent.selectAllHeight = this.checkAllParent.getBoundingClientRect().height;
            }
            else if (!ej2_base_2.isNullOrUndefined(this.checkAllParent)) {
                this.checkAllParent.parentElement.removeChild(this.checkAllParent);
                this.checkAllParent = null;
            }
        };
        CheckBoxSelection.prototype.destroy = function () {
            this.removeEventListener();
            ej2_base_1.EventHandler.remove(document, 'mousedown', this.onDocumentClick);
            this.checkAllParent = null;
            this.clearIconElement = null;
            this.filterInput = null;
            this.filterInputObj = null;
            this.checkWrapper = null;
            this.selectAllSpan = null;
        };
        CheckBoxSelection.prototype.listSelection = function (args) {
            var target;
            if (!ej2_base_2.isNullOrUndefined(args.e)) {
                var frameElm = args.li.querySelector('.e-checkbox-wrapper .e-frame');
                target = !ej2_base_2.isNullOrUndefined(args.e.target) ?
                    (args.e.target.classList.contains('e-frame')
                        && (!this.parent.showSelectAll
                            || (this.checkAllParent && !this.checkAllParent.contains(args.e.target)))) ?
                        args.e.target : args.li.querySelector('.e-checkbox-wrapper').childNodes[1]
                    : args.li.querySelector('.e-checkbox-wrapper').childNodes[1];
            }
            else {
                var checkboxWrapper = args.li.querySelector('.e-checkbox-wrapper');
                target = checkboxWrapper ? checkboxWrapper.childNodes[1] : args.li.lastElementChild.childNodes[1];
            }
            if (this.parent.itemTemplate || this.parent.enableGroupCheckBox) {
                target = args.li.firstElementChild.childNodes[1];
            }
            Eif (!ej2_base_2.isNullOrUndefined(target)) {
                this.checkWrapper = ej2_base_2.closest(target, '.' + CHECKBOXWRAP);
            }
            Eif (!ej2_base_2.isNullOrUndefined(this.checkWrapper)) {
                var checkElement = ej2_base_1.select('.' + CHECKBOXFRAME, this.checkWrapper);
                var selectAll = false;
                this.validateCheckNode(this.checkWrapper, checkElement.classList.contains(CHECK), args.li, args.e, selectAll);
            }
        };
        CheckBoxSelection.prototype.validateCheckNode = function (checkWrap, isCheck, li, e, selectAll) {
            this.changeState(checkWrap, isCheck ? 'uncheck' : 'check', e, true, selectAll);
        };
        CheckBoxSelection.prototype.clickHandler = function (e) {
            var target;
            if (e.currentTarget.classList.contains(this.checkAllParent.className) ||
                (e.currentTarget.classList.value === this.checkAllParent.className)) {
                target = e.currentTarget.firstElementChild.lastElementChild;
            }
            else {
                target = e.currentTarget;
            }
            this.checkWrapper = ej2_base_2.closest(target, '.' + CHECKBOXWRAP);
            var selectAll = true;
            Eif (!ej2_base_2.isNullOrUndefined(this.checkWrapper)) {
                var checkElement = ej2_base_1.select('.' + CHECKBOXFRAME, this.checkWrapper);
                this.validateCheckNode(this.checkWrapper, checkElement.classList.contains(CHECK), null, e, selectAll);
            }
            e.preventDefault();
        };
        CheckBoxSelection.prototype.changeState = function (wrapper, state, e, isPrevent, selectAll) {
            var ariaState;
            var frameSpan = wrapper.getElementsByClassName(CHECKBOXFRAME)[0];
            if (state === 'check' && !frameSpan.classList.contains(CHECK)) {
                frameSpan.classList.remove(INDETERMINATE);
                frameSpan.classList.add(CHECK);
                ariaState = 'true';
                if (selectAll) {
                    this.parent.selectAllItems(true, e);
                    this.setLocale(true);
                }
            }
            else if (state === 'uncheck' && (frameSpan.classList.contains(CHECK) || frameSpan.classList.contains(INDETERMINATE))) {
                ej2_base_1.removeClass([frameSpan], [CHECK, INDETERMINATE]);
                ariaState = 'false';
                if (selectAll) {
                    this.parent.selectAllItems(false, e);
                    this.setLocale();
                }
            }
            else if (state === 'indeterminate' && !(frameSpan.classList.contains(INDETERMINATE))) {
                ej2_base_1.removeClass([frameSpan], [CHECK]);
                frameSpan.classList.add(INDETERMINATE);
                ariaState = 'false';
                Iif (selectAll) {
                    this.parent.selectAllItems(false, e);
                    this.setLocale();
                }
            }
        };
        CheckBoxSelection.prototype.setSearchBox = function (args) {
            if (ej2_base_2.isNullOrUndefined(this.parent.filterParent)) {
                this.parent.filterParent = this.parent.createElement('span', {
                    className: filterParent
                });
                this.filterInput = this.parent.createElement('input', {
                    attrs: { type: 'text' },
                    className: filterInput
                });
                this.parent.element.parentNode.insertBefore(this.filterInput, this.parent.element);
                var backIcon = false;
                if (ej2_base_2.Browser.isDevice && this.parent.isDeviceFullScreen) {
                    backIcon = true;
                    this.parent.mobFilter = false;
                }
                this.filterInputObj = ej2_inputs_1.Input.createInput({
                    element: this.filterInput,
                    buttons: backIcon ? [searchBackIcon, filterBarClearIcon] : [filterBarClearIcon],
                    properties: { placeholder: this.parent.filterBarPlaceholder }
                }, this.parent.createElement);
                if (!ej2_base_2.isNullOrUndefined(this.parent.cssClass)) {
                    if (this.parent.cssClass.split(' ').indexOf('e-outline') !== -1) {
                        ej2_base_1.addClass([this.filterInputObj.container], 'e-outline');
                    }
                    else Eif (this.parent.cssClass.split(' ').indexOf('e-filled') !== -1) {
                        ej2_base_1.addClass([this.filterInputObj.container], 'e-filled');
                    }
                }
                ej2_base_2.append([this.filterInputObj.container], this.parent.filterParent);
                ej2_base_2.prepend([this.parent.filterParent], args.popupElement);
                ej2_base_2.attributes(this.filterInput, {
                    'aria-disabled': 'false',
                    'role': 'combobox',
                    'autocomplete': 'off',
                    'autocapitalize': 'off',
                    'spellcheck': 'false',
                    'aria-label': 'multiselect',
                    'aria-expanded': 'true',
                    'aria-controls': args.popupElement.id
                });
                this.clearIconElement = this.filterInput.parentElement.querySelector('.' + clearIcon);
                if (!ej2_base_2.Browser.isDevice && this.clearIconElement) {
                    ej2_base_1.EventHandler.add(this.clearIconElement, 'mousedown', this.clearText, this);
                    this.clearIconElement.style.visibility = 'hidden';
                }
                ej2_base_1.EventHandler.add(this.filterInput, 'input', this.parent.onInput, this.parent);
                ej2_base_1.EventHandler.add(this.filterInput, 'keyup', this.parent.keyUp, this.parent);
                ej2_base_1.EventHandler.add(this.filterInput, 'keydown', this.parent.onKeyDown, this.parent);
                ej2_base_1.EventHandler.add(this.filterInput, 'blur', this.onBlurHandler, this);
                ej2_base_1.EventHandler.add(this.filterInput, 'paste', this.parent.pasteHandler, this.parent);
                this.parent.searchBoxHeight = (this.filterInputObj.container.parentElement).getBoundingClientRect().height;
                return this.filterInputObj;
            }
        };
        CheckBoxSelection.prototype.clickOnBackIcon = function (e) {
            this.parent.hidePopup();
            ej2_base_1.removeClass([document.body, this.parent.popupObj.element], popupFullScreen);
            this.parent.inputElement.focus();
        };
        CheckBoxSelection.prototype.clearText = function (e) {
            this.parent.targetInputElement.value = '';
            Eif (this.parent.allowFiltering && this.parent.targetInputElement.value === '') {
                this.parent.search(null);
            }
            this.parent.refreshListItems(null);
            this.parent.refreshPopup();
            this.clearIconElement.style.visibility = 'hidden';
            this.filterInput.focus();
            Eif (!this.parent.enableVirtualization || (this.parent.enableVirtualization && (ej2_base_2.isNullOrUndefined(this.parent.value)
                || (this.parent.value && this.parent.value.length === 0)))) {
                this.setReorder(e);
            }
            this.boundPreventListSelection = this.preventListSelection.bind(this);
            this.parent.popupWrapper.addEventListener('mouseup', this.boundPreventListSelection, true);
            e.preventDefault();
        };
        CheckBoxSelection.prototype.preventListSelection = function (e) {
            e.stopPropagation();
            this.parent.popupWrapper.removeEventListener('mouseup', this.boundPreventListSelection, true);
            this.boundPreventListSelection = null;
        };
        CheckBoxSelection.prototype.setDeviceSearchBox = function () {
            this.parent.popupObj.element.classList.add(device);
            this.parent.popupObj.element.classList.add(mobileFilter);
            this.parent.popupObj.position = { X: 0, Y: 0 };
            this.parent.popupObj.dataBind();
            this.setSearchBoxPosition();
            this.backIconElement = this.filterInputObj.container.querySelector('.e-back-icon');
            this.clearIconElement = this.filterInputObj.container.querySelector('.' + clearIcon);
            this.clearIconElement.style.visibility = 'hidden';
            ej2_base_1.EventHandler.add(this.backIconElement, 'click', this.clickOnBackIcon, this);
            ej2_base_1.EventHandler.add(this.clearIconElement, 'click', this.clearText, this);
        };
        CheckBoxSelection.prototype.setSearchBoxPosition = function () {
            var searchBoxHeight = this.filterInput.parentElement.getBoundingClientRect().height;
            var selectAllHeight = 0;
            var footerHeight = 0;
            var headerHeight = 0;
            if (this.checkAllParent) {
                selectAllHeight = this.checkAllParent.getBoundingClientRect().height;
            }
            Iif (this.parent.header) {
                headerHeight = this.parent.header.getBoundingClientRect().height;
            }
            Iif (this.parent.footer) {
                footerHeight = this.parent.footer.getBoundingClientRect().height;
            }
            this.parent.popupObj.element.style.maxHeight = '100%';
            this.parent.popupObj.element.style.width = '100%';
            this.parent.list.style.maxHeight = (window.innerHeight - searchBoxHeight - selectAllHeight - headerHeight - footerHeight) + 'px';
            this.parent.list.style.height = (window.innerHeight - searchBoxHeight - selectAllHeight - headerHeight - footerHeight) + 'px';
            var clearElement = this.filterInput.parentElement.querySelector('.' + clearIcon);
            ej2_base_1.detach(this.filterInput);
            clearElement.parentElement.insertBefore(this.filterInput, clearElement);
        };
        CheckBoxSelection.prototype.setPopupFullScreen = function () {
            if (this.parent && this.parent.popupObj) {
                ej2_base_2.attributes(this.parent.popupObj.element, { style: 'left:0px;right:0px;top:0px;bottom:0px;' });
                ej2_base_1.addClass([document.body, this.parent.popupObj.element], popupFullScreen);
                this.parent.popupObj.element.style.maxHeight = '100%';
                this.parent.popupObj.element.style.width = '100%';
            }
        };
        CheckBoxSelection.prototype.targetElement = function () {
            Eif (!ej2_base_2.isNullOrUndefined(this.clearIconElement)) {
                this.parent.targetInputElement = this.filterInput;
                this.clearIconElement.style.visibility = this.parent.targetInputElement.value === '' ? 'hidden' : 'visible';
            }
            return this.parent.targetInputElement.value;
        };
        CheckBoxSelection.prototype.onBlurHandler = function (e) {
            Eif (!this.parent.element.classList.contains('e-listbox')) {
                var target = void 0;
                if (this.parent.keyAction) {
                    return;
                }
                if (ej2_base_2.Browser.isIE) {
                    target = !ej2_base_2.isNullOrUndefined(e) && e.target;
                }
                if (!ej2_base_2.Browser.isIE) {
                    target = !ej2_base_2.isNullOrUndefined(e) && e.relatedTarget;
                }
                if (this.parent.popupObj && document.body.contains(this.parent.popupObj.element) && this.parent.popupObj.element.contains(target)
                    && !ej2_base_2.Browser.isIE && this.filterInput) {
                    this.filterInput.focus();
                    return;
                }
                if (this.parent.scrollFocusStatus && this.filterInput) {
                    e.preventDefault();
                    this.filterInput.focus();
                    this.parent.scrollFocusStatus = false;
                    return;
                }
                if (this.parent.popupObj && document.body.contains(this.parent.popupObj.element)
                    && !this.parent.popupObj.element.classList.contains('e-popup-close')) {
                    this.parent.inputFocus = false;
                    this.parent.updateValueState(e, this.parent.value, this.parent.tempValues);
                    this.parent.dispatchEvent(this.parent.hiddenElement, 'change');
                }
                if (this.parent.popupObj && document.body.contains(this.parent.popupObj.element) &&
                    !this.parent.popupObj.element.classList.contains('e-popup-close')) {
                    this.parent.inputFocus = false;
                    this.parent.overAllWrapper.classList.remove(FOCUS);
                    this.parent.trigger('blur');
                    this.parent.focused = true;
                }
                if (this.parent.popupObj && document.body.contains(this.parent.popupObj.element) &&
                    !this.parent.popupObj.element.classList.contains('e-popup-close') && !ej2_base_2.Browser.isDevice) {
                    this.parent.hidePopup();
                }
            }
        };
        CheckBoxSelection.prototype.onDocumentClick = function (e) {
            if (this.parent.getLocaleName() !== 'listbox') {
                var target = e.target;
                if (!ej2_base_2.isNullOrUndefined(this.parent.popupObj) && ej2_base_2.closest(target, '[id="' + this.parent.popupObj.element.id + '"]')) {
                    Eif (!(this.filterInput && this.filterInput.value !== '')) {
                        e.preventDefault();
                    }
                }
                if (!(!ej2_base_2.isNullOrUndefined(this.parent.popupObj) && ej2_base_2.closest(target, '[id="' + this.parent.popupObj.element.id + '"]'))
                    && !ej2_base_2.isNullOrUndefined(this.parent.overAllWrapper) && !this.parent.overAllWrapper.contains(e.target)) {
                    if (this.parent.overAllWrapper.classList.contains(drop_down_base_1.dropDownBaseClasses.focus) || this.parent.isPopupOpen()) {
                        this.parent.inputFocus = false;
                        this.parent.scrollFocusStatus = false;
                        this.parent.hidePopup();
                        this.parent.onBlurHandler(e, true);
                        this.parent.focused = true;
                    }
                }
                else {
                    this.parent.scrollFocusStatus = (ej2_base_2.Browser.isIE || ej2_base_2.Browser.info.name === 'edge') &&
                        (document.activeElement === this.filterInput);
                }
                if (!ej2_base_2.isNullOrUndefined(this.parent.overAllWrapper) && !this.parent.overAllWrapper.contains(e.target) && this.parent.overAllWrapper.classList.contains('e-input-focus') &&
                    !this.parent.isPopupOpen()) {
                    if (ej2_base_2.Browser.isIE) {
                        this.parent.onBlurHandler();
                    }
                    else {
                        this.parent.onBlurHandler(e);
                    }
                }
                Iif (this.filterInput === target) {
                    this.filterInput.focus();
                }
            }
        };
        CheckBoxSelection.prototype.getFocus = function (e) {
            this.parent.overAllWrapper.classList.remove(FOCUS);
            Iif (this.parent.keyAction && e.value !== 'clear' && e.value !== 'focus') {
                this.parent.keyAction = false;
                return;
            }
            if (e.value === 'focus') {
                this.filterInput.focus();
                this.parent.removeFocus();
                ej2_base_1.EventHandler.remove(this.parent.list, 'keydown', this.parent.onKeyDown);
            }
            if (e.value === 'clear') {
                this.filterInput.value = '';
                this.clearIconElement.style.visibility = 'hidden';
            }
        };
        CheckBoxSelection.prototype.checkSelectAll = function (e) {
            if (e.value === 'check') {
                this.changeState(this.checkAllParent, e.value, null, null, false);
                this.setLocale(true);
            }
            if (e.value === 'uncheck') {
                this.changeState(this.checkAllParent, e.value, null, null, false);
                this.setLocale();
            }
            if (e.value === 'indeterminate') {
                this.changeState(this.checkAllParent, e.value, null, null, false);
                this.setLocale();
            }
        };
        CheckBoxSelection.prototype.setLocale = function (unSelect) {
            if (this.parent.selectAllText !== 'Select All' || this.parent.unSelectAllText !== 'Unselect All') {
                var template = unSelect ? this.parent.unSelectAllText : this.parent.selectAllText;
                this.selectAllSpan.textContent = '';
                var compiledString = ej2_base_1.compile(template);
                var templateName = unSelect ? 'unSelectAllText' : 'selectAllText';
                for (var _i = 0, _a = compiledString({}, this.parent, templateName, null, !this.parent.isStringTemplate); _i < _a.length; _i++) {
                    var item = _a[_i];
                    this.selectAllSpan.textContent = item.textContent;
                }
            }
            else {
                var l10nLocale = { selectAllText: 'Select All', unSelectAllText: 'Unselect All' };
                var l10n = new ej2_base_1.L10n(this.parent.getLocaleName(), {}, this.parent.locale);
                Eif (l10n.getConstant('selectAllText') === '') {
                    l10n = new ej2_base_1.L10n('dropdowns', l10nLocale, this.parent.locale);
                }
                Eif (!ej2_base_2.isNullOrUndefined(this.selectAllSpan)) {
                    this.selectAllSpan.textContent = unSelect ? l10n.getConstant('unSelectAllText') : l10n.getConstant('selectAllText');
                }
            }
        };
        CheckBoxSelection.prototype.getActiveList = function (args) {
            if (args.li.classList.contains('e-active')) {
                this.activeLi.push(args.li.cloneNode(true));
            }
            else {
                this.activeLi.splice(args.index, 1);
            }
        };
        CheckBoxSelection.prototype.setReorder = function (args) {
            if (this.parent.enableSelectionOrder && !ej2_base_2.isNullOrUndefined(this.parent.value)) {
                var activeLiCount = this.parent.ulElement.querySelectorAll('li.e-active').length;
                var remLi = void 0;
                var ulEle_1 = this.parent.createElement('ul', {
                    className: 'e-list-parent e-ul e-reorder'
                });
                if (activeLiCount > 0) {
                    var activeListItems = this.parent.ulElement.querySelectorAll('li.e-active');
                    activeListItems.forEach(function (item) {
                        ulEle_1.appendChild(item);
                    });
                    remLi = this.parent.ulElement.querySelectorAll('li.e-active');
                    ej2_base_1.addClass(remLi, 'e-reorder-hide');
                    if (this.parent.enableVirtualization) {
                        var virtualUlElement = this.parent.list.querySelector('.e-virtual-ddl-content');
                        ej2_base_2.prepend([ulEle_1], virtualUlElement);
                    }
                    else {
                        ej2_base_2.prepend([ulEle_1], this.parent.list);
                    }
                }
                this.parent.focusAtFirstListItem();
            }
        };
        return CheckBoxSelection;
    }());
    exports.CheckBoxSelection = CheckBoxSelection;
});