1/*! 2 * Sharrre.com - Make your sharing widget! 3 * Version: beta 1.3.5 4 * Author: Julien Hany 5 * License: MIT http://en.wikipedia.org/wiki/MIT_License or GPLv2 http://en.wikipedia.org/wiki/GNU_General_Public_License 6 */ 7 8;(function ( $, window, document, undefined ) { 9 10 /* Defaults 11 ================================================== */ 12 var pluginName = 'sharrre', 13 defaults = { 14 className: 'sharrre', 15 share: { 16 googlePlus: false, 17 facebook: false, 18 twitter: false, 19 digg: false, 20 delicious: false, 21 stumbleupon: false, 22 linkedin: false, 23 pinterest: false 24 }, 25 shareTotal: 0, 26 template: '', 27 title: '', 28 url: document.location.href, 29 text: document.title, 30 urlCurl: 'sharrre.php', //PHP script for google plus... 31 count: {}, //counter by social network 32 total: 0, //total of sharing 33 shorterTotal: true, //show total by k or M when number is to big 34 enableHover: true, //disable if you want to personalize hover event with callback 35 enableCounter: true, //disable if you just want use buttons 36 enableTracking: false, //tracking with google analitycs 37 hover: function(){}, //personalize hover event with this callback function 38 hide: function(){}, //personalize hide event with this callback function 39 click: function(){}, //personalize click event with this callback function 40 render: function(){}, //personalize render event with this callback function 41 buttons: { //settings for buttons 42 googlePlus : { //http://www.google.com/webmasters/+1/button/ 43 url: '', //if you need to personnalize button url 44 urlCount: false, //if you want to use personnalize button url on global counter 45 size: 'medium', 46 lang: 'en-US', 47 annotation: '' 48 }, 49 facebook: { //http://developers.facebook.com/docs/reference/plugins/like/ 50 url: '', //if you need to personalize url button 51 urlCount: false, //if you want to use personnalize button url on global counter 52 action: 'like', 53 layout: 'button_count', 54 width: '', 55 send: 'false', 56 faces: 'false', 57 colorscheme: '', 58 font: '', 59 lang: 'en_US' 60 }, 61 twitter: { //http://twitter.com/about/resources/tweetbutton 62 url: '', //if you need to personalize url button 63 urlCount: false, //if you want to use personnalize button url on global counter 64 count: 'horizontal', 65 hashtags: '', 66 via: '', 67 related: '', 68 lang: 'en' 69 }, 70 digg: { //http://about.digg.com/downloads/button/smart 71 url: '', //if you need to personalize url button 72 urlCount: false, //if you want to use personnalize button url on global counter 73 type: 'DiggCompact' 74 }, 75 delicious: { 76 url: '', //if you need to personalize url button 77 urlCount: false, //if you want to use personnalize button url on global counter 78 size: 'medium' //medium or tall 79 }, 80 stumbleupon: { //http://www.stumbleupon.com/badges/ 81 url: '', //if you need to personalize url button 82 urlCount: false, //if you want to use personnalize button url on global counter 83 layout: '1' 84 }, 85 linkedin: { //http://developer.linkedin.com/plugins/share-button 86 url: '', //if you need to personalize url button 87 urlCount: false, //if you want to use personnalize button url on global counter 88 counter: '' 89 }, 90 pinterest: { //http://pinterest.com/about/goodies/ 91 url: '', //if you need to personalize url button 92 media: '', 93 description: '', 94 layout: 'horizontal' 95 } 96 } 97 }, 98 /* Json URL to get count number 99 ================================================== */ 100 urlJson = { 101 googlePlus: "", 102 103 //new FQL method by Sire 104 //new FQL method by Sire 105 //facebook: "https://graph.facebook.com/fql?q=SELECT%20url,%20normalized_url,%20share_count,%20like_count,%20comment_count,%20total_count,commentsbox_count,%20comments_fbid,%20click_count%20FROM%20link_stat%20WHERE%20url=%27{url}%27&callback=?", 106 //old method 107 facebook: "https://graph.facebook.com/?id={url}&callback=?", 108 //facebook : "http://api.ak.facebook.com/restserver.php?v=1.0&method=links.getStats&urls={url}&format=json" 109 //old method facebook: "http://graph.facebook.com/?id={url}&callback=?", 110 //facebook : "http://api.ak.facebook.com/restserver.php?v=1.0&method=links.getStats&urls={url}&format=json" 111 // Old twitter count api endpoint. 112 //twitter: "http://cdn.api.twitter.com/1/urls/count.json?url={url}&callback=?", 113 // Now using http://opensharecount.com/ 114 twitter: "https://opensharecount.com/count.json?url={url}", 115 digg: "https://services.digg.com/2.0/story.getInfo?links={url}&type=javascript&callback=?", 116 delicious: 'https://feeds.delicious.com/v2/json/urlinfo/data?url={url}&callback=?', 117 //stumbleupon: "http://www.stumbleupon.com/services/1.01/badge.getinfo?url={url}&format=jsonp&callback=?", 118 stumbleupon: "", 119 //linkedin: "https://www.linkedin.com/countserv/count/share?format=jsonp&url={url}&callback=?", 120 linkedin: "https://www.linkedin.com/sharing/share-offsite/?url={url}&callback=?", 121 //linkedin: "https://www.linkedin.com/shareArticle?mini=true&url={url}&callback=?", 122 123 pinterest: "https://api.pinterest.com/v1/urls/count.json?url={url}&callback=?" 124 },
125 /* Load share buttons asynchronously 126 ================================================== */ 127 loadButton = { 128 googlePlus : function(self){ 129 var sett = self.options.buttons.googlePlus; 130 //$(self.element).find('.buttons').append('<div class="button googleplus"><g:plusone size="'+self.options.buttons.googlePlus.size+'" href="'+self.options.url+'"></g:plusone></div>'); 131 $(self.element).find('.buttons').append('<div class="button googleplus"><div class="g-plusone" data-size="'+sett.size+'" data-href="'+(sett.url !== '' ? sett.url : self.options.url)+'" data-annotation="'+sett.annotation+'"></div></div>'); 132 window.___gcfg = { 133 lang: self.options.buttons.googlePlus.lang 134 }; 135 var loading = 0; 136 if(typeof gapi === 'undefined' && loading == 0){ 137 loading = 1; 138 (function() { 139 var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; 140 po.src = '//apis.google.com/js/plusone.js'; 141 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s); 142 })(); 143 } 144 else{ 145 gapi.plusone.go(); 146 } 147 }, 148 facebook : function(self){ 149 var sett = self.options.buttons.facebook; 150 $(self.element).find('.buttons').append('<div class="button facebook"><div id="fb-root"></div><div class="fb-like" data-href="'+(sett.url !== '' ? sett.url : self.options.url)+'" data-send="'+sett.send+'" data-layout="'+sett.layout+'" data-width="'+sett.width+'" data-show-faces="'+sett.faces+'" data-action="'+sett.action+'" data-colorscheme="'+sett.colorscheme+'" data-font="'+sett.font+'" data-via="'+sett.via+'"></div></div>'); 151 var loading = 0; 152 if(typeof FB === 'undefined' && loading == 0){ 153 loading = 1; 154 (function(d, s, id) { 155 var js, fjs = d.getElementsByTagName(s)[0]; 156 if (d.getElementById(id)) {return;} 157 js = d.createElement(s); js.id = id; 158 js.src = '//connect.facebook.net/'+sett.lang+'/all.js#xfbml=1'; 159 fjs.parentNode.insertBefore(js, fjs); 160 }(document, 'script', 'facebook-jssdk')); 161 } 162 else{ 163 FB.XFBML.parse(); 164 } 165 }, 166 twitter : function(self){ 167 var sett = self.options.buttons.twitter; 168 $(self.element).find('.buttons').append('<div class="button twitter"><a href="https://twitter.com/share" class="twitter-share-button" data-url="'+(sett.url !== '' ? sett.url : self.options.url)+'" data-count="'+sett.count+'" data-text="'+self.options.text+'" data-via="'+sett.via+'" data-hashtags="'+sett.hashtags+'" data-related="'+sett.related+'" data-lang="'+sett.lang+'">Tweet</a></div>'); 169 var loading = 0; 170 if(typeof twttr === 'undefined' && loading == 0){ 171 loading = 1; 172 (function() { 173 var twitterScriptTag = document.createElement('script'); 174 twitterScriptTag.type = 'text/javascript'; 175 twitterScriptTag.async = true; 176 twitterScriptTag.src = '//platform.twitter.com/widgets.js'; 177 var s = document.getElementsByTagName('script')[0]; 178 s.parentNode.insertBefore(twitterScriptTag, s); 179 })(); 180 } 181 else{ 182 $.ajax({ url: '//platform.twitter.com/widgets.js', dataType: 'script', cache:true}); //http://stackoverflow.com/q/6536108 183 } 184 }, 185 digg : function(self){ 186 var sett = self.options.buttons.digg; 187 $(self.element).find('.buttons').append('<div class="button digg"><a class="DiggThisButton '+sett.type+'" rel="nofollow external" href="http://digg.com/submit?url='+encodeURIComponent((sett.url !== '' ? sett.url : self.options.url))+'"></a></div>'); 188 var loading = 0; 189 if(typeof __DBW === 'undefined' && loading == 0){ 190 loading = 1; 191 (function() { 192 var s = document.createElement('SCRIPT'), s1 = document.getElementsByTagName('SCRIPT')[0]; 193 s.type = 'text/javascript'; 194 s.async = true; 195 s.src = '//widgets.digg.com/buttons.js'; 196 s1.parentNode.insertBefore(s, s1); 197 })(); 198 } 199 }, 200 delicious : function(self){ 201 if(self.options.buttons.delicious.size == 'tall'){//tall 202 var css = 'width:50px;', 203 cssCount = 'height:35px;width:50px;font-size:15px;line-height:35px;', 204 cssShare = 'height:18px;line-height:18px;margin-top:3px;'; 205 } 206 else{//medium 207 var css = 'width:93px;', 208 cssCount = 'float:right;padding:0 3px;
208height:20px;width:26px;line-height:20px;', 209 cssShare = 'float:left;height:20px;line-height:20px;'; 210 } 211 var count = self.shorterTotal(self.options.count.delicious); 212 if(typeof count === "undefined"){ 213 count = 0; 214 } 215 $(self.element).find('.buttons').append( 216 '<div class="button delicious"><div style="'+css+'font:12px Arial,Helvetica,sans-serif;cursor:pointer;color:#666666;display:inline-block;float:none;height:20px;line-height:normal;margin:0;padding:0;text-indent:0;vertical-align:baseline;">'+ 217 '<div style="'+cssCount+'background-color:#fff;margin-bottom:5px;overflow:hidden;text-align:center;border:1px solid #ccc;border-radius:3px;">'+count+'</div>'+ 218 '<div style="'+cssShare+'display:block;padding:0;text-align:center;text-decoration:none;width:50px;background-color:#7EACEE;border:1px solid #40679C;border-radius:3px;color:#fff;">'+ 219 '<img src="http://www.delicious.com/static/img/delicious.small.gif" height="10" width="10" alt="Delicious" /> Add</div></div></div>'); 220 221 $(self.element).find('.delicious').on('click', function(){ 222 self.openPopup('delicious'); 223 }); 224 }, 225 stumbleupon : function(self){ 226 var sett = self.options.buttons.stumbleupon; 227 $(self.element).find('.buttons').append('<div class="button stumbleupon"><su:badge layout="'+sett.layout+'" location="'+(sett.url !== '' ? sett.url : self.options.url)+'"></su:badge></div>'); 228 var loading = 0; 229 if(typeof STMBLPN === 'undefined' && loading == 0){ 230 loading = 1; 231 (function() { 232 var li = document.createElement('script');li.type = 'text/javascript';li.async = true; 233 li.src = '//platform.stumbleupon.com/1/widgets.js'; 234 var s = document.getElementsByTagName('script')[0];s.parentNode.insertBefore(li, s); 235 })(); 236 s = window.setTimeout(function(){ 237 if(typeof STMBLPN !== 'undefined'){ 238 STMBLPN.processWidgets(); 239 clearInterval(s); 240 } 241 },500); 242 } 243 else{ 244 STMBLPN.processWidgets(); 245 } 246 }, 247 linkedin : function(self){ 248 var sett = self.options.buttons.linkedin; 249 $(self.element).find('.buttons').append('<div class="button linkedin"><script type="in/share" data-url="'+(sett.url !== '' ? sett.url : self.options.url)+'" data-counter="'+sett.counter+'"></script></div>'); 250 var loading = 0; 251 if(typeof window.IN === 'undefined' && loading == 0){ 252 loading = 1; 253 (function() { 254 var li = document.createElement('script');li.type = 'text/javascript';li.async = true; 255 li.src = '//platform.linkedin.com/in.js'; 256 var s = document.getElementsByTagName('script')[0];s.parentNode.insertBefore(li, s); 257 })(); 258 } 259 else{ 260 window.IN.init(); 261 } 262 }, 263 pinterest : function(self){ 264 var sett = self.options.buttons.pinterest; 265 $(self.element).find('.buttons').append('<div class="button pinterest"><a href="http://pinterest.com/pin/create/button/?url='+(sett.url !== '' ? sett.url : self.options.url)+'&media='+sett.media+'&description='+sett.description+'" class="pin-it-button" count-layout="'+sett.layout+'">Pin It</a></div>'); 266 267 (function() { 268 var li = document.createElement('script');li.type = 'text/javascript';li.async = true; 269 li.src = '//assets.pinterest.com/js/pinit.js'; 270 var s = document.getElementsByTagName('script')[0];s.parentNode.insertBefore(li, s); 271 })(); 272 } 273 }, 274 /* Tracking for Google Analytics 275 ================================================== */ 276 tracking = { 277 googlePlus: function(){}, 278 facebook: function(){ 279 //console.log('facebook'); 280 fb = window.setInterval(function(){ 281 if (typeof FB !== 'undefined') { 282 FB.Event.subscribe('edge.create', function(targetUrl) { 283 _gaq.push(['_trackSocial', 'facebook', 'like', targetUrl]); 284 }); 285 FB.Event.subscribe('edge.remove', function(targetUrl) { 286 _gaq.push(['_trackSocial', 'facebook', 'unlike', targetUrl]); 287 }); 288 FB.Event.subscribe('message.send', function(targetUrl) {
289 _gaq.push(['_trackSocial', 'facebook', 'send', targetUrl]); 290 }); 291 //console.log('ok'); 292 clearInterval(fb); 293 } 294 },1000); 295 }, 296 twitter: function(){ 297 //console.log('twitter'); 298 tw = window.setInterval(function(){ 299 if (typeof twttr !== 'undefined') { 300 twttr.events.bind('tweet', function(event) { 301 if (event) { 302 _gaq.push(['_trackSocial', 'twitter', 'tweet']); 303 } 304 }); 305 //console.log('ok'); 306 clearInterval(tw); 307 } 308 },1000); 309 }, 310 digg: function(){ 311 //if somenone find a solution, mail me ! 312 /*$(this.element).find('.digg').on('click', function(){ 313 _gaq.push(['_trackSocial', 'digg', 'add']); 314 });*/ 315 }, 316 delicious: function(){}, 317 stumbleupon: function(){}, 318 linkedin: function(){ 319 function LinkedInShare() { 320 _gaq.push(['_trackSocial', 'linkedin', 'share']); 321 } 322 }, 323 pinterest: function(){ 324 //if somenone find a solution, mail me ! 325 } 326 }, 327 /* Popup for each social network 328 ================================================== */ 329 popup = { 330 googlePlus: function(opt){ 331 window.open("https://plus.google.com/share?hl="+opt.buttons.googlePlus.lang+"&url="+encodeURIComponent((opt.buttons.googlePlus.url !== '' ? opt.buttons.googlePlus.url : opt.url)), "", "toolbar=0, status=0, width=900, height=500"); 332 }, 333 facebook: function(opt){ 334 window.open("https://www.facebook.com/sharer/sharer.php?u="+encodeURIComponent((opt.buttons.facebook.url !== '' ? opt.buttons.facebook.url : opt.url))+"&t="+opt.text+"", "", "toolbar=0, status=0, width=900, height=500"); 335 }, 336 twitter: function(opt){ 337 window.open("https://twitter.com/intent/tweet?text="+encodeURIComponent(opt.text)+"&url="+encodeURIComponent((opt.buttons.twitter.url !== '' ? opt.buttons.twitter.url : opt.url))+(opt.buttons.twitter.via !== '' ? '&via='+opt.buttons.twitter.via : ''), "", "toolbar=0, status=0, width=650, height=360"); 338 }, 339 digg: function(opt){ 340 window.open("http://digg.com/tools/diggthis/submit?url="+encodeURIComponent((opt.buttons.digg.url !== '' ? opt.buttons.digg.url : opt.url))+"&title="+opt.text+"&related=true&style=true", "", "toolbar=0, status=0, width=650, height=360"); 341 }, 342 delicious: function(opt){ 343 window.open('http://www.delicious.com/save?v=5&noui&jump=close&url='+encodeURIComponent((opt.buttons.delicious.url !== '' ? opt.buttons.delicious.url : opt.url))+'&title='+opt.text, 'delicious', 'toolbar=no,width=550,height=550'); 344 }, 345 stumbleupon: function(opt){ 346 window.open('http://www.stumbleupon.com/badge/?url='+encodeURIComponent((opt.buttons.stumbleupon.url !== '' ? opt.buttons.stumbleupon.url : opt.url)), 'stumbleupon', 'toolbar=no,width=550,height=550'); 347 }, 348 linkedin: function(opt){ 349 window.open('https://www.linkedin.com/cws/share?url='+encodeURIComponent((opt.buttons.linkedin.url !== '' ? opt.buttons.linkedin.url : opt.url))+'&token=&isFramed=true', 'linkedin', 'toolbar=no,width=550,height=550'); 350 }, 351 pinterest: function(opt){ 352 window.open('http://pinterest.com/pin/create/button/?url='+encodeURIComponent((opt.buttons.pinterest.url !== '' ? opt.buttons.pinterest.url : opt.url))+'&media='+encodeURIComponent(opt.buttons.pinterest.media)+'&description='+opt.buttons.pinterest.description, 'pinterest', 'toolbar=no,width=700,height=300'); 353 } 354 }; 355 356 /* Plugin constructor 357 ================================================== */ 358 function Plugin( element, options ) { 359 this.element = element; 360 361 this.options = $.extend( true, {}, defaults, options); 362 this.options.share = options.share; //simple solution to allow order of buttons 363 364 this._defaults = defaults; 365 this._name = pluginName; 366 367 this.init(); 368 }; 369 370 /* Initialization method 371 ================================================== */ 372 Plugin.prototype.init = function () { 373 var self = this; 374 if(this.options.urlCurl !== ''){ 375 urlJson.googlePlus = this.options.urlCurl + '?url={url}&type=googlePlus'; // PHP script for GooglePlus... 376 urlJson.stumbleupon = this.options.urlCurl + '?url={url}&type=stumbleupon'; // PHP script for Stumbleupon... 377 } 378 $(this.element).addClass(this.options.className);
378 //add class 379 380 //HTML5 Custom data 381 if(typeof $(this.element).data('title') !== 'undefined'){ 382 this.options.title = $(this.element).attr('data-title'); 383 } 384 if(typeof $(this.element).data('url') !== 'undefined'){ 385 this.options.url = $(this.element).data('url'); 386 } 387 if(typeof $(this.element).data('text') !== 'undefined'){ 388 this.options.text = $(this.element).data('text'); 389 } 390 391 //how many social website have been selected 392 $.each(this.options.share, function(name, val) { 393 if(val === true){ 394 self.options.shareTotal ++; 395 } 396 }); 397 398 if(self.options.enableCounter === true){ //if for some reason you don't need counter 399 //get count of social share that have been selected 400 $.each(this.options.share, function(name, val) { 401 if(val === true){ 402 //self.getSocialJson(name); 403 try { 404 self.getSocialJson(name); 405 } catch(e){ 406 } 407 } 408 }); 409 } 410 else if(self.options.template !== ''){ //for personalized button (with template) 411 this.options.render(this, this.options); 412 } 413 else{ // if you want to use official button like example 3 or 5 414 this.loadButtons(); 415 } 416 417 //add hover event 418 $(this.element).hover(function(){ 419 //load social button if enable and 1 time 420 if($(this).find('.buttons').length === 0 && self.options.enableHover === true){ 421 self.loadButtons(); 422 } 423 self.options.hover(self, self.options); 424 }, function(){ 425 self.options.hide(self, self.options); 426 }); 427 428 //click event 429 $(this.element).click(function(){ 430 self.options.click(self, self.options); 431 return false; 432 }); 433 }; 434 435 /* loadButtons methode 436 ================================================== */ 437 Plugin.prototype.loadButtons = function () { 438 var self = this; 439 $(this.element).append('<div class="buttons"></div>'); 440 $.each(self.options.share, function(name, val) { 441 if(val == true){ 442 loadButton[name](self); 443 if(self.options.enableTracking === true){ //add tracking 444 tracking[name](); 445 } 446 } 447 }); 448 }; 449 450 /* getSocialJson methode 451 ================================================== */ 452 Plugin.prototype.getSocialJson = function (name) { 453 var self = this, 454 count = 0, 455 url = urlJson[name].replace('{url}', encodeURIComponent(this.options.url)); 456 if(this.options.buttons[name].urlCount === true && this.options.buttons[name].url !== ''){ 457 url = urlJson[name].replace('{url}', this.options.buttons[name].url); 458 } 459 //console.log('name : ' + name + ' - url : '+url); //debug 460 if(url != '' && self.options.urlCurl !== ''){ //urlCurl = '' if you don't want to used PHP script but used social button 461 $.getJSON(url, function(json){ 462 if(typeof json.count !== "undefined"){ //GooglePlus, Stumbleupon, Twitter, Pinterest and Digg 463 var temp = json.count + ''; 464 temp = temp.replace('\u00c2\u00a0', ''); //remove google plus special chars 465 count += parseInt(temp, 10); 466 } 467 //get the FB total count (shares, likes and more) 468 //else if(json.data && json.data.length > 0 && typeof json.data[0].total_count !== "undefined"){ //Facebook total count 469 // count += parseInt(json.data[0].total_count, 10); 470 //} 471 472 // Hacked: matt: FB api no longer returns share count, switching api's 473 // returns data in this format now. 474 else if(json.share && json.share && typeof json.share.share_count !== "undefined"){ //Facebook total count 475 count += parseInt(json.share.share_count, 10); 476 } 477 // End hacked: matt 478 479 else if(typeof json[0] !== "undefined"){ //Delicious 480 count += parseInt(json[0].total_posts, 10); 481 } 482 else if(typeof json[0] !== "undefined"){ //Stumbleupon 483 } 484 self.options.count[name] = count; 485 self.options.total += count; 486 self.renderer(); 487 self.rendererPerso(); 488 //console.log(json); //debug 489 }) 490 .error(function() { 491 self.options.count[name] = 0; 492 self.rendererPerso(); 493 }); 494 } 495 else{ 496 self.renderer(); 497 self.options.count[name] = 0; 498 self.rendererPerso(); 499 } 500 }; 501 502 /* launch render methode 503 ================================================== */ 504 Plugin.prototype.rendererPerso = function () { 505 //check if this is the last social website to launch render 506 var shareCount = 0; 507 for (e in this.options.count) { shareCount++; } 508 if(shareCount === this.options.shareTotal){ 509 this.options.render(this, this.options); 510 } 511 }; 512 513 /* render methode 514 ================================================== */ 515 Plugin.prototype.renderer = function () { 516 var total = this.options.total, 517 template = this.options.template; 518 if(this.options.shorterTotal === true){ //format number like 1.2k or 5M 519 total = this.shorterTotal(total); 520 } 521 522 if(template !== ''){ //if there is a template 523 template = template.replace('{total}', total); 524 $(this.element).html(template); 525 } 526 else{ //template by defaults 527 $(this.element).html( 528 '<div class="box"><a class="count" href="#">
528' + total + '</a>' + 529 (this.options.title !== '' ? '<a class="share" href="#">' + this.options.title + '</a>' : '') + 530 '</div>' 531 ); 532 } 533 }; 534 535 /* format total numbers like 1.2k or 5M 536 ================================================== */ 537 Plugin.prototype.shorterTotal = function (num) { 538 if (num >= 1e6){ 539 num = (num / 1e6).toFixed(2) + "M" 540 } else if (num >= 1e3){ 541 num = (num / 1e3).toFixed(1) + "k" 542 } 543 return num; 544 }; 545 546 /* Methode for open popup 547 ================================================== */ 548 Plugin.prototype.openPopup = function (site) { 549 popup[site](this.options); //open 550 if(this.options.enableTracking === true){ //tracking! 551 var tracking = { 552 googlePlus: {site: 'Google', action: '+1'}, 553 facebook: {site: 'facebook', action: 'like'}, 554 twitter: {site: 'twitter', action: 'tweet'}, 555 digg: {site: 'digg', action: 'add'}, 556 delicious: {site: 'delicious', action: 'add'}, 557 stumbleupon: {site: 'stumbleupon', action: 'add'}, 558 linkedin: {site: 'linkedin', action: 'share'}, 559 pinterest: {site: 'pinterest', action: 'pin'} 560 }; 561 _gaq.push(['_trackSocial', tracking[site].site, tracking[site].action]); 562 } 563 }; 564 565 /* Methode for add +1 to a counter 566 ================================================== */ 567 Plugin.prototype.simulateClick = function () { 568 var html = $(this.element).html(); 569 $(this.element).html(html.replace(this.options.total, this.options.total+1)); 570 }; 571 572 /* Methode for add +1 to a counter 573 ================================================== */ 574 Plugin.prototype.update = function (url, text) { 575 if(url !== ''){ 576 this.options.url = url; 577 } 578 if(text !== ''){ 579 this.options.text = text; 580 } 581 }; 582 583 /* A really lightweight plugin wrapper around the constructor, preventing against multiple instantiations 584 ================================================== */ 585 $.fn[pluginName] = function ( options ) { 586 var args = arguments; 587 if (options === undefined || typeof options === 'object') { 588 return this.each(function () { 589 if (!$.data(this, 'plugin_' + pluginName)) { 590 $.data(this, 'plugin_' + pluginName, new Plugin( this, options )); 591 } 592 }); 593 } else if (typeof options === 'string' && options[0] !== '_' && options !== 'init') { 594 return this.each(function () { 595 var instance = $.data(this, 'plugin_' + pluginName); 596 if (instance instanceof Plugin && typeof instance[options] === 'function') { 597 instance[options].apply( instance, Array.prototype.slice.call( args, 1 ) ); 598 } 599 }); 600 } 601 }; 602})(jQuery, window, document);
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.