[d24f17c] | 1 | "use strict";
|
---|
| 2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
| 3 | exports.PhoneMatch = void 0;
|
---|
| 4 | var tslib_1 = require("tslib");
|
---|
| 5 | var match_1 = require("./match");
|
---|
| 6 | /**
|
---|
| 7 | * @class Autolinker.match.Phone
|
---|
| 8 | * @extends Autolinker.match.Match
|
---|
| 9 | *
|
---|
| 10 | * Represents a Phone number match found in an input string which should be
|
---|
| 11 | * Autolinked.
|
---|
| 12 | *
|
---|
| 13 | * See this class's superclass ({@link Autolinker.match.Match}) for more
|
---|
| 14 | * details.
|
---|
| 15 | */
|
---|
| 16 | var PhoneMatch = /** @class */ (function (_super) {
|
---|
| 17 | (0, tslib_1.__extends)(PhoneMatch, _super);
|
---|
| 18 | /**
|
---|
| 19 | * @method constructor
|
---|
| 20 | * @param {Object} cfg The configuration properties for the Match
|
---|
| 21 | * instance, specified in an Object (map).
|
---|
| 22 | */
|
---|
| 23 | function PhoneMatch(cfg) {
|
---|
| 24 | var _this = _super.call(this, cfg) || this;
|
---|
| 25 | /**
|
---|
| 26 | * @protected
|
---|
| 27 | * @property {String} number (required)
|
---|
| 28 | *
|
---|
| 29 | * The phone number that was matched, without any delimiter characters.
|
---|
| 30 | *
|
---|
| 31 | * Note: This is a string to allow for prefixed 0's.
|
---|
| 32 | */
|
---|
| 33 | _this.number = ''; // default value just to get the above doc comment in the ES5 output and documentation generator
|
---|
| 34 | /**
|
---|
| 35 | * @protected
|
---|
| 36 | * @property {Boolean} plusSign (required)
|
---|
| 37 | *
|
---|
| 38 | * `true` if the matched phone number started with a '+' sign. We'll include
|
---|
| 39 | * it in the `tel:` URL if so, as this is needed for international numbers.
|
---|
| 40 | *
|
---|
| 41 | * Ex: '+1 (123) 456 7879'
|
---|
| 42 | */
|
---|
| 43 | _this.plusSign = false; // default value just to get the above doc comment in the ES5 output and documentation generator
|
---|
| 44 | _this.number = cfg.number;
|
---|
| 45 | _this.plusSign = cfg.plusSign;
|
---|
| 46 | return _this;
|
---|
| 47 | }
|
---|
| 48 | /**
|
---|
| 49 | * Returns a string name for the type of match that this class represents.
|
---|
| 50 | * For the case of PhoneMatch, returns 'phone'.
|
---|
| 51 | *
|
---|
| 52 | * @return {String}
|
---|
| 53 | */
|
---|
| 54 | PhoneMatch.prototype.getType = function () {
|
---|
| 55 | return 'phone';
|
---|
| 56 | };
|
---|
| 57 | /**
|
---|
| 58 | * Returns the phone number that was matched as a string, without any
|
---|
| 59 | * delimiter characters.
|
---|
| 60 | *
|
---|
| 61 | * Note: This is a string to allow for prefixed 0's.
|
---|
| 62 | *
|
---|
| 63 | * @return {String}
|
---|
| 64 | */
|
---|
| 65 | PhoneMatch.prototype.getPhoneNumber = function () {
|
---|
| 66 | return this.number;
|
---|
| 67 | };
|
---|
| 68 | /**
|
---|
| 69 | * Alias of {@link #getPhoneNumber}, returns the phone number that was
|
---|
| 70 | * matched as a string, without any delimiter characters.
|
---|
| 71 | *
|
---|
| 72 | * Note: This is a string to allow for prefixed 0's.
|
---|
| 73 | *
|
---|
| 74 | * @return {String}
|
---|
| 75 | */
|
---|
| 76 | PhoneMatch.prototype.getNumber = function () {
|
---|
| 77 | return this.getPhoneNumber();
|
---|
| 78 | };
|
---|
| 79 | /**
|
---|
| 80 | * Returns the anchor href that should be generated for the match.
|
---|
| 81 | *
|
---|
| 82 | * @return {String}
|
---|
| 83 | */
|
---|
| 84 | PhoneMatch.prototype.getAnchorHref = function () {
|
---|
| 85 | return 'tel:' + (this.plusSign ? '+' : '') + this.number;
|
---|
| 86 | };
|
---|
| 87 | /**
|
---|
| 88 | * Returns the anchor text that should be generated for the match.
|
---|
| 89 | *
|
---|
| 90 | * @return {String}
|
---|
| 91 | */
|
---|
| 92 | PhoneMatch.prototype.getAnchorText = function () {
|
---|
| 93 | return this.matchedText;
|
---|
| 94 | };
|
---|
| 95 | return PhoneMatch;
|
---|
| 96 | }(match_1.Match));
|
---|
| 97 | exports.PhoneMatch = PhoneMatch;
|
---|
| 98 | //# sourceMappingURL=phone-match.js.map |
---|