source: node_modules/autolinker/dist/es2015/match/phone-match.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

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