1/** 2 * Salient Social. 3 * 4 * @author ThemeNectar 5 */ 6 /* global jQuery */ 7 8jQuery(document).ready(function ($) { 9 10 "use strict"; 11 12 function NectarSocial() { 13 14 this.$body = $('body'); 15 this.$window = $(window); 16 this.$wpAdminBar = $('#wpadminbar'); 17 this.usingMobileBrowser = (navigator.userAgent.match(/(Android|iPod|iPhone|iPad|BlackBerry|IEMobile|Opera Mini)/)) ? true : false; 18 19 // Events. 20 this.mouseEvents(); 21 22 // Nectar Love 23 this.nectarLove(); 24 25 // Fixed to bottom social sharing style. 26 if( $('body').find('.nectar-social.fixed').length > 0 ) { 27 this.fixedStyle(); 28 } 29 30 } 31 32 33 NectarSocial.prototype.mouseEvents = function() { 34 35 this.$body.on('click', '#single-below-header .nectar-social a', function () { 36 return false; 37 }); 38 39 $('body.single-product .nectar-social').addClass('woo'); 40 41 this.$body.on('click', '.facebook-share:not(.inactive)', this.facebookShare); 42 this.$body.on('click', '.nectar-social:not(".woo") .twitter-share:not(.inactive)', this.twitterShare); 43 this.$body.on('click', '.nectar-social.woo .twitter-share', this.wooTwitterShare); 44 this.$body.on('click', '.nectar-social:not(".woo") .linkedin-share:not(.inactive)', this.linkedInShare); 45 this.$body.on('click', '.nectar-social.woo .linkedin-share', this.woolinkedInShare); 46 this.$body.on('click', '.nectar-social:not(".woo") .pinterest-share:not(.inactive)', this.pinterestShare); 47 this.$body.on('click', '.nectar-social.woo .pinterest-share', this.wooPinterestShare); 48 49 this.$body.on('click', '.nectar-social.fixed > a', function () { 50 return false; 51 }); 52 53 54 // Hover style 55 // desktop 56 if (!this.usingMobileBrowser) { 57 58 var $socialTimeout; 59 this.$body.on('mouseenter', '.nectar-social.hover .share-btn', function () { 60 61 clearTimeout($socialTimeout); 62 63 64 // Hide other sibling items when needed. 65 if( $(this).parents('[id*="-meta"]').length > 0 ) { 66 $(this).parents('[id*="-meta"]').addClass('social-hovered'); 67 } 68 if( $(this).parents('#single-below-header').length > 0 ) { 69 $(this).parents('#single-below-header').addClass('social-hovered'); 70 } 71 72 $(this).parent().addClass('visible'); 73 74 75 }); 76 77 78 this.$body.on('mouseleave', '.nectar-social.hover', function () { 79 80 var $that = $(this); 81 82 $socialTimeout = setTimeout(function () { 83 84 $that.removeClass('visible'); 85 86 if( $that.parents('[id*="-meta"]').length > 0 ) { 87 $that.parents('[id*="-meta"]').removeClass('social-hovered'); 88 } 89 if( $that.parents('#single-below-header').length > 0 ) { 90 $that.parents('#single-below-header').removeClass('social-hovered'); 91 } 92 93 }, 200); 94 95 }); 96 97 } 98 99 // Click triggered on mobile 100 else { 101 102 this.$body.on('click', '.nectar-social.hover .share-btn', function () { 103 104 // Hide other sibling items when needed. 105 if( $(this).parents('[id*="-meta"]').length > 0 ) { 106 $(this).parents('[id*="-meta"]').addClass('social-hovered'); 107 } 108 if( $(this).parents('#single-below-header').length > 0 ) { 109 $(this).parents('#single-below-header').addClass('social-hovered'); 110 } 111 112 $(this).parent().addClass('visible'); 113 114 return false; 115 }); 116 117 } 118 119 120 }; 121 122 123 124 NectarSocial.prototype.facebookShare = function() { 125 var windowLocation = window.location.href.replace(window.location.hash, ''); 126 window.open('https://www.facebook.com/sharer/sharer.php?u=' + windowLocation, "facebookWindow", "height=380,width=660,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0"); 127 return false; 128 }; 129 130 131 NectarSocial.prototype.facebookShare = function() { 132 var windowLocation = window.location.href.replace(window.location.hash, ''); 133 window.open('https://www.facebook.com/sharer/sharer.php?u=' + windowLocation, "facebookWindow", "height=380,width=660,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0"); 134 return false;
135 }; 136 137 138 NectarSocial.prototype.twitterShare = function() { 139 var windowLocation = window.location.href.replace(window.location.hash, ''); 140 var $pageTitle; 141 142 if ($(".section-title h1").length > 0) { 143 $pageTitle = encodeURIComponent($(".section-title h1").text()); 144 } else { 145 $pageTitle = encodeURIComponent($(document).find("title").text()); 146 } 147 window.open('https://twitter.com/intent/tweet?text=' + $pageTitle + ' ' + windowLocation, "twitterWindow", "height=380,width=660,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0"); 148 return false; 149 }; 150 151 NectarSocial.prototype.wooTwitterShare = function() { 152 var windowLocation = window.location.href.replace(window.location.hash, ''); 153 window.open('https://twitter.com/intent/tweet?text=' + $("h1.product_title").text() + ' ' + windowLocation, "twitterWindow", "height=380,width=660,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0"); 154 return false; 155 }; 156 157 NectarSocial.prototype.linkedInShare = function() { 158 var windowLocation = window.location.href.replace(window.location.hash, ''); 159 var $pageTitle; 160 161 if ($(".section-title h1").length > 0) { 162 $pageTitle = encodeURIComponent($(".section-title h1").text()); 163 } else { 164 $pageTitle = encodeURIComponent($(document).find("title").text()); 165 } 166 window.open('https://www.linkedin.com/sharing/share-offsite/?mini=true&url=' + windowLocation + '&title=' + $pageTitle + '', "linkedInWindow", "height=480,width=660,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0"); 167 return false; 168 }; 169 170 NectarSocial.prototype.woolinkedInShare = function() { 171 var windowLocation = window.location.href.replace(window.location.hash, ''); 172 window.open('https://www.linkedin.com/sharing/share-offsite/?mini=true&url=' + windowLocation + '&title=' + $("h1.product_title").text(), "twitterWindow", "height=380,width=660,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0"); 173 return false; 174 }; 175 176 NectarSocial.prototype.pinterestShare = function() { 177 var windowLocation = window.location.href.replace(window.location.hash, ''); 178 var $sharingImg = ($('.single-portfolio').length > 0 && $('div[data-featured-img]').attr('data-featured-img') != 'empty') ? $('div[data-featured-img]').attr('data-featured-img') : $('#ajax-content-wrap img').first().attr('src'); 179 var $pageTitle; 180 181 if ($(".section-title h1").length > 0) { 182 $pageTitle = encodeURIComponent($(".section-title h1").text()); 183 } else { 184 $pageTitle = encodeURIComponent($(document).find("title").text()); 185 } 186 187 window.open('https://pinterest.com/pin/create/button/?url=' + windowLocation + '&media=' + $sharingImg + '&description=' + $pageTitle, "pinterestWindow", "height=640,width=660,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0"); 188 return false; 189 }; 190 191 NectarSocial.prototype.wooPinterestShare = function () { 192 var $imgToShare = ($('img.attachment-shop_single').length > 0) ? $('img.attachment-shop_single').first().attr('src') : $('.single-product-main-image img').first().attr('src'); 193 var windowLocation = window.location.href.replace(window.location.hash, ''); 194 window.open('https://pinterest.com/pin/create/button/?url=' + windowLocation + '&media=' + $imgToShare + '&description=' + $('h1.product_title').text(), "pinterestWindow", "height=640,width=660,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0"); 195 return false; 196 }; 197 198 199 NectarSocial.prototype.nectarLove = function() { 200 201 this.$body.on('click', '.nectar-love', function () { 202 203 var $loveLink = $(this), 204 $id = $(this).attr('id'), 205 $that = $(this); 206 207 if ($loveLink.hasClass('loved') || $(this).hasClass('inactive')) { 208 return false; 209 } 210 211 var $dataToPass = { 212 action: 'nectar-love', 213 loves_id: $id, 214 love_nonce: window.nectarLove.loveNonce 215 }; 216 217 $.post(window.nectarLove.ajaxurl, $dataToPass, function (data) { 218 $loveLink.find('.nectar-love-count').html(data); 219 $loveLink.addClass('loved').attr('title', 'You already love this!'); 220 $that.find('.icon-salient-heart-2').addClass('loved'); 221 }); 222 223 $(this).addClass('inactive'); 224 225 return false;
226 }); 227 228 }; 229 230 231 232 NectarSocial.prototype.fixedStyle = function() { 233 234 // Move DOM postiion. 235 $('.wpb_wrapper .nectar-social.fixed').each(function(i){ 236 237 // Remove any after first instance. 238 if( i !== 0 ) { 239 $(this).remove(); 240 } else { 241 242 var $fixedMarkup = $(this).clone(); 243 $('body').append($fixedMarkup); 244 $(this).remove(); 245 } 246 247 }); 248 249 function showFixedSharing() { 250 251 if ( $(window).scrollTop() > 150) { 252 253 $('.nectar-social.fixed').addClass('visible'); 254 255 $(window).off('scroll', showFixedSharing); 256 $(window).on('scroll', hideFixedSharing); 257 } 258 259 } 260 261 function hideFixedSharing() { 262 263 if ( $(window).scrollTop() < 150) { 264 265 $('.nectar-social.fixed').removeClass('visible'); 266 267 $(window).off('scroll', hideFixedSharing); 268 $(window).on('scroll', showFixedSharing); 269 } 270 271 } 272 273 if( $('.nectar-social.fixed').length > 0 ) { 274 275 if ( $(window).width() < 1000 ) { 276 if ( $(window).scrollTop() > 150) { 277 $(window).on('scroll', hideFixedSharing); 278 } else { 279 $(window).on('scroll', showFixedSharing); 280 } 281 } 282 283 $(window).on('smartresize',function () { 284 285 if ( $(window).width() > 1000) { 286 $('.nectar-social.fixed').addClass('visible'); 287 } else if ( $(window).scrollTop() < 150) { 288 $(window).off('scroll', hideFixedSharing); 289 $(window).on('scroll', showFixedSharing); 290 $('.nectar-social.fixed').removeClass('visible'); 291 } else { 292 $(window).off('scroll', showFixedSharing); 293 $(window).on('scroll', hideFixedSharing); 294 } 295 296 }); 297 298 } 299 300 }; 301 302 303 var nectarSocialInit = new NectarSocial(); 304 305 window.NectarSocial = NectarSocial; 306 307 308});
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.