all files / document-editor/implementation/list/ list-level.js

99.15% Statements 116/117
89.74% Branches 35/39
100% Functions 26/26
99.15% Lines 116/117
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   672× 672× 672× 672× 590×     82×   672× 672×     4106×     678×           3630×     615×           1477×     463×           4037×     683×           860×     515×           1184×     435×           1810×     515×         17104× 17104× 17104×       3904× 518×   3904× 660×     3244× 3244×   1783×   1461×     660× 660× 660× 660× 660× 660× 660× 660× 660×   4620× 4620× 4620× 660×     3960×     4478× 4478×   83× 83×   660× 660×   582× 582×     1833× 1833×   660× 660×   660× 660×   4478×   577× 576×   577× 577× 576× 576×   577× 576× 576×               11× 11× 11× 11× 10× 10×   11×        
define(["require", "exports", "../../base/dictionary", "../../base/unique-format", "../../base/unique-formats", "../format/character-format", "../format/paragraph-format", "./abstract-list", "@syncfusion/ej2-base"], function (require, exports, dictionary_1, unique_format_1, unique_formats_1, character_format_1, paragraph_format_1, abstract_list_1, ej2_base_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var WListLevel = (function () {
        function WListLevel(node) {
            this.uniqueListLevel = undefined;
            this.paragraphFormat = undefined;
            this.characterFormat = undefined;
            if (node instanceof abstract_list_1.WAbstractList) {
                this.ownerBase = node;
            }
            else {
                this.ownerBase = node;
            }
            this.characterFormat = new character_format_1.WCharacterFormat(undefined);
            this.paragraphFormat = new paragraph_format_1.WParagraphFormat(undefined);
        }
        Object.defineProperty(WListLevel.prototype, "listLevelPattern", {
            get: function () {
                return this.getPropertyValue('listLevelPattern');
            },
            set: function (listLevelPattern) {
                this.setPropertyValue('listLevelPattern', listLevelPattern);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WListLevel.prototype, "followCharacter", {
            get: function () {
                return this.getPropertyValue('followCharacter');
            },
            set: function (followCharacter) {
                this.setPropertyValue('followCharacter', followCharacter);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WListLevel.prototype, "startAt", {
            get: function () {
                return this.getPropertyValue('startAt');
            },
            set: function (startAt) {
                this.setPropertyValue('startAt', startAt);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WListLevel.prototype, "numberFormat", {
            get: function () {
                return this.getPropertyValue('numberFormat');
            },
            set: function (numberFormat) {
                this.setPropertyValue('numberFormat', numberFormat);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WListLevel.prototype, "paraStyleName", {
            get: function () {
                return this.getPropertyValue('paraStyleName');
            },
            set: function (paraStyleName) {
                this.setPropertyValue('paraStyleName', paraStyleName);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WListLevel.prototype, "restartLevel", {
            get: function () {
                return this.getPropertyValue('restartLevel');
            },
            set: function (restartLevel) {
                this.setPropertyValue('restartLevel', restartLevel);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WListLevel.prototype, "isLegalStyleNumbering", {
            get: function () {
                return this.getPropertyValue('isLegalStyleNumbering');
            },
            set: function (isLegalStyleNumbering) {
                this.setPropertyValue('isLegalStyleNumbering', isLegalStyleNumbering);
            },
            enumerable: true,
            configurable: true
        });
        WListLevel.prototype.getPropertyValue = function (property) {
            var propertyType = unique_format_1.WUniqueFormat.getPropertyType(WListLevel.uniqueFormatType, property);
            Eif (!ej2_base_1.isNullOrUndefined(this.uniqueListLevel) && this.uniqueListLevel.propertiesHash.containsKey(propertyType)) {
                return this.uniqueListLevel.propertiesHash.get(propertyType);
            }
            return WListLevel.getPropertyDefaultValue(property);
        };
        WListLevel.prototype.setPropertyValue = function (property, value) {
            if (ej2_base_1.isNullOrUndefined(value) || value === '') {
                value = WListLevel.getPropertyDefaultValue(property);
            }
            if (ej2_base_1.isNullOrUndefined(this.uniqueListLevel)) {
                this.initializeUniqueWListLevel(property, value);
            }
            else {
                var propertyType = unique_format_1.WUniqueFormat.getPropertyType(this.uniqueListLevel.uniqueFormatType, property);
                if (this.uniqueListLevel.propertiesHash.containsKey(propertyType) &&
                    this.uniqueListLevel.propertiesHash.get(propertyType) === value) {
                    return;
                }
                this.uniqueListLevel = WListLevel.uniqueListLevels.updateUniqueFormat(this.uniqueListLevel, property, value);
            }
        };
        WListLevel.prototype.initializeUniqueWListLevel = function (property, propValue) {
            var uniqueListLevelTemp = new dictionary_1.Dictionary();
            this.addUniqueWListLevel('listLevelPattern', property, propValue, uniqueListLevelTemp);
            this.addUniqueWListLevel('startAt', property, propValue, uniqueListLevelTemp);
            this.addUniqueWListLevel('followCharacter', property, propValue, uniqueListLevelTemp);
            this.addUniqueWListLevel('numberFormat', property, propValue, uniqueListLevelTemp);
            this.addUniqueWListLevel('paraStyleName', property, propValue, uniqueListLevelTemp);
            this.addUniqueWListLevel('restartLevel', property, propValue, uniqueListLevelTemp);
            this.addUniqueWListLevel('isLegalStyleNumbering', property, propValue, uniqueListLevelTemp);
            this.uniqueListLevel = WListLevel.uniqueListLevels.addUniqueFormat(uniqueListLevelTemp, WListLevel.uniqueFormatType);
        };
        WListLevel.prototype.addUniqueWListLevel = function (property, modifiedProperty, propValue, uniqueCharFormatTemp) {
            var propertyType;
            propertyType = unique_format_1.WUniqueFormat.getPropertyType(WListLevel.uniqueFormatType, property);
            if (property === modifiedProperty) {
                uniqueCharFormatTemp.add(propertyType, propValue);
            }
            else {
                uniqueCharFormatTemp.add(propertyType, WListLevel.getPropertyDefaultValue(property));
            }
        };
        WListLevel.getPropertyDefaultValue = function (property) {
            var value = undefined;
            switch (property) {
                case 'listLevelPattern':
                    value = 'Arabic';
                    break;
                case 'startAt':
                    value = 0;
                    break;
                case 'followCharacter':
                    value = 'Tab';
                    break;
                case 'paraStyleName':
                case 'numberFormat':
                    value = '';
                    break;
                case 'restartLevel':
                    value = 0;
                    break;
                case 'isLegalStyleNumbering':
                    value = false;
                    break;
            }
            return value;
        };
        WListLevel.prototype.destroy = function () {
            if (!ej2_base_1.isNullOrUndefined(this.uniqueListLevel)) {
                WListLevel.uniqueListLevels.remove(this.uniqueListLevel);
            }
            this.uniqueListLevel = undefined;
            if (!ej2_base_1.isNullOrUndefined(this.characterFormat)) {
                this.characterFormat.destroy();
                this.characterFormat = undefined;
            }
            if (!ej2_base_1.isNullOrUndefined(this.paragraphFormat)) {
                this.paragraphFormat.destroy();
                this.paragraphFormat = undefined;
            }
        };
        WListLevel.prototype.clearFormat = function () {
            Eif (!ej2_base_1.isNullOrUndefined(this.uniqueListLevel)) {
                WListLevel.uniqueListLevels.remove(this.uniqueListLevel);
            }
            this.uniqueListLevel = undefined;
            Eif (this.characterFormat) {
                this.characterFormat.clearFormat();
            }
            this.characterFormat = undefined;
            Eif (this.paragraphFormat) {
                this.paragraphFormat.clearFormat();
            }
            this.paragraphFormat = undefined;
        };
        WListLevel.clear = function () {
            this.uniqueListLevels.clear();
        };
        WListLevel.prototype.clone = function (node) {
            var listLevel = new WListLevel(node);
            listLevel.paragraphFormat = this.paragraphFormat.cloneFormat();
            listLevel.characterFormat = this.characterFormat.cloneFormat();
            if (this.uniqueListLevel) {
                listLevel.uniqueListLevel = this.uniqueListLevel;
                listLevel.uniqueListLevel.referenceCount++;
            }
            return listLevel;
        };
        WListLevel.dotBullet = String.fromCharCode(61623);
        WListLevel.squareBullet = String.fromCharCode(61607);
        WListLevel.arrowBullet = String.fromCharCode(10148);
        WListLevel.circleBullet = String.fromCharCode(61551) + String.fromCharCode(32);
        WListLevel.uniqueListLevels = new unique_formats_1.WUniqueFormats();
        WListLevel.uniqueFormatType = 9;
        return WListLevel;
    }());
    exports.WListLevel = WListLevel;
});