(function (global, factory) { if (typeof exports === 'object' && typeof module !== 'undefined') { module.exports = factory(); } else if (typeof define === 'function' && define.amd) { define([], factory); } else { if (typeof exports === 'object') { exports.WebflowTools = factory(); } else { global.WebflowTools = factory(); } } }(self, function () { 'use strict'; var exports = {}; exports.URLS = {}; exports.SUMMARY_ATTR = 'summary'; exports.TITLE_ATTR = 'title'; exports.SHARE_URL_ATTR = 'r-share-url'; exports.SHARE_FACEBOOK_ATTR = 'r-share-facebook'; exports.SHARE_TWITTER_ATTR = 'r-share-twitter'; exports.SHARE_LINKEDIN_ATTR = 'r-share-linkedin'; exports.SHARE_WHATSAPP_ATTR = 'r-share-whatsapp'; exports.SHARE_URL_ATTR = 'r-share-url'; exports.URLS = { tw: 'https://twitter.com/share?', wa: 'whatsapp://send?', fb: 'https://www.facebook.com/sharer/sharer.php?', in: 'https://www.linkedin.com/shareArticle?mini=true&' }; var _exports = exports; function requireModule(moduleId) { var cachedModule = _exports[moduleId]; if (cachedModule !== undefined) { return cachedModule.exports; } var module = _exports[moduleId] = { exports: {} }; requireModule(moduleId, module, requireModule); return module.exports; } var _requireModule = requireModule; function _require(moduleId) { return _requireModule(moduleId).exports; } (function () { var exports = _exports; function getAttributes(element) { return { title: element.getAttribute(exports.TITLE_ATTR) || '', summary: element.getAttribute(exports.SUMMARY_ATTR) || '' }; } function generateUrl(platform, data) { var params; if (platform === 'fb') { params = { u: window.location.href, title: data.title || document.title }; } else if (platform === 'wa') { params = { text: window.location.href, title: data.title || document.title }; } else { params = { url: window.location.href, title: data.title || document.title, summary: data.summary || '' }; } var queryParams = new URLSearchParams(params).toString(); return exports.URLS[platform] + queryParams; } document.querySelectorAll('[' + exports.SHARE_TWITTER_ATTR + ']').forEach(function (element) { var attributes = getAttributes(element); element.setAttribute('href', generateUrl('tw', attributes)); }); document.querySelectorAll('[' + exports.SHARE_WHATSAPP_ATTR + ']').forEach(function (element) { var attributes = getAttributes(element); element.setAttribute('href', generateUrl('wa', attributes)); }); document.querySelectorAll('[' + exports.SHARE_FACEBOOK_ATTR + ']').forEach(function (element) { var attributes = getAttributes(element); element.setAttribute('href', generateUrl('fb', attributes)); }); document.querySelectorAll('[' + exports.SHARE_LINKEDIN_ATTR + ']').forEach(function (element) { var attributes = getAttributes(element); element.setAttribute('href', generateUrl('in', attributes)); }); document.querySelectorAll('[' + exports.SHARE_URL_ATTR + ']').forEach(function (element) { var currentUrl = window.location.href; element.addEventListener('click', function () { var tempInput = document.createElement('input'); document.body.appendChild(tempInput); tempInput.value = currentUrl; tempInput.select(); tempInput.setSelectionRange(0, 99999); navigator.clipboard.writeText(tempInput.value); document.body.removeChild(tempInput); }); }); })(); return exports; }));