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