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 facebook: "https://graph.facebook.com/?id={url}", 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 facebook: "http://graph.facebook.com/?id={url}&callback=?", 107 //facebook : "http://api.ak.facebook.com/restserver.php?v=1.0&method=links.getStats&urls={url}&format=json" 108 // Old twitter count api endpoint. 109 //twitter: "http://cdn.api.twitter.com/1/urls/count.json?url={url}&callback=?", 110 // Now using http://opensharecount.com/ 111 twitter: "http://opensharecount.com/count.json?url={url}", 112 digg: "http://services.digg.com/2.0/story.getInfo?links={url}&type=javascript&callback=?", 113 delicious: 'http://feeds.delicious.com/v2/json/urlinfo/data?url={url}&callback=?', 114 //stumbleupon: "http://www.stumbleupon.com/services/1.01/badge.getinfo?url={url}&format=jsonp&callback=?", 115 stumbleupon: "", 116 linkedin: "http://www.linkedin.com/countserv/count/share?format=jsonp&url={url}&callback=?", 117 pinterest: "http://api.pinterest.com/v1/urls/count.json?url={url}&callback=?" 118 }, 119 /* Load share buttons asynchronously 120 ================================================== */ 121 loadButton = { 122 googlePlus : function(self){ 123 var sett = self.options.buttons.googlePlus; 124 //$(self.element).find('.buttons').append('<div class="button googleplus"><g:plusone size="'+self.options.buttons.googlePlus.size+'" href="'+self.options.url+'"></g:plusone></div>'); 125 $(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>'); 126 window.___gcfg = { 127 lang: self.options.buttons.googlePlus.lang 128 }; 129 var loading = 0; 130 if(typeof gapi === 'undefined' && loading == 0){ 131 loading = 1; 132 (function() { 133 var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; 134 po.src = '//apis.google.com/js/plusone.js'; 135 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s); 136 })(); 137 } 138 else{ 139 gapi.plusone.go(); 140 } 141 }, 142 facebook : function(self){ 143 var sett = self.options.buttons.facebook; 144 $(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>'); 145 var loading = 0; 146 if(typeof FB === 'undefined' && loading == 0){ 147 loading = 1; 148 (function(d, s, id) { 149 var js, fjs = d.getElementsByTagName(s)[0]; 150 if (d.getElementById(id)) {return;} 151 js = d.createElement(s); js.id = id; 152 js.src = '//connect.facebook.net/'+sett.lang+'/all.js#xfbml=1'; 153 fjs.parentNode.insertBefore(js, fjs); 154 }(document, 'script', 'facebook-jssdk')); 155 } 156 else{ 157 FB.XFBML.parse(); 158 } 159 }, 160 twitter : function(self){ 161 var sett = self.options.buttons.twitter; 162 $(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>'); 163 var loading = 0; 164 if(typeof twttr === 'undefined' && loading == 0){ 165 loading = 1; 166 (function() { 167 var twitterScriptTag = document.createElement('script'); 168 twitterScriptTag.type = 'text/javascript'; 169 twitterScriptTag.async = true; 170 twitterScriptTag.src = '//platform.twitter.com/widgets.js'; 171 var s = document.getElementsByTagName('script')[0]; 172 s.parentNode.insertBefore(twitterScriptTag, s); 173 })(); 174 } 175 else{ 176 $.ajax({ url: '//platform.twitter.com/widgets.js', dataType: '
176script', cache:true}); //http://stackoverflow.com/q/6536108 177 } 178 }, 179 digg : function(self){ 180 var sett = self.options.buttons.digg; 181 $(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>'); 182 var loading = 0; 183 if(typeof __DBW === 'undefined' && loading == 0){ 184 loading = 1; 185 (function() { 186 var s = document.createElement('SCRIPT'), s1 = document.getElementsByTagName('SCRIPT')[0]; 187 s.type = 'text/javascript'; 188 s.async = true; 189 s.src = '//widgets.digg.com/buttons.js'; 190 s1.parentNode.insertBefore(s, s1); 191 })(); 192 } 193 }, 194 delicious : function(self){ 195 if(self.options.buttons.delicious.size == 'tall'){//tall 196 var css = 'width:50px;', 197 cssCount = 'height:35px;width:50px;font-size:15px;line-height:35px;', 198 cssShare = 'height:18px;line-height:18px;margin-top:3px;'; 199 } 200 else{//medium 201 var css = 'width:93px;', 202 cssCount = 'float:right;padding:0 3px;height:20px;width:26px;line-height:20px;', 203 cssShare = 'float:left;height:20px;line-height:20px;'; 204 } 205 var count = self.shorterTotal(self.options.count.delicious); 206 if(typeof count === "undefined"){ 207 count = 0; 208 } 209 $(self.element).find('.buttons').append( 210 '<div class="button delicious">
210<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;">'+ 211 '<div style="'+cssCount+'background-color:#fff;margin-bottom:5px;overflow:hidden;text-align:center;border:1px solid #ccc;border-radius:3px;">'+count+'</div>'+ 212 '<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;">'+ 213 '<img src="http://www.delicious.com/static/img/delicious.small.gif" height="10" width="10" alt="Delicious" /> Add</div></div></div>'); 214 215 $(self.element).find('.delicious').on('click', function(){ 216 self.openPopup('delicious'); 217 }); 218 }, 219 stumbleupon : function(self){ 220 var sett = self.options.buttons.stumbleupon; 221 $(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>'); 222 var loading = 0; 223 if(typeof STMBLPN === 'undefined' && loading == 0){ 224 loading = 1; 225 (function() { 226 var li = document.createElement('script');li.type = 'text/javascript';li.async = true; 227 li.src = '//platform.stumbleupon.com/1/widgets.js'; 228 var s = document.getElementsByTagName('script')[0];s.parentNode.insertBefore(li, s); 229 })(); 230 s = window.setTimeout(function(){ 231 if(typeof STMBLPN !== 'undefined'){ 232 STMBLPN.processWidgets(); 233 clearInterval(s); 234 } 235 },500); 236 } 237 else{ 238 STMBLPN.processWidgets(); 239 } 240 }, 241 linkedin : function(self){ 242 var sett = self.options.buttons.linkedin; 243 $(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>'); 244 var loading = 0; 245 if(typeof window.IN === 'undefined' && loading == 0){ 246 loading = 1; 247 (function() { 248 var li = document.createElement('script');li.type = 'text/javascript';li.async = true; 249 li.src = '//platform.linkedin.com/in.js'; 250 var s = document.getElementsByTagName('script')[0];s.parentNode.insertBefore(li, s); 251 })(); 252 } 253 else{ 254 window.IN.init(); 255 } 256 }, 257 pinterest : function(self){ 258 var sett = self.options.buttons.pinterest; 259 $(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>'); 260 261 (function() { 262 var li = document.createElement('script');li.type = 'text/javascript';li.async = true; 263 li.src = '//assets.pinterest.com/js/pinit.js'; 264 var s = document.getElementsByTagName('script')[0];s.parentNode.insertBefore(li, s); 265 })(); 266 } 267 }, 268 /* Tracking for Google Analytics 269 ================================================== */ 270 tracking = { 271 googlePlus: function(){}, 272 facebook: function(){ 273 //console.log('facebook'); 274 fb = window.setInterval(function(){ 275 if (typeof FB !== 'undefined') { 276 FB.Event.subscribe('edge.create', function(targetUrl) {
277 _gaq.push(['_trackSocial', 'facebook', 'like', targetUrl]); 278 }); 279 FB.Event.subscribe('edge.remove', function(targetUrl) { 280 _gaq.push(['_trackSocial', 'facebook', 'unlike', targetUrl]); 281 }); 282 FB.Event.subscribe('message.send', function(targetUrl) { 283 _gaq.push(['_trackSocial', 'facebook', 'send', targetUrl]); 284 }); 285 //console.log('ok'); 286 clearInterval(fb); 287 } 288 },1000); 289 }, 290 twitter: function(){ 291 //console.log('twitter'); 292 tw = window.setInterval(function(){ 293 if (typeof twttr !== 'undefined') { 294 twttr.events.bind('tweet', function(event) { 295 if (event) { 296 _gaq.push(['_trackSocial', 'twitter', 'tweet']); 297 } 298 }); 299 //console.log('ok'); 300 clearInterval(tw); 301 } 302 },1000); 303 }, 304 digg: function(){ 305 //if somenone find a solution, mail me ! 306 /*$(this.element).find('.digg').on('click', function(){ 307 _gaq.push(['_trackSocial', 'digg', 'add']); 308 });*/ 309 }, 310 delicious: function(){}, 311 stumbleupon: function(){}, 312 linkedin: function(){ 313 function LinkedInShare() { 314 _gaq.push(['_trackSocial', 'linkedin', 'share']); 315 } 316 }, 317 pinterest: function(){ 318 //if somenone find a solution, mail me ! 319 } 320 }, 321 /* Popup for each social network 322 ================================================== */ 323 popup = { 324 googlePlus: function(opt){ 325 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"); 326 }, 327 facebook: function(opt){ 328 window.open("http://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"); 329 }, 330 twitter: function(opt){ 331 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"); 332 }, 333 digg: function(opt){ 334 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"); 335 }, 336 delicious: function(opt){ 337 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'); 338 }, 339 stumbleupon: function(opt){ 340 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'); 341 }, 342 linkedin: function(opt){ 343 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'); 344 }, 345 pinterest: function(opt){ 346 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'); 347 } 348 }; 349 350 /* Plugin constructor 351 ================================================== */ 352 function Plugin( element, options ) { 353 this.element = element; 354 355 this.options = $.extend( true, {}, defaults, options); 356 this.options.share = options.share; //simple solution to allow order of buttons 357 358 this._defaults = defaults; 359 this._name = pluginName; 360 361 this.init(); 362 }; 363 364 /* Initialization method 365 ================================================== */ 366 Plugin.prototype.init = function () { 367 var self = this; 368 if(this.options.urlCurl !== ''){
369 urlJson.googlePlus = this.options.urlCurl + '?url={url}&type=googlePlus'; // PHP script for GooglePlus... 370 urlJson.stumbleupon = this.options.urlCurl + '?url={url}&type=stumbleupon'; // PHP script for Stumbleupon... 371 } 372 $(this.element).addClass(this.options.className); //add class 373 374 //HTML5 Custom data 375 if(typeof $(this.element).data('title') !== 'undefined'){ 376 this.options.title = $(this.element).attr('data-title'); 377 } 378 if(typeof $(this.element).data('url') !== 'undefined'){ 379 this.options.url = $(this.element).data('url'); 380 } 381 if(typeof $(this.element).data('text') !== 'undefined'){ 382 this.options.text = $(this.element).data('text'); 383 } 384 385 //how many social website have been selected 386 $.each(this.options.share, function(name, val) { 387 if(val === true){ 388 self.options.shareTotal ++; 389 } 390 }); 391 392 if(self.options.enableCounter === true){ //if for some reason you don't need counter 393 //get count of social share that have been selected 394 $.each(this.options.share, function(name, val) { 395 if(val === true){ 396 //self.getSocialJson(name); 397 try { 398 self.getSocialJson(name); 399 } catch(e){ 400 } 401 } 402 }); 403 } 404 else if(self.options.template !== ''){ //for personalized button (with template) 405 this.options.render(this, this.options); 406 } 407 else{ // if you want to use official button like example 3 or 5 408 this.loadButtons(); 409 } 410 411 //add hover event 412 $(this.element).hover(function(){ 413 //load social button if enable and 1 time 414 if($(this).find('.buttons').length === 0 && self.options.enableHover === true){ 415 self.loadButtons(); 416 } 417 self.options.hover(self, self.options); 418 }, function(){ 419 self.options.hide(self, self.options); 420 }); 421 422 //click event 423 $(this.element).click(function(){ 424 self.options.click(self, self.options); 425 return false; 426 }); 427 }; 428 429 /* loadButtons methode 430 ================================================== */ 431 Plugin.prototype.loadButtons = function () { 432 var self = this; 433 $(this.element).append('<div class="buttons"></div>'); 434 $.each(self.options.share, function(name, val) { 435 if(val == true){ 436 loadButton[name](self); 437 if(self.options.enableTracking === true){ //add tracking 438 tracking[name](); 439 } 440 } 441 }); 442 }; 443 444 /* getSocialJson methode 445 ================================================== */ 446 Plugin.prototype.getSocialJson = function (name) { 447 var self = this, 448 count = 0, 449 url = urlJson[name].replace('{url}', encodeURIComponent(this.options.url)); 450 if(this.options.buttons[name].urlCount === true && this.options.buttons[name].url !== ''){
451 url = urlJson[name].replace('{url}', this.options.buttons[name].url); 452 } 453 //console.log('name : ' + name + ' - url : '+url); //debug 454 if(url != '' && self.options.urlCurl !== ''){ //urlCurl = '' if you don't want to used PHP script but used social button 455 $.getJSON(url, function(json){ 456 if(typeof json.count !== "undefined"){ //GooglePlus, Stumbleupon, Twitter, Pinterest and Digg 457 var temp = json.count + ''; 458 temp = temp.replace('\u00c2\u00a0', ''); //remove google plus special chars 459 count += parseInt(temp, 10); 460 } 461 //get the FB total count (shares, likes and more) 462 // else if(json.data && json.data.length > 0 && typeof json.data[0].total_count !== "undefined"){ //Facebook total count 463 // count += parseInt(json.data[0].total_count, 10); 464 // } 465 else if (json.share && typeof json.share.share_count !== "undefined"){ 466 count += parseInt(json.share.share_count, 10); 467 } 468 else if(typeof json[0] !== "undefined"){ //Delicious 469 count += parseInt(json[0].total_posts, 10); 470 } 471 else if(typeof json[0] !== "undefined"){ //Stumbleupon 472 } 473 self.options.count[name] = count; 474 self.options.total += count; 475 self.renderer(); 476 self.rendererPerso(); 477 //console.log(json); //debug 478 }) 479 .error(function() { 480 self.options.count[name] = 0; 481 self.rendererPerso(); 482 }); 483 } 484 else{ 485 self.renderer(); 486 self.options.count[name] = 0; 487 self.rendererPerso(); 488 } 489 }; 490 491 /* launch render methode 492 ================================================== */ 493 Plugin.prototype.rendererPerso = function () { 494 //check if this is the last social website to launch render 495 var shareCount = 0; 496 for (e in this.options.count) { shareCount++; } 497 if(shareCount === this.options.shareTotal){ 498 this.options.render(this, this.options); 499 } 500 }; 501 502 /* render methode 503 ================================================== */ 504 Plugin.prototype.renderer = function () { 505 var total = this.options.total, 506 template = this.options.template; 507 if(this.options.shorterTotal === true){ //format number like 1.2k or 5M 508 total = this.shorterTotal(total); 509 } 510 511 if(template !== ''){ //if there is a template 512 template = template.replace('{total}', total); 513 $(this.element).html(template); 514 } 515 else{ //template by defaults 516 $(this.element).html( 517 '<div class="box"><a class="count" href="#">' + total + '</a>' + 518 (this.options.title !== '' ? '<a class="share" href="#">' + this.options.title + '</a>' : '') + 519 '</div>' 520 ); 521 } 522 }; 523 524 /* format total numbers like 1.2k or 5M 525 ================================================== */ 526 Plugin.prototype.shorterTotal = function (num) { 527 if (num >= 1e6){ 528 num = (num / 1e6).toFixed(2) + "M" 529 } else if (num >= 1e3){ 530 num = (num / 1e3).toFixed(1) + "k" 531 } 532 return num; 533 }; 534 535 /* Methode for open popup 536 ================================================== */ 537 Plugin.prototype.openPopup = function (site) { 538 popup[site](this.options); //open 539 if(this.options.enableTracking === true){ //tracking! 540 var tracking = { 541 googlePlus: {site: 'Google', action: '+1'}, 542 facebook: {site: 'facebook', action: 'like'}, 543 twitter: {site: 'twitter', action: 'tweet'}, 544 digg: {site: 'digg', action: 'add'}, 545 delicious: {site: 'delicious', action: 'add'}, 546 stumbleupon: {site: 'stumbleupon', action: 'add'}, 547 linkedin: {site: 'linkedin', action: 'share'}, 548 pinterest: {site: 'pinterest', action: 'pin'} 549 };
550 _gaq.push(['_trackSocial', tracking[site].site, tracking[site].action]); 551 } 552 }; 553 554 /* Methode for add +1 to a counter 555 ================================================== */ 556 Plugin.prototype.simulateClick = function () { 557 var html = $(this.element).html(); 558 $(this.element).html(html.replace(this.options.total, this.options.total+1)); 559 }; 560 561 /* Methode for add +1 to a counter 562 ================================================== */ 563 Plugin.prototype.update = function (url, text) { 564 if(url !== ''){ 565 this.options.url = url; 566 } 567 if(text !== ''){ 568 this.options.text = text; 569 } 570 }; 571 572 /* A really lightweight plugin wrapper around the constructor, preventing against multiple instantiations 573 ================================================== */ 574 $.fn[pluginName] = function ( options ) { 575 var args = arguments; 576 if (options === undefined || typeof options === 'object') { 577 return this.each(function () { 578 if (!$.data(this, 'plugin_' + pluginName)) { 579 $.data(this, 'plugin_' + pluginName, new Plugin( this, options )); 580 } 581 }); 582 } else if (typeof options === 'string' && options[0] !== '_' && options !== 'init') { 583 return this.each(function () { 584 var instance = $.data(this, 'plugin_' + pluginName); 585 if (instance instanceof Plugin && typeof instance[options] === 'function') { 586 instance[options].apply( instance, Array.prototype.slice.call( args, 1 ) ); 587 } 588 }); 589 } 590 }; 591})(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.