all files / document-editor/implementation/format/ shading.js

100% Statements 79/79
96.55% Branches 28/29
100% Functions 19/19
100% Lines 79/79
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   14068× 14068× 14068×     27744×     396×           817×     294×           1259×     413×         29820× 29820× 3947× 3947× 3947×     25873×   1103×   1103× 454×     649× 649×   545×   104×     26784× 26784×   25847× 25847×   498× 498×   439× 439×   26784×   454× 454× 454× 454× 454×   1362× 1362× 454×     908×     2096× 297×   2096×   24× 24× 24× 24× 24×   2307× 98× 98× 98×     41786× 6068× 6068×   35718×          
define(["require", "exports", "@syncfusion/ej2-base", "../../base/unique-format", "../../base/unique-formats", "../../base/dictionary"], function (require, exports, ej2_base_1, unique_format_1, unique_formats_1, dictionary_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var WShading = (function () {
        function WShading(node) {
            this.uniqueShadingFormat = undefined;
            this.ownerBase = undefined;
            this.ownerBase = node;
        }
        Object.defineProperty(WShading.prototype, "backgroundColor", {
            get: function () {
                return this.getPropertyValue('backgroundColor');
            },
            set: function (value) {
                this.setPropertyValue('backgroundColor', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WShading.prototype, "foregroundColor", {
            get: function () {
                return this.getPropertyValue('foregroundColor');
            },
            set: function (value) {
                this.setPropertyValue('foregroundColor', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WShading.prototype, "textureStyle", {
            get: function () {
                return this.getPropertyValue('textureStyle');
            },
            set: function (value) {
                this.setPropertyValue('textureStyle', value);
            },
            enumerable: true,
            configurable: true
        });
        WShading.prototype.getPropertyValue = function (property) {
            var hasValue = this.hasValue(property);
            if (hasValue) {
                var propertyType = unique_format_1.WUniqueFormat.getPropertyType(WShading.uniqueFormatType, property);
                Eif (!ej2_base_1.isNullOrUndefined(this.uniqueShadingFormat) && this.uniqueShadingFormat.propertiesHash.containsKey(propertyType)) {
                    return this.uniqueShadingFormat.propertiesHash.get(propertyType);
                }
            }
            return WShading.getPropertyDefaultValue(property);
        };
        WShading.prototype.setPropertyValue = function (property, value) {
            if (ej2_base_1.isNullOrUndefined(value) || value === '') {
                value = WShading.getPropertyDefaultValue(property);
            }
            if (ej2_base_1.isNullOrUndefined(this.uniqueShadingFormat)) {
                this.initializeUniqueShading(property, value);
            }
            else {
                var propertyType = unique_format_1.WUniqueFormat.getPropertyType(this.uniqueShadingFormat.uniqueFormatType, property);
                if (this.uniqueShadingFormat.propertiesHash.containsKey(propertyType) &&
                    this.uniqueShadingFormat.propertiesHash.get(propertyType) === value) {
                    return;
                }
                this.uniqueShadingFormat = WShading.uniqueShadingFormats.updateUniqueFormat(this.uniqueShadingFormat, property, value);
            }
        };
        WShading.getPropertyDefaultValue = function (property) {
            var value = undefined;
            switch (property) {
                case 'backgroundColor':
                    value = 'empty';
                    break;
                case 'foregroundColor':
                    value = 'empty';
                    break;
                case 'textureStyle':
                    value = 'TextureNone';
                    break;
            }
            return value;
        };
        WShading.prototype.initializeUniqueShading = function (property, propValue) {
            var uniqueShadingTemp = new dictionary_1.Dictionary();
            this.addUniqueShading('backgroundColor', property, propValue, uniqueShadingTemp);
            this.addUniqueShading('foregroundColor', property, propValue, uniqueShadingTemp);
            this.addUniqueShading('textureStyle', property, propValue, uniqueShadingTemp);
            this.uniqueShadingFormat = WShading.uniqueShadingFormats.addUniqueFormat(uniqueShadingTemp, WShading.uniqueFormatType);
        };
        WShading.prototype.addUniqueShading = function (property, modifiedProperty, propValue, uniqueShadingTemp) {
            var propertyType = unique_format_1.WUniqueFormat.getPropertyType(WShading.uniqueFormatType, property);
            if (property === modifiedProperty) {
                uniqueShadingTemp.add(propertyType, propValue);
            }
            else {
                uniqueShadingTemp.add(propertyType, WShading.getPropertyDefaultValue(property));
            }
        };
        WShading.prototype.destroy = function () {
            if (!ej2_base_1.isNullOrUndefined(this.uniqueShadingFormat)) {
                WShading.uniqueShadingFormats.remove(this.uniqueShadingFormat);
            }
            this.uniqueShadingFormat = undefined;
        };
        WShading.prototype.cloneFormat = function () {
            var shading = new WShading(undefined);
            shading.backgroundColor = this.backgroundColor;
            shading.foregroundColor = this.foregroundColor;
            shading.textureStyle = this.textureStyle;
            return shading;
        };
        WShading.prototype.copyFormat = function (shading) {
            if (!ej2_base_1.isNullOrUndefined(shading) && !ej2_base_1.isNullOrUndefined(shading.uniqueShadingFormat)) {
                this.backgroundColor = shading.backgroundColor;
                this.foregroundColor = shading.foregroundColor;
                this.textureStyle = shading.textureStyle;
            }
        };
        WShading.prototype.hasValue = function (property) {
            if (!ej2_base_1.isNullOrUndefined(this.uniqueShadingFormat)) {
                var propertyType = unique_format_1.WUniqueFormat.getPropertyType(this.uniqueShadingFormat.uniqueFormatType, property);
                return this.uniqueShadingFormat.propertiesHash.containsKey(propertyType);
            }
            return false;
        };
        WShading.clear = function () {
            this.uniqueShadingFormats.clear();
        };
        WShading.uniqueShadingFormats = new unique_formats_1.WUniqueFormats();
        WShading.uniqueFormatType = 5;
        return WShading;
    }());
    exports.WShading = WShading;
});