1/** 2 * jQuery.share - social media sharing plugin 3 * --- 4 * @author Carol Skelly (http://in1.com) 5 * @version 1.0 6 * @license MIT license (http://opensource.org/licenses/mit-license.php) 7 * --- 8 */ 9 10;(function ( $, window, undefined ) { 11 12 var document = window.document; 13 14 $.fn.share = function(method) { 15 16 var methods = { 17 18 init : function(options) { 19 this.share.settings = $.extend({}, this.share.defaults, options); 20 var settings = this.share.settings, 21 networks = this.share.settings.networks, 22 theme = this.share.settings.theme, 23 orientation = this.share.settings.orientation, 24 affix = this.share.settings.affix, 25 margin = this.share.settings.margin, 26 pageTitle = this.share.settings.title||$(document).attr('title'), 27 pageUrl = this.share.settings.urlToShare||$(location).attr('href'), 28 pageDesc = ""; 29 30 $.each($(document).find('meta[name="description"]'),function(idx,item){ 31 pageDesc = $(item).attr("content"); 32 }); 33 34 // each instance of this plugin 35 return this.each(function() { 36 var $element = $(this), 37 id=$element.attr("id"), 38 u=encodeURIComponent(pageUrl), 39 t=encodeURIComponent(pageTitle), 40 d=pageDesc.substring(0,250), 41 href; 42 43 // append HTML for each network button 44 for (var item in networks) { 45 item = networks[item]; 46 href = helpers.networkDefs[item].url; 47 href = href.replace('|u|',u).replace('|t|',t).replace('|d|',d) 48 .replace('|140|',t.substring(0,130)); 49 $("<a href='"+href+"' title='Share this page on "+item+ 50 "' class='pop tooltip share-"+theme+" share-"+theme+"-"+item+"'></a>") 51 .appendTo($element); 52 } 53 54 // customize css 55 $("#"+id+".share-"+theme).css('margin',margin); 56 57 if (orientation != "horizontal"){ 58 $("#"+id+" a.share-"+theme).css('display','block'); 59 } 60 else { 61 $("#"+id+" a.share-"+theme).css('display','inline-block'); 62 } 63 64 if (typeof affix != "undefined"){ 65 $element.addClass('share-affix'); 66 if (affix.indexOf('right')!=-1){ 67 $element.css('left','auto'); 68 $element.css('right','0px'); 69 if (affix.indexOf('center')!=-1){ 70 $element.css('top','40%'); 71 } 72 } 73 else if (affix.indexOf('left center')!=-1){ 74 $element.css('top','40%'); 75 } 76 77 if (affix.indexOf('bottom')!=-1){ 78 $element.css('bottom','0px'); 79 $element.css('top','auto'); 80 if (affix.indexOf('center')!=-1){ 81 $element.css('left','40%'); 82 } 83 } 84 } 85 86 // bind click 87 $('.pop').click(function(){ 88 window.open($(this).attr('href'),'t','toolbar=0,resizable=1,status=0,width=640,height=528'); 89 return false; 90 }); 91 92 93 });// end plugin instance 94 95 } 96 } 97 98 var helpers = { 99 networkDefs: { 100 facebook:{url:'http://www.facebook.com/share.php?u=|u|'}, 101 //http://twitter.com/home?status=jQuery%20Share%20Social%20Media%20Plugin%20-%20Share%20to%20multiple%20social%20networks%20from%20a%20single%2
1010form%20http://plugins.in1.com/share/demo 102 twitter:{url:'https://twitter.com/share?url=|u|&text=|140|'}, 103 linkedin:{url:'http://www.linkedin.com/shareArticle?mini=true&url=|u|&title=|t|&summary=|d|&source=in1.com'}, 104 in1:{url:'http://www.in1.com/cast?u=|u|',w:'490',h:'529'}, 105 tumblr:{url:'http://www.tumblr.com/share?v=3&u=|u|'}, 106 digg:{url:'http://digg.com/submit?url=|u|&title=|t|'}, 107 googleplus:{url:'https://plusone.google.com/_/+1/confirm?hl=en&url=|u|'}, 108 reddit:{url:'http://reddit.com/submit?url=|u|'}, 109 pinterest:{url:'http://pinterest.com/pin/create/button/?url=|u|&media=&description=|d|'}, 110 posterous:{url:'http://posterous.com/share?linkto=|u|&title=|t|'}, 111 stumbleupon:{url:'http://www.stumbleupon.com/submit?url=|u|&title=|t|'}, 112 email:{url:'mailto:?subject=|t|'} 113 } 114 } 115 116 if (methods[method]) { 117 return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); 118 } else if (typeof method === 'object' || !method) { 119 return methods.init.apply(this, arguments); 120 } else { 121 $.error( 'Method "' + method + '" does not exist in social plugin'); 122 } 123 124 } 125 126 $.fn.share.defaults = { 127 networks: ['facebook','twitter','linkedin'], 128 theme: 'icon', // use round icons sprite 129 autoShow: true, 130 margin: '3px', 131 orientation: 'horizontal', 132 useIn1: false 133 } 134 135 $.fn.share.settings = {} 136 137})(jQuery, window);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.