Advertisement
HyperMitch

jQuery Social Buttons

Oct 27th, 2011
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="text/javascript">
  2.  
  3. // Tutorial ---> http://themergency.com/add-social-buttons-to-your-pages/
  4. // DEMO --> http://themergency.com/foobar1.4/index.htm
  5.  
  6.     jQuery(document).ready(function($) {
  7.    
  8.       //replace this URL with whatever URL you want shared.
  9.       var url = 'http://themergency.com/foobar-wordpress-plugin/';
  10.       //uncomment the line below and comment out the above to set the URL to the current URL
  11.       //var url = window.location;
  12.  
  13.       //replace this with your facebook app ID
  14.       var facebook_app_id = '125102657580278';
  15.      
  16.       var $target = $("#social_target");
  17.      
  18.       //add loading class
  19.       $target.addClass("socprog_loading");
  20.      
  21.       var $ul = $('<ul class="socialbuttons"></ul>');
  22.      
  23.       $target.append($ul);
  24.      
  25.       //add facebook HTML
  26.       var $facebook_li = $('<li/>')
  27.         .append('<iframe src="http://www.facebook.com/plugins/like.php?app_id='+facebook_app_id+'&amp;href='+encodeURIComponent(url)+'&amp;send=false&amp;layout=button_count&amp;width=90&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:90px; height:21px;" allowTransparency="true"></iframe>')
  28.         .appendTo($ul);
  29.      
  30.       var tweet = 'FooBar - the unobtrusive jQuery notification bar that doesnt suck';
  31.       var twitter = 'themergency';
  32.  
  33.       //add tweet HTML
  34.       var $twitter_li = $('<li/>')
  35.         .hide()
  36.         .append('<a href="http://twitter.com/share" class="twitter-share-button" data-url="'+url+'" data-text="'+tweet+'" data-count="horizontal" data-via="'+twitter+'">Tweet</a>')
  37.         .appendTo($ul);
  38.    
  39.       //load twitter
  40.       $.getScript('http://platform.twitter.com/widgets.js', function() {
  41.         $twitter_li.show(); //show it
  42.       });
  43.      
  44.       //add google+1 HTML
  45.       var $google_li = $('<li/>')
  46.         .hide()
  47.         .append('<g:plusone size="medium" href="'+url+'" count="true"></g:plusone>')
  48.         .appendTo($ul);
  49.      
  50.       // Load Google Plus
  51.       $.getScript('https://apis.google.com/js/plusone.js', function() {
  52.         $google_li.show();
  53.       });
  54.      
  55.       var $stumble_li = $('<li/>')
  56.         .hide()
  57.         .append('<div id="socialprogress-su"></div>')
  58.         .appendTo($ul);
  59.      
  60.       // Load StumbleUpon
  61.       $.getScript('http://www.stumbleupon.com/hostedbadge.php?s=2&r='+url+'&a=1&d=socialprogress-su', function() {
  62.         $stumble_li.show();
  63.       });
  64.      
  65.       var $linked_li = $('<li/>')
  66.         .hide()
  67.         .append('<scr'+'ipt type="in/share" data-url="'+url+'" data-counter="right"></scr'+'ipt>')
  68.         .appendTo($ul);
  69.      
  70.       // Load LinkedIn
  71.       $.getScript('http://platform.linkedin.com/in.js', function() {
  72.         $linked_li.show();
  73.       });
  74.     });
  75.    
  76.    
  77.   </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement