Debian Codegraph @

src/match/Email.js

raw symbols SCIP
1 /*global Autolinker */
2 /**
3 * @class Autolinker.match.Email
4 * @extends Autolinker.match.Match
5 *
6 * Represents a Email match found in an input string which should be Autolinked.
7 *
8 * See this class's superclass ({@link Autolinker.match.Match}) for more details.
9 */
10 Autolinker.match.Email = Autolinker.Util.extend( Autolinker.match.Match, {
11
12 /**
13 * @cfg {String} email (required)
14 *
15 * The email address that was matched.
16 */
17
18
19 /**
20 * @constructor
21 * @param {Object} cfg The configuration properties for the Match
22 * instance, specified in an Object (map).
23 */
24 constructor : function( cfg ) {
25 Autolinker.match.Match.prototype.constructor.call( this, cfg );
26
27 // @if DEBUG
28 if( !cfg.email ) throw new Error( '`email` cfg required' );
29 // @endif
30
31 this.email = cfg.email;
32 },
33
34
35 /**
36 * Returns a string name for the type of match that this class represents.
37 *
38 * @return {String}
39 */
40 getType : function() {
41 return 'email';
42 },
43
44
45 /**
46 * Returns the email address that was matched.
47 *
48 * @return {String}
49 */
50 getEmail : function() {
51 return this.email;
52 },
53
54
55 /**
56 * Returns the anchor href that should be generated for the match.
57 *
58 * @return {String}
59 */
60 getAnchorHref : function() {
61 return 'mailto:' + this.email;
62 },
63
64
65 /**
66 * Returns the anchor text that should be generated for the match.
67 *
68 * @return {String}
69 */
70 getAnchorText : function() {
71 return this.email;
72 }
73
74 } );