all files / signature/ signature.js

100% Statements 85/85
90.74% Branches 49/54
100% Functions 16/16
100% Lines 79/79
5 statements, 2 functions, 11 branches Ignored     
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    19× 19× 19×       279× 279× 279× 279×                                                 57×                   57×   57× 57× 57× 57× 57×                 481×                               11× 11× 11×                                                                                                      
/* istanbul ignore next */ 
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
/* istanbul ignore next */ 
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    Iif (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) Eif (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-base", "../common/signature-base"], function (require, exports, ej2_base_1, ej2_base_2, signature_base_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    /**
     * The Signature component allows user to draw smooth signatures as vector outline of strokes using variable width bezier curve interpolation.
     * It allows to save signature as image.
     * You can use your finger, pen, or mouse on a tablet, touchscreen, etc., to draw your own signature on this Signature component.
     * Signature component is a user interface to draw the Signature or Text.
     * It provides supports for various Background color, Stroke color and Background Image.
     * ```html
     * <canvas id="signature"></canvas>
     * ```
     * ```typescript
     * <script>
     *   let signatureObj: Signature = new Signature(null , "#signature");
     * </script>
     * ```
     */
    var Signature = /** @class */ (function (_super) {
        __extends(Signature, _super);
        /**
         * Constructor for creating the widget.
         *
         * @param {SignatureModel} options - Specifies the Signature model.
         * @param {string | HTMLCanvasElement} element - Specifies the element.
         * @private
         */
        function Signature(options, element) {
            return _super.call(this, options, element) || this;
        }
        Signature.prototype.preRender = function () {
            // pre render code snippets
        };
        /**
         * To Initialize the component rendering
         *
         * @private
         * @returns {void}
         */
        Signature.prototype.render = function () {
            this.initialize();
        };
        Signature.prototype.initialize = function () {
            this.element.setAttribute('role', 'img');
            this.element.setAttribute('aria-label', 'signature');
            ej2_base_2.addClass([this.element], 'e-' + this.getModuleName());
            _super.prototype.initialize.call(this, this.element);
            if (this.enablePersistence) {
                this.loadPersistedSignature();
            }
        };
        /**
         * To get component name.
         *
         * @returns {string} - Module Name
         * @private
         */
        Signature.prototype.getModuleName = function () {
            return _super.prototype.getModuleName.call(this);
        };
        /**
         * To get the properties to be maintained in the persisted state.
         *
         * @returns {string} - Persist data
         */
        Signature.prototype.getPersistData = function () {
            return _super.prototype.getPersistData.call(this);
        };
        /**
         * Called internally if any of the property value changed.
         *
         * @param  {SignatureModel} newProp - Specifies new properties
         * @param  {SignatureModel} oldProp - Specifies old properties
         * @returns {void}
         * @private
         */
        Signature.prototype.onPropertyChanged = function (newProp, oldProp) {
            for (var _i = 0, _a = Object.keys(newProp); _i < _a.length; _i++) {
                var prop = _a[_i];
                switch (prop) {
                    case 'backgroundColor':
                        _super.prototype.propertyChanged.call(this, prop, newProp.backgroundColor);
                        break;
                    case 'backgroundImage':
                        _super.prototype.propertyChanged.call(this, prop, newProp.backgroundImage);
                        break;
                    case 'strokeColor':
                        Eif (newProp.strokeColor !== oldProp.strokeColor) {
                            _super.prototype.propertyChanged.call(this, prop, newProp.strokeColor);
                        }
                        break;
                    case 'maxStrokeWidth':
                        Eif (newProp.maxStrokeWidth !== oldProp.maxStrokeWidth) {
                            _super.prototype.propertyChanged.call(this, prop, newProp.maxStrokeWidth);
                        }
                        break;
                    case 'minStrokeWidth':
                        Eif (newProp.minStrokeWidth !== oldProp.minStrokeWidth) {
                            _super.prototype.propertyChanged.call(this, prop, newProp.minStrokeWidth);
                        }
                        break;
                    case 'velocity':
                        Eif (newProp.velocity !== oldProp.velocity) {
                            _super.prototype.propertyChanged.call(this, prop, newProp.velocity);
                        }
                        break;
                    case 'saveWithBackground':
                        _super.prototype.propertyChanged.call(this, prop, newProp.saveWithBackground);
                        break;
                    case 'isReadOnly':
                        _super.prototype.propertyChanged.call(this, prop, newProp.isReadOnly);
                        break;
                    case 'disabled':
                        _super.prototype.propertyChanged.call(this, prop, newProp.disabled);
                        break;
                }
            }
        };
        __decorate([
            ej2_base_2.Property('')
        ], Signature.prototype, "backgroundColor", void 0);
        __decorate([
            ej2_base_2.Property('')
        ], Signature.prototype, "backgroundImage", void 0);
        __decorate([
            ej2_base_2.Property(false)
        ], Signature.prototype, "disabled", void 0);
        __decorate([
            ej2_base_2.Property(false)
        ], Signature.prototype, "isReadOnly", void 0);
        __decorate([
            ej2_base_2.Property(true)
        ], Signature.prototype, "saveWithBackground", void 0);
        __decorate([
            ej2_base_2.Property('#000000')
        ], Signature.prototype, "strokeColor", void 0);
        __decorate([
            ej2_base_2.Property(0.5)
        ], Signature.prototype, "minStrokeWidth", void 0);
        __decorate([
            ej2_base_2.Property(2)
        ], Signature.prototype, "maxStrokeWidth", void 0);
        __decorate([
            ej2_base_2.Property(0.7)
        ], Signature.prototype, "velocity", void 0);
        __decorate([
            ej2_base_2.Property('en-US')
        ], Signature.prototype, "locale", void 0);
        __decorate([
            ej2_base_2.Property(false)
        ], Signature.prototype, "enableRtl", void 0);
        __decorate([
            ej2_base_2.Property(false)
        ], Signature.prototype, "enablePersistence", void 0);
        __decorate([
            ej2_base_1.Event()
        ], Signature.prototype, "beforeSave", void 0);
        __decorate([
            ej2_base_1.Event()
        ], Signature.prototype, "change", void 0);
        __decorate([
            ej2_base_1.Event()
        ], Signature.prototype, "created", void 0);
        Signature = __decorate([
            ej2_base_2.NotifyPropertyChanges
        ], Signature);
        return Signature;
    }(signature_base_1.SignatureBase));
    exports.Signature = Signature;
});