1(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ 2'use strict'; 3 4/** 5 * Trigger custom OpenShare namespaced event 6 */ 7 8var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 9 10function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 11 12var Events = { 13 trigger: function trigger(element, event) { 14 var ev = document.createEvent('Event'); 15 ev.initEvent('OpenShare.' + event, true, true); 16 element.dispatchEvent(ev); 17 } 18}; 19 20var analytics = function analytics(type, cb) { 21 // eslint-disable-line 22 var isGA = type === 'event' || type === 'social'; 23 var isTagManager = type === 'tagManager'; 24 25 if (isGA) checkIfAnalyticsLoaded(type, cb); 26 if (isTagManager) setTagManager(cb); 27}; 28 29function checkIfAnalyticsLoaded(type, cb) { 30 if (window.ga) { 31 if (cb) cb(); 32 // bind to shared event on each individual node 33 listen(function (e) { 34 var platform = e.target.getAttribute('data-open-share'); 35 var target = e.target.getAttribute('data-open-share-link') || e.target.getAttribute('data-open-share-url') || e.target.getAttribute('data-open-share-username') || e.target.getAttribute('data-open-share-center') || e.target.getAttribute('data-open-share-search') || e.target.getAttribute('data-open-share-body'); 36 37 if (type === 'event') { 38 ga('send', 'event', { // eslint-disable-line no-undef 39 eventCategory: 'OpenShare Click', 40 eventAction: platform, 41 eventLabel: target, 42 transport: 'beacon' 43 }); 44 } 45 46 if (type === 'social') { 47 ga('send', { // eslint-disable-line no-undef 48 hitType: 'social', 49 socialNetwork: platform, 50 socialAction: 'share', 51 socialTarget: target 52 }); 53 } 54 }); 55 } else { 56 setTimeout(function () { 57 checkIfAnalyticsLoaded(type, cb); 58 }, 1000); 59 } 60} 61 62function setTagManager(cb) { 63 if (window.dataLayer && window.dataLayer[0]['gtm.start']) { 64 if (cb) cb(); 65 66 listen(onShareTagManger); 67 68 getCounts(function (e) { 69 var count = e.target ? e.target.innerHTML : e.innerHTML; 70 71 var platform = e.target ? e.target.getAttribute('data-open-share-count-url') : e.getAttribute('data-open-share-count-url'); 72 73 window.dataLayer.push({ 74 event: 'OpenShare Count', 75 platform: platform, 76 resource: count, 77 activity: 'count' 78 }); 79 }); 80 } else { 81 setTimeout(function () { 82 setTagManager(cb); 83 }, 1000); 84 } 85} 86 87function listen(cb) { 88 // bind to shared event on each individual node 89 [].forEach.call(document.querySelectorAll('[data-open-share]'), function (node) { 90 node.addEventListener('OpenShare.shared', cb); 91 }); 92} 93 94function getCounts(cb) { 95 var countNode = document.querySelectorAll('[data-open-share-count]'); 96 97 [].forEach.call(countNode, function (node) { 98 if (node.textContent) cb(node);else node.addEventListener('OpenShare.counted-' + node.getAttribute('data-open-share-count-url'), cb); 99 }); 100} 101 102function onShareTagManger(e) { 103 var platform = e.target.getAttribute('data-open-share'); 104 var target = e.target.getAttribute('data-open-share-link') || e.target.getAttribute('data-open-share-url') || e.target.getAttribute('data-open-share-username') || e.target.getAttribute('data-open-share-center') || e.target.getAttribute('data-open-share-search') || e.target.getAttribute('data-open-share-body'); 105 106 window.dataLayer.push({ 107 event: 'OpenShare Share', 108 platform: platform, 109 resource: target, 110 activity: 'share' 111 }); 112} 113 114function initializeNodes(opts) { 115 // loop through open share node collection 116 return function () { 117 // check for analytics 118 checkAnalytics(); 119 120 if (opts.api) {
121 var nodes = opts.container.querySelectorAll(opts.selector); 122 [].forEach.call(nodes, opts.cb); 123 124 // trigger completed event 125 Events.trigger(document, opts.api + '-loaded'); 126 } else { 127 // loop through open share node collection 128 var shareNodes = opts.container.querySelectorAll(opts.selector.share); 129 [].forEach.call(shareNodes, opts.cb.share); 130 131 // trigger completed event 132 Events.trigger(document, 'share-loaded'); 133 134 // loop through count node collection 135 var countNodes = opts.container.querySelectorAll(opts.selector.count); 136 [].forEach.call(countNodes, opts.cb.count); 137 138 // trigger completed event 139 Events.trigger(document, 'count-loaded'); 140 } 141 }; 142} 143 144function checkAnalytics() { 145 // check for analytics 146 if (document.querySelector('[data-open-share-analytics]')) { 147 var provider = document.querySelector('[data-open-share-analytics]').getAttribute('data-open-share-analytics'); 148 149 if (provider.indexOf(',') > -1) { 150 var providers = provider.split(','); 151 providers.forEach(function (p) { 152 return analytics(p); 153 }); 154 } else analytics(provider); 155 } 156} 157 158function initializeWatcher(watcher, fn) { 159 [].forEach.call(watcher, function (w) { 160 var observer = new MutationObserver(function (mutations) { 161 // target will match between all mutations so just use first 162 fn(mutations[0].target); 163 }); 164 165 observer.observe(w, { 166 childList: true 167 }); 168 }); 169} 170 171function init$1(opts) { 172 return function () { 173 var initNodes = initializeNodes({ 174 api: opts.api || null, 175 container: opts.container || document, 176 selector: opts.selector, 177 cb: opts.cb 178 }); 179 180 initNodes(); 181 182 // check for mutation observers before using, IE11 only 183 if (window.MutationObserver !== undefined) { 184 initializeWatcher(document.querySelectorAll('[data-open-share-watch]'), initNodes); 185 } 186 }; 187} 188 189/** 190 * Object of transform functions for each openshare api 191 * Transform functions passed into OpenShare instance when instantiated 192 * Return object containing URL and key/value args 193 */ 194var ShareTransforms = { 195 196 // set Twitter share URL 197 twitter: function twitter(data) { 198 var ios = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 199 200 // if iOS user and ios data attribute defined 201 // build iOS URL scheme as single string 202 if (ios && data.ios) { 203 var message = ''; 204 205 if (data.text) { 206 message += data.text; 207 } 208 209 if (data.url) { 210 message += ' - ' + data.url; 211 } 212 213 if (data.hashtags) { 214 var tags = data.hashtags.split(',');
215 tags.forEach(function (tag) { 216 message += ' #' + tag; 217 }); 218 } 219 220 if (data.via) { 221 message += ' via ' + data.via; 222 } 223 224 return { 225 url: 'twitter://post?', 226 data: { 227 message: message 228 } 229 }; 230 } 231 232 return { 233 url: 'https://twitter.com/share?', 234 data: data, 235 popup: { 236 width: 700, 237 height: 296 238 } 239 }; 240 }, 241 242 243 // set Twitter retweet URL 244 twitterRetweet: function twitterRetweet(data) { 245 var ios = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 246 247 // if iOS user and ios data attribute defined 248 if (ios && data.ios) { 249 return { 250 url: 'twitter://status?', 251 data: { 252 id: data.tweetId 253 } 254 }; 255 } 256 257 return { 258 url: 'https://twitter.com/intent/retweet?', 259 data: { 260 tweet_id: data.tweetId, 261 related: data.related 262 }, 263 popup: { 264 width: 700, 265 height: 296 266 } 267 }; 268 }, 269 270 271 // set Twitter like URL 272 twitterLike: function twitterLike(data) { 273 var ios = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 274 275 // if iOS user and ios data attribute defined 276 if (ios && data.ios) { 277 return { 278 url: 'twitter://status?', 279 data: { 280 id: data.tweetId 281 } 282 }; 283 } 284 285 return { 286 url: 'https://twitter.com/intent/favorite?', 287 data: { 288 tweet_id: data.tweetId, 289 related: data.related 290 }, 291 popup: { 292 width: 700, 293 height: 296 294 } 295 }; 296 }, 297 298 299 // set Twitter follow URL 300 twitterFollow: function twitterFollow(data) { 301 var ios = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 302 303 // if iOS user and ios data attribute defined 304 if (ios && data.ios) { 305 var iosData = data.screenName ? { 306 screen_name: data.screenName 307 } : { 308 id: data.userId 309 }; 310 311 return { 312 url: 'twitter://user?', 313 data: iosData 314 }; 315 } 316 317 return { 318 url: 'https://twitter.com/intent/user?', 319 data: { 320 screen_name: data.screenName, 321 user_id: data.userId 322 }, 323 popup: { 324 width: 700, 325 height: 296 326 } 327 }; 328 }, 329 330 331 // set Facebook share URL 332 facebook: function facebook(data) { 333 return { 334 url: 'https://www.facebook.com/dialog/feed?app_id=961342543922322&redirect_uri=http://facebook.com&', 335 data: data, 336 popup: { 337 width: 560, 338 height: 593 339 } 340 }; 341 }, 342 343 344 // set Facebook send URL 345 facebookSend: function facebookSend(data) { 346 return { 347 url: 'https://www.facebook.com/dialog/send?app_id=961342543922322&redirect_uri=http://facebook.com&', 348 data: data, 349 popup: { 350 width: 980, 351 height: 596 352 } 353 }; 354 }, 355 356 357 // set YouTube play URL 358 youtube: function youtube(data) { 359 var ios = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 360 361 // if iOS user 362 if (ios && data.ios) { 363 return { 364 url: 'youtube:' + data.video + '?' 365 }; 366 } 367 368 return { 369 url: 'https://www.youtube.com/watch?v=' + data.video + '?', 370 popup: { 371 width: 1086, 372 height: 608 373 } 374 }; 375 }, 376 377 378 // set YouTube subcribe URL 379 youtubeSubscribe: function youtubeSubscribe(data) { 380 var ios = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 381 382 // if iOS user 383 if (ios && data.ios) { 384 return { 385 url: 'youtube://www.youtube.com/user/' + data.user + '?' 386 }; 387 } 388 389 return { 390 url: 'https://www.youtube.com/user/' + data.user + '?', 391 popup: { 392 width: 880, 393 height: 350 394 } 395 }; 396 }, 397 398 399 // set Instagram follow URL 400 instagram: function instagram() { 401 return { 402 url: 'instagram://camera?' 403 }; 404 }, 405 406 407 // set Instagram follow URL 408 instagramFollow: function instagramFollow(data) { 409 var ios = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 410 411 // if iOS user 412 if (ios && data.ios) { 413 return { 414 url: 'instagram://user?', 415 data: data 416 }; 417 } 418 419 return { 420 url: 'http://www.instagram.com/' + data.username + '?', 421 popup: { 422 width: 980, 423 height: 655 424 } 425 }; 426 }, 427 428 429 // set Snapchat follow URL
430 snapchat: function snapchat(data) { 431 return { 432 url: 'snapchat://add/' + data.username + '?' 433 }; 434 }, 435 436 437 // set Google share URL 438 google: function google(data) { 439 return { 440 url: 'https://plus.google.com/share?', 441 data: data, 442 popup: { 443 width: 495, 444 height: 815 445 } 446 }; 447 }, 448 449 450 // set Google maps URL 451 googleMaps: function googleMaps(data) { 452 var ios = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 453 454 if (data.search) { 455 data.q = data.search; 456 delete data.search; 457 } 458 459 // if iOS user and ios data attribute defined 460 if (ios && data.ios) { 461 return { 462 url: 'comgooglemaps://?', 463 data: ios 464 }; 465 } 466 467 if (!ios && data.ios) { 468 delete data.ios; 469 } 470 471 return { 472 url: 'https://maps.google.com/?', 473 data: data, 474 popup: { 475 width: 800, 476 height: 600 477 } 478 }; 479 }, 480 481 482 // set Pinterest share URL 483 pinterest: function pinterest(data) { 484 return { 485 url: 'https://pinterest.com/pin/create/bookmarklet/?', 486 data: data, 487 popup: { 488 width: 745, 489 height: 620 490 } 491 }; 492 }, 493 494 495 // set LinkedIn share URL 496 linkedin: function linkedin(data) { 497 return { 498 url: 'http://www.linkedin.com/shareArticle?', 499 data: data, 500 popup: { 501 width: 780, 502 height: 492 503 } 504 }; 505 }, 506 507 508 // set Buffer share URL 509 buffer: function buffer(data) { 510 return { 511 url: 'http://bufferapp.com/add?', 512 data: data, 513 popup: { 514 width: 745, 515 height: 345 516 } 517 }; 518 }, 519 520 521 // set Tumblr share URL 522 tumblr: function tumblr(data) { 523 return { 524 url: 'https://www.tumblr.com/widgets/share/tool?', 525 data: data, 526 popup: { 527 width: 540, 528 height: 940 529 } 530 }; 531 }, 532 533 534 // set Reddit share URL 535 reddit: function reddit(data) { 536 return { 537 url: 'http://reddit.com/submit?', 538 data: data, 539 popup: { 540 width: 860, 541 height: 880 542 } 543 }; 544 }, 545 546 547 // set Flickr follow URL 548 flickr: function flickr(data) { 549 var ios = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 550 551 // if iOS user 552 if (ios && data.ios) { 553 return { 554 url: 'flickr://photos/' + data.username + '?' 555 }; 556 } 557 return { 558 url: 'http://www.flickr.com/photos/' + data.username + '?', 559 popup: { 560 width: 600, 561 height: 650 562 } 563 }; 564 }, 565 566 567 // set WhatsApp share URL 568 whatsapp: function whatsapp(data) { 569 return { 570 url: 'whatsapp://send?', 571 data: data 572 }; 573 }, 574 575 576 // set sms share URL 577 sms: function sms(data) { 578 var ios = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 579 580 return { 581 url: ios ? 'sms:&' : 'sms:?', 582 data: data 583 }; 584 }, 585 586 587 // set Email share URL 588 email: function email(data) { 589 var url = 'mailto:'; 590 591 // if to address specified then add to URL 592 if (data.to !== null) { 593 url += '' + data.to; 594 } 595 596 url += '?'; 597 598 return { 599 url: url, 600 data: { 601 subject: data.subject, 602 body: data.body 603 } 604 }; 605 }, 606 607 608 // set Github fork URL 609 github: function github(data) { 610 var ios = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 611 // eslint-disable-line no-unused-vars 612 var url = data.repo ? 'https://github.com/' + data.repo : data.url; 613 614 if (data.issue) { 615 url += '/issues/new?title=' + data.issue + '&body=' + data.body; 616 } 617 618 return { 619 url: url + '?', 620 popup: { 621 width: 1020, 622 height: 323 623 } 624 }; 625 }, 626 627 628 // set Dribbble share URL 629 dribbble: function dribbble(data) { 630 var ios = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 631 // eslint-disable-line no-unused-vars 632 var url = data.shot ? 'https://dribbble.com/shots/' + data.shot + '?' : data.url + '?'; 633 return { 634 url: url, 635 popup: { 636 width: 440, 637 height: 640 638 } 639 }; 640 }, 641 codepen: function codepen(data) { 642 var url = data.pen && data.username && data.view ? 'https://codepen.io/' + data.username + '/' + data.view + '/' + data.pen + '?' : data.url + '?'; 643 return { 644 url: url, 645 popup: { 646 width: 1200, 647 height: 800 648 } 649 }; 650 }, 651 paypal: function paypal(data) { 652 return { 653 data: data 654 }; 655 } 656}; 657 658/** 659 * OpenShare generates a single share link 660 */ 661 662var OpenShare = function () { 663 function OpenShare(type, transform) { 664 _classCallCheck(this, OpenShare); 665 666 this.ios = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; 667 this.type = type; 668 this.dynamic = false;
669 this.transform = transform; 670 671 // capitalized type 672 this.typeCaps = type.charAt(0).toUpperCase() + type.slice(1); 673 } 674 675 // returns function named as type set in constructor 676 // e.g twitter() 677 678 679 _createClass(OpenShare, [{ 680 key: 'setData', 681 value: function setData(data) { 682 // if iOS user and ios data attribute defined 683 // build iOS URL scheme as single string 684 if (this.ios) { 685 this.transformData = this.transform(data, true); 686 this.mobileShareUrl = this.template(this.transformData.url, this.transformData.data); 687 } 688 689 this.transformData = this.transform(data); 690 this.shareUrl = this.template(this.transformData.url, this.transformData.data); 691 } 692 693 // open share URL defined in individual platform functions 694 695 }, { 696 key: 'share', 697 value: function share() { 698 var _this = this; 699 700 // if iOS share URL has been set then use timeout hack 701 // test for native app and fall back to web 702 if (this.mobileShareUrl) { 703 var start = new Date().valueOf(); 704 705 setTimeout(function () { 706 var end = new Date().valueOf(); 707 708 // if the user is still here, fall back to web 709 if (end - start > 1600) { 710 return; 711 } 712 713 window.location = _this.shareUrl; 714 }, 1500); 715 716 window.location = this.mobileShareUrl; 717 718 // open mailto links in same window 719 } else if (this.type === 'email') { 720 window.location = this.shareUrl; 721 722 // open social share URLs in new window 723 } else { 724 // if popup object present then set window dimensions / position 725 if (this.popup && this.transformData.popup) { 726 return this.openWindow(this.shareUrl, this.transformData.popup); 727 } 728 729 window.open(this.shareUrl); 730 } 731 } 732 733 // create share URL with GET params 734 // appending valid properties to query string 735 736 }, { 737 key: 'template', 738 value: function template(url, data) { 739 //eslint-disable-line 740 var nonURLProps = ['appendTo', 'innerHTML', 'classes']; 741 742 var shareUrl = url, 743 i = void 0; 744 745 for (i in data) { 746 // only append valid properties 747 if (!data[i] || nonURLProps.indexOf(i) > -1) { 748 continue; //eslint-disable-line 749 } 750 751 // append URL encoded GET param to share URL 752 data[i] = encodeURIComponent(data[i]); 753 shareUrl += i + '=' + data[i] + '&'; 754 } 755 756 return shareUrl.substr(0, shareUrl.length - 1); 757 } 758 759 // center popup window supporting dual screens 760 761 }, { 762 key: 'openWindow', 763 value: function openWindow(url, options) { 764 //eslint-disable-line 765 var dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : screen.left, 766 dualScreenTop = window.screenTop !== undefined ? window.screenTop : screen.top, 767 width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width, 768 //eslint-disable-line 769 height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height, 770 //eslint-disable-line 771 left = width / 2 - options.width / 2 + dualScreenLeft, 772 top = height / 2 - options.height / 2 + dualScreenTop, 773 newWindow = window.open(url, 'OpenShare', 'width=' + options.width + ', height=' + options.height + ', top=' + top + ', left=' + left); 774
775 // Puts focus on the newWindow 776 if (window.focus) { 777 newWindow.focus(); 778 } 779 } 780 }]); 781 782 return OpenShare; 783}(); 784 785function setData(osInstance, osElement) { 786 osInstance.setData({ 787 url: osElement.getAttribute('data-open-share-url'), 788 text: osElement.getAttribute('data-open-share-text'), 789 via: osElement.getAttribute('data-open-share-via'), 790 hashtags: osElement.getAttribute('data-open-share-hashtags'), 791 tweetId: osElement.getAttribute('data-open-share-tweet-id'), 792 related: osElement.getAttribute('data-open-share-related'), 793 screenName: osElement.getAttribute('data-open-share-screen-name'), 794 userId: osElement.getAttribute('data-open-share-user-id'), 795 link: osElement.getAttribute('data-open-share-link'), 796 picture: osElement.getAttribute('data-open-share-picture'), 797 caption: osElement.getAttribute('data-open-share-caption'), 798 description: osElement.getAttribute('data-open-share-description'), 799 user: osElement.getAttribute('data-open-share-user'), 800 video: osElement.getAttribute('data-open-share-video'), 801 username: osElement.getAttribute('data-open-share-username'), 802 title: osElement.getAttribute('data-open-share-title'), 803 media: osElement.getAttribute('data-open-share-media'), 804 to: osElement.getAttribute('data-open-share-to'), 805 subject: osElement.getAttribute('data-open-share-subject'), 806 body: osElement.getAttribute('data-open-share-body'), 807 ios: osElement.getAttribute('data-open-share-ios'), 808 type: osElement.getAttribute('data-open-share-type'), 809 center: osElement.getAttribute('data-open-share-center'), 810 views: osElement.getAttribute('data-open-share-views'), 811 zoom: osElement.getAttribute('data-open-share-zoom'), 812 search: osElement.getAttribute('data-open-share-search'), 813 saddr: osElement.getAttribute('data-open-share-saddr'), 814 daddr: osElement.getAttribute('data-open-share-daddr'), 815 directionsmode: osElement.getAttribute('data-open-share-directions-mode'), 816 repo: osElement.getAttribute('data-open-share-repo'), 817 shot: osElement.getAttribute('data-open-share-shot'), 818 pen: osElement.getAttribute('data-open-share-pen'), 819 view: osElement.getAttribute('data-open-share-view'), 820 issue: osElement.getAttribute('data-open-share-issue'), 821 buttonId: osElement.getAttribute('data-open-share-buttonId'), 822 popUp: osElement.getAttribute('data-open-share-popup'), 823 key: osElement.getAttribute('data-open-share-key') 824 }); 825} 826 827function share(e, os, openShare) { 828 // if dynamic instance then fetch attributes again in case of updates 829 if (openShare.dynamic) { 830 setData(openShare, os); 831 } 832 833 openShare.share(e); 834 835 // trigger shared event 836 Events.trigger(os, 'shared'); 837} 838 839// type contains a dash 840// transform to camelcase for function reference 841// TODO: only supports single dash, should should support multiple 842var dashToCamel = function dashToCamel(dash, type) { 843 var nextChar = type.substr(dash + 1, 1); 844 var group = type.substr(dash, 2); 845 846 type = type.replace(group, nextChar.toUpperCase()); 847 return type; 848}; 849 850function initializeShareNode(os) { 851 // initialize open share object with type attribute 852 var type = os.getAttribute('data-open-share'); 853 var dash = type.indexOf('-'); 854 855 if (dash > -1) { 856 type = dashToCamel(dash, type); 857 } 858 859 var transform = ShareTransforms[type]; 860 861 if (!transform) { 862 throw new Error('Open Share: ' + type + ' is an invalid type'); 863 } 864 865 var openShare = new OpenShare(type, transform); 866 867 // specify if this is a dynamic instance 868 if (os.getAttribute('data-open-share-dynamic')) { 869 openShare.dynamic = true; 870 } 871
872 // specify if this is a popup instance 873 if (os.getAttribute('data-open-share-popup')) { 874 openShare.popup = true; 875 } 876 877 // set all optional attributes on open share instance 878 setData(openShare, os); 879 880 // open share dialog on click 881 os.addEventListener('click', function (e) { 882 share(e, os, openShare); 883 }); 884 885 os.addEventListener('OpenShare.trigger', function (e) { 886 share(e, os, openShare); 887 }); 888 889 os.setAttribute('data-open-share-node', type); 890} 891 892function round(x, precision) { 893 if (typeof x !== 'number') { 894 throw new TypeError('Expected value to be a number'); 895 } 896 897 var exponent = precision > 0 ? 'e' : 'e-'; 898 var exponentNeg = precision > 0 ? 'e-' : 'e'; 899 precision = Math.abs(precision); 900 901 return Number(Math.round(x + exponent + precision) + exponentNeg + precision); 902} 903 904function thousandify(num) { 905 return round(num / 1000, 1) + 'K'; 906} 907 908function millionify(num) { 909 return round(num / 1000000, 1) + 'M'; 910} 911 912function countReduce(el, count, cb) { 913 if (count > 999999) { 914 el.innerHTML = millionify(count); 915 if (cb && typeof cb === 'function') cb(el); 916 } else if (count > 999) { 917 el.innerHTML = thousandify(count); 918 if (cb && typeof cb === 'function') cb(el); 919 } else { 920 el.innerHTML = count; 921 if (cb && typeof cb === 'function') cb(el); 922 } 923} 924 925/* 926 Sometimes social platforms get confused and drop share counts. 927 In this module we check if the returned count is less than the count in 928 localstorage. 929 If the local count is greater than the returned count, 930 we store the local count + the returned count. 931 Otherwise, store the returned count. 932*/ 933 934var storeCount = function storeCount(t, count) { 935 var isArr = t.type.indexOf(',') > -1; 936 var local = Number(t.storeGet(t.type + '-' + t.shared)); 937 938 if (local > count && !isArr) { 939 var latestCount = Number(t.storeGet(t.type + '-' + t.shared + '-latestCount')); 940 t.storeSet(t.type + '-' + t.shared + '-latestCount', count); 941 942 count = isNumeric$1(latestCount) && latestCount > 0 ? count += local - latestCount : count += local; 943 } 944 945 if (!isArr) t.storeSet(t.type + '-' + t.shared, count); 946 return count; 947}; 948 949function isNumeric$1(n) { 950 return !isNaN(parseFloat(n)) && isFinite(n); 951} 952 953/** 954 * Object of transform functions for each openshare api 955 * Transform functions passed into OpenShare instance when instantiated 956 * Return object containing URL and key/value args 957 */ 958var CountTransforms = { 959 960 // facebook count data 961 facebook: function facebook(url) { 962 return { 963 type: 'get', 964 url: 'https://graph.facebook.com/?id=' + url, 965 transform: function transform(xhr) { 966 var fb = JSON.parse(xhr.responseText); 967 968 var count = fb.share && fb.share.share_count || 0; 969 970 return storeCount(this, count); 971 } 972 }; 973 }, 974 975 976 // pinterest count data 977 pinterest: function pinterest(url) { 978 return { 979 type: 'jsonp', 980 url: 'https://api.pinterest.com/v1/urls/count.json?callback=?&url=' + url, 981 transform: function transform(data) { 982 var count = data.count || 0; 983 return storeCount(this, count); 984 } 985 }; 986 }, 987 988 989 // linkedin count data 990 linkedin: function linkedin(url) { 991 return { 992 type: 'jsonp', 993 url: 'https://www.linkedin.com/countserv/count/share?url=' + url + '&format=jsonp&callback=?', 994 transform: function transform(data) { 995 var count = data.count || 0; 996 return storeCount(this, count); 997 } 998 }; 999 }, 1000 1001 1002 // reddit count data 1003 reddit: function reddit(url) { 1004 return { 1005 type: 'get', 1006 url: 'https://www.reddit.com/api/info.json?url=' + url, 1007 transform: function transform(xhr) { 1008 var reddit = JSON.parse(xhr.responseText); 1009 var posts = reddit.data && reddit.data.children || null; 1010 var ups = 0; 1011 1012 if (posts) { 1013 posts.forEach(function (post) { 1014 ups += Number(post.data.ups); 1015 }); 1016 } 1017 1018 return storeCount(this, ups); 1019 } 1020 }; 1021 }, 1022 1023 1024 // google count data 1025 google: function google(url) { 1026 return { 1027 type: 'post', 1028 data: { 1029 method: 'pos.plusones.get', 1030 id: 'p', 1031 params: { 1032 nolog: true, 1033 id: url, 1034 source: 'widget', 1035 userId: '@viewer', 1036 groupId: '@self' 1037 }, 1038 jsonrpc: '2.0', 1039 key: 'p', 1040 apiVersion: 'v1' 1041 }, 1042 url: 'https://clients6.google.com/rpc', 1043 transform: function transform(xhr) { 1044 var google = JSON.parse(xhr.responseText); 1045 var count = google.result && google.result.metadata && google.result.metadata.globalCounts && google.result.metadata.globalCounts.count || 0; 1046 return storeCount(this, count); 1047 } 1048 }; 1049 }, 1050 1051 1052 // github star count 1053 githubStars: function githubStars(repo) { 1054 repo = repo.indexOf('github.com/') > -1 ? repo.split('github.com/')[1] : repo; 1055 return { 1056 type: 'get', 1057 url: 'https://api.github.com/repos/' + repo, 1058 transform: function transform(xhr) { 1059 var count = JSON.parse(xhr.responseText).stargazers_count || 0; 1060 return storeCount(this, count); 1061 } 1062 }; 1063 }, 1064 1065 1066 // github forks count 1067 githubForks: function githubForks(repo) { 1068 repo = repo.indexOf('github.com/') > -1 ? repo.split('github.com/')[1] : repo; 1069 return { 1070 type: 'get', 1071 url: 'https://api.github.com/repos/' + repo, 1072 transform: function transform(xhr) { 1073 var count = JSON.parse(xhr.responseText).forks_count || 0; 1074 return storeCount(this, count); 1075 } 1076 }; 1077 }, 1078 1079 1080 // github watchers count 1081 githubWatchers: function githubWatchers(repo) { 1082 repo = repo.indexOf('github.com/') > -1 ? repo.split('github.com/')[1] : repo; 1083 return { 1084 type: 'get', 1085 url: 'https://api.github.com/repos/' + repo, 1086 transform: function transform(xhr) { 1087 var count = JSON.parse(xhr.responseText).watchers_count || 0; 1088 return storeCount(this, count); 1089 } 1090 }; 1091 }, 1092 1093 1094 // dribbble likes count 1095 dribbble: function dribbble(shot) { 1096 shot = shot.indexOf('dribbble.com/shots') > -1 ? shot.split('shots/')[1] : shot; 1097 var url = 'https://api.dribbble.com/v1/shots/' + shot + '/likes'; 1098 return { 1099 type: 'get', 1100 url: url, 1101 transform: function transform(xhr, Events) { 1102 var _this2 = this; 1103 1104 var count = JSON.parse(xhr.responseText).length; 1105 1106 // at this time dribbble limits a response of 12 likes per page 1107 if (count === 12) { 1108 var page = 2; 1109 recursiveCount(url, page, count, function (finalCount) {
1110 if (_this2.appendTo && typeof _this2.appendTo !== 'function') { 1111 _this2.appendTo.appendChild(_this2.os); 1112 } 1113 countReduce(_this2.os, finalCount, _this2.cb); 1114 Events.trigger(_this2.os, 'counted-' + _this2.url); 1115 return storeCount(_this2, finalCount); 1116 }); 1117 } else { 1118 return storeCount(this, count); 1119 } 1120 } 1121 }; 1122 }, 1123 twitter: function twitter(url) { 1124 return { 1125 type: 'get', 1126 url: 'https://public.newsharecounts.com/count.json?url=' + url, 1127 transform: function transform(xhr) { 1128 var count = JSON.parse(xhr.responseText).count || 0; 1129 return storeCount(this, count); 1130 } 1131 }; 1132 } 1133}; 1134 1135function recursiveCount(url, page, count, cb) { 1136 var xhr = new XMLHttpRequest(); 1137 xhr.open('GET', url + '?page=' + page); 1138 xhr.addEventListener('load', function () { 1139 //eslint-disable-line 1140 var likes = JSON.parse(this.response); 1141 count += likes.length; 1142 1143 // dribbble like per page is 12 1144 if (likes.length === 12) { 1145 page++; 1146 recursiveCount(url, page, count, cb); 1147 } else { 1148 cb(count); 1149 } 1150 }); 1151 xhr.send(); 1152} 1153 1154/** 1155 * Generate share count instance from one to many networks 1156 */ 1157 1158var Count = function () { 1159 function Count(type, url) { 1160 var _this3 = this; 1161 1162 _classCallCheck(this, Count); 1163 1164 // throw error if no url provided 1165 if (!url) { 1166 throw new Error('Open Share: no url provided for count'); 1167 } 1168 1169 // check for Github counts 1170 if (type.indexOf('github') === 0) { 1171 if (type === 'github-stars') { 1172 type = 'githubStars'; 1173 } else if (type === 'github-forks') { 1174 type = 'githubForks'; 1175 } else if (type === 'github-watchers') { 1176 type = 'githubWatchers'; 1177 } else { 1178 console.error('Invalid Github count type. Try github-stars, github-forks, or github-watchers.'); 1179 } 1180 } 1181 1182 // if type is comma separate list create array 1183 if (type.indexOf(',') > -1) { 1184 this.type = type; 1185 this.typeArr = this.type.split(','); 1186 this.countData = []; 1187 1188 // check each type supplied is valid 1189 this.typeArr.forEach(function (t) { 1190 if (!CountTransforms[t]) { 1191 throw new Error('Open Share: ' + type + ' is an invalid count type'); 1192 } 1193 1194 _this3.countData.push(CountTransforms[t](url)); 1195 }); 1196 1197 var count = this.storeGet(this.type + '-' + this.shared); 1198 1199 if (count) { 1200 if (this.appendTo && typeof this.appendTo !== 'function') { 1201 this.appendTo.appendChild(this.os); 1202 } 1203 countReduce(this.os, count); 1204 } 1205 1206 // throw error if invalid type provided 1207 } else if (!CountTransforms[type]) { 1208 throw new Error('Open Share: ' + type + ' is an invalid count type'); 1209 1210 // single count 1211 // store count URL and transform function 1212 } else { 1213 this.type = type; 1214 this.countData = CountTransforms[type](url); 1215 } 1216 } 1217 1218 // handle calling getCount / getCounts 1219 // depending on number of types 1220 1221 1222 _createClass(Count, [{ 1223 key: 'count', 1224 value: function count(os, cb, appendTo) { 1225 this.os = os; 1226 this.appendTo = appendTo; 1227 this.cb = cb; 1228 this.url = this.os.getAttribute('data-open-share-count'); 1229 this.shared = this.os.getAttribute('data-open-share-count-url'); 1230 this.key = this.os.getAttribute('data-open-share-key'); 1231 1232 if (!Array.isArray(this.countData)) { 1233 this.getCount(); 1234 } else { 1235 this.getCounts(); 1236 } 1237 } 1238 1239 // fetch count either AJAX or JSONP 1240 1241 }, { 1242 key: 'getCount', 1243 value: function getCount() { 1244 var count = this.storeGet(this.type + '-' + this.shared); 1245 1246 if (count) { 1247 if (this.appendTo && typeof this.appendTo !== 'function') { 1248 this.appendTo.appendChild(this.os); 1249 } 1250 countReduce(this.os, count); 1251 } 1252 this[this.countData.type](this.countData); 1253 } 1254 1255 // fetch multiple counts and aggregate 1256 1257 }, { 1258 key: 'getCounts', 1259 value: function getCounts() { 1260 var _this4 = this; 1261 1262 this.total = []; 1263 1264 var count = this.storeGet(this.type + '-' + this.shared); 1265 1266 if (count) { 1267 if (this.appendTo && typeof this.appendTo !== 'function') { 1268 this.appendTo.appendChild(this.os); 1269 } 1270 countReduce(this.os, count); 1271 } 1272 1273 this.countData.forEach(function (countData) { 1274 _this4[countData.type](countData, function (num) { 1275 _this4.total.push(num); 1276 1277 // total counts length now equals type array length 1278 // so aggregate, store and insert into DOM 1279 if (_this4.total.length === _this4.typeArr.length) { 1280 var tot = 0; 1281 1282 _this4.total.forEach(function (t) { 1283 tot += t; 1284 }); 1285 1286 if (_this4.appendTo && typeof _this4.appendTo !== 'function') { 1287 _this4.appendTo.appendChild(_this4.os); 1288 } 1289 1290 var local = Number(_this4.storeGet(_this4.type + '-' + _this4.shared)); 1291 if (local > tot) { 1292 // const latestCount = Number(this.storeGet(`${this.type}-${this.shared}-latestCount`)); 1293 // this.storeSet(`${this.type}-${this.shared}-latestCount`, tot); 1294 // 1295 // tot = isNumeric(latestCount) && latestCount > 0 ? 1296 // tot += local - latestCount : 1297 // tot += local; 1298 tot = local; 1299 } 1300 _this4.storeSet(_this4.type + '-' + _this4.shared, tot); 1301 1302 countReduce(_this4.os, tot); 1303 } 1304 }); 1305 }); 1306 1307 if (this.appendTo && typeof this.appendTo !== 'function') { 1308 this.appendTo.appendChild(this.os); 1309 } 1310 } 1311 1312 // handle JSONP requests 1313 1314 }, { 1315 key: 'jsonp', 1316 value: function jsonp(countData, cb) { 1317 var _this5 = this; 1318 1319 // define random callback and assign transform function 1320 var callback = Math.random().toString(36).substring(7).replace(/[^a-zA-Z]/g, ''); 1321 window[callback] = function (data) { 1322 var count = countData.transform.apply(_this5, [data]) || 0; 1323 1324 if (cb && typeof cb === 'function') { 1325 cb(count); 1326 } else { 1327 if (_this5.appendTo && typeof _this5.appendTo !== 'function') { 1328 _this5.appendTo.appendChild(_this5.os); 1329 } 1330 countReduce(_this5.os, count, _this5.cb); 1331 } 1332 1333 Events.trigger(_this5.os, 'counted-' + _this5.url); 1334 }; 1335 1336 // append JSONP script tag to page 1337 var script = document.createElement('script'); 1338 script.src = countData.url.replace('callback=?', 'callback=' + callback); 1339 document.getElementsByTagName('head')[0].appendChild(script); 1340 1341 return; 1342 } 1343 1344 // handle AJAX GET request 1345 1346 }, { 1347 key: 'get', 1348 value: function get(countData, cb) { 1349 var _this6 = this; 1350 1351 var xhr = new XMLHttpRequest(); 1352 1353 // on success pass response to transform function 1354 xhr.onreadystatechange = function () { 1355 if (xhr.readyState === 4) { 1356 if (xhr.status === 200) { 1357 var count = countData.transform.apply(_this6, [xhr, Events]) || 0; 1358 1359 if (cb && typeof cb === 'function') { 1360 cb(count); 1361 } else { 1362 if (_this6.appendTo && typeof _this6.appendTo !== 'function') { 1363 _this6.appendTo.appendChild(_this6.os); 1364 } 1365 countReduce(_this6.os, count, _this6.cb); 1366 } 1367 1368 Events.trigger(_this6.os, 'counted-' + _this6.url); 1369 return; 1370 } else if (countData.url.toLowerCase().indexOf('https://api.openshare.social/job?') === 0) { 1371 console.warn('Please sign up for Twitter counts at https://openshare.social/twitter/auth'); 1372 var _count = 0; 1373 1374 if (cb && typeof cb === 'function') { 1375 cb(_count); 1376 } else { 1377 if (_this6.appendTo && typeof _this6.appendTo !== 'function') { 1378 _this6.appendTo.appendChild(_this6.os); 1379 } 1380 countReduce(_this6.os, _count, _this6.cb); 1381 } 1382 1383 Events.trigger(_this6.os, 'counted-' + _this6.url); 1384 } else { 1385 console.warn('Failed to get API data from', countData.url, '. Please use the latest version of OpenShare.'); 1386 var _count2 = 0; 1387 1388 if (cb && typeof cb === 'function') { 1389 cb(_count2); 1390 } else { 1391 if (_this6.appendTo && typeof _this6.appendTo !== 'function') { 1392 _this6.appendTo.appendChild(_this6.os); 1393 } 1394 countReduce(_this6.os, _count2, _this6.cb); 1395 } 1396 1397 Events.trigger(_this6.os, 'counted-' + _this6.url); 1398 } 1399 } 1400 }; 1401 1402 countData.url = countData.url.startsWith('https://api.openshare.social/job?') && this.key ? countData.url + this.key : countData.url; 1403 1404 xhr.open('GET', countData.url); 1405 xhr.send(); 1406 } 1407 1408 // handle AJAX POST request 1409 1410 }, { 1411 key: 'post', 1412 value: function post(countData, cb) { 1413 var _this7 = this; 1414 1415 var xhr = new XMLHttpRequest(); 1416 1417 // on success pass response to transform function 1418 xhr.onreadystatechange = function () { 1419 if (xhr.readyState !== XMLHttpRequest.DONE || xhr.status !== 200) { 1420 return; 1421 } 1422 1423 var count = countData.transform.apply(_this7, [xhr]) || 0; 1424 1425 if (cb && typeof cb === 'function') { 1426 cb(count); 1427 } else { 1428 if (_this7.appendTo && typeof _this7.appendTo !== 'function') { 1429 _this7.appendTo.appendChild(_this7.os); 1430 } 1431 countReduce(_this7.os, count, _this7.cb); 1432 } 1433 Events.trigger(_this7.os, 'counted-' + _this7.url); 1434 }; 1435 1436 xhr.open('POST', countData.url); 1437 xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8'); 1438 xhr.send(JSON.stringify(countData.data)); 1439 } 1440 }, { 1441 key: 'storeSet', 1442 value: function storeSet(type) { 1443 var count = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; 1444 //eslint-disable-line 1445 if (!window.localStorage || !type) { 1446 return; 1447 } 1448 1449 localStorage.setItem('OpenShare-' + type, count); 1450 } 1451 }, { 1452 key: 'storeGet', 1453 value: function storeGet(type) { 1454 //eslint-disable-line 1455 if (!window.localStorage || !type) { 1456 return; 1457 } 1458 1459 return localStorage.getItem('OpenShare-' + type); 1460 } 1461 }]); 1462 1463 return Count; 1464}(); 1465 1466function initializeCountNode(os) { 1467 // initialize open share object with type attribute 1468 var type = os.getAttribute('data-open-share-count'); 1469 var url = os.getAttribute('data-open-share-count-repo') || os.getAttribute('data-open-share-count-shot') || os.getAttribute('data-open-share-count-url'); 1470 var count = new Count(type, url); 1471 1472 count.count(os); 1473 os.setAttribute('data-open-share-node', type); 1474} 1475
1476function init() { 1477 init$1({ 1478 selector: { 1479 share: '[data-open-share]:not([data-open-share-node])', 1480 count: '[data-open-share-count]:not([data-open-share-node])' 1481 }, 1482 cb: { 1483 share: initializeShareNode, 1484 count: initializeCountNode 1485 } 1486 })(); 1487} 1488var DataAttr = function DataAttr() { 1489 if (document.readyState === 'complete') { 1490 return init(); 1491 } 1492 document.addEventListener('readystatechange', function () { 1493 if (document.readyState === 'complete') { 1494 init(); 1495 } 1496 }, false); 1497}; 1498 1499/** 1500 * Global OpenShare API to generate instances programmatically 1501 */ 1502var ShareAPI = function ShareAPI() { 1503 // global OpenShare referencing internal class for instance generation 1504 var OpenShare$$1 = function () { 1505 function OpenShare$$1(data, element) { 1506 var _this8 = this; 1507 1508 _classCallCheck(this, OpenShare$$1); 1509 1510 if (!data.bindClick) data.bindClick = true; 1511 1512 var dash = data.type.indexOf('-'); 1513 1514 if (dash > -1) { 1515 data.type = dashToCamel(dash, data.type); 1516 } 1517 1518 var node = void 0; 1519 this.element = element; 1520 this.data = data; 1521 1522 this.os = new OpenShare(data.type, ShareTransforms[data.type]); 1523 this.os.setData(data); 1524 1525 if (!element || data.element) { 1526 element = data.element; 1527 node = document.createElement(element || 'a'); 1528 if (data.type) { 1529 node.classList.add('open-share-link', data.type); 1530 node.setAttribute('data-open-share', data.type); 1531 node.setAttribute('data-open-share-node', data.type); 1532 } 1533 if (data.innerHTML) node.innerHTML = data.innerHTML; 1534 } 1535 if (node) element = node; 1536 1537 if (data.bindClick) { 1538 element.addEventListener('click', function () { 1539 _this8.share(); 1540 }); 1541 } 1542 1543 if (data.appendTo) { 1544 data.appendTo.appendChild(element); 1545 } 1546 1547 if (data.classes && Array.isArray(data.classes)) { 1548 data.classes.forEach(function (cssClass) { 1549 element.classList.add(cssClass); 1550 }); 1551 } 1552 1553 if (data.type.toLowerCase() === 'paypal') { 1554 var action = data.sandbox ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr'; 1555 1556 var buyGIF = data.sandbox ? 'https://www.sandbox.paypal.com/en_US/i/btn/btn_buynow_LG.gif' : 'https://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif'; 1557 1558 var pixelGIF = data.sandbox ? 'https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif' : 'https://www.paypalobjects.com/en_US/i/scr/pixel.gif'; 1559 1560 var paypalButton = '<form action=' + action + ' method="post" target="_blank">\n\n <!-- Saved buttons use the "secure click" command -->\n <input type="hidden" name="cmd" value="_s-xclick">\n\n <!-- Saved buttons are identified by their button IDs -->\n <input type="hidden" name="hosted_button_id" value="' + data.buttonId + '">\n\n <!-- Saved buttons display an appropriate button image. -->\n <input type="image" name="submit"\n src=' + buyGIF + '\n alt="PayPal - The safer, easier way to pay online">\n <img alt="" width="1" height="1"\n src=' + pixelGIF + ' >\n\n </form>'; 1561 1562 var hiddenDiv = document.createElement('div'); 1563 hiddenDiv.style.display = 'none'; 1564 hiddenDiv.innerHTML = paypalButton; 1565 document.body.appendChild(hiddenDiv); 1566 1567 this.paypal = hiddenDiv.querySelector('form'); 1568 } 1569 1570 this.element = element; 1571 return element; 1572 } 1573 1574 // public share method to trigger share programmatically 1575 1576 1577 _createClass(OpenShare$$1, [{ 1578 key: 'share', 1579 value: function share(e) { 1580 // if dynamic instance then fetch attributes again in case of updates 1581 if (this.data.dynamic) { 1582 //eslint-disable-next-line 1583 this.os.setData(data); // data is not defined 1584 } 1585 1586 if (this.data.type.toLowerCase() === 'paypal') { 1587 this.paypal.submit(); 1588 } else this.os.share(e); 1589 1590 Events.trigger(this.element, 'shared'); 1591 } 1592 }]); 1593 1594 return OpenShare$$1; 1595 }(); 1596 1597 return OpenShare$$1; 1598}; 1599 1600/** 1601 * count API 1602 */ 1603 1604var CountAPI = function CountAPI() { 1605 //eslint-disable-line
1606 // global OpenShare referencing internal class for instance generation 1607 var Count$$1 = function Count$$1(_ref, cb) { 1608 var type = _ref.type, 1609 url = _ref.url, 1610 _ref$appendTo = _ref.appendTo, 1611 appendTo = _ref$appendTo === undefined ? false : _ref$appendTo, 1612 element = _ref.element, 1613 classes = _ref.classes, 1614 _ref$key = _ref.key, 1615 key = _ref$key === undefined ? null : _ref$key; 1616 1617 _classCallCheck(this, Count$$1); 1618 1619 var countNode = document.createElement(element || 'span'); 1620 1621 countNode.setAttribute('data-open-share-count', type); 1622 countNode.setAttribute('data-open-share-count-url', url); 1623 if (key) countNode.setAttribute('data-open-share-key', key); 1624 1625 countNode.classList.add('open-share-count'); 1626 1627 if (classes && Array.isArray(classes)) { 1628 classes.forEach(function (cssCLass) { 1629 countNode.classList.add(cssCLass); 1630 }); 1631 } 1632 1633 if (appendTo) { 1634 return new Count(type, url).count(countNode, cb, appendTo); 1635 } 1636 1637 return new Count(type, url).count(countNode, cb); 1638 }; 1639 1640 return Count$$1; 1641}; 1642 1643var browser = function browser() { 1644 DataAttr(OpenShare, Count, ShareTransforms, Events); 1645 window.OpenShare = { 1646 share: ShareAPI(OpenShare, ShareTransforms, Events), 1647 count: CountAPI(), 1648 analytics: analytics 1649 }; 1650}; 1651var browser_js = browser(); 1652 1653module.exports = browser_js; 1654 1655},{}]},{},[1]);
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.