all files / rich-text-editor/renderer/ video-module.js

92.72% Statements 841/907
85.93% Branches 696/810
94.32% Functions 83/88
92.72% Lines 841/907
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 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470   1826× 1826× 1826× 1826× 1826× 1826× 1826× 1826× 1826× 1826× 1826× 1826× 1826× 1826× 1826×   1826×     1826× 1826× 1826× 1826× 1826× 1826× 1826× 1826× 1826× 1826× 1826× 1826× 1826× 1826× 1826× 1826× 1826×   1825× 1825× 1825× 1825× 1825× 1825× 1825× 1825× 1825× 1825× 1825× 1825× 1825× 1825× 1825× 1825× 1825× 1825× 1825× 1825× 1825× 1820× 1820× 1820× 1820× 1820×       1839× 1839× 1839× 1834× 1834× 1834×     1882× 66× 66× 66×   1882× 66× 66× 66×   1882× 66× 66× 66×   1882×   1882×   1882× 66× 66× 66×   1882× 66× 66× 66×     126×               11× 11× 11× 11× 11×             11×                                                                                         15× 15× 15×   15× 15× 15× 15×   15× 15×   404× 404×     404× 404× 404× 46× 46× 46× 14×   46×   404× 20×   20× 20× 20× 20× 20× 20×   20×   20×   20×   20× 16×   20×       17× 17× 17×       20× 16× 16× 16×       161× 16×     14× 13×       161× 11×             46× 46× 46× 46× 46×     46×     46×     46×     46×   46× 46× 46× 46×   75×     73×     60×     58×     85×   83× 83× 83× 83× 83× 83×   83× 83× 83× 83× 83× 83× 83× 83× 83×   83× 83× 83× 83× 83×   83×         83× 83×   83×           80×           37× 37×     37× 37×   37× 37× 37× 37× 29× 29× 29× 11×   18×     18× 12×           12×                                               12× 12× 12× 12×                   12× 12×     40× 40× 40× 40×     39×       37×         37× 37× 37× 37×       40×   40× 40× 40× 40× 40× 40× 40× 40× 40× 40× 33×           26× 26× 26× 26× 10× 10× 10× 10× 10×     83×           81×   14×   14× 14×           620× 620× 620× 620× 620× 620× 620× 620×   620× 602× 602×   620× 160× 160× 615×       620×   71× 71× 32×   39× 21×     620×   586× 586× 586× 586×             620×   620× 65×                           65×       620× 45×   620×   14×   14×     66×   66× 66× 42× 28×         14×           24×       66×       620×                                         32×         32×           21×         21×         293× 293× 285×                         23× 18×                                                                     620× 620×     620× 30×   620×                 620× 18×   18×   16×       620×         24×                     354×       354× 354× 354× 21×     21×   333× 222× 222× 222× 222× 222× 32×     32× 32× 32×   32× 32×     190×       80× 80×   48×   32× 32× 32× 32× 32× 32×     32× 32×   32×   32× 32×               32×       195×           1935×   43×     1892×     63× 63× 54× 54× 54× 54×             73× 73×   66× 66× 66× 66× 66× 66× 66× 66×                                     46×           46× 46× 19× 19×     46× 46×     66× 66× 66×   66× 66× 66× 66× 66× 66× 66×   66× 66× 10× 10×     56×   66× 66× 66× 66×     66× 66× 12× 10× 10× 10×     12×     12×       66× 66× 66× 66× 66× 66× 66× 66× 66×       66× 10× 10×           66×       66× 23× 23×     22×       66× 10×           66× 66×         66× 58×           66× 66×         66×       27× 27×     66× 66×   66× 66× 66× 66× 66× 66×         63× 63×   66× 66× 66× 66× 66×     66× 66×     66× 66× 66× 66× 66× 66× 66× 66× 66× 66×     66× 66× 66× 66× 66×         11× 11× 11× 11× 11× 10× 10× 10×                         14×                                                                         66× 66× 66× 66×   10× 10×                   28× 28× 28× 28× 28× 27×   28×                     27× 26×           26× 26× 26×                       26× 26×   25×     3623× 1798×   1825× 1825× 1825×       1825× 1825×   32823×        
define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-base", "../base/constant", "../base/classes", "@syncfusion/ej2-inputs", "@syncfusion/ej2-buttons", "../base/enum", "../base/util", "../../common/util"], function (require, exports, ej2_base_1, ej2_base_2, events, classes, ej2_inputs_1, ej2_buttons_1, enum_1, util_1, util_2) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var Video = (function () {
        function Video(parent, serviceLocator) {
            this.isVideoUploaded = false;
            this.isAllowedTypes = true;
            this.pageX = null;
            this.pageY = null;
            this.mouseX = null;
            this.deletedVid = [];
            this.isResizeBind = true;
            this.parent = parent;
            this.rteID = parent.element.id;
            this.i10n = serviceLocator.getService('rteLocale');
            this.rendererFactory = serviceLocator.getService('rendererFactory');
            this.dialogRenderObj = serviceLocator.getService('dialogRenderObject');
            this.addEventListener();
            this.isDestroyed = false;
            this.docClick = this.onDocumentClick.bind(this);
        }
        Video.prototype.addEventListener = function () {
            Iif (this.parent.isDestroyed) {
                return;
            }
            this.parent.on(events.keyDown, this.onKeyDown, this);
            this.parent.on(events.keyUp, this.onKeyUp, this);
            this.parent.on(events.insertVideo, this.insertingVideo, this);
            this.parent.on(events.initialEnd, this.afterRender, this);
            this.parent.on(events.dynamicModule, this.afterRender, this);
            this.parent.on(events.windowResize, this.onWindowResize, this);
            this.parent.on(events.showVideoDialog, this.showDialog, this);
            this.parent.on(events.closeVideoDialog, this.closeDialog, this);
            this.parent.on(events.dropDownSelect, this.alignmentSelect, this);
            this.parent.on(events.videoDelete, this.deleteVideo, this);
            this.parent.on(events.videoToolbarAction, this.onToolbarAction, this);
            this.parent.on(events.editAreaClick, this.editAreaClickHandler, this);
            this.parent.on(events.iframeMouseDown, this.onIframeMouseDown, this);
            this.parent.on(events.videoSize, this.videoSize, this);
            this.parent.on(events.insertCompleted, this.showVideoQuickToolbar, this);
            this.parent.on(events.clearDialogObj, this.clearDialogObj, this);
            this.parent.on(events.destroy, this.destroy, this);
        };
        Video.prototype.removeEventListener = function () {
            this.parent.off(events.keyDown, this.onKeyDown);
            this.parent.off(events.keyUp, this.onKeyUp);
            this.parent.off(events.insertVideo, this.insertingVideo);
            this.parent.off(events.windowResize, this.onWindowResize);
            this.parent.off(events.initialEnd, this.afterRender);
            this.parent.off(events.dynamicModule, this.afterRender);
            this.parent.off(events.showVideoDialog, this.showDialog);
            this.parent.off(events.closeVideoDialog, this.closeDialog);
            this.parent.off(events.dropDownSelect, this.alignmentSelect);
            this.parent.off(events.videoDelete, this.deleteVideo);
            this.parent.off(events.videoToolbarAction, this.onToolbarAction);
            this.parent.off(events.editAreaClick, this.editAreaClickHandler);
            this.parent.off(events.iframeMouseDown, this.onIframeMouseDown);
            this.parent.off(events.videoSize, this.videoSize);
            this.parent.off(events.insertCompleted, this.showVideoQuickToolbar);
            this.parent.off(events.clearDialogObj, this.clearDialogObj);
            this.parent.off(events.destroy, this.destroy);
            Eif (!ej2_base_1.isNullOrUndefined(this.contentModule)) {
                ej2_base_1.EventHandler.remove(this.contentModule.getEditPanel(), ej2_base_2.Browser.touchEndEvent, this.videoClick);
                this.parent.formatter.editorManager.observer.off(events.checkUndo, this.undoStack);
                if (this.parent.insertVideoSettings.resize) {
                    ej2_base_1.EventHandler.remove(this.parent.contentModule.getEditPanel(), ej2_base_2.Browser.touchStartEvent, this.resizeStart);
                    this.parent.element.ownerDocument.removeEventListener('mousedown', this.docClick);
                    this.docClick = null;
                    ej2_base_1.EventHandler.remove(this.contentModule.getEditPanel(), 'cut', this.onCutHandler);
                    ej2_base_1.EventHandler.remove(this.contentModule.getDocument(), ej2_base_2.Browser.touchMoveEvent, this.resizing);
                }
            }
        };
        Video.prototype.afterRender = function () {
            this.contentModule = this.rendererFactory.getRenderer(enum_1.RenderType.Content);
            ej2_base_1.EventHandler.add(this.contentModule.getEditPanel(), ej2_base_2.Browser.touchEndEvent, this.videoClick, this);
            if (this.parent.insertVideoSettings.resize) {
                ej2_base_1.EventHandler.add(this.parent.contentModule.getEditPanel(), ej2_base_2.Browser.touchStartEvent, this.resizeStart, this);
                this.parent.element.ownerDocument.addEventListener('mousedown', this.docClick);
                ej2_base_1.EventHandler.add(this.contentModule.getEditPanel(), 'cut', this.onCutHandler, this);
            }
        };
        Video.prototype.clearDialogObj = function () {
            if (this.uploadObj && !this.uploadObj.isDestroyed) {
                this.uploadObj.destroy();
                ej2_base_1.detach(this.uploadObj.element);
                this.uploadObj = null;
            }
            if (this.webUrlBtn && !this.webUrlBtn.isDestroyed) {
                this.webUrlBtn.destroy();
                ej2_base_1.detach(this.webUrlBtn.element);
                this.webUrlBtn = null;
            }
            if (this.embedUrlBtn && !this.embedUrlBtn.isDestroyed) {
                this.embedUrlBtn.destroy();
                ej2_base_1.detach(this.embedUrlBtn.element);
                this.embedUrlBtn = null;
            }
            if (this.widthNum && !this.widthNum.isDestroyed) {
                this.widthNum.destroy();
                ej2_base_1.detach(this.widthNum.element);
                this.widthNum = null;
            }
            if (this.heightNum && !this.heightNum.isDestroyed) {
                this.heightNum.destroy();
                ej2_base_1.detach(this.heightNum.element);
                this.heightNum = null;
            }
            if (this.button && !this.button.isDestroyed) {
                this.button.destroy();
                ej2_base_1.detach(this.button.element);
                this.heightNum = null;
            }
            if (this.dialogObj && this.dialogObj.element) {
                this.dialogObj.destroy();
                ej2_base_1.detach(this.dialogObj.element);
                this.dialogObj = null;
            }
        };
        Video.prototype.onKeyUp = function (event) {
            if (!ej2_base_2.isNullOrUndefined(this.deletedVid) && this.deletedVid.length > 0) {
                for (var i = 0; i < this.deletedVid.length; i++) {
                    var args = {
                        element: this.deletedVid[i],
                        src: this.deletedVid[i].tagName !== 'IFRAME' ? this.deletedVid[i].querySelector('source').getAttribute('src') :
                            this.deletedVid[i].src
                    };
                    this.parent.trigger(events.afterMediaDelete, args);
                }
            }
        };
        Video.prototype.undoStack = function (args) {
            Eif ((args.subCommand.toLowerCase() === 'undo' || args.subCommand.toLowerCase() === 'redo') && this.parent.editorMode === 'HTML') {
                for (var i = 0; i < this.parent.formatter.getUndoRedoStack().length; i++) {
                    var temp = this.parent.createElement('div');
                    var contentElem = this.parent.formatter.getUndoRedoStack()[i].text;
                    temp.appendChild(contentElem.cloneNode(true));
                    var vid = temp.querySelectorAll('video');
                    if (temp.querySelector('.e-vid-resize') && vid.length > 0) {
                        for (var j = 0; j < vid.length; j++) {
                            vid[j].style.outline = '';
                        }
                        ej2_base_1.detach(temp.querySelector('.e-vid-resize'));
                        var clonedElement = temp.cloneNode(true);
                        var fragment = document.createDocumentFragment();
                        while (clonedElement.firstChild) {
                            fragment.appendChild(clonedElement.firstChild);
                        }
                        this.parent.formatter.getUndoRedoStack()[i].text = fragment;
                    }
                }
            }
        };
        Video.prototype.onIframeMouseDown = function () {
            if (this.dialogObj) {
                this.dialogObj.hide({ returnValue: true });
            }
        };
        Video.prototype.videoSize = function (e) {
            var _this = this;
            Iif (e.selectNode[0].nodeName !== 'VIDEO' && !this.isEmbedVidElem(e.selectNode[0])) {
                return;
            }
            this.insertVideo(e);
            Eif (!ej2_base_1.isNullOrUndefined(this.dialogObj)) {
                var vidSizeHeader = this.i10n.getConstant('videoSizeHeader');
                var linkUpdate = this.i10n.getConstant('dialogUpdate');
                var dialogContent = this.vidsizeInput(e);
                var selectObj_1 = { args: e.args, selfVideo: this, selection: e.selection, selectNode: e.selectNode };
                this.dialogObj.setProperties({
                    width: '290px', header: vidSizeHeader, content: dialogContent,
                    buttons: [{
                            click: function (e) {
                                _this.insertSize(selectObj_1);
                            },
                            buttonModel: {
                                content: linkUpdate, cssClass: 'e-flat e-update-size', isPrimary: true
                            }
                        }]
                });
                this.dialogObj.element.style.maxHeight = 'inherit';
                this.dialogObj.content.querySelector('input').focus();
            }
        };
        Video.prototype.vidsizeInput = function (e) {
            var _this = this;
            var selectNode = e.selectNode[0];
            var vidHeight = this.i10n.getConstant('videoHeight');
            var vidWidth = this.i10n.getConstant('videoWidth');
            var vidSizeWrap = this.parent.createElement('div', { className: 'e-video-sizewrap' });
            var widthVal = ej2_base_1.isNullOrUndefined(this.changedWidthValue) && (selectNode.style.width.toString() === 'auto' ||
                selectNode.style.width !== '') ? selectNode.style.width : !ej2_base_1.isNullOrUndefined(this.changedWidthValue) ?
                this.changedWidthValue : (parseInt(selectNode.getClientRects()[0].width.toString(), 10)).toString();
            var heightVal = ej2_base_1.isNullOrUndefined(this.changedHeightValue) && (selectNode.style.height.toString() === 'auto' ||
                selectNode.style.height !== '') ? selectNode.style.height : !ej2_base_1.isNullOrUndefined(this.changedHeightValue) ?
                this.changedHeightValue : (parseInt(selectNode.getClientRects()[0].height.toString(), 10)).toString();
            this.changedWidthValue = null;
            this.changedHeightValue = null;
            var content = '<div class="e-rte-label"><label>' + vidWidth +
                '</label></div><div class="e-rte-field"><input type="text" id="vidwidth" class="e-vid-width" value=' +
                widthVal
                + ' /></div>' +
                '<div class="e-rte-label">' + '<label>' + vidHeight + '</label></div><div class="e-rte-field"> ' +
                '<input type="text" id="vidheight" class="e-vid-height" value=' +
                heightVal
                + ' /></div>';
            var contentElem = util_1.parseHtml(content);
            vidSizeWrap.appendChild(contentElem);
            this.widthNum = new ej2_inputs_1.TextBox({
                value: ej2_base_1.formatUnit(widthVal),
                enableRtl: this.parent.enableRtl,
                input: function (e) {
                    _this.inputWidthValue = ej2_base_1.formatUnit((e.value));
                }
            });
            this.widthNum.createElement = this.parent.createElement;
            this.widthNum.appendTo(vidSizeWrap.querySelector('#vidwidth'));
            this.heightNum = new ej2_inputs_1.TextBox({
                value: ej2_base_1.formatUnit(heightVal),
                enableRtl: this.parent.enableRtl,
                input: function (e) {
                    _this.inputHeightValue = ej2_base_1.formatUnit((e.value));
                }
            });
            this.heightNum.createElement = this.parent.createElement;
            this.heightNum.appendTo(vidSizeWrap.querySelector('#vidheight'));
            return vidSizeWrap;
        };
        Video.prototype.insertSize = function (e) {
            e.selection.restore();
            var proxy = e.selfVideo;
            Eif (proxy.parent.formatter.getUndoRedoStack().length === 0) {
                proxy.parent.formatter.saveData();
            }
            var dialogEle = proxy.dialogObj.element;
            this.changedWidthValue = this.inputWidthValue;
            this.changedHeightValue = this.inputHeightValue;
            var width = dialogEle.querySelector('.e-vid-width').value;
            var height = dialogEle.parentElement.querySelector('.e-vid-height').value;
            proxy.parent.formatter.process(this.parent, e.args, e.args, {
                width: width, height: height, selectNode: e.selectNode,
                subCommand: e.args.item.subCommand
            });
            if (this.vidResizeDiv) {
                e.selectNode[0] = (e.selectNode[0].tagName === 'VIDEO' || e.selectNode[0].tagName === 'IFRAME') ?
                    e.selectNode[0] : e.selectNode[0].querySelector('iframe');
                proxy.vidResizePos(e.selectNode[0], this.vidResizeDiv);
            }
            proxy.dialogObj.hide({ returnValue: true });
        };
        Video.prototype.resizeEnd = function (e) {
            this.resizeBtnInit();
            this.videoEle.parentElement.style.cursor = 'auto';
            if (ej2_base_2.Browser.isDevice) {
                ej2_base_2.removeClass([e.target.parentElement], 'e-mob-span');
            }
            var args = { event: e, requestType: 'videos' };
            this.parent.trigger(events.resizeStop, args);
            var pageX = this.getPointX(e);
            var pageY = (this.parent.iframeSettings.enable) ? window.pageYOffset +
                this.parent.element.getBoundingClientRect().top + e.clientY : e.pageY;
            this.parent.formatter.editorManager.observer.on(events.checkUndo, this.undoStack, this);
            this.parent.formatter.saveData();
        };
        Video.prototype.resizeStart = function (e, ele) {
            var _this = this;
            Iif (this.parent.readonly) {
                return;
            }
            var target = ele ? ele : !this.isEmbedVidElem(e.target) ? e.target : e.target.querySelector('iframe');
            this.prevSelectedVidEle = this.videoEle;
            if (target.tagName === 'VIDEO' || target.tagName === 'IFRAME') {
                this.parent.preventDefaultResize(e);
                var videoElem = target;
                if (this.vidResizeDiv && this.contentModule.getEditPanel().contains(this.vidResizeDiv)) {
                    ej2_base_1.detach(this.vidResizeDiv);
                }
                this.videoResize(videoElem);
            }
            if (target.classList.contains('e-rte-videoboxmark')) {
                if (this.parent.formatter.getUndoRedoStack().length === 0) {
                    this.parent.formatter.saveData();
                }
                this.pageX = this.getPointX(e);
                this.pageY = this.getPointY(e);
                e.preventDefault();
                e.stopImmediatePropagation();
                this.resizeBtnInit();
                if (this.quickToolObj) {
                    this.quickToolObj.videoQTBar.hidePopup();
                }
                if (target.classList.contains('e-rte-topLeft')) {
                    this.resizeBtnStat.topLeft = true;
                }
                if (target.classList.contains('e-rte-topRight')) {
                    this.resizeBtnStat.topRight = true;
                }
                if (target.classList.contains('e-rte-botLeft')) {
                    this.resizeBtnStat.botLeft = true;
                }
                if (target.classList.contains('e-rte-botRight')) {
                    this.resizeBtnStat.botRight = true;
                }
                if (ej2_base_2.Browser.isDevice && this.contentModule.getEditPanel().contains(this.vidResizeDiv) &&
                    !this.vidResizeDiv.classList.contains('e-mob-span')) {
                    ej2_base_1.addClass([this.vidResizeDiv], 'e-mob-span');
                }
                else {
                    var args = { event: e, requestType: 'videos' };
                    this.parent.trigger(events.resizeStart, args, function (resizeStartArgs) {
                        if (resizeStartArgs.cancel) {
                            _this.cancelResizeAction();
                        }
                    });
                }
                if (this.isResizeBind) {
                    ej2_base_1.EventHandler.add(this.contentModule.getDocument(), ej2_base_2.Browser.touchMoveEvent, this.resizing, this);
                    ej2_base_1.EventHandler.add(this.contentModule.getDocument(), ej2_base_2.Browser.touchEndEvent, this.resizeEnd, this);
                    this.isResizeBind = false;
                }
            }
        };
        Video.prototype.videoClick = function (e) {
            if (ej2_base_2.Browser.isDevice) {
                if ((e.target.tagName === 'VIDEO' || this.isEmbedVidElem(e.target))) {
                    this.contentModule.getEditPanel().setAttribute('contenteditable', 'false');
                    e.target.focus();
                }
                else {
                    if (!this.parent.readonly) {
                        this.contentModule.getEditPanel().setAttribute('contenteditable', 'true');
                    }
                }
            }
            if (e.target.tagName === 'VIDEO' || this.isEmbedVidElem(e.target)) {
                e.preventDefault();
            }
        };
        Video.prototype.onCutHandler = function () {
            if (this.vidResizeDiv && this.contentModule.getEditPanel().contains(this.vidResizeDiv)) {
                this.cancelResizeAction();
            }
        };
        Video.prototype.videoResize = function (e) {
            this.resizeBtnInit();
            this.videoEle = e;
            ej2_base_1.addClass([this.videoEle], 'e-resize');
            this.vidResizeDiv = this.parent.createElement('span', { className: 'e-vid-resize', id: this.rteID + '_vidResize' });
            this.vidResizeDiv.appendChild(this.parent.createElement('span', {
                className: 'e-rte-videoboxmark e-rte-topLeft', styles: 'cursor: nwse-resize'
            }));
            this.vidResizeDiv.appendChild(this.parent.createElement('span', {
                className: 'e-rte-videoboxmark e-rte-topRight', styles: 'cursor: nesw-resize'
            }));
            this.vidResizeDiv.appendChild(this.parent.createElement('span', {
                className: 'e-rte-videoboxmark e-rte-botLeft', styles: 'cursor: nesw-resize'
            }));
            this.vidResizeDiv.appendChild(this.parent.createElement('span', {
                className: 'e-rte-videoboxmark e-rte-botRight', styles: 'cursor: nwse-resize'
            }));
            if (ej2_base_2.Browser.isDevice) {
                ej2_base_1.addClass([this.vidResizeDiv], 'e-mob-rte');
            }
            e.style.outline = '2px solid #4a90e2';
            this.vidResizePos(e, this.vidResizeDiv);
            this.resizeVidDupPos(e);
            this.contentModule.getEditPanel().appendChild(this.vidResizeDiv);
        };
        Video.prototype.getPointX = function (e) {
            if (e.touches && e.touches.length) {
                return e.touches[0].pageX;
            }
            else {
                return e.pageX;
            }
        };
        Video.prototype.getPointY = function (e) {
            if (e.touches && e.touches.length) {
                return e.touches[0].pageY;
            }
            else {
                return e.pageY;
            }
        };
        Video.prototype.vidResizePos = function (e, vidResizeDiv) {
            if (ej2_base_1.isNullOrUndefined(vidResizeDiv)) {
                return;
            }
            var pos = this.calcPos(e);
            var top = pos.top;
            var left = pos.left;
            var vidWid = e.width !== 0 && e.width !== 'auto' && e.width !== 'NaN' ? e.width : e.getBoundingClientRect().width;
            var vidHgt = e.height !== 0 && e.height !== 'auto' && e.height !== 'NaN' ? e.height : e.getBoundingClientRect().height;
            var borWid = (ej2_base_2.Browser.isDevice) ? (4 * parseInt((e.style.outline.slice(-3)), 10)) + 2 :
                (2 * parseInt((e.style.outline.slice(-3)), 10)) + 2;
            var devWid = ((ej2_base_2.Browser.isDevice) ? 0 : 2);
            vidResizeDiv.querySelector('.e-rte-botLeft').style.left = (left - borWid) + 'px';
            vidResizeDiv.querySelector('.e-rte-botLeft').style.top = ((parseInt(vidHgt.toString(), 10) - borWid) + top) + 'px';
            vidResizeDiv.querySelector('.e-rte-botRight').style.left = ((parseInt(vidWid.toString(), 10) - (borWid - devWid)) + left) + 'px';
            vidResizeDiv.querySelector('.e-rte-botRight').style.top = ((parseInt(vidHgt.toString(), 10) - borWid) + top) + 'px';
            vidResizeDiv.querySelector('.e-rte-topRight').style.left = ((parseInt(vidWid.toString(), 10) - (borWid - devWid)) + left) + 'px';
            vidResizeDiv.querySelector('.e-rte-topRight').style.top = (top - (borWid)) + 'px';
            vidResizeDiv.querySelector('.e-rte-topLeft').style.left = (left - borWid) + 'px';
            vidResizeDiv.querySelector('.e-rte-topLeft').style.top = (top - borWid) + 'px';
        };
        Video.prototype.calcPos = function (elem) {
            var ignoreOffset = ['TD', 'TH', 'TABLE', 'A'];
            var parentOffset = { top: 0, left: 0 };
            var elementOffset;
            var doc = elem.ownerDocument;
            var offsetParent = ((elem.offsetParent && (elem.offsetParent.classList.contains('e-video-clickelem') ||
                ignoreOffset.indexOf(elem.offsetParent.tagName) > -1)) ? ej2_base_2.closest(elem, '#' + this.parent.getID() + '_rte-edit-view') : elem.offsetParent) || doc.documentElement;
            while (offsetParent &&
                (offsetParent === doc.body || offsetParent === doc.documentElement) &&
                offsetParent.style.position === 'static') {
                offsetParent = offsetParent.parentNode;
            }
            Eif (offsetParent && offsetParent !== elem && offsetParent.nodeType === 1) {
                parentOffset = offsetParent.getBoundingClientRect();
            }
            if (elem && elem.nodeType === 1 && elem.tagName === 'IFRAME') {
                elementOffset = elem.getBoundingClientRect();
                return {
                    top: elementOffset.top - parentOffset.top,
                    left: elementOffset.left - parentOffset.left
                };
            }
            else {
                return {
                    top: elem.offsetTop,
                    left: elem.offsetLeft
                };
            }
        };
        Video.prototype.setAspectRatio = function (vid, expectedX, expectedY, e) {
            var vidEleStyle = getComputedStyle(vid);
            Iif (ej2_base_1.isNullOrUndefined(vidEleStyle)) {
                return;
            }
            var regExp = RegExp;
            var width = vidEleStyle.width !== '' ? vidEleStyle.width.match(new regExp('^\\d+(\\.\\d*)?%$', 'g')) ? parseFloat(vidEleStyle.width) :
                parseInt(vidEleStyle.width, 10) : vid.style.width !== '' ? vid.style.width : vid.width;
            var height = vidEleStyle.height !== '' ? parseInt(vidEleStyle.height, 10) : vid.style.height !== '' ? vid.style.height : vid.height;
            width = width.toString().match(new regExp('\\b\\d+(\\.\\d*)?(%|$)\\b', 'g')) ? parseFloat(width.toString()) : parseInt(width.toString(), 10);
            height = height.toString().match(new regExp('\\b\\d+(\\.\\d*)?(%|$)\\b', 'g')) ? parseFloat(height.toString()) : parseInt(height.toString(), 10);
            if (width > height) {
                vid.style.minWidth = this.parent.insertVideoSettings.minWidth === 0 ? '200px' : ej2_base_1.formatUnit(this.parent.insertVideoSettings.minWidth);
                vid.style.minHeight = this.parent.insertVideoSettings.minHeight === 0 ? '90px' : ej2_base_1.formatUnit(this.parent.insertVideoSettings.minHeight);
                if (this.parent.insertVideoSettings.resizeByPercent) {
                    this.updateVidEleWidth(vid, width, height, expectedX, expectedY);
                }
                else Iif ((vid.style.width === '' && vid.style.height !== '') || (vidEleStyle.width === '' && vidEleStyle.height !== '')) {
                    vid.style.height = expectedY + 'px';
                }
                else if ((vid.style.width !== '' && vid.style.height === '') || (vidEleStyle.width !== '' && vidEleStyle.height === '')) {
                    var currentWidth = ((width / height * expectedY) +
                        width / height) <
                        (this.parent.inputElement.getBoundingClientRect().right - 32) ?
                        ((width / height * expectedY) +
                            width / height) :
                        (this.parent.inputElement.getBoundingClientRect().right - 32);
                    vid.style.width = currentWidth.toString() + 'px';
                }
                else Eif (vid.style.width !== '' || vidEleStyle.width !== '') {
                    var currentWidth = (width / height * expectedY) <
                        (this.parent.inputElement.getBoundingClientRect().right - 32) ?
                        (width / height * expectedY) :
                        (this.parent.inputElement.getBoundingClientRect().right - 32);
                    vid.style.width = currentWidth + 'px';
                    vid.style.height = expectedY + 'px';
                }
                else {
                    vid.setAttribute('width', (parseInt(((width / height * expectedY) + width / height).toString(), 10)).toString());
                }
            }
            else if (height > width) {
                if (this.parent.insertVideoSettings.resizeByPercent) {
                    this.updateVidEleWidth(vid, width, height, expectedX, expectedY);
                }
                else Eif (vidEleStyle.width !== '' || vid.style.width !== '') {
                    vid.style.width = expectedX + 'px';
                    vid.style.height = (height / width * expectedX) + 'px';
                }
                else {
                    vid.setAttribute('width', this.resizeBtnStat.botRight ? (this.getPointX(e.event) - vid.getBoundingClientRect().left).toString() : expectedX.toString());
                }
            }
            else {
                Eif (this.parent.insertVideoSettings.resizeByPercent) {
                    vid.style.width = this.pixToPerc(expectedX, (vid.previousElementSibling || vid.parentElement)) + '%';
                    vid.style.height = null;
                    vid.removeAttribute('height');
                }
                else {
                    vid.style.width = expectedX + 'px';
                    vid.style.height = expectedX + 'px';
                }
            }
        };
        Video.prototype.updateVidEleWidth = function (vid, width, height, expectedX, expectedY) {
            Eif (parseInt('' + vid.getBoundingClientRect().width + '', 10) !== 0 && parseInt('' + width + '', 10) !== 0) {
                var original = vid.offsetWidth + this.mouseX;
                var finalWidthByPerc = (original / vid.offsetWidth) * (parseFloat(vid.style.width).toString() === 'NaN' ? (vid.offsetWidth / (parseFloat(getComputedStyle(this.parent.element).width)) * 100) : parseFloat(vid.style.width));
                vid.style.width = ((finalWidthByPerc > 3) ? finalWidthByPerc : 3) + '%';
            }
            else {
                if (width > height) {
                    vid.style.width = this.pixToPerc(width / height * expectedY, (vid.previousElementSibling || vid.parentElement)) + '%';
                }
                else {
                    vid.style.width = this.pixToPerc((expectedX / height * expectedY), (vid.previousElementSibling || vid.parentElement)) + '%';
                }
            }
            vid.style.height = null;
            vid.removeAttribute('height');
        };
        Video.prototype.pixToPerc = function (expected, parentEle) {
            return expected / parseFloat(getComputedStyle(parentEle).width) * 100;
        };
        Video.prototype.vidDupMouseMove = function (width, height, e) {
            var _this = this;
            var args = { event: e, requestType: 'videos' };
            this.parent.trigger(events.onResize, args, function (resizingArgs) {
                if (resizingArgs.cancel) {
                    _this.cancelResizeAction();
                }
                else {
                    if ((parseInt(_this.parent.insertVideoSettings.minWidth, 10) >= parseInt(width, 10) ||
                        (parseInt(_this.parent.getInsertVidMaxWidth(), 10) <= parseInt(width, 10) &&
                            ej2_base_2.isNullOrUndefined(_this.videoEle.style.width)))) {
                        return;
                    }
                    Iif (!_this.parent.insertVideoSettings.resizeByPercent &&
                        (parseInt(_this.parent.insertVideoSettings.minHeight, 10) >= parseInt(height, 10) ||
                            parseInt(_this.parent.insertVideoSettings.maxHeight, 10) <= parseInt(height, 10))) {
                        return;
                    }
                    _this.videoEle.parentElement.style.cursor = 'pointer';
                    _this.setAspectRatio(_this.videoEle, parseInt(width, 10), parseInt(height, 10), args);
                    _this.resizeVidDupPos(_this.videoEle);
                    _this.vidResizePos(_this.videoEle, _this.vidResizeDiv);
                }
            });
        };
        Video.prototype.resizing = function (e) {
            if (this.videoEle.offsetWidth >= this.parent.getInsertVidMaxWidth()) {
                this.videoEle.style.maxHeight = this.videoEle.offsetHeight + 'px';
            }
            var pageX = this.getPointX(e);
            var pageY = this.getPointY(e);
            var mouseX = (this.resizeBtnStat.botLeft || this.resizeBtnStat.topLeft) ? -(pageX - this.pageX) : (pageX - this.pageX);
            var mouseY = (this.resizeBtnStat.topLeft || this.resizeBtnStat.topRight) ? -(pageY - this.pageY) : (pageY - this.pageY);
            var width = parseInt(this.vidDupPos.width, 10) + mouseX;
            var height = parseInt(this.vidDupPos.height, 10) + mouseY;
            this.pageX = pageX;
            this.pageY = pageY;
            this.mouseX = mouseX;
            if (this.resizeBtnStat.botRight) {
                this.vidDupMouseMove(width + 'px', height + 'px', e);
            }
            else if (this.resizeBtnStat.botLeft) {
                this.vidDupMouseMove(width + 'px', height + 'px', e);
            }
            else if (this.resizeBtnStat.topRight) {
                this.vidDupMouseMove(width + 'px', height + 'px', e);
            }
            else Eif (this.resizeBtnStat.topLeft) {
                this.vidDupMouseMove(width + 'px', height + 'px', e);
            }
        };
        Video.prototype.cancelResizeAction = function () {
            this.isResizeBind = true;
            ej2_base_1.EventHandler.remove(this.contentModule.getDocument(), ej2_base_2.Browser.touchMoveEvent, this.resizing);
            ej2_base_1.EventHandler.remove(this.contentModule.getDocument(), ej2_base_2.Browser.touchEndEvent, this.resizeEnd);
            if (this.videoEle && this.vidResizeDiv && this.contentModule.getEditPanel().contains(this.vidResizeDiv)) {
                ej2_base_1.detach(this.vidResizeDiv);
                this.videoEle.style.outline = '';
                this.vidResizeDiv = null;
                this.pageX = null;
                this.pageY = null;
            }
        };
        Video.prototype.resizeVidDupPos = function (e) {
            this.vidDupPos = {
                width: (e.style.width !== '' && (this.parent.insertVideoSettings &&
                    !this.parent.insertVideoSettings.resizeByPercent)) ? this.videoEle.style.width : e.width !== 'auto' && e.width !== 0 && e.width !== 'NaN' ? e.width + 'px' : parseInt(getComputedStyle(e).width, 10) + 'px',
                height: (e.style.height !== '') ? this.videoEle.style.height : e.height !== 'auto' && e.height !== 0 && e.height !== 'NaN' ? e.height + 'px' : parseInt(getComputedStyle(e).height, 10) + 'px'
            };
        };
        Video.prototype.resizeBtnInit = function () {
            return this.resizeBtnStat = { botLeft: false, botRight: false, topRight: false, topLeft: false };
        };
        Video.prototype.onToolbarAction = function (args) {
            if (util_2.isIDevice()) {
                this.parent.notify(events.selectionRestore, {});
            }
            var item = args.args.item;
            switch (item.subCommand) {
                case 'VideoReplace':
                    this.parent.notify(events.insertVideo, args);
                    break;
                case 'VideoRemove':
                    this.parent.notify(events.videoDelete, args);
                    break;
                case 'VideoDimension':
                    this.parent.notify(events.videoSize, args);
            }
        };
        Video.prototype.onKeyDown = function (event) {
            var originalEvent = event.args;
            var range;
            var save;
            var selectNodeEle;
            var selectParentEle;
            this.deletedVid = [];
            var isCursor;
            var keyCodeValues = [27, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
                44, 45, 9, 16, 17, 18, 19, 20, 33, 34, 35, 36, 37, 38, 39, 40, 91, 92, 93, 144, 145, 182, 183];
            if (this.parent.editorMode === 'HTML') {
                range = this.parent.formatter.editorManager.nodeSelection.getRange(this.parent.contentModule.getDocument());
                isCursor = range.startContainer === range.endContainer && range.startOffset === range.endOffset;
            }
            if (!isCursor && this.parent.editorMode === 'HTML' && keyCodeValues.indexOf(originalEvent.which) < 0) {
                var nodes = this.parent.formatter.editorManager.nodeSelection.getNodeCollection(range);
                for (var i = 0; i < nodes.length; i++) {
                    if (nodes[i].nodeName === 'VIDEO' || nodes[i].nodeName === 'IFRAME') {
                        this.deletedVid.push(nodes[i]);
                    }
                }
            }
            if (this.parent.editorMode === 'HTML' && ((originalEvent.which === 8 && originalEvent.code === 'Backspace') ||
                (originalEvent.which === 46 && originalEvent.code === 'Delete'))) {
                var isCursor_1 = range.startContainer === range.endContainer && range.startOffset === range.endOffset;
                if ((originalEvent.which === 8 && originalEvent.code === 'Backspace' && isCursor_1)) {
                    this.checkVideoBack(range);
                }
                else if ((originalEvent.which === 46 && originalEvent.code === 'Delete' && isCursor_1)) {
                    this.checkVideoDel(range);
                }
            }
            if (!ej2_base_1.isNullOrUndefined(this.parent.formatter.editorManager.nodeSelection) &&
                originalEvent.code !== 'KeyK') {
                range = this.parent.formatter.editorManager.nodeSelection.getRange(this.parent.contentModule.getDocument());
                selectNodeEle = this.parent.formatter.editorManager.nodeSelection.getNodeCollection(range);
                selectParentEle = this.parent.formatter.editorManager.nodeSelection.getParentNodeCollection(range);
                if (!originalEvent.ctrlKey && originalEvent.key && (originalEvent.key.length === 1 || originalEvent.action === 'enter') &&
                    ((!ej2_base_2.isNullOrUndefined(selectParentEle[0]) && selectParentEle[0].tagName === 'VIDEO' || this.isEmbedVidElem(selectParentEle[0]))) &&
                    selectParentEle[0].parentElement) {
                    var prev = selectParentEle[0].parentElement.childNodes[0];
                    Iif (this.contentModule.getEditPanel().querySelector('.e-vid-resize')) {
                        this.removeResizeEle();
                    }
                    this.parent.formatter.editorManager.nodeSelection.setSelectionText(this.contentModule.getDocument(), prev, prev, prev.textContent.length, prev.textContent.length);
                    ej2_base_2.removeClass([selectParentEle[0]], classes.CLS_VID_FOCUS);
                    this.quickToolObj.videoQTBar.hidePopup();
                }
            }
            if (originalEvent.ctrlKey && (originalEvent.keyCode === 89 || originalEvent.keyCode === 90)) {
                this.undoStack({ subCommand: (originalEvent.keyCode === 90 ? 'undo' : 'redo') });
            }
            if (originalEvent.keyCode === 8 || originalEvent.keyCode === 46) {
                Iif (selectNodeEle && selectNodeEle[0] && (selectNodeEle[0].nodeName === 'VIDEO' || this.isEmbedVidElem(selectNodeEle[0])) && selectNodeEle.length < 1) {
                    if (!ej2_base_1.isNullOrUndefined(this.parent.formatter.editorManager.nodeSelection)) {
                        save = this.parent.formatter.editorManager.nodeSelection.save(range, this.parent.contentModule.getDocument());
                    }
                    originalEvent.preventDefault();
                    var event_1 = {
                        selectNode: selectNodeEle, selection: save, selectParent: selectParentEle,
                        args: {
                            item: { command: 'Videos', subCommand: 'VideoRemove' },
                            originalEvent: originalEvent
                        }
                    };
                    this.deleteVideo(event_1, originalEvent.keyCode);
                }
                Iif (this.parent.contentModule.getEditPanel().querySelector('.e-vid-resize')) {
                    this.removeResizeEle();
                }
            }
            if (originalEvent.code === 'Backspace') {
                originalEvent.action = 'backspace';
            }
            switch (originalEvent.action) {
                case 'escape':
                    if (!ej2_base_1.isNullOrUndefined(this.dialogObj)) {
                        this.dialogObj.close();
                    }
                    break;
                case 'backspace':
                case 'delete':
                    for (var i = 0; i < this.deletedVid.length; i++) {
                        var src = this.deletedVid[i].src;
                        this.videoRemovePost(src);
                    }
                    Eif (this.parent.editorMode !== 'Markdown') {
                        if (range.startContainer.nodeType === 3) {
                            if (originalEvent.code === 'Backspace') {
                                if (range.startContainer.previousElementSibling && range.startOffset === 0 &&
                                    range.startContainer.previousElementSibling.classList.contains(classes.CLS_VIDEOWRAP)) {
                                    ej2_base_1.detach(range.startContainer.previousElementSibling);
                                }
                            }
                            else {
                                if (range.startContainer.nextElementSibling &&
                                    range.endContainer.textContent.length === range.endOffset &&
                                    range.startContainer.nextElementSibling.classList.contains(classes.CLS_VIDEOWRAP)) {
                                    ej2_base_1.detach(range.startContainer.nextElementSibling);
                                }
                            }
                        }
                        else if (range.startContainer.nodeType === 1 && (range.startContainer.classList &&
                            range.startContainer.classList.contains(classes.CLS_VIDEOWRAP))) {
                            ej2_base_1.detach(range.startContainer);
                        }
                    }
                    break;
                case 'insert-video':
                    Eif (!ej2_base_1.isNullOrUndefined(this.parent.formatter.editorManager.nodeSelection)) {
                        save = this.parent.formatter.editorManager.nodeSelection.save(range, this.parent.contentModule.getDocument());
                    }
                    this.openDialog(true, originalEvent, save, selectNodeEle, selectParentEle);
                    originalEvent.preventDefault();
                    break;
            }
            if (originalEvent.ctrlKey && originalEvent.key === 'a') {
                this.handleSelectAll();
            }
        };
        Video.prototype.handleSelectAll = function () {
            this.cancelResizeAction();
            var videoFocusNodes = this.parent.inputElement.querySelectorAll('.' + classes.CLS_VID_FOCUS);
            ej2_base_2.removeClass(videoFocusNodes, classes.CLS_VID_FOCUS);
        };
        Video.prototype.openDialog = function (isInternal, event, selection, ele, parentEle) {
            var range;
            var save;
            var selectNodeEle;
            var selectParentEle;
            if (!isInternal && !ej2_base_2.isNullOrUndefined(this.parent.formatter.editorManager.nodeSelection)) {
                range = this.parent.formatter.editorManager.nodeSelection.getRange(this.parent.contentModule.getDocument());
                save = this.parent.formatter.editorManager.nodeSelection.save(range, this.parent.contentModule.getDocument());
                selectNodeEle = this.parent.formatter.editorManager.nodeSelection.getNodeCollection(range);
                selectParentEle = this.parent.formatter.editorManager.nodeSelection.getParentNodeCollection(range);
            }
            else {
                save = selection;
                selectNodeEle = ele;
                selectParentEle = parentEle;
            }
            Eif (this.parent.editorMode === 'HTML') {
                this.insertVideo({
                    args: {
                        item: { command: 'Videos', subCommand: 'Video' },
                        originalEvent: event,
                        name: !isInternal ? 'showDialog' : null
                    },
                    selectNode: selectNodeEle,
                    selection: save,
                    selectParent: selectParentEle
                });
            }
        };
        Video.prototype.showDialog = function () {
            this.openDialog(false);
        };
        Video.prototype.closeDialog = function () {
            Eif (this.dialogObj) {
                this.dialogObj.hide({ returnValue: true });
            }
        };
        Video.prototype.checkVideoBack = function (range) {
            Iif (range.startContainer.nodeName === '#text' && range.startOffset === 0 &&
                !ej2_base_2.isNullOrUndefined(range.startContainer.previousSibling) && (range.startContainer.previousSibling.nodeName === 'VIDEO' ||
                this.isEmbedVidElem(range.startContainer.previousSibling))) {
                this.deletedVid.push(range.startContainer.previousSibling);
            }
            else Iif (range.startContainer.nodeName !== '#text' && !ej2_base_2.isNullOrUndefined(range.startContainer.childNodes[range.startOffset - 1]) &&
                (range.startContainer.childNodes[range.startOffset - 1].nodeName === 'VIDEO' ||
                    this.isEmbedVidElem(range.startContainer.childNodes[range.startOffset - 1]))) {
                this.deletedVid.push(range.startContainer.childNodes[range.startOffset - 1]);
            }
        };
        Video.prototype.checkVideoDel = function (range) {
            Iif (range.startContainer.nodeName === '#text' && range.startOffset === range.startContainer.textContent.length &&
                !ej2_base_2.isNullOrUndefined(range.startContainer.nextSibling) && (range.startContainer.nextSibling.nodeName === 'VIDEO' ||
                this.isEmbedVidElem(range.startContainer.nextSibling))) {
                this.deletedVid.push(range.startContainer.nextSibling);
            }
            else if (range.startContainer.nodeName !== '#text' && !ej2_base_2.isNullOrUndefined(range.startContainer.childNodes[range.startOffset]) &&
                (range.startContainer.childNodes[range.startOffset].nodeName === 'VIDEO' ||
                    this.isEmbedVidElem(range.startContainer.childNodes[range.startOffset]))) {
                this.deletedVid.push(range.startContainer.childNodes[range.startOffset]);
            }
        };
        Video.prototype.alignmentSelect = function (e) {
            var item = e.item;
            if (!document.body.contains(document.body.querySelector('.e-rte-quick-toolbar')) || item.command !== 'Videos') {
                return;
            }
            var range = this.parent.formatter.editorManager.nodeSelection.getRange(this.parent.contentModule.getDocument());
            var selectNodeEle = this.parent.formatter.editorManager.nodeSelection.getNodeCollection(range);
            selectNodeEle = (selectNodeEle[0].nodeName === 'VIDEO') ? selectNodeEle : [this.videoEle];
            var args = { args: e, selectNode: selectNodeEle };
            if (this.parent.formatter.getUndoRedoStack().length === 0) {
                this.parent.formatter.saveData();
            }
            switch (item.subCommand) {
                case 'JustifyLeft':
                case 'JustifyCenter':
                case 'JustifyRight':
                    this.alignVideo(args, item.subCommand);
                    break;
                case 'Inline':
                    this.inline(args);
                    break;
                case 'Break':
                    this.break(args);
                    break;
            }
            Iif (this.quickToolObj && document.body.contains(this.quickToolObj.videoQTBar.element)) {
                this.quickToolObj.videoQTBar.hidePopup();
                ej2_base_2.removeClass([selectNodeEle[0]], classes.CLS_VID_FOCUS);
            }
            this.cancelResizeAction();
        };
        Video.prototype.deleteVideo = function (e, keyCode) {
            if (e.selectNode[0].nodeName !== 'VIDEO' && !this.isEmbedVidElem(e.selectNode[0])) {
                return;
            }
            if (this.isEmbedVidElem(e.selectNode[0])) {
                e.selectNode[0] = e.selectNode[0].classList.contains(classes.CLS_VID_CLICK_ELEM) ? e.selectNode[0] :
                    e.selectNode[0].parentElement;
            }
            var args = {
                element: !this.isEmbedVidElem(e.selectNode[0]) ? e.selectNode[0].querySelector('iframe') :
                    e.selectNode[0],
                src: !this.isEmbedVidElem(e.selectNode[0]) ? e.selectNode[0].querySelector('source').getAttribute('src') :
                    e.selectNode[0].querySelector('iframe').getAttribute('src')
            };
            if (this.parent.formatter.getUndoRedoStack().length === 0) {
                this.parent.formatter.saveData();
            }
            e.selection.restore();
            this.parent.formatter.process(this.parent, e.args, e.args.originalEvent, {
                selectNode: e.selectNode,
                subCommand: e.args.item.subCommand
            });
            this.videoRemovePost(args.src);
            if (this.quickToolObj && document.body.contains(this.quickToolObj.videoQTBar.element)) {
                this.quickToolObj.videoQTBar.hidePopup();
            }
            this.cancelResizeAction();
            Eif (ej2_base_1.isNullOrUndefined(keyCode)) {
                this.parent.trigger(events.afterMediaDelete, args);
            }
        };
        Video.prototype.videoRemovePost = function (src) {
            var proxy = this;
            var absoluteUrl = '';
            if (ej2_base_2.isNullOrUndefined(this.parent.insertVideoSettings.removeUrl) || this.parent.insertVideoSettings.removeUrl === '') {
                return;
            }
            Eif (src.indexOf('http://') > -1 || src.indexOf('https://') > -1) {
                absoluteUrl = src;
            }
            else {
                absoluteUrl = new URL(src, document.baseURI).href;
            }
            this.removingVideoName = absoluteUrl.replace(/^.*[\\\/]/, '');
            var xhr = new XMLHttpRequest();
            xhr.addEventListener('readystatechange', function () {
                Iif (this.readyState === 4 && this.status === 200) {
                    proxy.triggerPost(this.response);
                }
            });
            xhr.open('GET', absoluteUrl);
            xhr.responseType = 'blob';
            xhr.send();
        };
        Video.prototype.triggerPost = function (response) {
            var removeUrl = this.parent.insertVideoSettings.removeUrl;
            if (ej2_base_2.isNullOrUndefined(removeUrl) || removeUrl === '') {
                return;
            }
            var file = new File([response], this.removingVideoName);
            var ajax = new ej2_base_1.Ajax(removeUrl, 'POST', true, null);
            var formData = new FormData();
            formData.append('UploadFiles', file);
            ajax.send(formData);
        };
        Video.prototype.onDocumentClick = function (e) {
            var target = e.target;
            Iif (ej2_base_2.isNullOrUndefined(this.contentModule.getEditPanel())) {
                return;
            }
            if (target.nodeName === 'VIDEO' || this.isEmbedVidElem(target)) {
                this.videoEle = !this.isEmbedVidElem(target) ? target : target.querySelector('iframe');
            }
            if (!ej2_base_1.isNullOrUndefined(this.dialogObj) && ((!ej2_base_2.closest(target, '[id=' + "'" + this.dialogObj.element.id + "'" + ']') && this.parent.toolbarSettings.enable && this.parent.getToolbarElement() &&
                !this.parent.getToolbarElement().contains(e.target)) ||
                (this.parent.getToolbarElement() && this.parent.getToolbarElement().contains(e.target) &&
                    !ej2_base_2.closest(target, '#' + this.parent.getID() + '_toolbar_Video') &&
                    !target.querySelector('#' + this.parent.getID() + '_toolbar_Video')))) {
                Iif (e.offsetX > e.target.clientWidth || e.offsetY > e.target.clientHeight) {
                }
                else {
                    this.parent.notify(events.documentClickClosedBy, { closedBy: "outside click" });
                    this.dialogObj.hide({ returnValue: true });
                    this.parent.isBlur = true;
                    util_1.dispatchEvent(this.parent.element, 'focusout');
                }
            }
            if (this.contentModule.getEditPanel().querySelector('.e-vid-resize')) {
                if (target.tagName !== 'VIDEO' && !this.isEmbedVidElem(target)) {
                    this.removeResizeEle();
                }
                if ((target.tagName !== 'VIDEO' && !this.isEmbedVidElem(target)) && !ej2_base_2.isNullOrUndefined(this.videoEle)) {
                    this.videoEle.style.outline = '';
                }
                else if (!ej2_base_2.isNullOrUndefined(this.prevSelectedVidEle) &&
                    this.prevSelectedVidEle !== ((target.tagName === 'IFRAME' || target.tagName === 'VIDEO') ? target : target.querySelector('iframe'))) {
                    this.prevSelectedVidEle.style.outline = '';
                }
            }
            Iif (this.parent.inlineMode.enable && target && this.dialogObj && !ej2_base_2.closest(target, '#' + this.dialogObj.element.id)) {
                this.dialogObj.hide();
            }
        };
        Video.prototype.removeResizeEle = function () {
            this.isResizeBind = true;
            ej2_base_1.EventHandler.remove(this.contentModule.getDocument(), ej2_base_2.Browser.touchMoveEvent, this.resizing);
            ej2_base_1.EventHandler.remove(this.contentModule.getDocument(), ej2_base_2.Browser.touchEndEvent, this.resizeEnd);
            ej2_base_1.detach(this.contentModule.getEditPanel().querySelector('.e-vid-resize'));
        };
        Video.prototype.onWindowResize = function () {
            if (!ej2_base_2.isNullOrUndefined(this.contentModule) && !ej2_base_2.isNullOrUndefined(this.contentModule.getEditPanel().querySelector('.e-vid-resize'))) {
                this.cancelResizeAction();
            }
        };
        Video.prototype.break = function (e) {
            if (e.selectNode[0].nodeName !== 'VIDEO' && !this.isEmbedVidElem(e.selectNode[0])) {
                return;
            }
            var subCommand = (e.args.item) ?
                e.args.item.subCommand : 'Break';
            this.parent.formatter.process(this.parent, e.args, e.args.originalEvent, { selectNode: e.selectNode, subCommand: subCommand });
        };
        Video.prototype.inline = function (e) {
            if (e.selectNode[0].nodeName !== 'VIDEO' && !this.isEmbedVidElem(e.selectNode[0])) {
                return;
            }
            var subCommand = (e.args.item) ?
                e.args.item.subCommand : 'Inline';
            this.parent.formatter.process(this.parent, e.args, e.args.originalEvent, { selectNode: e.selectNode, subCommand: subCommand });
        };
        Video.prototype.alignVideo = function (e, type) {
            var subCommand = (e.args.item) ?
                e.args.item.subCommand : type;
            this.parent.formatter.process(this.parent, e.args, e.args.originalEvent, { selectNode: e.selectNode, subCommand: subCommand });
        };
        Video.prototype.editAreaClickHandler = function (e) {
            Iif (this.parent.readonly) {
                this.hideVideoQuickToolbar();
                return;
            }
            var args = e.args;
            var showOnRightClick = this.parent.quickToolbarSettings.showOnRightClick;
            if (args.which === 2 || (showOnRightClick && args.which === 1) || (!showOnRightClick && args.which === 3)) {
                if ((showOnRightClick && args.which === 1) && !ej2_base_1.isNullOrUndefined(args.target) &&
                    (args.target.tagName === 'VIDEO' || this.isEmbedVidElem(args.target))) {
                    this.parent.formatter.editorManager.nodeSelection.Clear(this.contentModule.getDocument());
                    this.parent.formatter.editorManager.nodeSelection.setSelectionContents(this.contentModule.getDocument(), args.target);
                }
                return;
            }
            if (this.parent.editorMode === 'HTML' && this.parent.quickToolbarModule && this.parent.quickToolbarModule.videoQTBar) {
                this.quickToolObj = this.parent.quickToolbarModule;
                var target = args.target;
                this.contentModule = this.rendererFactory.getRenderer(enum_1.RenderType.Content);
                var isPopupOpen = this.quickToolObj.videoQTBar.element.classList.contains('e-rte-pop');
                if ((target.nodeName === 'VIDEO' || this.isEmbedVidElem(target)) && this.parent.quickToolbarModule) {
                    Iif (isPopupOpen) {
                        return;
                    }
                    this.parent.formatter.editorManager.nodeSelection.Clear(this.contentModule.getDocument());
                    this.parent.formatter.editorManager.nodeSelection.setSelectionContents(this.contentModule.getDocument(), target);
                    if (util_2.isIDevice()) {
                        this.parent.notify(events.selectionSave, e);
                    }
                    ej2_base_1.addClass([!this.isEmbedVidElem(target) ? target : target.querySelector('iframe')], classes.CLS_VID_FOCUS);
                    this.showVideoQuickToolbar({ args: args, type: 'Videos', elements: [args.target] });
                }
                else {
                    this.hideVideoQuickToolbar();
                }
            }
        };
        Video.prototype.showVideoQuickToolbar = function (e) {
            var _this = this;
            if (e.type !== 'Videos' || (!ej2_base_1.isNullOrUndefined(e.args) && e.args.detail === 2) || ej2_base_1.isNullOrUndefined(this.parent.quickToolbarModule)
                || ej2_base_1.isNullOrUndefined(this.parent.quickToolbarModule.videoQTBar) || ej2_base_1.isNullOrUndefined(e.args)) {
                return;
            }
            this.quickToolObj = this.parent.quickToolbarModule;
            var args = e.args;
            var target = e.elements;
            [].forEach.call(e.elements, function (element, index) {
                Eif (index === 0) {
                    target = element;
                }
            });
            Eif (target.tagName === 'VIDEO' || this.isEmbedVidElem(target)) {
                ej2_base_1.addClass([(!this.isEmbedVidElem(target) || target.tagName === 'IFRAME') ? target : target.querySelector('iframe')], [classes.CLS_VID_FOCUS]);
            }
            var pageY = (this.parent.iframeSettings.enable) ? window.pageYOffset +
                this.parent.element.getBoundingClientRect().top + args.clientY : args.pageY;
            Eif (this.parent.quickToolbarModule.videoQTBar) {
                Iif (e.isNotify) {
                    this.showPopupTime = setTimeout(function () {
                        _this.parent.formatter.editorManager.nodeSelection.Clear(_this.contentModule.getDocument());
                        _this.parent.formatter.editorManager.nodeSelection.setSelectionContents(_this.contentModule.getDocument(), target);
                        _this.quickToolObj.videoQTBar.showPopup(args.pageX - 50, pageY + (target.getBoundingClientRect().height / 2) - target.offsetTop, target);
                    }, 400);
                }
                else {
                    this.quickToolObj.videoQTBar.showPopup(args.pageX - 50, pageY + (target.getBoundingClientRect().height / 2) - target.offsetTop, target);
                }
            }
        };
        Video.prototype.hideVideoQuickToolbar = function () {
            if (!ej2_base_1.isNullOrUndefined(this.contentModule.getEditPanel().querySelector('.' + classes.CLS_VID_FOCUS))) {
                ej2_base_2.removeClass([this.contentModule.getEditPanel().querySelector('.' + classes.CLS_VID_FOCUS)], classes.CLS_VID_FOCUS);
                Eif (!ej2_base_2.isNullOrUndefined(this.videoEle)) {
                    this.videoEle.style.outline = '';
                }
                Eif (!ej2_base_2.isNullOrUndefined(this.contentModule.getEditPanel().querySelector('.e-vid-resize'))) {
                    ej2_base_1.detach(this.contentModule.getEditPanel().querySelector('.e-vid-resize'));
                }
                Eif (this.quickToolObj && this.quickToolObj.videoQTBar && document.body.contains(this.quickToolObj.videoQTBar.element)) {
                    this.quickToolObj.videoQTBar.hidePopup();
                }
            }
        };
        Video.prototype.isEmbedVidElem = function (target) {
            if ((target && target.nodeType !== 3 && target.nodeName !== 'BR' && (target.classList && target.classList.contains(classes.CLS_VID_CLICK_ELEM))) ||
                (target && target.nodeName === 'IFRAME')) {
                return true;
            }
            else {
                return false;
            }
        };
        Video.prototype.insertingVideo = function (e) {
            this.insertVideo(e);
            if (!ej2_base_1.isNullOrUndefined(this.dialogObj)) {
                this.dialogObj.element.style.maxHeight = 'inherit';
                var dialogContent = this.dialogObj.element.querySelector('.e-video-content');
                Eif (!ej2_base_1.isNullOrUndefined(this.parent.insertVideoSettings.path) || this.parent.editorMode === 'HTML') {
                    document.getElementById(this.rteID + '_insertVideo').focus();
                }
                else {
                    dialogContent.querySelector('.e-video-url').focus();
                }
            }
        };
        Video.prototype.insertVideo = function (e) {
            var _this = this;
            if (this.dialogObj) {
                this.dialogObj.hide({ returnValue: true });
                return;
            }
            var videoDialog = this.parent.createElement('div', { className: 'e-rte-video-dialog', id: this.rteID + '_video' });
            this.parent.rootContainer.appendChild(videoDialog);
            var videoInsert = this.i10n.getConstant('dialogInsert');
            var videolinkCancel = this.i10n.getConstant('dialogCancel');
            var videoHeader = this.i10n.getConstant('videoHeader');
            var selection = e.selection;
            var selectObj = { selfVideo: this, selection: e.selection, args: e.args, selectParent: e.selectParent };
            var dialogModel = {
                header: videoHeader,
                cssClass: classes.CLS_RTE_ELEMENTS,
                enableRtl: this.parent.enableRtl,
                locale: this.parent.locale,
                showCloseIcon: true, closeOnEscape: true, width: (ej2_base_2.Browser.isDevice) ? '290px' : '340px',
                isModal: ej2_base_2.Browser.isDevice,
                buttons: [{
                        click: this.insertVideoUrl.bind(selectObj),
                        buttonModel: { content: videoInsert, cssClass: 'e-flat e-insertVideo', isPrimary: true, disabled: true }
                    },
                    {
                        click: function (e) {
                            _this.cancelDialog(e);
                        },
                        buttonModel: { cssClass: 'e-flat e-cancel', content: videolinkCancel }
                    }],
                target: (ej2_base_2.Browser.isDevice) ? document.body : this.parent.element,
                animationSettings: { effect: 'None' },
                close: function (event) {
                    if (_this.isVideoUploaded) {
                        Iif (_this.dialogObj.element.querySelector('.e-file-abort-btn')) {
                            _this.dialogObj.element.querySelector('.e-file-abort-btn').click();
                        }
                        else {
                            _this.uploadObj.remove();
                        }
                    }
                    _this.parent.isBlur = false;
                    if (event && !ej2_base_2.isNullOrUndefined(event.event) && event.event.returnValue) {
                        Eif (_this.parent.editorMode === 'HTML') {
                            selection.restore();
                        }
                    }
                    _this.clearDialogObj();
                    _this.dialogRenderObj.close(event);
                }
            };
            var dialogContent = this.parent.createElement('div', { className: 'e-video-content' });
            Eif (!ej2_base_1.isNullOrUndefined(this.parent.insertVideoSettings.path) || this.parent.editorMode === 'HTML') {
                dialogContent.appendChild(this.videoUpload(e));
            }
            var linkHeader = this.parent.createElement('div', { className: 'e-videoheader' });
            var embedLinkHeader = this.parent.createElement('div', { className: 'e-embed-videoheader' });
            var linkHeaderText = this.i10n.getConstant('videoLinkHeader');
            var embedLinkHeaderText = this.i10n.getConstant('embedVideoLinkHeader');
            Eif (this.parent.editorMode === 'HTML') {
                linkHeader.innerHTML = linkHeaderText;
                embedLinkHeader.innerHTML = embedLinkHeaderText;
            }
            dialogContent.appendChild(this.urlPopup(e));
            if (e.selectNode && e.selectNode[0].nodeType === 1 && (e.selectNode[0].tagName === 'VIDEO' || this.isEmbedVidElem(e.selectNode[0]))) {
                dialogModel.header = this.parent.localeObj.getConstant('editVideoHeader');
                dialogModel.content = dialogContent;
            }
            else {
                dialogModel.content = dialogContent;
            }
            this.dialogObj = this.dialogRenderObj.render(dialogModel);
            this.dialogObj.createElement = this.parent.createElement;
            this.dialogObj.appendTo(videoDialog);
            if (e.selectNode && e.selectNode[0].nodeType === 1 && (e.selectNode[0].tagName === 'VIDEO' || this.isEmbedVidElem(e.selectNode[0]))
                && (e.name === 'insertVideo')) {
                this.dialogObj.element.querySelector('.e-insertVideo').textContent = this.parent.localeObj.getConstant('dialogUpdate');
            }
            videoDialog.style.maxHeight = 'inherit';
            if (this.quickToolObj) {
                if (this.quickToolObj.videoQTBar && document.body.contains(this.quickToolObj.videoQTBar.element)) {
                    this.quickToolObj.videoQTBar.hidePopup();
                    Eif (!ej2_base_1.isNullOrUndefined(e.selectParent)) {
                        ej2_base_2.removeClass([e.selectParent[0]], classes.CLS_VID_FOCUS);
                    }
                }
                Iif (this.quickToolObj.inlineQTBar && document.body.contains(this.quickToolObj.inlineQTBar.element)) {
                    this.quickToolObj.inlineQTBar.hidePopup();
                }
                if (this.quickToolObj.textQTBar && this.parent.element.ownerDocument.body.contains(this.quickToolObj.textQTBar.element)) {
                    this.quickToolObj.textQTBar.hidePopup();
                }
            }
        };
        Video.prototype.urlPopup = function (e) {
            var _this = this;
            var videoUrl = this.parent.createElement('div', { className: 'e-video-url-wrap' });
            var urlContent = this.parent.createElement('div', { id: 'urlcontent' });
            var placeUrl = this.i10n.getConstant('videoUrl');
            var content = '<input id="embedURL" type="radio">' + '<input id="webURL" type="radio" >';
            var contentElem = util_1.parseHtml(content);
            videoUrl.appendChild(contentElem);
            videoUrl.appendChild(urlContent);
            this.embedInputUrl = this.parent.createElement('textarea', {
                className: 'e-input e-embed-video-url',
                attrs: { placeholder: this.i10n.getConstant('pasteEmbeddedCodeHere'), type: 'text', tabindex: '-1', 'aria-label': this.i10n.getConstant('embedVideoLinkHeader') }
            });
            this.embedInputUrl.addEventListener('keyup', function () {
                Eif (!ej2_base_2.isNullOrUndefined(_this.embedInputUrl)) {
                    if (_this.embedInputUrl.value.length === 0) {
                        _this.dialogObj.getButtons(0).element.disabled = true;
                    }
                    else {
                        _this.dialogObj.getButtons(0).element.removeAttribute('disabled');
                    }
                }
            });
            this.inputUrl = this.parent.createElement('input', {
                className: 'e-input e-video-url',
                attrs: { placeholder: placeUrl, spellcheck: 'false' }
            });
            this.inputUrl.addEventListener('input', function () {
                Eif (!ej2_base_2.isNullOrUndefined(_this.inputUrl)) {
                    if (_this.inputUrl.value.length === 0) {
                        _this.dialogObj.getButtons(0).element.disabled = true;
                    }
                    else {
                        _this.dialogObj.getButtons(0).element.removeAttribute('disabled');
                    }
                }
            });
            if (e.selectNode && e.selectNode[0] && (e.selectNode[0].nodeName === 'VIDEO' || this.isEmbedVidElem(e.selectNode[0]))) {
                if (e.selectNode[0].nodeName === 'VIDEO') {
                    var regex = new RegExp(/([^\S]|^)(((https?:\/\/)|(www\.))(\S+))/gi);
                    var sourceElement = e.selectNode[0].querySelector('source');
                    this.inputUrl.value = sourceElement && sourceElement.src && sourceElement.src.match(regex) ? sourceElement.src : '';
                }
                else {
                    this.embedInputUrl.value = e.selectNode[0].nodeName === 'IFRAME' ? e.selectNode[0].outerHTML
                        : e.selectNode[0].querySelector('iframe').outerHTML;
                }
            }
            var isWebUrl = this.inputUrl.value ? true : false;
            this.embedUrlBtn = new ej2_buttons_1.RadioButton({
                label: this.i10n.getConstant('embeddedCode'),
                checked: !isWebUrl,
                name: 'URL',
                created: function () {
                    if (!isWebUrl) {
                        urlContent.appendChild(_this.embedInputUrl);
                    }
                },
                change: function () {
                    urlContent.innerHTML = '';
                    urlContent.appendChild(_this.embedInputUrl);
                }
            });
            this.embedUrlBtn.appendTo(videoUrl.querySelector('#embedURL'));
            this.webUrlBtn = new ej2_buttons_1.RadioButton({
                label: this.i10n.getConstant('webUrl'),
                checked: isWebUrl,
                name: 'URL',
                created: function () {
                    if (isWebUrl) {
                        urlContent.appendChild(_this.inputUrl);
                    }
                },
                change: function () {
                    urlContent.innerHTML = '';
                    urlContent.appendChild(_this.inputUrl);
                }
            });
            this.webUrlBtn.appendTo(videoUrl.querySelector('#webURL'));
            return videoUrl;
        };
        Video.prototype.videoUpload = function (e) {
            var _this = this;
            var save;
            var selectParent;
            var proxy = this;
            var iframe = proxy.parent.iframeSettings.enable;
            if (proxy.parent.editorMode === 'HTML' && (!iframe && ej2_base_1.isNullOrUndefined(ej2_base_2.closest(e.selection.range.startContainer.parentNode, '[id='
                + "'" + this.parent.contentModule.getPanel().id + "'" + ']'))
                || (iframe && !util_1.hasClass(e.selection.range.startContainer.parentNode.ownerDocument.querySelector('body'), 'e-lib')))) {
                this.contentModule.getEditPanel().focus();
                var range = this.parent.formatter.editorManager.nodeSelection.getRange(this.parent.contentModule.getDocument());
                save = this.parent.formatter.editorManager.nodeSelection.save(range, this.parent.contentModule.getDocument());
                selectParent = this.parent.formatter.editorManager.nodeSelection.getParentNodeCollection(range);
            }
            else {
                save = e.selection;
                selectParent = e.selectParent;
            }
            var uploadParentEle = this.parent.createElement('div', { className: 'e-vid-uploadwrap e-droparea' });
            var deviceVideoUpMsg = this.i10n.getConstant('videoDeviceUploadMessage');
            var videoUpMsg = this.i10n.getConstant('videoUploadMessage');
            var span = this.parent.createElement('span', { className: 'e-droptext' });
            var spanMsg = this.parent.createElement('span', {
                className: 'e-rte-upload-text', innerHTML: ((ej2_base_2.Browser.isDevice) ? deviceVideoUpMsg : videoUpMsg)
            });
            span.appendChild(spanMsg);
            var btnEle = this.parent.createElement('button', {
                className: 'e-browsebtn', id: this.rteID + '_insertVideo', attrs: { autofocus: 'true', type: 'button' }
            });
            span.appendChild(btnEle);
            uploadParentEle.appendChild(span);
            var browserMsg = this.i10n.getConstant('browse');
            this.button = new ej2_buttons_1.Button({ content: browserMsg, enableRtl: this.parent.enableRtl });
            this.button.isStringTemplate = true;
            this.button.createElement = this.parent.createElement;
            this.button.appendTo(btnEle);
            var btnClick = (ej2_base_2.Browser.isDevice) ? span : btnEle;
            ej2_base_1.EventHandler.add(btnClick, 'click', this.fileSelect, this);
            var uploadEle = this.parent.createElement('input', {
                id: this.rteID + '_upload', attrs: { type: 'File', name: 'UploadFiles' }
            });
            uploadParentEle.appendChild(uploadEle);
            var fileName;
            var selectArgs;
            var filesData;
            this.uploadObj = new ej2_inputs_1.Uploader({
                asyncSettings: { saveUrl: this.parent.insertVideoSettings.saveUrl, removeUrl: this.parent.insertVideoSettings.removeUrl },
                dropArea: span, multiple: false, enableRtl: this.parent.enableRtl,
                allowedExtensions: this.parent.insertVideoSettings.allowedTypes.toString(),
                selected: function (e) {
                    proxy.isVideoUploaded = true;
                    selectArgs = e;
                    filesData = e.filesData;
                    _this.parent.trigger(events.fileSelected, selectArgs, function (selectArgs) {
                        if (!selectArgs.cancel) {
                            _this.checkExtension(selectArgs.filesData[0]);
                            fileName = selectArgs.filesData[0].name;
                            if (_this.parent.editorMode === 'HTML' && ej2_base_1.isNullOrUndefined(_this.parent.insertVideoSettings.path)) {
                                var reader_1 = new FileReader();
                                reader_1.addEventListener('load', function (e) {
                                    var url = _this.parent.insertVideoSettings.saveFormat === 'Base64' ? reader_1.result :
                                        URL.createObjectURL(util_1.convertToBlob(reader_1.result));
                                    proxy.uploadUrl = {
                                        url: url, selection: save, fileName: fileName,
                                        selectParent: selectParent
                                    };
                                    proxy.inputUrl.setAttribute('disabled', 'true');
                                    proxy.embedInputUrl.setAttribute('disabled', 'true');
                                    if (ej2_base_1.isNullOrUndefined(proxy.parent.insertVideoSettings.saveUrl) && _this.isAllowedTypes
                                        && !ej2_base_1.isNullOrUndefined(_this.dialogObj)) {
                                        _this.dialogObj.getButtons(0).element.removeAttribute('disabled');
                                    }
                                });
                                reader_1.readAsDataURL(selectArgs.filesData[0].rawFile);
                            }
                        }
                    });
                },
                beforeUpload: function (args) {
                    _this.parent.trigger(events.beforeFileUpload, args);
                },
                uploading: function (e) {
                    Eif (!_this.parent.isServerRendered) {
                        _this.parent.trigger(events.fileUploading, e);
                    }
                },
                success: function (e) {
                    _this.parent.trigger(events.fileUploadSuccess, e, function (e) {
                        if (!ej2_base_1.isNullOrUndefined(_this.parent.insertVideoSettings.path)) {
                            var url = _this.parent.insertVideoSettings.path + e.file.name;
                            var value = { url: url, selection: save };
                            proxy.uploadUrl = {
                                url: url, selection: save, fileName: fileName, selectParent: selectParent,
                                width: {
                                    width: proxy.parent.insertVideoSettings.width, minWidth: proxy.parent.insertVideoSettings.minWidth,
                                    maxWidth: proxy.parent.getInsertImgMaxWidth()
                                },
                                height: {
                                    height: proxy.parent.insertVideoSettings.height, minHeight: proxy.parent.insertVideoSettings.minHeight,
                                    maxHeight: proxy.parent.insertVideoSettings.maxHeight
                                }
                            };
                            proxy.embedInputUrl.setAttribute('disabled', 'true');
                        }
                        if (e.operation === 'upload' && !ej2_base_1.isNullOrUndefined(_this.dialogObj)) {
                            _this.dialogObj.getButtons(0).element.removeAttribute('disabled');
                        }
                    });
                },
                failure: function (e) {
                    _this.parent.trigger(events.fileUploadFailed, e);
                },
                removing: function () {
                    _this.parent.trigger(events.fileRemoving, e, function (e) {
                        proxy.isVideoUploaded = false;
                        _this.dialogObj.getButtons(0).element.disabled = true;
                        if (proxy.inputUrl.getAttribute('disabled')) {
                            proxy.inputUrl.removeAttribute('disabled');
                        }
                        if (proxy.embedInputUrl.getAttribute('disabled')) {
                            proxy.embedInputUrl.removeAttribute('disabled');
                        }
                        Eif (proxy.uploadUrl) {
                            proxy.uploadUrl.url = '';
                        }
                    });
                }
            });
            this.uploadObj.isStringTemplate = true;
            this.uploadObj.createElement = this.parent.createElement;
            this.uploadObj.appendTo(uploadEle);
            return uploadParentEle;
        };
        Video.prototype.checkExtension = function (e) {
            Eif (this.uploadObj.allowedExtensions) {
                if (this.uploadObj.allowedExtensions.toLocaleLowerCase().indexOf(('.' + e.type).toLocaleLowerCase()) === -1) {
                    this.dialogObj.getButtons(0).element.setAttribute('disabled', 'disabled');
                    this.isAllowedTypes = false;
                }
                else {
                    this.isAllowedTypes = true;
                }
            }
        };
        Video.prototype.fileSelect = function () {
            this.dialogObj.element.getElementsByClassName('e-file-select-wrap')[0].querySelector('button').click();
            return false;
        };
        Video.prototype.cancelDialog = function (e) {
            this.parent.isBlur = false;
            this.dialogObj.hide({ returnValue: true });
            Iif (this.isVideoUploaded) {
                this.uploadObj.removing();
            }
        };
        Video.prototype.insertVideoUrl = function (e) {
            var proxy = this.selfVideo;
            proxy.isVideoUploaded = false;
            var url = proxy.inputUrl.value;
            var embedUrl = proxy.embedInputUrl.value;
            if (proxy.parent.formatter.getUndoRedoStack().length === 0) {
                proxy.parent.formatter.saveData();
            }
            if (!ej2_base_1.isNullOrUndefined(proxy.uploadUrl) && proxy.uploadUrl.url !== '') {
                proxy.uploadUrl.cssClass = (proxy.parent.insertVideoSettings.layoutOption === 'Inline' ?
                    classes.CLS_VIDEOINLINE : classes.CLS_VIDEOBREAK);
                proxy.uploadUrl.width = {
                    width: proxy.parent.insertVideoSettings.width, minWidth: proxy.parent.insertVideoSettings.minWidth,
                    maxWidth: proxy.parent.getInsertImgMaxWidth()
                };
                proxy.uploadUrl.height = {
                    height: proxy.parent.insertVideoSettings.height, minHeight: proxy.parent.insertVideoSettings.minHeight,
                    maxHeight: proxy.parent.insertVideoSettings.maxHeight
                };
                proxy.dialogObj.hide({ returnValue: false });
                Iif (proxy.dialogObj !== null) {
                    return;
                }
                proxy.parent.formatter.process(proxy.parent, this.args, this.args.originalEvent, proxy.uploadUrl);
                proxy.uploadUrl.url = '';
            }
            else if (proxy.parent.editorMode === 'HTML' && (url !== '' || embedUrl !== '')) {
                Iif (proxy.parent.editorMode === 'HTML' && ej2_base_1.isNullOrUndefined(ej2_base_2.closest(this.selection.range.startContainer.parentNode, '[id=' + "'" + proxy.contentModule.getPanel().id + "'" + ']'))) {
                    proxy.contentModule.getEditPanel().focus();
                    var range = proxy.parent.formatter.editorManager.nodeSelection.getRange(proxy.contentModule.getDocument());
                    this.selection = proxy.parent.formatter.editorManager.nodeSelection.save(range, proxy.contentModule.getDocument());
                    this.selectParent = proxy.parent.formatter.editorManager.nodeSelection.getParentNodeCollection(range);
                }
                var webUrlBtn = document.getElementById('webURL');
                var name_1 = webUrlBtn.checked ? url.split('/')[url.split('/').length - 1] : embedUrl;
                var value = {
                    cssClass: (proxy.parent.insertVideoSettings.layoutOption === 'Inline' ? classes.CLS_VIDEOINLINE : classes.CLS_VIDEOBREAK),
                    url: url, selection: this.selection, fileName: name_1, isEmbedUrl: !webUrlBtn.checked,
                    selectParent: this.selectParent, width: {
                        width: proxy.parent.insertVideoSettings.width, minWidth: proxy.parent.insertVideoSettings.minWidth,
                        maxWidth: proxy.parent.getInsertImgMaxWidth()
                    },
                    height: {
                        height: proxy.parent.insertVideoSettings.height, minHeight: proxy.parent.insertVideoSettings.minHeight,
                        maxHeight: proxy.parent.insertVideoSettings.maxHeight
                    }
                };
                proxy.dialogObj.hide({ returnValue: false });
                if (proxy.dialogObj !== null) {
                    return;
                }
                proxy.parent.formatter.process(proxy.parent, this.args, this.args.originalEvent, value);
            }
        };
        Video.prototype.destroy = function () {
            if (this.isDestroyed) {
                return;
            }
            this.prevSelectedVidEle = undefined;
            this.removeEventListener();
            Iif (this.showPopupTime) {
                clearTimeout(this.showPopupTime);
                this.showPopupTime = null;
            }
            this.clearDialogObj();
            this.isDestroyed = true;
        };
        Video.prototype.getModuleName = function () {
            return 'video';
        };
        return Video;
    }());
    exports.Video = Video;
});