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