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