all files / document-editor/implementation/dialogs/ style-dialog.js

78.23% Statements 672/859
61.85% Branches 248/401
53.42% Functions 39/73
78.55% Lines 670/853
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   148× 148× 148× 148× 148× 148× 148× 148× 148× 148× 148× 148× 148× 148× 148× 148× 148× 148× 148× 148× 148× 148× 148× 148× 148× 148× 148× 148× 148× 148× 148× 148× 148× 148×                         148×       148×       148×       148×                                                       148×   148×   148×     148×                 148×                 148×                 148×                 148×       148×                           148×         148×   148×         148×   148×         148×     148×     148×     148×                                                                                                   148×           148×                       148×   148×   148×   14469×                                                                                       112×           112× 112× 112×                                                                             98× 98× 21×   98× 98× 98× 98×           16×     14× 14× 14×   16×       12× 12× 12× 12× 12× 12× 12× 12×   12× 10×       12× 12×   12× 12× 12× 12× 12×               12× 12× 12× 12× 12× 12×                                                                                                                                                                                                             104× 104× 20×   104×   12×                                                         203×       203×   203×   203×   203×   203×   203×   203×   203×   203×     203× 203×       203×   203×   203×   203×   203×   203×   203×     203×     203×     203× 203× 203×   203×   203×     203× 14×   203× 14×   203× 14×   203× 14×   203× 14×   203× 14×   203× 14×   203× 14×   203× 14×   203× 14×   203×   203×   203×   203×     203×   203×   203×   203×   203×   203×   203×   203×   203×   203×   203×   203×   203×   203×   203×   203×   203×   203×   203×   203×   203×   203×   203×   203×   203×   203×   203×   203×   203×   203×   203×   203×          
define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-dropdowns", "@syncfusion/ej2-buttons", "../../implementation/format/style", "../../base/index", "./index", "@syncfusion/ej2-data", "../list/abstract-list", "../index", "@syncfusion/ej2-inputs", "@syncfusion/ej2-splitbuttons", "@syncfusion/ej2-base"], function (require, exports, ej2_base_1, ej2_dropdowns_1, ej2_buttons_1, style_1, index_1, index_2, ej2_data_1, abstract_list_1, index_3, ej2_inputs_1, ej2_splitbuttons_1, ej2_base_2) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var StyleDialog = (function () {
        function StyleDialog(documentHelper) {
            var _this = this;
            this.target = undefined;
            this.styleType = undefined;
            this.styleBasedOn = undefined;
            this.styleParagraph = undefined;
            this.onlyThisDocument = undefined;
            this.template = undefined;
            this.fontFamily = undefined;
            this.fontSize = undefined;
            this.characterFormat = undefined;
            this.paragraphFormat = undefined;
            this.textAlignment = undefined;
            this.lineSpacing = undefined;
            this.leftIndent = undefined;
            this.beforeSpacing = undefined;
            this.afterSpacing = undefined;
            this.setLeftAlignmentClickHandler = this.onSetLeftAlignmentClick.bind(this);
            this.setCenterAlignmentClickHandler = this.onSetCenterAlignmentClick.bind(this);
            this.setRightAlignmentClickHandler = this.onSetRightAlignmentClick.bind(this);
            this.setJustifyAlignmentClickHandler = this.onSetJustifyAlignmentClick.bind(this);
            this.setSingleLineSpacingClickHandler = this.setSingleLineSpacing.bind(this);
            this.setOnePointFiveLineSpacingClickHandler = this.setOnePointFiveLineSpacing.bind(this);
            this.setDoubleLineSpacingClickHandler = this.setDoubleLineSpacing.bind(this);
            this.increaseIndentValueHandler = this.increaseIndentValue.bind(this);
            this.decreaseIndentValueHandler = this.decreaseIndentValue.bind(this);
            this.increaseBeforeAfterSpacingValueHandler = this.onIncreaseBeforeAfterSpacing.bind(this);
            this.decreaseBeforeAfterSpacingValueHandler = this.onDecreaseBeforeAfterSpacing.bind(this);
            this.setUnderlinePropertyHandler = this.onSetUnderlineProperty.bind(this);
            this.setItalicPropertyHandler = this.onSetItalicProperty.bind(this);
            this.setBoldPropertyHandler = this.onSetBoldProperty.bind(this);
            this.openDialogHandler = this.onOpenDialog.bind(this);
            this.updateOkButtonClickHandler = this.onUpdateOkButtonClick.bind(this);
            this.updateNextStyleHandler = this.onUpdateNextStyle.bind(this);
            this.openDialog = function (args) {
                switch (args.item.id) {
                    case 'style_font':
                        _this.showFontDialog();
                        break;
                    case 'style_paragraph':
                        _this.showParagraphDialog();
                        break;
                    case 'style_numbering':
                        _this.showNumberingBulletDialog();
                        break;
                }
            };
            this.setBoldProperty = function () {
                _this.characterFormat.bold = !_this.characterFormat.bold;
                _this.fontButtonClicked();
            };
            this.setItalicProperty = function () {
                _this.characterFormat.italic = !_this.characterFormat.italic;
                _this.fontButtonClicked();
            };
            this.setUnderlineProperty = function () {
                _this.characterFormat.underline = _this.characterFormat.underline === 'None' ? 'Single' : 'None';
                _this.fontButtonClicked();
            };
            this.fontButtonClicked = function () {
                Iif (_this.characterFormat.bold) {
                    if (!_this.bold.classList.contains('e-active')) {
                        _this.bold.classList.add('e-active');
                    }
                }
                else {
                    Iif (_this.bold.classList.contains('e-active')) {
                        _this.bold.classList.remove('e-active');
                    }
                }
                Iif (_this.characterFormat.italic) {
                    if (!_this.italic.classList.contains('e-active')) {
                        _this.italic.classList.add('e-active');
                    }
                }
                else {
                    Iif (_this.italic.classList.contains('e-active')) {
                        _this.italic.classList.remove('e-active');
                    }
                }
                Iif (_this.characterFormat.underline !== undefined && _this.characterFormat.underline !== 'None') {
                    if (!_this.underline.classList.contains('e-active')) {
                        _this.underline.classList.add('e-active');
                        _this.characterFormat.underline = 'Single';
                    }
                }
                else {
                    Iif (_this.underline.classList.contains('e-active')) {
                        _this.underline.classList.remove('e-active');
                        _this.characterFormat.underline = 'None';
                    }
                }
            };
            this.fontSizeUpdate = function (args) {
                _this.characterFormat.fontSize = args.value;
            };
            this.fontFamilyChanged = function (args) {
                _this.characterFormat.fontFamily = args.value.toString();
            };
            this.fontColorUpdate = function (args) {
                _this.characterFormat.fontColor = args.currentValue.hex;
            };
            this.setLeftAlignment = function () {
                if (_this.textAlignment === 'Left') {
                    _this.textAlignment = 'Justify';
                }
                else {
                    _this.textAlignment = 'Left';
                }
                _this.updateParagraphFormat();
            };
            this.setRightAlignment = function () {
                if (_this.textAlignment === 'Right') {
                    _this.textAlignment = 'Left';
                }
                else {
                    _this.textAlignment = 'Right';
                }
                _this.updateParagraphFormat();
            };
            this.setCenterAlignment = function () {
                if (_this.textAlignment === 'Center') {
                    _this.textAlignment = 'Left';
                }
                else {
                    _this.textAlignment = 'Center';
                }
                _this.updateParagraphFormat();
            };
            this.setJustifyAlignment = function () {
                if (_this.textAlignment === 'Justify') {
                    _this.textAlignment = 'Left';
                }
                else {
                    _this.textAlignment = 'Justify';
                }
                _this.updateParagraphFormat();
            };
            this.increaseBeforeAfterSpacing = function () {
                _this.beforeSpacing += 6;
                _this.afterSpacing += 6;
            };
            this.decreaseBeforeAfterSpacing = function () {
                if (_this.beforeSpacing >= 6) {
                    _this.beforeSpacing -= 6;
                }
                else {
                    _this.beforeSpacing = 0;
                }
                if (_this.afterSpacing >= 6) {
                    _this.afterSpacing -= 6;
                }
                else {
                    _this.afterSpacing = 0;
                }
            };
            this.updateNextStyle = function (args) {
                var typedName = args.srcElement.value;
                if (_this.getTypeValue() === _this.localObj.getConstant('Paragraph') && !ej2_base_1.isNullOrUndefined(typedName) && typedName !== '' && !_this.isUserNextParaUpdated) {
                    var styles = _this.documentHelper.styles.getStyleNames(_this.getTypeValue());
                    Iif (_this.isEdit) {
                        styles = styles.filter(function (e) { return e !== _this.editStyleName; });
                    }
                    styles.push(typedName);
                    _this.styleParagraph.dataSource = styles;
                    _this.styleParagraph.index = null;
                    _this.styleParagraph.index = styles.indexOf(typedName);
                }
            };
            this.updateOkButton = function () {
                var styleName = _this.target.getElementsByClassName('e-input e-de-style-dlg-name-input').item(0).value;
                _this.enableOrDisableOkButton();
            };
            this.styleTypeChange = function (args) {
                if (args.isInteracted) {
                    var type = void 0;
                    if (args.value === 'Character') {
                        _this.style = new style_1.WCharacterStyle();
                        type = 'Character';
                    }
                    if (args.value === 'Paragraph' || args.value === 'Linked Style') {
                        _this.style = new style_1.WParagraphStyle();
                        type = 'Paragraph';
                    }
                    _this.toggleDisable();
                    _this.updateStyleNames(type);
                }
            };
            this.styleBasedOnChange = function () {
            };
            this.styleParagraphChange = function (args) {
                if (args.isInteracted) {
                    _this.isUserNextParaUpdated = true;
                }
            };
            this.showFontDialog = function () {
                Eif (!ej2_base_1.isNullOrUndefined(_this.documentHelper.owner.fontDialogModule)) {
                    _this.documentHelper.owner.showFontDialog(_this.characterFormat);
                }
                _this.updateCharacterFormat();
            };
            this.showParagraphDialog = function () {
                Eif (!ej2_base_1.isNullOrUndefined(_this.documentHelper.owner.paragraphDialogModule)) {
                    _this.documentHelper.owner.showParagraphDialog(_this.paragraphFormat);
                }
            };
            this.showNumberingBulletDialog = function () {
                _this.numberingBulletDialog = new index_2.BulletsAndNumberingDialog(_this.documentHelper);
                Eif (_this.style instanceof style_1.WParagraphStyle && (!ej2_base_1.isNullOrUndefined(_this.style.paragraphFormat))) {
                    _this.numberingBulletDialog.showNumberBulletDialog(_this.style.paragraphFormat.listFormat, _this.abstractList);
                }
            };
            this.onOkButtonClick = function () {
                var styleName = _this.documentHelper.owner.stylesDialogModule.getStyleName(ej2_base_2.SanitizeHtmlHelper.sanitize(_this.styleNameElement.value));
                Eif (styleName.length > 0) {
                    var style = _this.documentHelper.styles.findByName(styleName);
                    var name_1;
                    Eif (!ej2_base_1.isNullOrUndefined(style)) {
                        _this.documentHelper.owner.editorHistoryModule.initializeHistory('ModifyStyle');
                        Eif (_this.styleType.value === 'Paragraph' || _this.styleType.value === 'Linked Style') {
                            _this.updateList();
                        }
                        Eif (_this.documentHelper.owner.editorHistoryModule.currentBaseHistoryInfo && _this.documentHelper.owner.editorHistoryModule.currentBaseHistoryInfo.action === 'ModifyStyle') {
                            var listId_1 = style instanceof style_1.WParagraphStyle ? style.paragraphFormat.listFormat.listId : -1;
                            var styleObject = _this.documentHelper.owner.getStyleObject(style, listId_1);
                            _this.documentHelper.owner.editorHistoryModule.currentBaseHistoryInfo.modifiedProperties.push(styleObject);
                            _this.applyParagraphFormat();
                        }
                        _this.documentHelper.owner.editorHistoryModule.updateHistory();
                        _this.style.type = _this.getTypeValue();
                        _this.style.basedOn = _this.documentHelper.styles.findByName(_this.documentHelper.owner.stylesDialogModule.getStyleName(_this.styleBasedOn.value));
                        Eif (_this.styleType.value === 'Paragraph' || _this.styleType.value === 'Linked Style') {
                            _this.style.next = _this.documentHelper.styles.findByName(_this.documentHelper.owner.stylesDialogModule.getStyleName(_this.styleParagraph.value));
                            _this.style.characterFormat.assignFormat(_this.characterFormat);
                            _this.style.paragraphFormat.assignFormat(_this.paragraphFormat, true);
                            _this.style.link = (_this.styleType.value === 'Linked Style') ? _this.createLinkStyle(styleName, _this.isEdit) : undefined;
                        }
                        _this.style.name = style.name;
                        name_1 = style.name;
                        style = _this.style;
                        var listId = _this.style instanceof style_1.WParagraphStyle ? _this.style.paragraphFormat.listFormat.listId : -1;
                        _this.documentHelper.owner.setStyleData(name_1, listId);
                        _this.documentHelper.owner.isShiftingEnabled = true;
                        _this.documentHelper.owner.editorModule.isSkipOperationsBuild = _this.documentHelper.owner.enableCollaborativeEditing;
                        _this.documentHelper.owner.editorModule.layoutWholeDocument();
                        _this.documentHelper.owner.editorModule.isSkipOperationsBuild = false;
                        _this.documentHelper.owner.isShiftingEnabled = false;
                    }
                    else {
                        var tmpStyle = _this.getTypeValue() === 'Paragraph' ? new style_1.WParagraphStyle() : new style_1.WCharacterStyle;
                        tmpStyle.copyStyle(_this.style);
                        if (_this.getTypeValue() === 'Character') {
                            tmpStyle.characterFormat.copyFormat(_this.characterFormat);
                        }
                        var basedOn = _this.documentHelper.styles.findByName(_this.documentHelper.owner.stylesDialogModule.getStyleName(_this.styleBasedOn.value));
                        if (_this.styleType.value === 'Paragraph' || _this.styleType.value === 'Linked Style') {
                            if (styleName === _this.documentHelper.owner.stylesDialogModule.getStyleName(_this.styleParagraph.value)) {
                                tmpStyle.next = tmpStyle;
                            }
                            else {
                                tmpStyle.next = _this.documentHelper.styles.findByName(_this.documentHelper.owner.stylesDialogModule.getStyleName(_this.styleParagraph.value));
                            }
                            _this.updateList();
                        }
                        tmpStyle.link = (_this.styleType.value === 'Linked Style') ? _this.createLinkStyle(styleName) : undefined;
                        tmpStyle.type = _this.getTypeValue();
                        tmpStyle.name = styleName;
                        tmpStyle.basedOn = basedOn;
                        _this.documentHelper.styles.push(tmpStyle);
                        _this.documentHelper.addToStylesMap(tmpStyle);
                        name_1 = styleName;
                        _this.documentHelper.owner.editorHistoryModule.initializeHistory('ModifyStyle');
                        if (_this.documentHelper.owner.editorHistoryModule.currentBaseHistoryInfo && _this.documentHelper.owner.editorHistoryModule.currentBaseHistoryInfo.action === 'ModifyStyle') {
                            var listId_2 = tmpStyle instanceof style_1.WParagraphStyle ? tmpStyle.paragraphFormat.listFormat.listId : -1;
                            var styleObject = _this.documentHelper.owner.getStyleObject(tmpStyle, listId_2);
                            styleObject["isNew"] = true;
                            _this.documentHelper.owner.editorHistoryModule.currentBaseHistoryInfo.modifiedProperties.push(styleObject);
                            _this.applyParagraphFormat();
                        }
                        _this.documentHelper.owner.editorHistoryModule.updateHistory();
                        var listId = _this.style instanceof style_1.WParagraphStyle ? _this.style.paragraphFormat.listFormat.listId : -1;
                        _this.documentHelper.owner.setStyleData(name_1, listId);
                        _this.documentHelper.owner.editorModule.isSkipOperationsBuild = _this.styleType.value === 'Character' && _this.documentHelper.owner.enableCollaborativeEditing;
                        _this.documentHelper.owner.editorModule.applyStyle(name_1, true);
                        _this.documentHelper.owner.editorModule.isSkipOperationsBuild = false;
                        _this.documentHelper.owner.notify(index_1.internalStyleCollectionChange, {});
                    }
                    _this.documentHelper.dialog2.hide();
                    _this.documentHelper.updateFocus();
                }
                else {
                    throw new Error('Enter valid Style name');
                }
                Eif (_this.style) {
                }
                _this.documentHelper.updateFocus();
            };
            this.loadStyleDialog = function () {
                _this.documentHelper.updateFocus();
                _this.isUserNextParaUpdated = false;
                _this.styleNameElement = _this.target.getElementsByClassName('e-input e-de-style-dlg-name-input').item(0);
                _this.styleNameElement.value = null;
                if (!_this.isEdit) {
                    _this.styleType.index = 0;
                }
                var name;
                if (_this.isEdit) {
                    var localValue = new ej2_base_1.L10n('documenteditor', _this.documentHelper.owner.defaultLocale);
                    localValue.setLocale(_this.documentHelper.owner.locale);
                    var styleName = localValue.getConstant(_this.editStyleName);
                    Iif (styleName === '') {
                        styleName = _this.editStyleName;
                    }
                    _this.styleNameElement.value = styleName;
                    name = _this.editStyleName;
                }
                _this.okButton = _this.documentHelper.dialog2.element.getElementsByClassName('e-flat e-style-okay').item(0);
                _this.enableOrDisableOkButton();
                _this.updateStyleNames(_this.getTypeValue(), name);
                _this.updateCharacterFormat(_this.style.characterFormat);
                _this.updateParagraphFormat(_this.style.paragraphFormat);
            };
            this.applyParagraphFormat = function () {
                Iif (ej2_base_1.isNullOrUndefined(_this.paragraphFormat)) {
                    _this.paragraphFormat = new index_3.WParagraphFormat();
                }
                Eif (!ej2_base_1.isNullOrUndefined(_this.textAlignment)) {
                    _this.paragraphFormat.textAlignment = _this.textAlignment;
                }
                Iif (!ej2_base_1.isNullOrUndefined(_this.beforeSpacing)) {
                    _this.paragraphFormat.beforeSpacing = _this.beforeSpacing;
                }
                Iif (!ej2_base_1.isNullOrUndefined(_this.afterSpacing)) {
                    _this.paragraphFormat.afterSpacing = _this.afterSpacing;
                }
                Iif (!ej2_base_1.isNullOrUndefined(_this.leftIndent)) {
                    _this.paragraphFormat.leftIndent = _this.leftIndent;
                }
                Eif (!ej2_base_1.isNullOrUndefined(_this.lineSpacing)) {
                    _this.paragraphFormat.lineSpacing = _this.lineSpacing;
                }
                _this.updateParagraphFormat();
            };
            this.onCancelButtonClick = function () {
                _this.style = undefined;
                _this.characterFormat = undefined;
                _this.paragraphFormat = undefined;
                _this.textAlignment = undefined;
                _this.lineSpacing = undefined;
                _this.leftIndent = undefined;
                _this.beforeSpacing = undefined;
                _this.afterSpacing = undefined;
                _this.documentHelper.dialog2.hide();
                _this.documentHelper.updateFocus();
            };
            this.closeStyleDialog = function () {
                _this.documentHelper.updateFocus();
                _this.textAlignment = undefined;
                _this.lineSpacing = undefined;
                _this.leftIndent = undefined;
                _this.beforeSpacing = undefined;
                _this.afterSpacing = undefined;
            };
            this.documentHelper = documentHelper;
        }
        StyleDialog.prototype.getModuleName = function () {
            return 'StyleDialog';
        };
        StyleDialog.prototype.initStyleDialog = function (localValue, isRtl) {
            var instance = this;
            this.localObj = localValue;
            this.target = ej2_base_1.createElement('div', { className: 'e-de-style-dialog' });
            this.container = ej2_base_1.createElement('div');
            this.properties = ej2_base_1.createElement('div', { className: 'e-de-para-dlg-heading', innerHTML: localValue.getConstant('Properties') });
            this.container.appendChild(this.properties);
            this.styleNameTypeDiv = ej2_base_1.createElement('div', { className: 'e-de-container-row' });
            this.container.appendChild(this.styleNameTypeDiv);
            this.nameWholeDiv = ej2_base_1.createElement('div', { className: 'e-de-subcontainer-left' });
            this.styleNameTypeDiv.appendChild(this.nameWholeDiv);
            this.nameValue = ej2_base_1.createElement('input', { className: 'e-input e-de-style-dlg-name-input' });
            this.nameValue.addEventListener('keyup', this.updateOkButtonClickHandler);
            this.nameValue.addEventListener('input', this.updateOkButtonClickHandler);
            this.nameValue.addEventListener('blur', this.updateNextStyleHandler);
            this.nameWholeDiv.appendChild(this.nameValue);
            new ej2_inputs_1.TextBox({ placeholder: localValue.getConstant('Name') + ':', floatLabelType: 'Always' }, this.nameValue);
            this.styleTypeWholeDiv = ej2_base_1.createElement('div', { className: 'e-de-subcontainer-right' });
            this.styleNameTypeDiv.appendChild(this.styleTypeWholeDiv);
            this.styleTypeDivElement = ej2_base_1.createElement('div');
            this.styleTypeValue = ej2_base_1.createElement('select');
            this.styleTypeValue.innerHTML = '<option value="Paragraph">' + localValue.getConstant('Paragraph') + '</option><option value="Character">' + localValue.getConstant('Character') + '</option><option value="Linked Style">' + localValue.getConstant('Linked Style') + '</option>';
            this.styleTypeDivElement.appendChild(this.styleTypeValue);
            this.styleType = new ej2_dropdowns_1.DropDownList({
                change: this.styleTypeChange,
                popupHeight: '253px', enableRtl: isRtl,
                placeholder: localValue.getConstant('Style type') + ':', floatLabelType: 'Always'
            });
            this.styleType.appendTo(this.styleTypeValue);
            this.styleTypeWholeDiv.appendChild(this.styleTypeDivElement);
            this.styleBasedParaDiv = ej2_base_1.createElement('div', { className: 'e-de-container-row' });
            this.container.appendChild(this.styleBasedParaDiv);
            this.styleBasedOnWholeDiv = ej2_base_1.createElement('div', { className: 'e-de-subcontainer-left' });
            this.styleBasedParaDiv.appendChild(this.styleBasedOnWholeDiv);
            this.styleBasedOnDivElement = ej2_base_1.createElement('div', { className: 'e-de-style-style-based-on-div' });
            this.styleBasedOnValue = ej2_base_1.createElement('input');
            this.styleBasedOnDivElement.appendChild(this.styleBasedOnValue);
            this.styleBasedOn = new ej2_dropdowns_1.DropDownList({
                dataSource: [], select: this.styleBasedOnChange, popupHeight: '253px', enableRtl: isRtl,
                placeholder: localValue.getConstant('Style based on') + ':', floatLabelType: 'Always'
            });
            this.styleBasedOn.appendTo(this.styleBasedOnValue);
            this.styleBasedOnWholeDiv.appendChild(this.styleBasedOnDivElement);
            this.styleParagraphWholeDiv = ej2_base_1.createElement('div', { className: 'e-de-subcontainer-right' });
            this.styleBasedParaDiv.appendChild(this.styleParagraphWholeDiv);
            if (isRtl) {
                this.nameWholeDiv.classList.add('e-de-rtl');
                this.styleBasedOnWholeDiv.classList.add('e-de-rtl');
                this.styleParagraphWholeDiv.classList.add('e-de-rtl');
            }
            this.styleParagraphDivElement = ej2_base_1.createElement('div');
            this.styleParagraphValue = ej2_base_1.createElement('input');
            this.styleParagraphDivElement.appendChild(this.styleParagraphValue);
            this.styleParagraph = new ej2_dropdowns_1.DropDownList({
                dataSource: [], select: this.styleParagraphChange, popupHeight: '253px', enableRtl: isRtl,
                placeholder: localValue.getConstant('Style for following paragraph') + ':', floatLabelType: 'Always'
            });
            this.styleParagraph.appendTo(this.styleParagraphValue);
            this.styleParagraphWholeDiv.appendChild(this.styleParagraphDivElement);
            this.formatting = ej2_base_1.createElement('div', { className: 'e-de-para-dlg-heading', innerHTML: localValue.getConstant('Formatting') });
            this.container.appendChild(this.formatting);
            this.optionsDiv = ej2_base_1.createElement('div', { className: 'e-de-style-options-div' });
            this.container.appendChild(this.optionsDiv);
            this.fontOptionsDiv = ej2_base_1.createElement('div', { styles: 'display:flex;margin-bottom: 14px;' });
            this.optionsDiv.appendChild(this.fontOptionsDiv);
            this.createFontOptions(this.fontOptionsDiv, isRtl);
            this.paragraphOptionsDiv = ej2_base_1.createElement('div', { styles: 'display:flex', className: 'e-style-paragraph' });
            this.optionsDiv.appendChild(this.paragraphOptionsDiv);
            this.createParagraphOptions(this.paragraphOptionsDiv);
            this.createFormatDropdown(this.container, localValue, isRtl);
            this.target.appendChild(this.container);
        };
        StyleDialog.prototype.createFormatDropdown = function (parentDiv, localValue, isRtl) {
            var _this = this;
            this.formatBtn = ej2_base_1.createElement('button', {
                id: 'style_format_dropdown', innerHTML: localValue.getConstant('Format'),
                attrs: { type: 'button' }
            });
            this.formatBtn.style.height = '31px';
            parentDiv.appendChild(this.formatBtn);
            var items = [{ text: localValue.getConstant('Font') + '...', id: 'style_font' },
                { text: localValue.getConstant('Paragraph') + '...', id: 'style_paragraph' },
                { text: localValue.getConstant('Numbering') + '...', id: 'style_numbering' }];
            this.styleDropdwn = new ej2_splitbuttons_1.DropDownButton({
                items: items, cssClass: 'e-de-style-format-dropdwn', enableRtl: isRtl,
                beforeItemRender: function (args) {
                    if (_this.styleType.value === localValue.getConstant('Character')) {
                        if (args.item.id === "style_paragraph") {
                            args.element.classList.add('e-disabled');
                        }
                        if (args.item.id === 'style_numbering') {
                            args.element.classList.add('e-disabled');
                        }
                    }
                    else {
                        if (args.item.id === "style_paragraph") {
                            args.element.classList.remove('e-disabled');
                        }
                        if (args.item.id === 'style_numbering') {
                            args.element.classList.remove('e-disabled');
                        }
                    }
                },
            });
            this.styleDropdwn.appendTo(this.formatBtn);
            this.styleDropdwn.addEventListener('select', this.openDialogHandler);
        };
        StyleDialog.prototype.onOpenDialog = function (args) {
            this.openDialog(args);
        };
        StyleDialog.prototype.createFontOptions = function (parentDiv, isRtl) {
            var _this = this;
            this.fontFamilyElement = ej2_base_1.createElement('input', {
                id: this.target.id + '_fontName',
            });
            var fontStyle;
            var isStringTemplate = true;
            var itemTemplate = ej2_base_1.initializeCSPTemplate(function (data) { return "<span style=\"font-family: " + data.FontName + ";\">" + data.FontName + "</span>"; });
            parentDiv.appendChild(this.fontFamilyElement);
            this.fontFamily = new ej2_dropdowns_1.ComboBox({
                dataSource: fontStyle, query: new ej2_data_1.Query().select(['FontName']), fields: { text: 'FontName', value: 'value' },
                allowCustom: true, width: '123px', popupWidth: '123px',
                cssClass: 'e-style-font-fmaily-right', enableRtl: isRtl, change: this.fontFamilyChanged,
                showClearButton: false, itemTemplate: itemTemplate
            });
            this.fontFamily.appendTo(this.fontFamilyElement);
            this.fontFamily.isStringTemplate = isStringTemplate;
            var fontFamilyValue = this.documentHelper.owner.documentEditorSettings.fontFamilies;
            for (var i = 0; i < fontFamilyValue.length; i++) {
                var fontValue = fontFamilyValue[i];
                var fontStyleValue = { 'FontName': fontValue, 'value': fontValue };
                this.fontFamily.addItem(fontStyleValue, i);
            }
            this.fontFamily.focus = function () { _this.fontFamily.element.select(); };
            this.fontFamily.element.parentElement.setAttribute('title', this.localObj.getConstant('Font'));
            this.fontSizeElement = ej2_base_1.createElement('input');
            parentDiv.appendChild(this.fontSizeElement);
            var sizeDataSource = [8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72];
            this.fontSize = new ej2_dropdowns_1.ComboBox({
                dataSource: sizeDataSource, width: '73px', cssClass: 'e-style-font-fmaily-right',
                enableRtl: isRtl, change: this.fontSizeUpdate
            });
            this.fontSize.showClearButton = false;
            this.fontSize.appendTo(this.fontSizeElement);
            this.fontGroupButton = ej2_base_1.createElement('div', { className: 'e-de-style-font-group-button' });
            parentDiv.appendChild(this.fontGroupButton);
            this.bold = this.createButtonElement(this.fontGroupButton, 'e-de-bold', 'e-de-style-bold-button-size', this.documentHelper.owner.containerId + '_style_bold');
            this.bold.setAttribute('aria-label', 'bold');
            this.bold.addEventListener('click', this.setBoldPropertyHandler);
            this.italic = this.createButtonElement(this.fontGroupButton, 'e-de-italic', 'e-de-style-icon-button-size', this.documentHelper.owner.containerId + '_style_italic');
            this.italic.setAttribute('aria-label', 'italic');
            this.italic.addEventListener('click', this.setItalicPropertyHandler);
            this.underline = this.createButtonElement(this.fontGroupButton, 'e-de-underline', 'e-de-style-icon-button-size', this.documentHelper.owner.containerId + '_style_underline');
            this.underline.setAttribute('aria-label', 'underline');
            this.underline.addEventListener('click', this.setUnderlinePropertyHandler);
            this.fontColorElement = ej2_base_1.createElement('input', { attrs: { type: 'color' }, className: 'e-de-style-icon-button-size' });
            parentDiv.appendChild(this.fontColorElement);
            var _a = this.documentHelper.owner.documentEditorSettings.colorPickerSettings, columns = _a.columns, createPopupOnClick = _a.createPopupOnClick, disabled = _a.disabled, enablePersistence = _a.enablePersistence, enableRtl = _a.enableRtl, inline = _a.inline, mode = _a.mode, modeSwitcher = _a.modeSwitcher, noColor = _a.noColor, presetColors = _a.presetColors, showButtons = _a.showButtons;
            this.fontColor = new ej2_inputs_1.ColorPicker({ cssClass: 'e-de-style-font-color-picker', enableRtl: isRtl, change: this.fontColorUpdate, locale: this.documentHelper.owner.locale, enableOpacity: false, mode: mode, modeSwitcher: modeSwitcher, showButtons: showButtons, columns: columns, createPopupOnClick: createPopupOnClick, disabled: disabled, enablePersistence: enablePersistence, inline: inline, noColor: noColor, presetColors: presetColors });
            this.documentHelper.fontColor = this.fontColor;
            this.fontColor.appendTo(this.fontColorElement);
        };
        StyleDialog.prototype.onSetBoldProperty = function () {
            this.setBoldProperty();
        };
        StyleDialog.prototype.onSetItalicProperty = function () {
            this.setItalicProperty();
        };
        StyleDialog.prototype.onSetUnderlineProperty = function () {
            this.setUnderlineProperty();
        };
        StyleDialog.prototype.createParagraphOptions = function (parentDiv) {
            this.alignmentDiv = ej2_base_1.createElement('div', { className: 'e-de-style-paragraph-group-button' });
            parentDiv.appendChild(this.alignmentDiv);
            this.leftAlign = this.createButtonElement(this.alignmentDiv, 'e-de-align-left', 'e-de-style-icon-button-size');
            this.leftAlign.setAttribute('aria-label', 'leftAlign');
            this.leftAlign.addEventListener('click', this.setLeftAlignmentClickHandler);
            this.centerAlign = this.createButtonElement(this.alignmentDiv, 'e-de-align-center', 'e-de-style-icon-button-size');
            this.centerAlign.setAttribute('aria-label', 'centerAlign');
            this.centerAlign.addEventListener('click', this.setCenterAlignmentClickHandler);
            this.rightAlign = this.createButtonElement(this.alignmentDiv, 'e-de-align-right', 'e-de-style-icon-button-size');
            this.rightAlign.setAttribute('aria-label', 'rightAlign');
            this.rightAlign.addEventListener('click', this.setRightAlignmentClickHandler);
            this.justify = this.createButtonElement(this.alignmentDiv, 'e-de-justify', 'e-de-style-icon-button-last-size');
            this.justify.setAttribute('aria-label', 'justify');
            this.justify.addEventListener('click', this.setJustifyAlignmentClickHandler);
            this.lineSpacingDiv = ej2_base_1.createElement('div', { className: 'e-de-style-paragraph-group-button' });
            parentDiv.appendChild(this.lineSpacingDiv);
            this.singleLineSpacing = this.createButtonElement(this.lineSpacingDiv, 'e-de-single-spacing', 'e-de-style-icon-button-first-size');
            this.singleLineSpacing.setAttribute('aria-label', 'singleLineSpacing');
            this.singleLineSpacing.addEventListener('click', this.setSingleLineSpacingClickHandler);
            this.onePointFiveLineSpacing = this.createButtonElement(this.lineSpacingDiv, 'e-de-one-point-five-spacing', 'e-de-style-icon-button-size');
            this.onePointFiveLineSpacing.setAttribute('aria-label', 'onePointFiveLineSpacing');
            this.onePointFiveLineSpacing.addEventListener('click', this.setOnePointFiveLineSpacingClickHandler);
            this.doubleLineSpacing = this.createButtonElement(this.lineSpacingDiv, 'e-de-double-spacing', 'e-de-style-icon-button-last-size');
            this.doubleLineSpacing.setAttribute('aria-label', 'doubleLineSpacing');
            this.doubleLineSpacing.addEventListener('click', this.setDoubleLineSpacingClickHandler);
            this.spacingDiv = ej2_base_1.createElement('div', { className: 'e-de-style-paragraph-group-button' });
            parentDiv.appendChild(this.spacingDiv);
            this.beforeSpacingEle = this.createButtonElement(this.spacingDiv, 'e-de-before-spacing', 'e-de-style-icon-button-first-size');
            this.beforeSpacingEle.setAttribute('aria-label', 'beforeSpacing');
            this.afterSpacingEle = this.createButtonElement(this.spacingDiv, 'e-de-after-spacing', 'e-de-style-icon-button-last-size');
            this.afterSpacingEle.setAttribute('aria-label', 'afterSpacing');
            this.beforeSpacingEle.addEventListener('click', this.increaseBeforeAfterSpacingValueHandler);
            this.afterSpacingEle.addEventListener('click', this.decreaseBeforeAfterSpacingValueHandler);
            this.indentingDiv = ej2_base_1.createElement('div', { className: 'e-de-style-paragraph-indent-group-button' });
            parentDiv.appendChild(this.indentingDiv);
            this.decreaseIndent = this.createButtonElement(this.indentingDiv, 'e-de-indent', 'e-de-style-icon-button-first-size');
            this.decreaseIndent.setAttribute('aria-label', 'decreaseIndent');
            this.decreaseIndent.addEventListener('click', this.decreaseIndentValueHandler);
            this.increaseindent = this.createButtonElement(this.indentingDiv, 'e-de-outdent', 'e-de-style-icon-button-size');
            this.increaseindent.setAttribute('aria-label', 'increaseindent');
            this.increaseindent.addEventListener('click', this.increaseIndentValueHandler);
        };
        StyleDialog.prototype.setSingleLineSpacing = function () {
            this.lineSpacing = 1;
            this.updateParagraphFormat();
        };
        StyleDialog.prototype.setOnePointFiveLineSpacing = function () {
            this.lineSpacing = 1.5;
            this.updateParagraphFormat();
        };
        StyleDialog.prototype.setDoubleLineSpacing = function () {
            this.lineSpacing = 2;
            this.updateParagraphFormat();
        };
        StyleDialog.prototype.increaseIndentValue = function () {
            this.leftIndent += 36;
        };
        StyleDialog.prototype.decreaseIndentValue = function () {
            if (this.leftIndent >= 36) {
                this.leftIndent -= 36;
            }
            else {
                this.leftIndent = 0;
            }
        };
        StyleDialog.prototype.onSetLeftAlignmentClick = function () {
            this.setLeftAlignment();
        };
        StyleDialog.prototype.onSetRightAlignmentClick = function () {
            this.setRightAlignment();
        };
        StyleDialog.prototype.onSetCenterAlignmentClick = function () {
            this.setCenterAlignment();
        };
        StyleDialog.prototype.onSetJustifyAlignmentClick = function () {
            this.setJustifyAlignment();
        };
        StyleDialog.prototype.createButtonElement = function (parentDiv, iconCss, className, id) {
            var buttonElement = ej2_base_1.createElement('button', { attrs: { type: 'button' } });
            if (!ej2_base_1.isNullOrUndefined(id)) {
                buttonElement.id = id;
            }
            parentDiv.appendChild(buttonElement);
            var button = new ej2_buttons_1.Button({ iconCss: iconCss, cssClass: className });
            button.appendTo(buttonElement);
            return buttonElement;
        };
        StyleDialog.prototype.onIncreaseBeforeAfterSpacing = function () {
            this.increaseBeforeAfterSpacing();
        };
        StyleDialog.prototype.onDecreaseBeforeAfterSpacing = function () {
            this.decreaseBeforeAfterSpacing();
        };
        StyleDialog.prototype.toggleDisable = function () {
            if (this.styleType.value === this.localObj.getConstant('Character')) {
                this.styleParagraph.enabled = false;
                this.target.getElementsByClassName('e-style-paragraph').item(0).setAttribute('style', 'display:flex;pointer-events:none;opacity:0.5');
            }
            else {
                this.styleParagraph.enabled = true;
                this.target.getElementsByClassName('e-style-paragraph').item(0).removeAttribute('style');
                this.target.getElementsByClassName('e-style-paragraph').item(0).setAttribute('style', 'display:flex');
            }
            this.styleBasedOn.enabled = true;
        };
        StyleDialog.prototype.onUpdateNextStyle = function (args) {
            this.updateNextStyle(args);
        };
        StyleDialog.prototype.onUpdateOkButtonClick = function () {
            this.updateOkButton();
        };
        StyleDialog.prototype.show = function (styleName, header) {
            var localObj = new ej2_base_1.L10n('documenteditor', this.documentHelper.owner.defaultLocale);
            this.isEdit = (!ej2_base_1.isNullOrUndefined(styleName) && styleName.length > 0) ? true : false;
            this.editStyleName = styleName;
            this.abstractList = new abstract_list_1.WAbstractList();
            var style = this.documentHelper.styles.findByName(styleName);
            this.style = !this.isEdit ? new style_1.WParagraphStyle() : style ? style : this.getStyle(styleName);
            localObj.setLocale(this.documentHelper.owner.locale);
            if (!this.target) {
                this.initStyleDialog(localObj, this.documentHelper.owner.enableRtl);
            }
            if (!this.isEdit) {
                this.styleType.value = 'Paragraph';
            }
            else {
                this.styleType.value = this.style instanceof style_1.WCharacterStyle ? 'Character' : 'Paragraph';
            }
            Eif (ej2_base_1.isNullOrUndefined(header)) {
                header = localObj.getConstant('Create New Style');
            }
            this.documentHelper.dialog2.header = header;
            this.documentHelper.dialog2.height = 'auto';
            this.documentHelper.dialog2.width = 'auto';
            this.documentHelper.dialog2.content = this.target;
            this.documentHelper.dialog2.buttons = [{
                    click: this.onOkButtonClick,
                    buttonModel: { content: localObj.getConstant('Ok'), cssClass: 'e-flat e-style-okay', isPrimary: true }
                },
                {
                    click: this.onCancelButtonClick,
                    buttonModel: { content: localObj.getConstant('Cancel'), cssClass: 'e-flat e-style-cancel' }
                }];
            this.toggleDisable();
            this.documentHelper.dialog2.dataBind();
            this.documentHelper.dialog2.beforeOpen = this.loadStyleDialog;
            this.documentHelper.dialog2.close = this.closeStyleDialog;
            this.documentHelper.dialog2.position = { X: 'center', Y: 'center' };
            this.documentHelper.dialog2.show();
        };
        StyleDialog.prototype.updateList = function () {
            var listId = this.style.paragraphFormat.listFormat.listId;
            Iif (listId > -1) {
                if (this.documentHelper.lists.filter(function (a) { return (a.listId === listId); }).length === 0) {
                    this.documentHelper.lists.push(this.style.paragraphFormat.listFormat.list);
                }
                else {
                    this.documentHelper.lists = this.documentHelper.lists.filter(function (a) { return (a.listId !== listId); });
                    this.documentHelper.lists.push(this.style.paragraphFormat.listFormat.list);
                }
            }
            Iif (this.abstractList.abstractListId !== -1) {
                this.documentHelper.abstractLists.push(this.abstractList);
            }
        };
        StyleDialog.prototype.createLinkStyle = function (name, isEdit) {
            var charStyle;
            if (isEdit) {
                charStyle = this.documentHelper.styles.findByName((name + ' Char'), 'Character');
            }
            else {
                charStyle = new style_1.WCharacterStyle();
            }
            charStyle.type = 'Character';
            charStyle.name = name + ' Char';
            charStyle.characterFormat = this.style.characterFormat.cloneFormat();
            charStyle.basedOn = this.style.basedOn;
            if (!isEdit) {
                this.documentHelper.styles.push(charStyle);
            }
            return this.documentHelper.styles.findByName(charStyle.name, 'Character');
        };
        StyleDialog.prototype.updateCharacterFormat = function (characterFormat) {
            if (!ej2_base_1.isNullOrUndefined(characterFormat)) {
                this.characterFormat = characterFormat.cloneFormat();
            }
            this.fontFamily.value = this.characterFormat.fontFamily;
            this.fontSize.value = this.characterFormat.fontSize;
            var color = this.characterFormat.fontColor;
            this.fontColor.value = (color === 'empty' || color === '#00000000') ? '#000000' : color;
            this.fontButtonClicked();
        };
        StyleDialog.prototype.updateParagraphFormat = function (paragraphFOrmat) {
            if (!ej2_base_1.isNullOrUndefined(paragraphFOrmat)) {
                this.paragraphFormat = paragraphFOrmat.cloneFormat();
                this.textAlignment = paragraphFOrmat.textAlignment;
                this.lineSpacing = paragraphFOrmat.lineSpacing;
            }
            Iif (ej2_base_1.isNullOrUndefined(this.paragraphFormat)) {
                return;
            }
            Eif (this.textAlignment === 'Left') {
                if (!this.leftAlign.classList.contains('e-active')) {
                    this.leftAlign.classList.add('e-active');
                }
                Iif (this.rightAlign.classList.contains('e-active')) {
                    this.rightAlign.classList.remove('e-active');
                }
                Iif (this.centerAlign.classList.contains('e-active')) {
                    this.centerAlign.classList.remove('e-active');
                }
                Iif (this.justify.classList.contains('e-active')) {
                    this.justify.classList.remove('e-active');
                }
            }
            else if (this.textAlignment === 'Right') {
                if (this.leftAlign.classList.contains('e-active')) {
                    this.leftAlign.classList.remove('e-active');
                }
                if (!this.rightAlign.classList.contains('e-active')) {
                    this.rightAlign.classList.add('e-active');
                }
                if (this.centerAlign.classList.contains('e-active')) {
                    this.centerAlign.classList.remove('e-active');
                }
                if (this.justify.classList.contains('e-active')) {
                    this.justify.classList.remove('e-active');
                }
            }
            else if (this.textAlignment === 'Center') {
                if (this.leftAlign.classList.contains('e-active')) {
                    this.leftAlign.classList.remove('e-active');
                }
                if (this.rightAlign.classList.contains('e-active')) {
                    this.rightAlign.classList.remove('e-active');
                }
                if (!this.centerAlign.classList.contains('e-active')) {
                    this.centerAlign.classList.add('e-active');
                }
                if (this.justify.classList.contains('e-active')) {
                    this.justify.classList.remove('e-active');
                }
            }
            else if (this.textAlignment === 'Justify') {
                if (this.leftAlign.classList.contains('e-active')) {
                    this.leftAlign.classList.remove('e-active');
                }
                if (this.rightAlign.classList.contains('e-active')) {
                    this.rightAlign.classList.remove('e-active');
                }
                if (this.centerAlign.classList.contains('e-active')) {
                    this.centerAlign.classList.remove('e-active');
                }
                if (!this.justify.classList.contains('e-active')) {
                    this.justify.classList.add('e-active');
                }
            }
            if (this.lineSpacing === 1) {
                this.singleLineSpacing.classList.add('e-active');
                this.onePointFiveLineSpacing.classList.remove('e-active');
                this.doubleLineSpacing.classList.remove('e-active');
            }
            else Iif (this.lineSpacing === 1.5) {
                this.singleLineSpacing.classList.remove('e-active');
                this.onePointFiveLineSpacing.classList.add('e-active');
                this.doubleLineSpacing.classList.remove('e-active');
            }
            else Iif (this.lineSpacing === 2) {
                this.singleLineSpacing.classList.remove('e-active');
                this.onePointFiveLineSpacing.classList.remove('e-active');
                this.doubleLineSpacing.classList.add('e-active');
            }
            else {
                this.singleLineSpacing.classList.remove('e-active');
                this.onePointFiveLineSpacing.classList.remove('e-active');
                this.doubleLineSpacing.classList.remove('e-active');
            }
        };
        StyleDialog.prototype.enableOrDisableOkButton = function () {
            Eif (!ej2_base_1.isNullOrUndefined(this.okButton)) {
                this.okButton.disabled = (this.styleNameElement.value === '');
            }
        };
        StyleDialog.prototype.getTypeValue = function (type) {
            var value = !ej2_base_1.isNullOrUndefined(type) ? type : this.styleType.value;
            Eif (value === 'Linked Style' || value === 'Paragraph') {
                return 'Paragraph';
            }
            else {
                return 'Character';
            }
        };
        StyleDialog.prototype.updateStyleNames = function (type, name) {
            var localValue = new ej2_base_1.L10n('documenteditor', this.documentHelper.owner.defaultLocale);
            localValue.setLocale(this.documentHelper.owner.locale);
            var styles = this.documentHelper.styles.getStyleNames(type);
            var finalList = [];
            for (var i = 0; i < styles.length; i++) {
                var styleName = localValue.getConstant(styles[parseInt(i.toString(), 10)]);
                if (styleName === '') {
                    styleName = styles[parseInt(i.toString(), 10)];
                }
                finalList.push(styleName);
            }
            this.styleParagraph.dataSource = finalList;
            this.styleParagraph.index = null;
            if (name) {
                this.styleBasedOn.dataSource = finalList.filter(function (e) { return e !== name; });
                this.styleBasedOn.index = null;
                var style = this.getStyle(name);
                Iif (style.basedOn instanceof String || ej2_base_1.isNullOrUndefined(style.basedOn)) {
                    this.styleBasedOn.enabled = false;
                }
                else {
                    this.styleBasedOn.index = styles.indexOf(style.basedOn.name) > -1 ? styles.indexOf(style.basedOn.name) : 0;
                }
                Eif (style.type === 'Paragraph') {
                    Eif (!ej2_base_1.isNullOrUndefined(style.link)) {
                        this.styleType.index = 2;
                    }
                    else {
                        this.styleType.index = 0;
                    }
                }
                else {
                    this.styleType.index = 1;
                }
                Eif (!ej2_base_1.isNullOrUndefined(style.next)) {
                    var nxtName = style.next.name;
                    var index = 0;
                    Eif (styles.indexOf(nxtName) > -1) {
                        index = styles.indexOf(nxtName);
                    }
                    this.styleParagraph.index = index;
                    this.isUserNextParaUpdated = (nxtName === name) ? false : true;
                }
            }
            else {
                this.styleBasedOn.dataSource = finalList;
                this.styleBasedOn.index = null;
                var basedOnIndex = 0;
                Eif (this.documentHelper.owner.selectionModule) {
                    var styleName = void 0;
                    if (type === 'Character') {
                        styleName = this.documentHelper.owner.selectionModule.characterFormat.styleName;
                    }
                    else {
                        styleName = this.documentHelper.owner.selectionModule.paragraphFormat.styleName;
                    }
                    basedOnIndex = styles.indexOf(styleName);
                }
                this.styleBasedOn.index = basedOnIndex;
                this.styleParagraph.index = 0;
            }
            if (this.isEdit) {
                this.styleType.enabled = false;
            }
            else {
                this.styleType.enabled = true;
            }
        };
        StyleDialog.prototype.getStyle = function (styleName) {
            Iif (ej2_base_1.isNullOrUndefined(this.documentHelper.styles.findByName(styleName))) {
                this.documentHelper.owner.editorModule.createStyle(this.documentHelper.preDefinedStyles.get(styleName));
            }
            return this.documentHelper.styles.findByName(styleName);
        };
        StyleDialog.prototype.destroy = function () {
            if (!ej2_base_1.isNullOrUndefined(this.target)) {
                if (this.target.parentElement) {
                    this.target.parentElement.removeChild(this.target);
                }
                for (var n = 0; n < this.target.childNodes.length; n++) {
                    this.target.removeChild(this.target.childNodes[n]);
                    n--;
                }
                this.target = undefined;
            }
            if (this.characterFormat) {
                this.characterFormat.destroy();
                this.characterFormat = undefined;
            }
            if (this.paragraphFormat) {
                this.paragraphFormat.destroy();
                this.paragraphFormat = undefined;
            }
            if (this.fontColor) {
                this.fontColor.destroy();
                this.fontColor = undefined;
            }
            if (this.fontSize) {
                this.fontSize.destroy();
                this.fontSize = undefined;
            }
            if (this.fontFamily) {
                this.fontFamily.destroy();
                this.fontFamily = undefined;
            }
            if (this.styleType) {
                this.styleType.destroy();
                this.styleType = undefined;
            }
            if (this.styleBasedOn) {
                this.styleBasedOn.destroy();
                this.styleBasedOn = undefined;
            }
            if (this.styleParagraph) {
                this.styleParagraph.destroy();
                this.styleParagraph = undefined;
            }
            Iif (this.onlyThisDocument) {
                this.onlyThisDocument.destroy();
            }
            this.onlyThisDocument = undefined;
            Iif (this.template) {
                this.template.destroy();
                this.template = undefined;
            }
            if (this.style) {
                this.style.destroy();
                this.style = undefined;
            }
            if (this.abstractList) {
                this.abstractList.destroy();
                this.abstractList = undefined;
            }
            if (this.numberingBulletDialog) {
                this.numberingBulletDialog.destroy();
                this.numberingBulletDialog = undefined;
            }
            if (this.styleDropdwn) {
                this.styleDropdwn.destroy();
                this.styleDropdwn = undefined;
            }
            if (this.textAlignment) {
                this.textAlignment = undefined;
            }
            if (this.lineSpacing) {
                this.lineSpacing = undefined;
            }
            Iif (this.leftIndent) {
                this.leftIndent = undefined;
            }
            Iif (this.beforeSpacing) {
                this.beforeSpacing = undefined;
            }
            Iif (this.afterSpacing) {
                this.afterSpacing = undefined;
            }
            this.removeEvents();
            this.removeElements();
            this.documentHelper = undefined;
        };
        StyleDialog.prototype.removeEvents = function () {
            if (this.nameValue) {
                this.nameValue.removeEventListener('input', this.updateOkButtonClickHandler);
                this.nameValue.removeEventListener('keyup', this.updateOkButtonClickHandler);
                this.nameValue.removeEventListener('blur', this.updateNextStyleHandler);
            }
            Iif (this.styleDropdwn) {
                this.styleDropdwn.removeEventListener('select', this.openDialogHandler);
            }
            if (this.bold) {
                this.bold.removeEventListener('click', this.setBoldPropertyHandler);
            }
            if (this.italic) {
                this.italic.removeEventListener('click', this.setItalicPropertyHandler);
            }
            if (this.underline) {
                this.underline.removeEventListener('click', this.setUnderlinePropertyHandler);
            }
            if (this.leftAlign) {
                this.leftAlign.removeEventListener('click', this.setLeftAlignmentClickHandler);
            }
            if (this.centerAlign) {
                this.centerAlign.removeEventListener('click', this.setCenterAlignmentClickHandler);
            }
            if (this.rightAlign) {
                this.rightAlign.removeEventListener('click', this.setRightAlignmentClickHandler);
            }
            if (this.justify) {
                this.justify.removeEventListener('click', this.setJustifyAlignmentClickHandler);
            }
            if (this.singleLineSpacing) {
                this.singleLineSpacing.removeEventListener('click', this.setSingleLineSpacingClickHandler);
            }
            if (this.onePointFiveLineSpacing) {
                this.onePointFiveLineSpacing.removeEventListener('click', this.setOnePointFiveLineSpacingClickHandler);
            }
            if (this.doubleLineSpacing) {
                this.doubleLineSpacing.removeEventListener('click', this.setDoubleLineSpacingClickHandler);
            }
            if (this.beforeSpacingEle) {
                this.beforeSpacingEle.removeEventListener('click', this.increaseBeforeAfterSpacingValueHandler);
            }
            if (this.afterSpacingEle) {
                this.afterSpacingEle.removeEventListener('click', this.decreaseBeforeAfterSpacingValueHandler);
            }
            if (this.decreaseIndent) {
                this.decreaseIndent.removeEventListener('click', this.decreaseIndentValueHandler);
            }
            if (this.increaseindent) {
                this.increaseindent.removeEventListener('click', this.increaseIndentValueHandler);
            }
        };
        StyleDialog.prototype.removeElements = function () {
            if (this.container) {
                this.container.remove();
                this.container = undefined;
            }
            if (this.properties) {
                this.properties.remove();
                this.properties = undefined;
            }
            if (this.styleNameTypeDiv) {
                this.styleNameTypeDiv.remove();
                this.styleNameTypeDiv = undefined;
            }
            if (this.nameWholeDiv) {
                this.nameWholeDiv.remove();
                this.nameWholeDiv = undefined;
            }
            if (this.nameValue) {
                this.nameValue.remove();
                this.nameValue = undefined;
            }
            if (this.styleTypeWholeDiv) {
                this.styleTypeWholeDiv.remove();
                this.styleTypeWholeDiv = undefined;
            }
            if (this.styleTypeDivElement) {
                this.styleTypeDivElement.remove();
                this.styleTypeDivElement = undefined;
            }
            if (this.styleTypeValue) {
                this.styleTypeValue.remove();
                this.styleTypeValue = undefined;
            }
            if (this.styleBasedParaDiv) {
                this.styleBasedParaDiv.remove();
                this.styleBasedParaDiv = undefined;
            }
            if (this.styleBasedOnWholeDiv) {
                this.styleBasedOnWholeDiv.remove();
                this.styleBasedOnWholeDiv = undefined;
            }
            if (this.styleBasedOnDivElement) {
                this.styleBasedOnDivElement.remove();
                this.styleBasedOnDivElement = undefined;
            }
            if (this.styleBasedOnValue) {
                this.styleBasedOnValue.remove();
                this.styleBasedOnValue = undefined;
            }
            if (this.styleParagraphWholeDiv) {
                this.styleParagraphWholeDiv.remove();
                this.styleParagraphWholeDiv = undefined;
            }
            if (this.styleParagraphDivElement) {
                this.styleParagraphDivElement.remove();
                this.styleParagraphDivElement = undefined;
            }
            if (this.styleParagraphValue) {
                this.styleParagraphValue.remove();
                this.styleParagraphValue = undefined;
            }
            if (this.formatting) {
                this.formatting.remove();
                this.formatting = undefined;
            }
            if (this.optionsDiv) {
                this.optionsDiv.remove();
                this.optionsDiv = undefined;
            }
            if (this.fontOptionsDiv) {
                this.fontOptionsDiv.remove();
                this.fontOptionsDiv = undefined;
            }
            if (this.paragraphOptionsDiv) {
                this.paragraphOptionsDiv.remove();
                this.paragraphOptionsDiv = undefined;
            }
            if (this.formatBtn) {
                this.formatBtn.remove();
                this.formatBtn = undefined;
            }
            if (this.fontFamilyElement) {
                this.fontFamilyElement.remove();
                this.fontFamilyElement = undefined;
            }
            if (this.fontSizeElement) {
                this.fontSizeElement.remove();
                this.fontSizeElement = undefined;
            }
            if (this.fontGroupButton) {
                this.fontGroupButton.remove();
                this.fontGroupButton = undefined;
            }
            if (this.fontColorElement) {
                this.fontColorElement.remove();
                this.fontColorElement = undefined;
            }
            if (this.alignmentDiv) {
                this.alignmentDiv.remove();
                this.alignmentDiv = undefined;
            }
            if (this.lineSpacingDiv) {
                this.lineSpacingDiv.remove();
                this.lineSpacingDiv = undefined;
            }
            if (this.spacingDiv) {
                this.spacingDiv.remove();
                this.spacingDiv = undefined;
            }
            if (this.beforeSpacingEle) {
                this.beforeSpacingEle.remove();
                this.beforeSpacingEle = undefined;
            }
            if (this.afterSpacingEle) {
                this.afterSpacingEle.remove();
                this.afterSpacingEle = undefined;
            }
            if (this.indentingDiv) {
                this.indentingDiv.remove();
                this.indentingDiv = undefined;
            }
            if (this.decreaseIndent) {
                this.decreaseIndent.remove();
                this.decreaseIndent = undefined;
            }
            if (this.increaseindent) {
                this.increaseindent.remove();
                this.increaseindent = undefined;
            }
        };
        return StyleDialog;
    }());
    exports.StyleDialog = StyleDialog;
});