/*global Autolinker */ /** * @abstract * @class Autolinker.match.Match * * Represents a match found in an input string which should be Autolinked. A Match object is what is provided in a * {@link Autolinker#replaceFn replaceFn}, and may be used to query for details about the match. * * For example: * * var input = "..."; // string with URLs, Email Addresses, and Twitter Handles * * var linkedText = Autolinker.link( input, { * replaceFn : function( autolinker, match ) { * console.log( "href = ", match.getAnchorHref() ); * console.log( "text = ", match.getAnchorText() ); * * switch( match.getType() ) { * case 'url' : * console.log( "url: ", match.getUrl() ); * * case 'email' : * console.log( "email: ", match.getEmail() ); * * case 'twitter' : * console.log( "twitter: ", match.getTwitterHandle() ); * } * } * } ); * * See the {@link Autolinker} class for more details on using the {@link Autolinker#replaceFn replaceFn}. */ Autolinker.match.Match = Autolinker.Util.extend( Object, { /** * @cfg {String} matchedText (required) * * The original text that was matched. */ /** * @constructor * @param {Object} cfg The configuration properties for the Match instance, specified in an Object (map). */ constructor : function( cfg ) { Autolinker.Util.assign( this, cfg ); }, /** * Returns a string name for the type of match that this class represents. * * @abstract * @return {String} */ getType : Autolinker.Util.abstractMethod, /** * Returns the original text that was matched. * * @return {String} */ getMatchedText : function() { return this.matchedText; }, /** * Returns the anchor href that should be generated for the match. * * @abstract * @return {String} */ getAnchorHref : Autolinker.Util.abstractMethod, /** * Returns the anchor text that should be generated for the match. * * @abstract * @return {String} */ getAnchorText : Autolinker.Util.abstractMethod } );