all files / document/automatic-fields/ composite-field.js

100% Statements 45/45
88.89% Branches 16/18
100% Functions 14/14
100% Lines 42/42
11 statements, 6 functions, 9 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                20×               160×             20× 20× 20× 20× 40× 40×     20×        
/* 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 __());
    };
})();
define(["require", "exports", "./multiple-value-field"], function (require, exports, multiple_value_field_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var PdfCompositeField = (function (_super) {
        __extends(PdfCompositeField, _super);
        function PdfCompositeField(font, brush, text) {
            var list = [];
            for (var _i = 3; _i < arguments.length; _i++) {
                list[_i - 3] = arguments[_i];
            }
            var _this = _super.call(this) || this;
            _this.internalAutomaticFields = null;
            _this.internalText = '';
            _this.font = font;
            _this.brush = brush;
            _this.text = text;
            _this.automaticFields = list;
            return _this;
        }
        Object.defineProperty(PdfCompositeField.prototype, "text", {
            get: function () {
                return this.internalText;
            },
            set: function (value) {
                this.internalText = value;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PdfCompositeField.prototype, "automaticFields", {
            get: function () {
                return this.internalAutomaticFields;
            },
            set: function (value) {
                this.internalAutomaticFields = value;
            },
            enumerable: true,
            configurable: true
        });
        PdfCompositeField.prototype.getValue = function (graphics) {
            var values = [];
            var text = this.text.toString();
            Eif (typeof this.automaticFields !== 'undefined' && this.automaticFields != null && this.automaticFields.length > 0) {
                for (var i = 0; i < this.automaticFields.length; i++) {
                    var automaticField = this.automaticFields[i];
                    text = text.replace('{' + i + '}', automaticField.getValue(graphics));
                }
            }
            return text;
        };
        return PdfCompositeField;
    }(multiple_value_field_1.PdfMultipleValueField));
    exports.PdfCompositeField = PdfCompositeField;
});