var ctf_js_exists = (typeof ctf_js_exists !== 'undefined') ? true : false; if(!ctf_js_exists){ (function ($) { //Runs every time new tweets are loaded function ctfScripts( $ctf ){ //Loop through each newly loaded tweet $ctf.find('.ctf-item.ctf-new').each(function(){ var $ctfItem = $(this), $ctfTextMedia = $ctfItem.find('.ctf-tweet-text-media-wrap'), $ctfText = $ctfItem.find('.ctf-tweet-text').remove('.ctf-tweet-text-media-wrap'), ctfTextStr = ' ' + $ctfText.html(); if( $ctf.attr('data-ctfdisablelinks') != 'true' && typeof ctfTextStr !== 'undefined' ){ var ctfLinkColor = $ctf.attr('data-ctflinktextcolor'), ctfLinkColorHex = ''; if( ctfLinkColor ) ctfLinkColorHex = ctfLinkColor.replace(';','').split("#")[1]; //Link URLs window.ctfLinkify=(function(){var k="[a-z\\d.-]+://",h="(?:(?:[0-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])\\.){3}(?:[0-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])",c="(?:(?:[^\\s!@#$%^&*()_=+[\\]{}\\\\|;:'\",.<>/?]+)\\.)+",n="(?:ac|ad|aero|ae|af|ag|ai|al|am|an|ao|aq|arpa|ar|asia|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|biz|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|cat|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|coop|com|co|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|info|int|in|io|iq|ir|is|it|je|jm|jobs|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mil|mk|ml|mm|mn|mobi|mo|mp|mq|mr|ms|mt|museum|mu|mv|mw|mx|my|mz|name|na|nc|net|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pro|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tel|tf|tg|th|tj|tk|tl|tm|tn|to|tp|travel|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|xn--0zwm56d|xn--11b5bs3a9aj6g|xn--80akhbyknj4f|xn--9t4b11yi5a|xn--deba0ad|xn--g6w251d|xn--hgbk6aj7f53bba|xn--hlcj6aya9esc7a|xn--jxalpdlp|xn--kgbechtv|xn--zckzah|ye|yt|yu|za|zm|zw)",f="(?:"+c+n+"|"+h+")",o="(?:[;/][^#?<>\\s]*)?",e="(?:\\?[^#<>\\s]*)?(?:#[^<>\\s]*)?",d="\\b"+k+"[^<>\\s]+",a="\\b"+f+o+e+"(?!\\w)",m="mailto:",j="(?:"+m+")?[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@"+f+e+"(?!\\w)",l=new RegExp("(?:"+d+"|"+a+"|"+j+")","ig"),g=new RegExp("^"+k,"i"),b={"'":"`",">":"<",")":"(","]":"[","}":"{","B;":"B+","b:":"b9"},i={callback:function(q,p){return p?''+q+"":q},punct_regexp:/(?:[!?.,:;'"]|(?:&|&)(?:lt|gt|quot|apos|raquo|laquo|rsaquo|lsaquo);)$/};return function(u,z){z=z||{};var w,v,A,p,x="",t=[],s,E,C,y,q,D,B,r;for(v in i){if(z[v]===undefined){z[v]=i[v]}}while(w=l.exec(u)){A=w[0];E=l.lastIndex;C=E-A.length;if(/[\/:]/.test(u.charAt(C-1))){continue}do{y=A;r=A.substr(-1);B=b[r];if(B){q=A.match(new RegExp("\\"+B+"(?!$)","g"));D=A.match(new RegExp("\\"+r,"g"));if((q?q.length:0)<(D?D.length:0)){A=A.substr(0,A.length-1);E--}}if(z.punct_regexp){A=A.replace(z.punct_regexp,function(F){E-=F.length;return""})}}while(A.length&&A!==y);p=A;if(!g.test(p)){p=(p.indexOf("@")!==-1?(!p.indexOf(m)?"":m):!p.indexOf("irc.")?"irc://":!p.indexOf("ftp.")?"ftp://":"http://")+p}if(s!=C){t.push([u.slice(s,C)]);s=E}t.push([A,p])}t.push([u.substr(s)]);for(v=0;v' + replacementString + ''; } } //Replace hashtags in text if(ctfTextStr.length > 0){ //Add a space after all
tags so that #hashtags immediately after them are also converted to hashtag links. Without the space they aren't captured by the regex. ctfTextStr = ctfTextStr.replace(/
/g, "
"); ctfTextStr = ctfTextStr.replace( ctfHashRegex , ctfHashReplacer ); } //Link @tags function ctfReplaceTags(tag){ var replacementString = jQuery.trim(tag); return ' ' + replacementString + ''; } var tagRegex = /[\s][@]+[A-Za-z0-9-_]+/g; ctfTextStr = ctfTextStr.replace( tagRegex , ctfReplaceTags ); //Replace text with linked version $ctfText.html( ctfTextStr.trim() ); $ctfText.append($ctfTextMedia); //Add link color $ctfText.find('a').css('color', '#' + ctfLinkColorHex); $ctfTextMedia.css('color', '#' + ctfLinkColorHex); } // End "ctfdata-disablelinks" check }); // End .ctfItem loop //Change color of retweet icon to match text // $ctf.find('.ctf-retweet-icon').css({'background' : $ctf.find('.ctf-tweet-text a').css('color')}); //This doesn't work well if the link color is set to white as the default color of the icon text is also white //Change colors of some items to match tweet text $ctf.find('.ctf-author-name, .ctf-tweet-date, .ctf-author-screenname, .ctf-twitterlink, .ctf-author-box-link, .ctf-retweet-text, .ctf-quoted-tweet').css('color', $ctf.find('.ctf-tweet-text').css('color') ); //Set the line height of the twitter link to match the icons so that it's centered vertically var $ctfIconFirst = $ctf.find('.ctf-tweet-actions a').first(); $ctf.find('.ctf-twitterlink').css('line-height', $ctfIconFirst.height() + 'px' ); //Adjust icon number font size to be slightly smaller than the icon size if( $ctfIconFirst.length ){ var ctfIconSize = parseInt( $ctfIconFirst.css('font-size').replace('px', '') ); $ctf.find('.ctf-action-count').css({'display' : 'block', 'font-size' : (ctfIconSize-4) + 'px', 'line-height' : $ctfIconFirst.height() + 'px' }); } //Header profile pic hover $ctf.find('.ctf-header .ctf-header-link').hover(function(){ $ctf.find('.ctf-header .ctf-header-img-hover').fadeIn(200); }, function(){ $ctf.find('.ctf-header .ctf-header-img-hover').stop().fadeOut(600); }); // Call Custom JS if it exists if (typeof ctf_custom_js == 'function') ctf_custom_js($); } // end ctfScripts() function ctfLoadTweets( lastIDData, shortcodeData , $ctf, $ctfMore, numNeeded, persistentIndex ) { //Display loader $ctfMore.addClass('ctf-loading').append('
'); $ctfMore.find('.ctf-loader').css('background-color', $ctfMore.css('color')); jQuery.ajax({ url : ctf.ajax_url, type : 'post', data : { action : 'ctf_get_more_posts', last_id_data : lastIDData, shortcode_data : shortcodeData, num_needed : numNeeded, persistent_index: persistentIndex }, success : function(data) { if(lastIDData !== '') { // appends the html echoed out in ctf_get_new_posts() to the last post element if(data.indexOf(' 0) { var $ctfMore = $ctf.find('.ctf-more'), lastIDData = $ctf.find('.ctf-item').last().attr('id'), persistentIndex = $ctf.find('.ctf-item').length, shortcodeData = $ctf.attr('data-ctfshortcode'); ctfLoadTweets( lastIDData, shortcodeData , $ctf, $ctfMore, numNeeded, persistentIndex ); } },500); // add the load more button and input to simulate a dynamic json file call $ctf.find('.ctf-more').on('click', function() { // read the json that is in the ctf-shortcode-data that contains all of the shortcode arguments var $ctfMore = $(this), lastIDData = $ctf.find('.ctf-item').last().attr('id'), persistentIndex = $ctf.find('.ctf-item').length, shortcodeData = $ctf.attr('data-ctfshortcode'); ctfLoadTweets( lastIDData, shortcodeData , $ctf, $ctfMore, 0, persistentIndex ); }); $ctf.find('.ctf-author-box-link p:empty').remove(); }); // end .cff each loop })(jQuery); } //End ctf_js_exists check