(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 0; var wrapper = document.createElement('div'); wrapper.classList.add('sharetastic__sprite'); wrapper.innerHTML = SPRITE; if (!spriteExistsOnPage) { document.body.insertBefore(wrapper, document.body.firstChild); } } }, { key: 'getMetaContent', value: function getMetaContent(prop) { var meta = document.querySelector('meta[property="' + prop + '"]'); return meta.getAttribute('content'); } }, { key: 'generateOpenGraph', value: function generateOpenGraph() { return { url: this.element.getAttribute('data-url') || this.getMetaContent('og:url'), title: this.element.getAttribute('data-title') || this.getMetaContent('og:title'), description: this.element.getAttribute('data-description') || this.getMetaContent('og:description'), image: this.element.getAttribute('data-image') || this.getMetaContent('og:image') }; } }, { key: 'generateUrl', value: function generateUrl(append) { if (!this.page.url) return; var prefix = append || ''; return prefix + encodeURIComponent(this.page.url); } }, { key: 'generateTitle', value: function generateTitle(append) { if (!this.page.title) return; var prefix = append || ''; return prefix + encodeURIComponent(this.page.title); } }, { key: 'generateDescription', value: function generateDescription(append) { if (!this.page.description) return; var prefix = append || ''; return prefix + encodeURIComponent(this.page.description); } }, { key: 'generateImage', value: function generateImage(append) { if (!this.page.image) return; var prefix = append || ''; return prefix + encodeURIComponent(this.page.image); } }, { key: 'generateOptions', value: function generateOptions(options) { var defaults = { popup: true, services: { facebook: { order: 0, name: 'Facebook', href: 'https://www.facebook.com/sharer/sharer.php?' + this.generateUrl('u=') + this.generateTitle('&title=') + this.generateDescription('&description='), icon: { width: 32, height: 32, id: 'sharetastic-facebook' } }, instagram: false, twitter: { order: 2, name: 'Twitter', href: 'https://twitter.com/intent/tweet?text=' + this.generateTitle() + this.generateUrl(' - '), icon: { width: 32, height: 32, id: 'sharetastic-twitter' } }, pinterest: { order: 3, name: 'Pinterest', href: 'http://pinterest.com/pin/create/link/?' + this.generateUrl('url=') + this.generateTitle('&description=') + this.generateImage('&media='), icon: { width: 32, height: 32, id: 'sharetastic-pinterest' } }, linkedin: { order: 4, name: 'LinkedIn', href: 'https://www.linkedin.com/shareArticle?mini=true' + this.generateUrl('&url=') + this.generateTitle('&title=') + this.generateDescription('&summary='), icon: { width: 32, height: 32, id: 'sharetastic-linkedin' } }, googleplus: { order: 5, name: 'Google +', href: 'https://plus.google.com/share?' + this.generateUrl('url='), icon: { width: 32, height: 32, id: 'sharetastic-googleplus' } }, flickr: false, tumblr: { order: 7, name: 'Tumblr', href: 'http://www.tumblr.com/share/link?' + this.generateUrl('&url=') + this.generateTitle('&name=') + this.generateDescription('&description='), icon: { width: 32, height: 32, id: 'sharetastic-tumblr' } }, email: { order: 8, name: 'Email', href: 'mailto:?Body=' + this.page.title + '%0A' + this.page.description + '%0A' + this.page.url, icon: { width: 32, height: 32, id: 'sharetastic-email' } }, whatsapp: { order: 8, name: 'WhatsApp', href: 'https://api.whatsapp.com/send?text=' + this.page.title + ' - ' + this.page.description + ' ' + this.page.url, icon: { width: 32, height: 32, id: 'sharetastic-whatsapp' } }, print: { order: 9, name: 'Print', href: 'window.print()', icon: { width: 32, height: 32, id: 'sharetastic-print' } } } }; var exportOptions = $.extend(true, defaults, options); if (this.element.hasAttribute('data-tweet')) { exportOptions.services.twitter.href = 'https://twitter.com/intent/tweet?text=' + encodeURIComponent(this.element.getAttribute('data-tweet')); } return exportOptions; } }, { key: 'popup', value: function popup(url, width, height) { var left = screen.width / 2 - width / 2; var top = screen.height / 2 - height / 2; window.open(url, "", 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,width=' + width + ',height=' + height + ',left=' + left + ',top=' + top); } }, { key: 'build', value: function build() { var _this = this; this.serviceOrder.map(function (key) { var action = key === 'print' ? 'onclick' : 'href'; var link = document.createElement('a'); var self = _this; var service = _this.options.services[key]; link.classList.add('sharetastic__button'); link.classList.add('sharetastic__button--' + key); link.setAttribute(action, service.href); if (key !== 'email') { link.setAttribute('target', '_blank') } link.innerHTML = '' + service.name; if (key !== 'email' && key !== 'print' && _this.options.popup) { link.addEventListener('click', function (e) { e.preventDefault(); self.popup(e.currentTarget.getAttribute('href'), 500, 300); }); } _this.element.appendChild(link); }); } }, { key: 'sort', value: function sort() { var _this2 = this; this.serviceOrder = []; Object.keys(this.options.services).map(function (k, i) { Object.keys(_this2.options.services).map(function (key) { if (_this2.options.services[key].order === i) { _this2.serviceOrder.push(key); } }); }); this.build(); } }]); return Sharetastic; }(); (function (window, $) { $.fn.sharetastic = function (options) { return this.each(function () { var element = $(this); var isInitialized = element.hasClass('sharetastic--initialized'); if (!isInitialized) { new Sharetastic(element[0], options).sort(); } }); }; })(window, jQuery); },{}]},{},[1]);