0byt3m1n1
Path:
/
var
/
www
/
clients
/
client38
/
web37
/
web
/
wp-content
/
themes
/
Impreza
/
common
/
js
/
elements
/
[
Home
]
File: sharing.min.js
!function($){"use strict";$us.UsSharing=function(container,options){this.init(container,options)};$us.UsSharing.prototype={init:function(container,options){this.$container=$(container);if(!!this.$container.find('.w-sharing-list').data('content-image')){if($('.l-canvas img:first-child').length){this.sharingImage=$('.l-canvas img:first-child').attr('src')}else{this.sharingImage=''} this.setSharingImage()} if(!this.$container.hasClass('w-sharing-tooltip')){if(this.$container.find('.whatsapp').length&&$.isMobile){this.setWhatsAppUrl(this.$container.find('.whatsapp'))}}else{this.$copy2clipboard=this.$container.find('.w-sharing-item.copy2clipboard');this.selectedText='';this.activeArea='.l-main';if(this.$container.data('sharing-area')==='post_content'){this.activeArea='.w-post-elm.post_content'} this.$container.appendTo("body");$('body').not(this.activeArea).bind('mouseup',function(){var selection=this.getSelection();if(selection===''){this.$container.hide()}}.bind(this));$(this.activeArea).on('mouseup',function(e){var selection=this.getSelection();if(selection!==''){this.selectedText=selection;this.showTooltip(e)}else{this.selectedText='';this.hideTooltip()}}.bind(this));this.$copy2clipboard.on('click',function(){this.copyToClipboard()}.bind(this))}},showTooltip:function(e){this.$container.find('.w-sharing-item').each(function(index,elm){if($(elm).hasClass('copy2clipboard')){return} if($.isMobile&&$(elm).hasClass('whatsapp')){this.setWhatsAppUrl($(elm))} $(elm).attr('href',$(elm).data('url').replace('{{text}}',this.selectedText))}.bind(this));this.$container.css({"display":"inline-block","left":e.pageX,"top":e.pageY-50,})},setSharingImage:function(){this.$container.find('.w-sharing-item').each(function(index,elm){if($(elm).hasClass('copy2clipboard')){return} $(elm).attr('href',$(elm).attr('href').replace('{{image}}',this.sharingImage));if($(elm).attr('data-url')){$(elm).attr('data-url',$(elm).attr('data-url').replace('{{image}}',this.sharingImage))}}.bind(this))},setWhatsAppUrl:function($elm){$elm.attr('href',$elm.attr('href').replace('https://web','https://api'))},hideTooltip:function(){this.$container.hide()},copyToClipboard:function(){var url,el=document.createElement('textarea');if(this.$copy2clipboard.parent().data('sharing-url')!==undefined&&this.$copy2clipboard.parent().data('sharing-url')!==''){url=this.$copy2clipboard.parent().attr('data-sharing-url')}else{url=window.location} el.value=this.selectedText+' '+url;el.setAttribute('readonly','');el.style.position='absolute';el.style.left='-9999px';document.body.appendChild(el);el.select();document.execCommand('copy');document.body.removeChild(el);this.hideTooltip()},getSelection:function(){var selection='';if(window.getSelection){selection=window.getSelection()}else if(document.selection){selection=document.selection.createRange()} return selection.toString().trim()},};$.fn.UsSharing=function(options){return this.each(function(){$(this).data('UsSharing',new $us.UsSharing(this,options))})};$(function(){$('.w-sharing-tooltip, .w-sharing').UsSharing()})}(jQuery)