Skip to content

Commit 8f509f2

Browse files
committed
Update a few doc comments and variable names on Autolinker and AnchorTagBuilder.
1 parent dc8d4b0 commit 8f509f2

File tree

4 files changed

+59
-87
lines changed

4 files changed

+59
-87
lines changed

dist/Autolinker.js

Lines changed: 29 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@
9191
/**
9292
* @cfg {Boolean} stripPrefix
9393
*
94-
* `true` if 'http://' or 'https://' and/or the 'www.' should be stripped from the beginning of links, `false` otherwise.
94+
* `true` if 'http://' or 'https://' and/or the 'www.' should be stripped from the beginning of URL links' text,
95+
* `false` otherwise.
9596
*/
9697
stripPrefix : true,
9798

@@ -100,10 +101,10 @@
100101
*
101102
* A number for how many characters long URLs/emails/twitter handles should be truncated to inside the text of
102103
* a link. If the URL/email/twitter is over this number of characters, it will be truncated to this length by
103-
* adding a two period ellipsis ('..') into the middle of the string.
104+
* adding a two period ellipsis ('..') to the end of the string.
104105
*
105106
* For example: A url like 'http://www.yahoo.com/some/long/path/to/a/file' truncated to 25 characters might look
106-
* something like this: 'http://www...th/to/a/file'
107+
* something like this: 'yahoo.com/some/long/pat..'
107108
*/
108109

109110
/**
@@ -591,55 +592,31 @@
591592
* @extends Object
592593
*
593594
* Builds the anchor (<a>) tags for the Autolinker utility when a match is found.
594-
*
595-
* @constructor
596-
* @param {Object} [config] The configuration options for the AnchorTagBuilder instance, specified in an Object (map).
597595
*/
598-
Autolinker.AnchorTagBuilder = function( cfg ) {
599-
// Assign the properties of `cfg` onto the Autolinker instance
600-
for( var prop in cfg )
601-
if( cfg.hasOwnProperty( prop ) ) this[ prop ] = cfg[ prop ];
602-
};
603-
604-
605-
Autolinker.AnchorTagBuilder.prototype = {
606-
constructor : Autolinker.AnchorTagBuilder,
607-
596+
Autolinker.AnchorTagBuilder = Autolinker.Util.extend( Object, {
608597

609598
/**
610599
* @cfg {Boolean} newWindow
611600
*
612-
* `true` if the links should open in a new window, `false` otherwise.
601+
* See {@link Autolinker#newWindow} for details.
613602
*/
614603

615604
/**
616605
* @cfg {Boolean} stripPrefix
617606
*
618-
* `true` if 'http://' or 'https://' and/or the 'www.' should be stripped from the beginning of links, `false` otherwise.
607+
* See {@link Autolinker#stripPrefix} for details.
619608
*/
620609

621610
/**
622611
* @cfg {Number} truncate
623612
*
624-
* A number for how many characters long URLs/emails/twitter handles should be truncated to inside the text of
625-
* a link. If the URL/email/twitter is over this number of characters, it will be truncated to this length by
626-
* adding a two period ellipsis ('..') into the middle of the string.
627-
*
628-
* For example: A url like 'http://www.yahoo.com/some/long/path/to/a/file' truncated to 25 characters might look
629-
* something like this: 'http://www...th/to/a/file'
613+
* See {@link Autolinker#truncate} for details.
630614
*/
631615

632616
/**
633617
* @cfg {String} className
634618
*
635-
* A CSS class name to add to the generated links. This class will be added to all links, as well as this class
636-
* plus url/email/twitter suffixes for styling url/email/twitter links differently.
637-
*
638-
* For example, if this config is provided as "myLink", then:
639-
*
640-
* 1) URL links will have the CSS classes: "myLink myLink-url"
641-
* 2) Email links will have the CSS classes: "myLink myLink-email", and
642-
* 3) Twitter links will have the CSS classes: "myLink myLink-twitter"
619+
* See {@link Autolinker#className} for details.
643620
*/
644621

645622

@@ -652,16 +629,25 @@
652629
urlPrefixRegex: /^(https?:\/\/)?(www\.)?/i,
653630

654631

632+
/**
633+
* @constructor
634+
* @param {Object} [cfg] The configuration options for the AnchorTagBuilder instance, specified in an Object (map).
635+
*/
636+
constructor : function( cfg ) {
637+
Autolinker.Util.assign( this, cfg );
638+
},
639+
640+
655641
/**
656642
* Generates the actual anchor (<a>) tag to use in place of a source url/email/twitter link.
657643
*
658-
* @param {"url"/"email"/"twitter"} linkType The type of link that an anchor tag is being generated for.
644+
* @param {"url"/"email"/"twitter"} matchType The type of match that an anchor tag is being generated for.
659645
* @param {String} anchorHref The href for the anchor tag.
660646
* @param {String} anchorText The anchor tag's text (i.e. what will be displayed).
661647
* @return {String} The full HTML for the anchor tag.
662648
*/
663-
createAnchorTag : function( linkType, anchorHref, anchorText ) {
664-
var attributesStr = this.createAnchorAttrsStr( linkType, anchorHref );
649+
createAnchorTag : function( matchType, anchorHref, anchorText ) {
650+
var attributesStr = this.createAnchorAttrsStr( matchType, anchorHref );
665651
anchorText = this.processAnchorText( anchorText );
666652

667653
return '<a ' + attributesStr + '>' + anchorText + '</a>';
@@ -672,14 +658,14 @@
672658
* Creates the string which will be the HTML attributes for the anchor (&lt;a&gt;) tag being generated.
673659
*
674660
* @private
675-
* @param {"url"/"email"/"twitter"} linkType The type of link that an anchor tag is being generated for.
661+
* @param {"url"/"email"/"twitter"} matchType The type of match that an anchor tag is being generated for.
676662
* @param {String} href The href for the anchor tag.
677663
* @return {String} The anchor tag's attribute. Ex: `href="http://google.com" class="myLink myLink-url" target="_blank"`
678664
*/
679-
createAnchorAttrsStr : function( linkType, anchorHref ) {
665+
createAnchorAttrsStr : function( matchType, anchorHref ) {
680666
var attrs = [ 'href="' + anchorHref + '"' ]; // we'll always have the `href` attribute
681667

682-
var cssClass = this.createCssClass( linkType );
668+
var cssClass = this.createCssClass( matchType );
683669
if( cssClass ) {
684670
attrs.push( 'class="' + cssClass + '"' );
685671
}
@@ -692,21 +678,21 @@
692678

693679

694680
/**
695-
* Creates the CSS class that will be used for a given anchor tag, based on the `linkType` and the {@link #className}
681+
* Creates the CSS class that will be used for a given anchor tag, based on the `matchType` and the {@link #className}
696682
* config.
697683
*
698684
* @private
699-
* @param {"url"/"email"/"twitter"} linkType The type of link that an anchor tag is being generated for.
685+
* @param {"url"/"email"/"twitter"} matchType The type of match that an anchor tag is being generated for.
700686
* @return {String} The CSS class string for the link. Example return: "myLink myLink-url". If no {@link #className}
701687
* was configured, returns an empty string.
702688
*/
703-
createCssClass : function( linkType ) {
689+
createCssClass : function( matchType ) {
704690
var className = this.className;
705691

706692
if( !className )
707693
return "";
708694
else
709-
return className + " " + className + "-" + linkType; // ex: "myLink myLink-url", "myLink myLink-email", or "myLink myLink-twitter"
695+
return className + " " + className + "-" + matchType; // ex: "myLink myLink-url", "myLink myLink-email", or "myLink myLink-twitter"
710696
},
711697

712698

@@ -776,7 +762,7 @@
776762
return anchorText;
777763
}
778764

779-
};
765+
} );
780766
/**
781767
* @private
782768
* @abstract

0 commit comments

Comments
 (0)