vendor: 14,847 bytes, lines 1-487
1/** 2 * @preserve 3 * Sharer.js 4 * 5 * @description Create your own social share buttons 6 * @version 0.5.1 7 * @author Ellison Leao <[email protected]> 8 * @license MIT 9 * 10 */ 11 12(function (window, document) { 13 'use strict'; 14 /** 15 * @constructor 16 */ 17 var Sharer = function (elem) { 18 this.elem = elem; 19 }; 20 21 /** 22 * @function init 23 * @description bind the events for multiple sharer elements 24 * @returns {Empty} 25 */ 26 Sharer.init = function () { 27 var elems = document.querySelectorAll('[data-sharer]'), 28 i, 29 l = elems.length; 30 31 for (i = 0; i < l; i++) { 32 elems[i].addEventListener('click', Sharer.add); 33 } 34 }; 35 36 /** 37 * @function add 38 * @description bind the share event for a single dom element 39 * @returns {Empty} 40 */ 41 Sharer.add = function (elem) { 42 var target = elem.currentTarget || elem.srcElement; 43 var sharer = new Sharer(target); 44 sharer.share(); 45 }; 46 47 // instance methods 48 Sharer.prototype = { 49 constructor: Sharer, 50 /** 51 * @function getValue 52 * @description Helper to get the attribute of a DOM element 53 * @param {String} attr DOM element attribute 54 * @returns {String|Empty} returns the attr value or empty string 55 */ 56 getValue: function (attr) { 57 var val = this.elem.getAttribute('data-' + attr); 58 // handing facebook hashtag attribute 59 if (val && attr === 'hashtag') { 60 if (!val.startsWith('#')) { 61 val = '#' + val; 62 } 63 } 64 if (attr == "title" && !val) { 65 val = document.querySelector("title").innerHTML; 66 } 67 68 return val === null ? '' : val; 69 }, 70 71 /** 72 * @event share 73 * @description Main share event. Will pop a window or redirect to a link 74 * based on the data-sharer attribute. 75 */ 76 share: function () { 77 var sharer = this.getValue('sharer').toLowerCase(), 78 sharers = { 79 facebook: { 80 shareUrl: 'https://www.facebook.com/sharer/sharer.php', 81 params: { 82 u: this.getValue('url'), 83 hashtag: this.getValue('hashtag'), 84 quote: this.getValue('quote'), 85 }, 86 }, 87 linkedin: { 88 shareUrl: 'https://www.linkedin.com/shareArticle', 89 params: { 90 url: this.getValue('url'), 91 mini: true, 92 }, 93 }, 94 twitter: { 95 shareUrl: 'https://twitter.com/intent/tweet', 96 params: { 97 text: this.getValue('title'), 98 url: this.getValue('url'), 99 hashtags: this.getValue('hashtags'), 100 via: this.getValue('via'), 101 related: this.getValue('related'), 102 in_reply_to: this.getValue('in_reply_to') 103 }, 104 }, 105 email: { 106 shareUrl: 'mailto:' + this.getValue('to'), 107 params: { 108 subject: this.getValue('subject'), 109 body: this.getValue('title') + '\n' + this.getValue('url'), 110 }, 111 }, 112 whatsapp: { 113 shareUrl: this.getValue('web') === 'true' ? 'https://web.whatsapp.com/send' : 'https://wa.me/', 114 params: { 115 phone: this.getValue('to'), 116 text: this.getValue('title') + ' ' + this.getValue('url'), 117 }, 118 }, 119 telegram: { 120 shareUrl: 'https://t.me/share', 121 params: { 122 text: this.getValue('title'), 123 url: this.getValue('url'), 124 }, 125 }, 126 viber: { 127 shareUrl: 'viber://forward', 128 params: { 129 text: this.getValue('title') + ' ' + this.getValue('url'), 130 }, 131 }, 132 line: { 133 shareUrl: 134 'http://line.me/R/msg/text/?' + encodeURIComponent(this.getValue('title') + ' ' + this.getValue('url')), 135 }, 136 pinterest: { 137 shareUrl: 'https://www.pinterest.com/pin/create/button/', 138 params: { 139 url: this.getValue('url'), 140 media: this.getValue('image'), 141 description: this.getValue('description'), 142 }, 143 }, 144 tumblr: { 145 shareUrl: 'http://tumblr.com/widgets/share/tool', 146 params: { 147 canonicalUrl: this.getValue('url'), 148 content: this.getValue('url'), 149 posttype: 'link', 150 title: this.getValue('title'), 151 caption: this.getValue('caption'), 152 tags: this.getValue('tags'), 153 }, 154 }, 155 hackernews: { 156 shareUrl: 'https://news.ycombinator.com/submitlink', 157 params: { 158 u: this.getValue('url'), 159 t: this.getValue('title'), 160 }, 161 }, 162 reddit: { 163 shareUrl: 'https://www.reddit.com/submit', 164 params: { url: this.getValue('url'), title: this.getValue('title') }, 165 }, 166 vk: { 167 shareUrl: 'http://vk.com/share.php', 168 params: { 169 url: this.getValue('url'), 170 title: this.getValue('title'), 171 description: this.getValue('caption'), 172 image: this.getValue('image'), 173 }, 174 }, 175 xing: { 176 shareUrl: 'https://www.xing.com/social/share/spi', 177 params: { 178 url: this.getValue('url'), 179 }, 180 }, 181 buffer: { 182 shareUrl: 'https://buffer.com/add', 183 params: { 184 url: this.getValue('url'), 185 title: this.getValue('title'), 186 via: this.getValue('via'), 187 picture: this.getValue('picture'), 188 }, 189 }, 190 instapaper: { 191 shareUrl: 'http://www.instapaper.com/edit', 192 params: { 193 url: this.getValue('url'), 194 title: this.getValue('title'), 195 description: this.getValue('description'), 196 }, 197 }, 198 pocket: { 199 shareUrl: 'https://getpocket.com/save', 200 params: { 201 url: this.getValue('url'), 202 }, 203 }, 204 mashable: { 205 shareUrl: 'https://mashable.com/submit', 206 params: { 207 url: this.getValue('url'), 208 title: this.getValue('title'), 209 }, 210 }, 211 mix: { 212 shareUrl: 'https://mix.com/add', 213 params: { 214 url: this.getValue('url'), 215 }, 216 }, 217 flipboard: { 218 shareUrl: 'https://share.flipboard.com/bookmarklet/popout', 219 params: { 220 v: 2, 221 title: this.getValue('title'), 222 url: this.getValue('url'), 223 t: Date.now(), 224 }, 225 }, 226 weibo: { 227 shareUrl: 'http://service.weibo.com/share/share.php', 228 params: { 229 url: this.getValue('url'), 230 title: this.getValue('title'), 231 pic: this.getValue('image'), 232 appkey: this.getValue('appkey'), 233 ralateUid: this.getValue('ralateuid'), 234 language: 'zh_cn', 235 }, 236 }, 237 blogger: { 238 shareUrl: 'https://www.blogger.com/blog-this.g', 239 params: { 240 u: this.getValue('url'), 241 n: this.getValue('title'), 242 t: this.getValue('description'), 243 }, 244 }, 245 baidu: { 246 shareUrl: 'http://cang.baidu.com/do/add', 247 params: { 248 it: this.getValue('title'), 249 iu: this.getValue('url'), 250 }, 251 }, 252 douban: { 253 shareUrl: 'https://www.douban.com/share/service', 254 params: { 255 name: this.getValue('name'), 256 href: this.getValue('url'), 257 image: this.getValue('image'), 258 comment: this.getValue('description'), 259 }, 260 }, 261 okru: { 262 shareUrl: 'https://connect.ok.ru/dk', 263 params: { 264 'st.cmd': 'WidgetSharePreview', 265 'st.shareUrl': this.getValue('url'), 266 title: this.getValue('title'), 267 }, 268 }, 269 mailru: { 270 shareUrl: 'http://connect.mail.ru/share', 271 params: { 272 share_url: this.getValue('url'), 273 linkname: this.getValue('title'), 274 linknote: this.getValue('description'), 275 type: 'page', 276 }, 277 }, 278 evernote: { 279 shareUrl: 'https://www.evernote.com/clip.action', 280 params: { 281 url: this.getValue('url'), 282 title: this.getValue('title'), 283 }, 284 }, 285 skype: { 286 shareUrl: 'https://web.skype.com/share', 287 params: { 288 url: this.getValue('url'), 289 title: this.getValue('title'), 290 }, 291 }, 292 delicious: { 293 shareUrl: 'https://del.icio.us/post', 294 params: { 295 url: this.getValue('url'), 296 title: this.getValue('title'), 297 }, 298 }, 299 sms: { 300 shareUrl: 'sms://', 301 params: { 302 body: this.getValue('body'), 303 }, 304 }, 305 trello: { 306 shareUrl: 'https://trello.com/add-card', 307 params: { 308 url: this.getValue('url'), 309 name: this.getValue('title'), 310 desc: this.getValue('description'), 311 mode: 'popup', 312 }, 313 }, 314 messenger: { 315 shareUrl: 'fb-messenger://share', 316 params: { 317 link: this.getValue('url'), 318 }, 319 }, 320 odnoklassniki: { 321 shareUrl: 'https://connect.ok.ru/dk', 322 params: { 323 st: { 324 cmd: 'WidgetSharePreview', 325 deprecated: 1, 326 shareUrl: this.getValue('url'), 327 }, 328 }, 329 }, 330 meneame: { 331 shareUrl: 'https://www.meneame.net/submit', 332 params: { 333 url: this.getValue('url'), 334 }, 335 }, 336 diaspora: { 337 shareUrl: 'https://share.diasporafoundation.org', 338 params: { 339 title: this.getValue('title'), 340 url: this.getValue('url'), 341 }, 342 }, 343 googlebookmarks: { 344 shareUrl: 'https://www.google.com/bookmarks/mark', 345 params: { 346 op: 'edit', 347 bkmk: this.getValue('url'), 348 title: this.getValue('title'), 349 }, 350 }, 351 qzone: { 352 shareUrl: 'https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey', 353 params: { 354 url: this.getValue('url'), 355 }, 356 }, 357 refind: { 358 shareUrl: 'https://refind.com', 359 params: { 360 url: this.getValue('url'), 361 }, 362 }, 363 surfingbird: { 364 shareUrl: 'https://surfingbird.ru/share', 365 params: { 366 url: this.getValue('url'), 367 title: this.getValue('title'), 368 description: this.getValue('description'), 369 }, 370 }, 371 yahoomail: { 372 shareUrl: 'http://compose.mail.yahoo.com', 373 params: { 374 to: this.getValue('to'), 375 subject: this.getValue('subject'), 376 body: this.getValue('body'), 377 }, 378 }, 379 wordpress: { 380 shareUrl: 'https://wordpress.com/wp-admin/press-this.php', 381 params: { 382 u: this.getValue('url'), 383 t: this.getValue('title'), 384 s: this.getValue('title'), 385 }, 386 }, 387 amazon: { 388 shareUrl: 'https://www.amazon.com/gp/wishlist/static-add', 389 params: { 390 u: this.getValue('url'), 391 t: this.getValue('title'), 392 }, 393 }, 394 pinboard: { 395 shareUrl: 'https://pinboard.in/add', 396 params: { 397 url: this.getValue('url'), 398 title: this.getValue('title'), 399 description: this.getValue('description'), 400 }, 401 }, 402 threema: { 403 shareUrl: 'threema://compose', 404 params: { 405 text: this.getValue('text'), 406 id: this.getValue('id'), 407 }, 408 }, 409 kakaostory: { 410 shareUrl: 'https://story.kakao.com/share', 411 params: { 412 url: this.getValue('url'), 413 }, 414 }, 415 yummly: { 416 shareUrl: 'http://www.yummly.com/urb/verify', 417 params: { 418 url: this.getValue('url'), 419 title: this.getValue('title'), 420 yumtype: 'button', 421 }, 422 }, 423 }, 424 s = sharers[sharer]; 425 426 // custom popups sizes 427 if (s) { 428 s.width = this.getValue('width'); 429 s.height = this.getValue('height'); 430 } 431 return s !== undefined ? this.urlSharer(s) : false; 432 }, 433 /** 434 * @event urlSharer 435 * @param {Object} sharer 436 */ 437 urlSharer: function (sharer) { 438 var p = sharer.params || {}, 439 keys = Object.keys(p), 440 i, 441 str = keys.length > 0 ? '?' : ''; 442 for (i = 0; i < keys.length; i++) { 443 if (str !== '?') { 444 str += '&'; 445 } 446 if (p[keys[i]]) { 447 str += keys[i] + '=' + encodeURIComponent(p[keys[i]]); 448 } 449 } 450 sharer.shareUrl += str; 451 452 var isLink = this.getValue('link') === 'true'; 453 var isBlank = this.getValue('blank') === 'true'; 454 455 if (isLink) { 456 if (isBlank) { 457 window.open(sharer.shareUrl, '_blank'); 458 } else { 459 window.location.href = sharer.shareUrl; 460 } 461 } else { 462 console.log(sharer.shareUrl); 463 // defaults to popup if no data-link is provided 464 var popWidth = sharer.width || 600, 465 popHeight = sharer.height || 480, 466 left = window.innerWidth / 2 - popWidth / 2 + window.screenX, 467 top = window.innerHeight / 2 - popHeight / 2 + window.screenY, 468 popParams = 'scrollbars=no, width=' + popWidth + ', height=' + popHeight + ', top=' + top + ', left=' + left, 469 newWindow = window.open(sharer.shareUrl, '', popParams); 470 471 if (window.focus) { 472 newWindow.focus(); 473 } 474 } 475 }, 476 }; 477 478 // adding sharer events on domcontentload 479 if (document.readyState === 'complete' || document.readyState !== 'loading') { 480 Sharer.init(); 481 } else { 482 document.addEventListener('DOMContentLoaded', Sharer.init); 483 } 484 485 // exporting sharer for external usage 486 window.Sharer = Sharer; 487})(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.