/* * Twitter Follow Box jQuery Plugin * https://jobyj.in/twitter-follow-box-widget/ * * Copyright 2012, Joby Joseph * Free to use under the MIT license. * https://www.opensource.org/licenses/mit-license.php * */ (function($) { $.fn.followbox = function(options) { var element=$(this); //change this file path if the tiny twitter logo is not showing var settings = $.extend( { 'user' : 'jobysblog', 'width' : 292, 'height' : 252, 'theme' : 'light', 'border_color' : '#AAA', 'bg_color' : '#fff', 'bg_image' : '', 'title_color' : '#3B5998', 'total_count_color' : '#333', 'follower_name_color' : '#BBB' }, options); //twitter user lookup $.ajax({ url: 'https://api.twitter.com/1/users/lookup.json?screen_name='+settings.user+'&include_entities=true', dataType: 'jsonp', success: function(data) { var widget_width=settings.width-2; var widget_height=settings.height-2; var grid_container_height=settings.height-115; var number_images_row=parseInt(settings.width / 55); var number_images_col=parseInt(grid_container_height / 69)+1; var total_followers=number_images_row*number_images_col; element.html('
'); //applying dark style if theme is 'dark' if(settings.theme=='dark'){ element.find('.follow_box_main').addClass('dark'); } element.find('.follow_box_follower_count').text(element.find('.follow_box_follower_count').text().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") ); if($.browser.msie && !$.support.boxModel) $('.follow_box .connections').css('padding-bottom','14px'); element.find('.follow_box_main').css({ 'border-color':settings.border_color }); if(settings.theme=='custom') { element.find('.follow_box_main').css({ 'border-color':settings.border_color, 'background-color':settings.bg_color, 'background-image': 'url("'+settings.bg_image+'")' }); element.find('.follow_box a').css({ 'color':settings.title_color }); element.find('.follow_box .total').css({ 'color':settings.total_count_color }); } $.ajax({ url: 'https://api.twitter.com/1/followers/ids.json?cursor=-1&screen_name='+settings.user, dataType: 'jsonp', success: function(followers) { var idlist_string=getfollowers(total_followers,followers.ids); $.ajax({ url: 'https://api.twitter.com/1/users/lookup.json?user_id='+idlist_string+'&include_entities=true', dataType: 'jsonp', success: function(follower_details) { for(var i=0;i
'+namearray[0].toLowerCase()+'
'; element.find('.connections_grid').append(grid_item_html); } if(settings.theme=='custom') { element.find('.connections .connections_grid .grid_item .name').css({ 'color':settings.follower_name_color }); } } }); } }); } }); function getfollowers(number,followers){ if(number>100) number=100; var idlist=new Array(); for(var i=0;i