|
91 | 91 | /**
|
92 | 92 | * @cfg {Boolean} stripPrefix
|
93 | 93 | *
|
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. |
95 | 96 | */
|
96 | 97 | stripPrefix : true,
|
97 | 98 |
|
|
100 | 101 | *
|
101 | 102 | * A number for how many characters long URLs/emails/twitter handles should be truncated to inside the text of
|
102 | 103 | * 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. |
104 | 105 | *
|
105 | 106 | * 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..' |
107 | 108 | */
|
108 | 109 |
|
109 | 110 | /**
|
|
591 | 592 | * @extends Object
|
592 | 593 | *
|
593 | 594 | * 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). |
597 | 595 | */
|
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, { |
608 | 597 |
|
609 | 598 | /**
|
610 | 599 | * @cfg {Boolean} newWindow
|
611 | 600 | *
|
612 |
| - * `true` if the links should open in a new window, `false` otherwise. |
| 601 | + * See {@link Autolinker#newWindow} for details. |
613 | 602 | */
|
614 | 603 |
|
615 | 604 | /**
|
616 | 605 | * @cfg {Boolean} stripPrefix
|
617 | 606 | *
|
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. |
619 | 608 | */
|
620 | 609 |
|
621 | 610 | /**
|
622 | 611 | * @cfg {Number} truncate
|
623 | 612 | *
|
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. |
630 | 614 | */
|
631 | 615 |
|
632 | 616 | /**
|
633 | 617 | * @cfg {String} className
|
634 | 618 | *
|
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. |
643 | 620 | */
|
644 | 621 |
|
645 | 622 |
|
|
652 | 629 | urlPrefixRegex: /^(https?:\/\/)?(www\.)?/i,
|
653 | 630 |
|
654 | 631 |
|
| 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 | + |
655 | 641 | /**
|
656 | 642 | * Generates the actual anchor (<a>) tag to use in place of a source url/email/twitter link.
|
657 | 643 | *
|
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. |
659 | 645 | * @param {String} anchorHref The href for the anchor tag.
|
660 | 646 | * @param {String} anchorText The anchor tag's text (i.e. what will be displayed).
|
661 | 647 | * @return {String} The full HTML for the anchor tag.
|
662 | 648 | */
|
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 ); |
665 | 651 | anchorText = this.processAnchorText( anchorText );
|
666 | 652 |
|
667 | 653 | return '<a ' + attributesStr + '>' + anchorText + '</a>';
|
|
672 | 658 | * Creates the string which will be the HTML attributes for the anchor (<a>) tag being generated.
|
673 | 659 | *
|
674 | 660 | * @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. |
676 | 662 | * @param {String} href The href for the anchor tag.
|
677 | 663 | * @return {String} The anchor tag's attribute. Ex: `href="http://google.com" class="myLink myLink-url" target="_blank"`
|
678 | 664 | */
|
679 |
| - createAnchorAttrsStr : function( linkType, anchorHref ) { |
| 665 | + createAnchorAttrsStr : function( matchType, anchorHref ) { |
680 | 666 | var attrs = [ 'href="' + anchorHref + '"' ]; // we'll always have the `href` attribute
|
681 | 667 |
|
682 |
| - var cssClass = this.createCssClass( linkType ); |
| 668 | + var cssClass = this.createCssClass( matchType ); |
683 | 669 | if( cssClass ) {
|
684 | 670 | attrs.push( 'class="' + cssClass + '"' );
|
685 | 671 | }
|
|
692 | 678 |
|
693 | 679 |
|
694 | 680 | /**
|
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} |
696 | 682 | * config.
|
697 | 683 | *
|
698 | 684 | * @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. |
700 | 686 | * @return {String} The CSS class string for the link. Example return: "myLink myLink-url". If no {@link #className}
|
701 | 687 | * was configured, returns an empty string.
|
702 | 688 | */
|
703 |
| - createCssClass : function( linkType ) { |
| 689 | + createCssClass : function( matchType ) { |
704 | 690 | var className = this.className;
|
705 | 691 |
|
706 | 692 | if( !className )
|
707 | 693 | return "";
|
708 | 694 | 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" |
710 | 696 | },
|
711 | 697 |
|
712 | 698 |
|
|
776 | 762 | return anchorText;
|
777 | 763 | }
|
778 | 764 |
|
779 |
| - }; |
| 765 | + } ); |
780 | 766 | /**
|
781 | 767 | * @private
|
782 | 768 | * @abstract
|
|
0 commit comments