1/** 2 * Easy Social Share Buttons for WordPress Core Javascript 3 * 4 * @package EasySocialShareButtons 5 * @author appscreo 6 * @since 5.0 7 */ 8 9/** 10 * jQuery function extension package for Easy Social Share Buttons 11 */ 12jQuery(document).ready(function ($) { 13 "use strict"; 14 15 jQuery.fn.essb_toggle_more = function () { 16 return this.each(function () { 17 $(this).removeClass('essb_after_more'); 18 $(this).addClass('essb_before_less'); 19 }); 20 }; 21 22 jQuery.fn.essb_toggle_less = function () { 23 return this.each(function () { 24 $(this).addClass('essb_after_more'); 25 $(this).removeClass('essb_before_less'); 26 }); 27 }; 28 29 jQuery.fn.extend({ 30 center: function () { 31 return this.each(function () { 32 var top = (jQuery(window).height() - jQuery(this).outerHeight()) / 2; 33 var left = (jQuery(window).width() - jQuery(this).outerWidth()) / 2; 34 jQuery(this).css({ position: 'fixed', margin: 0, top: (top > 0 ? top : 0) + 'px', left: (left > 0 ? left : 0) + 'px' }); 35 }); 36 } 37 }); 38 39}); 40 41(function ($) { 42 $.fn.countTo = function (options) { 43 options = options || {}; 44 45 return $(this).each(function () { 46 // set options for current element 47 var settings = $.extend({}, $.fn.countTo.defaults, { 48 from: $(this).data('from'), 49 to: $(this).data('to'), 50 speed: $(this).data('speed'), 51 refreshInterval: $(this).data('refresh-interval'), 52 decimals: $(this).data('decimals') 53 }, options); 54 55 // how many times to update the value, and how much to increment the value on each update 56 var loops = Math.ceil(settings.speed / settings.refreshInterval), 57 increment = (settings.to - settings.from) / loops; 58 59 // references & variables that will change with each update 60 var self = this, 61 $self = $(this), 62 loopCount = 0, 63 value = settings.from, 64 data = $self.data('countTo') || {}; 65 66 $self.data('countTo', data); 67 68 // if an existing interval can be found, clear it first 69 if (data.interval) { 70 clearInterval(data.interval); 71 } 72 data.interval = setInterval(updateTimer, settings.refreshInterval); 73 74 // initialize the element with the starting value 75 render(value); 76 77 function updateTimer() { 78 value += increment; 79 loopCount++; 80 81 render(value); 82 83 if (typeof (settings.onUpdate) == 'function') { 84 settings.onUpdate.call(self, value); 85 } 86 87 if (loopCount >= loops) { 88 // remove the interval 89 $self.removeData('countTo'); 90 clearInterval(data.interval); 91 value = settings.to; 92 93 if (typeof (settings.onComplete) == 'function') { 94 settings.onComplete.call(self, value); 95 } 96 } 97 } 98 99 function render(value) { 100 var formattedValue = settings.formatter.call(self, value, settings); 101 $self.text(formattedValue); 102 } 103 }); 104 }; 105 106 $.fn.countTo.defaults = { 107 from: 0, // the number the element should start at 108 to: 0, // the number the element should end at 109 speed: 1000, // how long it should take to count between the target numbers 110 refreshInterval: 100, // how often the element should be updated 111 decimals: 0, // the number of decimal places to show 112 formatter: formatter, // handler for formatting the value before rendering 113 onUpdate: null, // callback method for every time the element is updated 114 onComplete: null // callback method for when the element finishes updating 115 }; 116 117 function formatter(value, settings) { 118 return value.toFixed(settings.decimals); 119 } 120 121 122 123}(jQuery)); 124 125(function ($) { 126 "use strict"; 127 128 /** 129 * Easy Social Share Buttons for WordPress 130 * 131 * @package EasySocialShareButtons 132 * @since 5.0 133 * @author appscreo 134 */ 135 var essb = window.essb = {}; 136 137 var debounce = function (func, wait) { 138 var timeout, args, context, timestamp; 139 return function () { 140 context = this; 141 args = [].slice.call(arguments, 0); 142 timestamp = new Date(); 143 var later = function () { 144 var last = (new Date()) - timestamp; 145 if (last < wait) { 146 timeout = setTimeout(later, wait - last); 147 } else { 148 timeout = null;
149 func.apply(context, args); 150 } 151 }; 152 if (!timeout) { 153 timeout = setTimeout(later, wait); 154 } 155 }; 156 }; 157 158 var isElementInViewport = function (el) { 159 160 //special bonus for those using jQuery 161 if (typeof jQuery === "function" && el instanceof jQuery) { 162 el = el[0]; 163 } 164 165 var rect = el.getBoundingClientRect(); 166 167 return ( 168 rect.top >= 0 && 169 rect.left >= 0 && 170 rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && /*or $(window).height() */ 171 rect.right <= (window.innerWidth || document.documentElement.clientWidth) /*or $(window).width() */ 172 ); 173 }; 174 175 var isVisibleSelector = function (selector) { 176 var top_of_element = $(selector).offset().top; 177 var bottom_of_element = $(selector).offset().top + $(selector).outerHeight(); 178 var bottom_of_screen = $(window).scrollTop() + $(window).innerHeight(); 179 var top_of_screen = $(window).scrollTop(); 180 181 if ((bottom_of_screen > top_of_element) && (top_of_screen < bottom_of_element)) { 182 return true; 183 } else { 184 return false; 185 } 186 }; 187 188 essb.add_event = function (eventID, user_function) { 189 if (!essb.events) essb.events = {}; 190 essb.events[eventID] = user_function; 191 }; 192 193 essb.trigger = function (eventID, options) { 194 if (!essb.events) return; 195 if (essb.events[eventID]) essb.events[eventID](options); 196 }; 197 198 essb.window = function (url, service, instance, trackingOnly) { 199 var element = $('.essb_' + instance), 200 instance_post_id = $(element).attr('data-essb-postid') || '', 201 instance_position = $(element).attr('data-essb-position') || '', 202 wnd, 203 isMobile = $(window).width() <= 1024 ? true : false, 204 keyWin = 'essb_share_window' + (isMobile) + '-' + (Date.now()).toString(); 205 206 var w = (service == 'twitter') ? '500' : '800', 207 h = (service == 'twitter') ? '300' : '500', 208 left = (screen.width / 2) - (Number(w) / 2), 209 top = (screen.height / 2) - (Number(h) / 2); 210 211 if (typeof essbShareWindowURLFilter != 'undefined') 212 url = essbShareWindowURLFilter(service, url, instance_post_id, instance_position); 213 214 if (!trackingOnly) 215 wnd = window.open(url, keyWin, "height=" + (service == 'twitter' ? '500' : '500') + ",width=" + (service == 'twitter' ? '500' : '800') + ",resizable=1,scrollbars=yes,top=" + top + ",left=" + left); 216 217 218 if (typeof (essb_settings) != "undefined") { 219 if (essb_settings.essb3_stats) { 220 essb.handleInternalStats(service, instance_post_id, instance); 221 } 222 223 if (essb_settings.essb3_ga) 224 essb_ga_tracking(service, url, instance_position); 225 226 if (essb_settings.essb3_ga_ntg && typeof (gtag) != 'undefined') { 227 gtag('event', 'social share', { 228 'event_category': 'NTG social', 229 'event_label': service, 230 'non_interaction': false 231 }); 232 } 233 234 } 235 236 if (typeof (essb_settings) != 'undefined') { 237 if (typeof (essb_settings.stop_postcount) == 'undefined') essb_self_postcount(service, instance_post_id); 238 } 239 240 if (typeof (essb_abtesting_logger) != "undefined") 241 essb_abtesting_logger(service, instance_post_id, instance); 242 243 if (typeof (essb_conversion_tracking) != 'undefined') 244 essb_conversion_tracking(service, instance_post_id, instance); 245 246 if (service == 'pinpro' || service == 'pinterest') { 247 if (document.querySelector('.essb-pinterest-follow-box-container')) { 248 var pinProFollowTrigger = document.querySelector('.essb-pinterest-follow-box-container').getAttribute('data-trigger') || '', 249 canTrigger = true; 250 251 if (pinProFollowTrigger == 'pinpro' && service != 'pinpro') canTrigger = false; 252 if (pinProFollowTrigger == 'content' && service != 'pinterest') canTrigger = false; 253 254 if (canTrigger && typeof (window.essbDisplayPinterestFollowBox) != 'undefined') 255 window.essbDisplayPinterestFollowBox(); 256 257 258 259 } 260 } 261 262 if (!trackingOnly) 263 var pollTimer = window.setInterval(function () { 264 if (wnd.closed !== false) { 265 window.clearInterval(pollTimer); 266 essb_smart_onclose_events(service, instance_post_id); 267 268 if (instance_position == 'booster' && typeof (essb_booster_close_from_action) != 'undefined') 269 essb_booster_close_from_action(); 270 } 271 }, 200); 272 273 }; 274 275 essb.share_window = function (url, custom_position, service) { 276 var w = '800', h = '500', left = (screen.width / 2) - (Number(w) / 2), top = (screen.height / 2) - (Number(h) / 2); 277 wnd = window.open(url, "essb_share_window", "height=" + '500' + ",width="
277+ '800' + ",resizable=1,scrollbars=yes,top=" + top + ",left=" + left); 278 279 if (typeof (essb_settings) != "undefined") { 280 if (essb_settings.essb3_stats) { 281 essb.handleLogInternalStats(service, essb_settings["post_id"] || '', custom_position); 282 } 283 284 if (essb_settings.essb3_ga) 285 essb_ga_tracking(service, url, custom_position); 286 287 if (essb_settings.essb3_ga_ntg && gtag) { 288 gtag('event', 'social share', { 289 'event_category': 'NTG social', 290 'event_label': service, 291 'non_interaction': false 292 }); 293 } 294 } 295 }; 296 297 essb.fbmessenger = function (app_id, url, saltKey) { 298 var isMobile = $(window).width() <= 1024 ? true : false, 299 cmd = ''; 300 301 if (isMobile) cmd = 'fb-messenger://share/?link=' + url; 302 else cmd = 'https://www.facebook.com/dialog/send?app_id=' + app_id + '&link=' + url + '&redirect_uri=https://facebook.com'; 303 if (isMobile) { 304 window.open(cmd, "_self"); 305 essb.tracking_only('', 'messenger', saltKey, true); 306 } 307 else { 308 essb.window(cmd, 'messenger', saltKey); 309 } 310 311 return false; 312 }; 313 314 essb.whatsapp = function (url, saltKey) { 315 var isMobile = $(window).width() <= 1024 ? true : false, 316 cmd = ''; 317 318 if (isMobile) cmd = 'whatsapp://send?text=' + url; 319 else cmd = 'https://web.whatsapp.com/send?text=' + url; 320 if (isMobile) { 321 window.open(cmd, "_self"); 322 essb.tracking_only('', 'whatsapp', saltKey, true); 323 } 324 else { 325 essb.window(cmd, 'whatsapp', saltKey); 326 } 327 328 return false; 329 }; 330 331 essb.sms = function (url, saltKey) { 332 var iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream, 333 cmd = 'sms:' + (iOS ? '&' : '?') + 'body=' + url; 334 window.open(cmd, "_self"); 335 essb.tracking_only('', 'sms', saltKey, true); 336 337 return false; 338 }; 339 340 essb.tracking_only = function (url, service, instance, afterShare) { 341 if (url == '') 342 url = document.URL; 343 344 essb.window(url, service, instance, true); 345 346 var element = $('.essb_' + instance), 347 instance_position = $(element).attr('data-essb-position') || ''; 348 349 if (afterShare) { 350 setTimeout(function () { 351 var instance_post_id = $('.essb_' + instance).attr('data-essb-postid') || ''; 352 essb_smart_onclose_events(service, instance_post_id); 353 354 if (instance_position == 'booster' && typeof (essb_booster_close_from_action) != 'undefined') 355 essb_booster_close_from_action(); 356 }, 1500); 357 } 358 }; 359 360 essb.pinterest_picker = function (instance) { 361 essb.tracking_only('', 'pinterest', instance); 362 var e = document.createElement('script'); 363 e.setAttribute('type', 'text/javascript'); 364 e.setAttribute('charset', 'UTF-8'); 365 e.setAttribute('src', '//assets.pinterest.com/js/pinmarklet.js?r=' + Math.random() * 99999999); 366 document.body.appendChild(e); 367 }; 368 369 essb.print = function (instance) { 370 essb.tracking_only('', 'print', instance); 371 window.print(); 372 }; 373 374 essb.setCookie = function (cname, cvalue, exdays) { 375 var d = new Date(); 376 d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); 377 var expires = "expires=" + d.toGMTString(); 378 document.cookie = cname + "=" + cvalue + "; " + expires + "; path=/"; 379 }; 380 381 essb.getCookie = function (cname) { 382 var name = cname + "="; 383 var ca = document.cookie.split(';'); 384 for (var i = 0; i < ca.length; i++) { 385 var c = ca[i].trim(); 386 if (c.indexOf(name) == 0) return c.substring(name.length, c.length); 387 } 388 return ""; 389 }; 390 391 essb.loveThis = function (instance) { 392 console.log(window.essb_love_you_message_thanks); 393 394 if (typeof (essb_love_you_message_loved) == 'undefined') var essb_love_you_message_loved = ''; 395 if (typeof (essb_love_you_message_thanks) == 'undefined') var essb_love_you_message_thanks = ''; 396 397 if (typeof (window.essb_love_you_message_thanks) != 'undefined') essb_love_you_message_thanks = window.essb_love_you_message_thanks; 398 if (typeof (window.essb_love_you_message_loved) != 'undefined') essb_love_you_message_loved = window.essb_love_you_message_loved; 399 400 if (essb.clickedLoveThis) { 401 if (!essb.loveDisableLoved) alert(essb_love_you_message_loved ? essb_love_you_message_loved : 'You already love this today'); 402 return; 403 } 404 405 var element = $('.essb_' + instance); 406 if (!element.length) return; 407
408 var instance_post_id = $(element).attr("data-essb-postid") || ""; 409 410 var cookie_set = essb.getCookie("essb_love_" + instance_post_id); 411 if (cookie_set) { 412 if (!essb.loveDisableLoved) alert(essb_love_you_message_loved ? essb_love_you_message_loved : 'You already love this today'); 413 return; 414 } 415 416 if (typeof (essb_settings) != "undefined") { 417 $.post(essb_settings.ajax_url, { 418 'action': 'essb_love_action', 419 'post_id': instance_post_id, 420 'service': 'love', 421 'nonce': essb_settings.essb3_nonce 422 }, function (data) { 423 if (data) { 424 if (!essb.loveDisableThanks) alert(essb_love_you_message_thanks ? essb_love_you_message_thanks : 'Thank you for loving this'); 425 } 426 }, 'json'); 427 } 428 429 essb.tracking_only('', 'love', instance, true); 430 }; 431 432 essb.toggle_more = function (unique_id) { 433 if (essb['is_morebutton_clicked']) { 434 essb.toggle_less(unique_id); 435 return; 436 } 437 $('.essb_' + unique_id + ' .essb_after_more').essb_toggle_more(); 438 439 var moreButton = $('.essb_' + unique_id).find('.essb_link_more'); 440 if (typeof (moreButton) != "undefined") { 441 moreButton.hide(); 442 moreButton.addClass('essb_hide_more_sidebar'); 443 } 444 445 moreButton = $('.essb_' + unique_id).find('.essb_link_more_dots'); 446 if (typeof (moreButton) != "undefined") { 447 moreButton.hide(); 448 moreButton.addClass('essb_hide_more_sidebar'); 449 } 450 451 essb['is_morebutton_clicked'] = true; 452 }; 453 454 essb.toggle_less = function (unique_id) { 455 essb['is_morebutton_clicked'] = false; 456 $('.essb_' + unique_id + ' .essb_before_less').essb_toggle_less(); 457 458 var moreButton = $('.essb_' + unique_id).find('.essb_link_more'); 459 if (typeof (moreButton) != "undefined") { 460 moreButton.show(); 461 moreButton.removeClass('essb_hide_more_sidebar'); 462 } 463 464 moreButton = $('.essb_' + unique_id).find('.essb_link_more_dots'); 465 if (typeof (moreButton) != "undefined") { 466 moreButton.show(); 467 moreButton.removeClass('essb_hide_more_sidebar'); 468 } 469 }; 470 471 essb.toggle_more_popup = function (unique_id) { 472 if (typeof essb_open_morepopup_window != 'undefined') 473 essb_open_morepopup_window(unique_id); 474 }; 475 476 essb.toggle_less_popup = function (unique_id) { 477 if (typeof essb_close_morepopup_window != 'undefined') 478 essb_close_morepopup_window(unique_id); 479 }; 480 481 essb.subscribe_popup_close = function (key) { 482 $('.essb-subscribe-form-' + key).fadeOut(400); 483 $('.essb-subscribe-form-overlay-' + key).fadeOut(400); 484 }; 485 486 essb.sharebutton = function (key) { 487 if ($('.essb-windowcs-' + key).length) { 488 489 /** 490 * @since 8.3 Custom pop-up size 491 */ 492 var win_width = $(window).width(), win_height = $(window).height(), 493 popup_width = $('.essb-windowcs-' + key).data('width'), popup_height = $('.essb-windowcs-' + key).data('height'), 494 customPosition = false; 495 496 if (Number(popup_width || 0) > 0 || Number(popup_height || 0) > 0) { 497 if (Number(popup_width) > Number(win_width)) popup_width = win_width; 498 if (Number(popup_height) > Number(win_height)) popup_height = win_height; 499 500 if (Number(popup_width) > 0) $('.essb-windowcs-' + key).css({ 'width': popup_width + 'px' }); 501 if (Number(popup_height) > 0) $('.essb-windowcs-' + key).css({ 'height': popup_height + 'px' }); 502 503 $('.essb-windowcs-' + key).center(); 504 customPosition = true; 505 } 506 507 508 $('.essb-windowcs-' + key).fadeIn(200); 509 if (!customPosition) $('.essb-windowcs-' + key + ' .inner-content').center(); 510 else { 511 $('.essb-windowcs-' + key + ' .inner-content').css({ 'position': 'absolute', 'left': '50%', 'top': '50%', 'transform': 'translate(-50%,-50%)', 'width': '90%' });
512 } 513 } 514 }; 515 516 essb.sharebutton_close = function (key) { 517 if ($('.essb-windowcs-' + key).length) { 518 $('.essb-windowcs-' + key).fadeOut(200); 519 } 520 }; 521 522 essb.toggle_subscribe = function (key) { 523 // subsribe container do not exist 524 if (!$('.essb-subscribe-form-' + key).length) return; 525 526 if (!essb['essb_subscribe_opened']) 527 essb['essb_subscribe_opened'] = {}; 528 529 var asPopup = $('.essb-subscribe-form-' + key).attr("data-popup") || ""; 530 531 // it is not popup (in content methods is asPopup == "") 532 if (asPopup != '1') { 533 if ($('.essb-subscribe-form-' + key).hasClass("essb-subscribe-opened")) { 534 $('.essb-subscribe-form-' + key).slideUp('fast'); 535 $('.essb-subscribe-form-' + key).removeClass("essb-subscribe-opened"); 536 } 537 else { 538 $('.essb-subscribe-form-' + key).slideDown('fast'); 539 $('.essb-subscribe-form-' + key).addClass("essb-subscribe-opened"); 540 541 if (!essb['essb_subscribe_opened'][key]) { 542 essb['essb_subscribe_opened'][key] = key; 543 essb.tracking_only('', 'subscribe', key, true); 544 } 545 } 546 } 547 else { 548 var win_width = $(window).width(); 549 var doc_height = $('document').height(); 550 551 var base_width = 600; 552 553 if (win_width < base_width) { base_width = win_width - 40; } 554 555 556 $('.essb-subscribe-form-' + key).css({ width: base_width + 'px' }); 557 $('.essb-subscribe-form-' + key).center(); 558 559 $('.essb-subscribe-form-' + key).fadeIn(400); 560 $('.essb-subscribe-form-overlay-' + key).fadeIn(200); 561 562 } 563 564 }; 565 566 essb.is_after_comment = function () { 567 var addr = window.location.href; 568 569 return addr.indexOf('#comment') > -1 ? true : false; 570 }; 571 572 essb.flyin_close = function () { 573 $(".essb-flyin").fadeOut(200); 574 }; 575 576 essb.popup_close = function () { 577 578 $(".essb-popup").fadeOut(200); 579 $(".essb-popup-shadow").fadeOut(400); 580 }; 581 582 essb.copy_link_direct = function (currentLocation) { 583 essb_copy_link_direct(currentLocation); 584 }; 585 586 essb.copy_link = function (instance_id, user_href) { 587 if (essb_settings && essb_settings.copybutton_direct) { 588 let currentLocation = window.location.href; 589 590 if (instance_id && document.querySelector('.essb_' + instance_id)) { 591 let instance_url = document.querySelector('.essb_' + instance_id).getAttribute('data-essb-url') || ''; 592 if (instance_url != '') currentLocation = instance_url; 593 } 594 595 if (user_href && user_href != '') currentLocation = user_href; 596 597 essb.copy_link_direct(currentLocation); 598 return; 599 } 600 essb_open_copy_link_window(instance_id, user_href); 601 }; 602 603 /** 604 * Mobile Display Code 605 */ 606 607 essb.mobile_sharebar_open = function () { 608 var element = $('.essb-mobile-sharebar-window'); 609 if (!element.length) return; 610 611 var sharebar_element = $('.essb-mobile-sharebar'); 612 if (!sharebar_element.length) 613 sharebar_element = $('.essb-mobile-sharepoint'); 614 615 if (!sharebar_element.length) 616 return; 617 618 619 if (essb['is_displayed_sharebar']) { 620 essb.mobile_sharebar_close(); 621 return; 622 } 623 624 var current_height_of_bar = $(sharebar_element).outerHeight(); 625 var win_height = $(window).height(); 626 var win_width = $(window).width(); 627 win_height -= current_height_of_bar; 628 629 if ($('#wpadminbar').length) 630 $("#wpadminbar").hide(); 631 632 633 var element_inner = $('.essb-mobile-sharebar-window-content'); 634 if (element_inner.length) { 635 element_inner.css({ 636 height: (win_height - 60) + 'px' 637 }); 638 } 639 640 $(element).css({ 641 width: win_width + 'px', 642 height: win_height + 'px' 643 }); 644 $(element).fadeIn(400); 645 essb['is_displayed_sharebar'] = true; 646 }; 647 648 essb.mobile_sharebar_close = function () { 649 var element = $('.essb-mobile-sharebar-window'); 650 if (!element.length) 651 return; 652 653 654 $(element).fadeOut(400); 655 essb['is_displayed_sharebar'] = false; 656 }; 657 658 essb.responsiveEventsCanRun = function (element) { 659 var hideOnMobile = $(element).hasClass('essb_mobile_hidden'), 660 hideOnDesktop = $(element).hasClass('essb_desktop_hidden'), 661 hideOnTablet = $(element).hasClass('essb_tablet_hidden'), 662 windowWidth = $(window).width(), 663 canRun = true; 664 665 if (windowWidth <= 768 && hideOnMobile) canRun = false; 666 if (windowWidth > 768 && windowWidth <= 1100 && hideOnTablet) canRun = false; 667 if (windowWidth > 1100 && hideOnDesktop) canRun = false; 668 669 if (!$(element).length) canRun = false; 670 671 return canRun; 672 }; 673 674 essb.handleInternalStats = function (service, postID, instance) { 675 let element = document.querySelector('.essb_' + instance); 676 if (element) {
677 let instance_postion = element.getAttribute('data-essb-position') || '', 678 instance_template = element.getAttribute('data-essb-template') || '', 679 instance_button = element.getAttribute('data-essb-button-style') || '', 680 instance_counters = element.classList.contains('essb_counters'), 681 instance_nostats = element.classList.contains('essb_nostats'); 682 683 if (instance_nostats) return; 684 685 essb.logInternalStats(service, postID, instance_postion, instance_template, instance_button, instance_counters); 686 } 687 } 688 689 essb.handleLogInternalStats = function (service, postId, position) { 690 essb.logInternalStats(service, postId, position, position, position, false); 691 } 692 693 essb.logInternalStats = function (service, postId, position, template, senderButton, usingCounters) { 694 let instanceIsMobile = false; 695 696 if ((/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i).test(navigator.userAgent)) 697 instanceIsMobile = true; 698 699 if (typeof (essb_settings) != "undefined") { 700 fetch(essb_settings.ajax_url, { 701 method: 'POST', 702 headers: { 703 'Content-Type': 'application/x-www-form-urlencoded', 704 'Accept': '*/*' 705 }, 706 body: new URLSearchParams({ 707 'action': 'essb_stat_log', 708 'post_id': postId, 709 'service': service, 710 'template': template, 711 'mobile': instanceIsMobile, 712 'position': position, 713 'button': senderButton, 714 'counter': usingCounters, 715 'nonce': essb_settings.essb3_nonce 716 }) 717 }).then(response => response.text()) 718 .then(data => console.log(data)); 719 } 720 else { 721 console.log('[error] essb.logInternalStats: Missing configuration data') 722 } 723 }; 724 725 window.essb = essb; 726 727 /** 728 * Incore Specific Functions & Events 729 */ 730 731 var essb_int_value = function (value) { 732 value = parseInt(value); 733 734 if (isNaN(value) || !isFinite(value)) value = 0; 735 return value; 736 } 737 738 var essb_self_postcount = function (service, countID) { 739 if (typeof (essb_settings) != "undefined") { 740 countID = String(countID); 741 742 $.post(essb_settings.ajax_url, { 743 'action': 'essb_self_postcount', 744 'post_id': countID, 745 'service': service, 746 'nonce': essb_settings.essb3_nonce 747 }, function (data) { }, 'json'); 748 } 749 }; 750 751 var essb_smart_onclose_events = function (service, postID) { 752 // 7.0 - trigger only on selected networks (when such are present) 753 if (essb_settings && essb_settings['aftershare_networks']) { 754 var workingNetworks = essb_settings['aftershare_networks'] != '' ? essb_settings['aftershare_networks'].split(',') : []; 755 if (workingNetworks.indexOf(service) == -1) return; 756 } 757 else { 758 // 6.0.3 - adding email & mail as also ignoring options 759 if (service == "subscribe" || service == "comments" || service == 'email' || service == 'mail') return; 760 } 761 762 if (service == "subscribe" || service == "comments" || service == 'email' || service == 'mail') return; 763 764 if (typeof (essbasc_popup_show) == 'function') 765 essbasc_popup_show(); 766 767 if (typeof essb_acs_code == 'function') 768 essb_acs_code(service, postID); 769 770 if ($('.essb-aftershare-subscribe-form').length) { 771 var key = $('.essb-aftershare-subscribe-form').data('salt') || ''; 772 if (key != '') essb.toggle_subscribe(key); 773 } 774 }; 775 776 777 var essb_ga_tracking = function (service, url, position) { 778 var essb_ga_type = essb_settings.essb3_ga_mode; 779 780 if ('ga' in window && window.ga !== undefined && typeof window.ga === 'function') { 781 if (essb_ga_type == "extended") 782 ga('send', 'event', 'social', service + ' ' + position, url); 783 784 else 785 ga('send', 'event', 'social', service, url); 786 787 } 788 789 if (essb_ga_type == "layers" && typeof (dataLayer) != "undefined") { 790 dataLayer.push({ 791 'service': service, 792 'position': position, 793 'url': url, 794 'event': 'social' 795 }); 796 } 797 }; 798 799 var essb_open_mailform = window.essb_open_mailform = function (unique_id) { 800 if (essb['essb_mailform_opened']) { 801 essb_close_mailform(unique_id); 802 return; 803 } 804 805 var sender_element = $(".essb_" + unique_id); 806 if (!sender_element.length) return; 807
808 var sender_post_id = $(sender_element).attr("data-essb-postid") || ""; 809 810 $("#essb_mail_instance").val(unique_id); 811 $("#essb_mail_post").val(sender_post_id); 812 813 var win_width = $(window).width(), 814 win_height = $(window).height(), 815 base_width = 400; 816 817 if (win_width < base_width) base_width = win_width - 30; 818 819 var height_correction = 20, 820 element_class = ".essb_mailform", 821 element_class_shadow = ".essb_mailform_shadow"; 822 823 $(element_class).css({ width: base_width + 'px' }); 824 825 var popup_height = $(element_class).outerHeight(); 826 if (popup_height > (win_height - 30)) { 827 $(element_class).css({ height: (win_height - height_correction) + 'px' }); 828 } 829 830 $("#essb_mailform_from").val(""); 831 $("#essb_mailform_to").val(""); 832 $('#essb_mailform_from_name').val(''); 833 if ($("#essb_mailform_c").length) 834 $("#essb_mailform_c").val(""); 835 836 // Maybe load reCAPTCHA. 837 if (typeof (essb_recaptcha) != 'undefined' && essb_recaptcha && essb_recaptcha.recaptchaSitekey) { 838 grecaptcha.render('essb-modal-recaptcha', { 839 sitekey: essb_recaptcha.recaptchaSitekey 840 }); 841 } 842 843 $(element_class).center(); 844 $(element_class).slideDown(200); 845 $(element_class_shadow).fadeIn(200); 846 $('#essb_mailform_status_message').html(''); 847 essb['essb_mailform_opened'] = true; 848 essb.tracking_only("", "mail", unique_id); 849 }; 850 851 var essb_close_mailform = window.essb_close_mailform = function () { 852 $(".essb_mailform").fadeOut(200); 853 $(".essb_mailform_shadow").fadeOut(200); 854 $('#essb_mailform_status_message').html(''); 855 essb['essb_mailform_opened'] = false; 856 }; 857 858 var essb_mailform_send = window.essb_mailform_send = function () { 859 var highlight = function (id) { 860 $(id).css('background-color', '#ffd8d8'); 861 setTimeout(function () { 862 $(id).css('background-color', '#fff'); 863 }, 5000); 864 }; 865 866 $('#essb_mailform_status_message').html(''); 867 $('.essb_mailform_content_buttons').css('visibility', 'visible'); 868 869 var sender_email = $("#essb_mailform_from").val(), 870 sender_name = $('#essb_mailform_from_name').val(), 871 recepient_email = $("#essb_mailform_to").val(), 872 captcha_validate = $("#essb_mailform_c").length ? true : false, 873 errorMessage = $('.essb_mailform').attr('data-error') || '', 874 sendingMessage = $('.essb_mailform').attr('data-sending') || '', 875 captcha = captcha_validate ? $("#essb_mailform_c").val() : "", 876 recaptcha = $('#g-recaptcha-response').val(), 877 sender_aff_id = $('#essb_mail_affiliate_id').length ? $('#essb_mail_affiliate_id').val() : '', 878 custom_message = ''; 879 880 if (sender_name == '' || sender_email == "" || recepient_email == "" || (captcha == "" && captcha_validate)) { 881 882 if (sender_name == '') highlight("#essb_mailform_from_name"); 883 if (sender_email == '') highlight("#essb_mailform_from"); 884 if (recepient_email == '') highlight("#essb_mailform_to"); 885 $('#essb_mailform_status_message').html('<span style="color: #d80001;">' + errorMessage + '</span>'); 886 return; 887 } 888 889 var mail_salt = $("#essb_mail_salt").val(), 890 instance_post_id = $("#essb_mail_post").val(); 891 892 if (typeof (essb_settings) != "undefined") { 893 // hiding buttons before sending of the message 894 $('.essb_mailform_content_buttons').css('visibility', 'hidden'); 895 $('#essb_mailform_status_message').html(sendingMessage + ' ' + recepient_email); 896 897 $.post(essb_settings.ajax_url, { 898 "action": "essb_mail_action", 899 "post_id": instance_post_id, 900 "from": sender_email, 901 "from_name": sender_name, 902 "to": recepient_email, 903 "c": captcha, 904 "cu": custom_message, 905 "salt": mail_salt, 906 'affid': sender_aff_id, 907 'recapcha': recaptcha, 908 "nonce": essb_settings.essb3_nonce 909 }, function (data) { 910 if (data) { 911 $('.essb_mailform_content_buttons').css('visibility', 'visible'); 912 if (data['message']) $('#essb_mailform_status_message').html('<span style="color: #d80001;">' + data['message'] + '</span>'); 913 if (data["code"] == "1") { 914 essb_close_mailform(); 915 alert(data['message']); 916 } 917 if (data['code']) { 918 if (data['code'] == '101' && $("#essb_mailform_c").length) highlight("#essb_mailform_c"); 919 if (data['code'] == '102' && $("#essb_mailform_to").length) highlight("#essb_mailform_to"); 920 if (data['code'] == '104' && $("#essb_mailform_from").length) highlight("#essb_mailform_from"); 921 } 922 } 923 }, 'json'); 924 } 925 }; 926 927 /** 928 * After Share Events functions 929 */ 930 var essbasc_popup_show = window.essbasc_popup_show = function () { 931 if (!$('.essbasc-popup').length) return; 932 if (essb.getCookie('essb_aftershare')) return; // cookie already set for visible events 933 934 var cookie_len = (typeof (essbasc_cookie_live) != "undefined") ? essbasc_cookie_live : 7; 935 if (parseInt(cookie_len) == 0) { cookie_len = 7; } 936 937 var win_width = $(window).width(), base_width = 800, 938 userwidth = $('.essbasc-popup').attr("data-popup-width") || '', 939 singleShow = $('.essbasc-popup').attr("data-single") || ''; 940 941 if (Number(userwidth) && Number(userwidth) > 0) base_width = userwidth; 942 if (win_width < base_width) base_width = win_width - 60; 943 944 $(".essbasc-popup").css({ width: base_width + 'px' }); 945 $(".essbasc-popup").center(); 946 $(".essbasc-popup").fadeIn(300); 947 $(".essbasc-popup-shadow").fadeIn(100); 948 949 if (singleShow == 'true') essb.setCookie('essb_aftershare', "yes", cookie_len); 950 }; 951 952 var essbasc_popup_close = window.essbasc_popup_close = function () { 953 $(".essbasc-popup").fadeOut(200); 954 $(".essbasc-popup-shadow").fadeOut(100); 955 }; 956 957 $(document).ready(function () { 958 959 /** 960 * Mobile Share Bar 961 */ 962 963 var mobileHideOnScroll = false; 964 var mobileHideTriggerPercent = 90;
965 var mobileAppearOnScroll = false; 966 var mobileAppearOnScrollPercent = 0; 967 var mobileAdBarConnected = false; 968 969 var essb_mobile_sharebuttons_onscroll = function () { 970 971 var current_pos = $(window).scrollTop(); 972 var height = $(document).height() - $(window).height(); 973 var percentage = current_pos / height * 100; 974 975 var isVisible = true; 976 if (mobileAppearOnScroll && !mobileHideOnScroll) { 977 if (percentage < mobileAppearOnScrollPercent) isVisible = false; 978 } 979 if (mobileHideOnScroll && !mobileAppearOnScroll) { 980 if (percentage > mobileHideTriggerPercent) isVisible = false; 981 } 982 if (mobileAppearOnScroll && mobileHideOnScroll) { 983 if (percentage > mobileHideTriggerPercent || percentage < mobileAppearOnScrollPercent) isVisible = false; 984 985 } 986 987 if (!isVisible) { 988 if (!$('.essb-mobile-sharebottom').hasClass("essb-mobile-break")) { 989 $('.essb-mobile-sharebottom').addClass("essb-mobile-break"); 990 $('.essb-mobile-sharebottom').fadeOut(400); 991 } 992 993 if ($('.essb-adholder-bottom').length && mobileAdBarConnected) { 994 if (!$('.essb-adholder-bottom').hasClass("essb-mobile-break")) { 995 $('.essb-adholder-bottom').addClass("essb-mobile-break"); 996 $('.essb-adholder-bottom').fadeOut(400); 997 } 998 } 999 1000 } else { 1001 if ($('.essb-mobile-sharebottom').hasClass("essb-mobile-break")) { 1002 $('.essb-mobile-sharebottom').removeClass("essb-mobile-break"); 1003 $('.essb-mobile-sharebottom').fadeIn(400); 1004 } 1005 1006 if ($('.essb-adholder-bottom').length && mobileAdBarConnected) { 1007 if ($('.essb-adholder-bottom').hasClass("essb-mobile-break")) { 1008 $('.essb-adholder-bottom').removeClass("essb-mobile-break"); 1009 $('.essb-adholder-bottom').fadeIn(400); 1010 } 1011 } 1012 } 1013 }; 1014 1015 if ($('.essb-mobile-sharebottom').length) { 1016 1017 var hide_on_end = $('.essb-mobile-sharebottom').attr('data-hideend'); 1018 var hide_on_end_user = $('.essb-mobile-sharebottom').attr('data-hideend-percent'); 1019 var appear_on_scroll = $('.essb-mobile-sharebottom').attr('data-show-percent') || ''; 1020 var check_responsive = $('.essb-mobile-sharebottom').attr('data-responsive') || ''; 1021 1022 if (Number(appear_on_scroll)) { 1023 mobileAppearOnScroll = true; 1024 mobileAppearOnScrollPercent = Number(appear_on_scroll); 1025 } 1026 1027 if (hide_on_end == 'true') mobileHideOnScroll = true; 1028 1029 var instance_mobile = false; 1030 if ((/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i).test(navigator.userAgent)) { 1031 instance_mobile = true; 1032 } 1033 1034 if ($('.essb-adholder-bottom').length) { 1035 $adbar_connected = $('.essb-adholder-bottom').attr('data-connected') || ''; 1036 if ($adbar_connected == 'true') mobileAdBarConnected = true; 1037 } 1038 1039 if (mobileHideOnScroll || mobileAppearOnScroll) { 1040 if (parseInt(hide_on_end_user) > 0) 1041 mobileHideTriggerPercent = parseInt(hide_on_end_user); 1042 1043 if (check_responsive == '' || (check_responsive == 'true' && instance_mobile)) 1044 $(window).on('scroll', debounce(essb_mobile_sharebuttons_onscroll, 1)); 1045 1046 } 1047 } 1048 1049 1050 /** 1051 * Display Methods: Float on top 1052 */ 1053 if ($('.essb_displayed_float').length) { 1054 1055 var floatingTop = $('.essb_displayed_float').offset().top - parseFloat($('.essb_displayed_float').css('marginTop').replace(/auto/, 0)), 1056 basicElementWidth = '', 1057 hide_float_percent = $('.essb_displayed_float').data('float-hide') || '', 1058 custom_top_postion = $('.essb_displayed_float').data('float-top') || '', 1059 hide_float_active = false; 1060 1061 if (hide_float_percent != '' && Number(hide_float_percent) > 0) { 1062 hide_float_percent = parseInt(hide_float_percent); 1063 hide_float_active = true; 1064 } 1065 1066 var active_custom_top = false; 1067 if (custom_top_postion != '' && Number(custom_top_postion) > 0) { 1068 custom_top_postion = parseInt(custom_top_postion); 1069 active_custom_top = true; 1070 } 1071 1072 /** 1073 * Hold down scroll event for floating top display method when such is present 1074 * inside code 1075 */ 1076 function essbFloatingButtons() { 1077 var y = $(window).scrollTop(); 1078 1079 if (active_custom_top) 1080 y -= custom_top_postion; 1081 1082 var height = $(document).height() - $(window).height(); 1083 var percentage = y / height * 100; 1084 // whether that's below the form 1085 if (y >= floatingTop) { 1086 // if so, ad the fixed class 1087 if (basicElementWidth == '') { 1088 var widthOfContainer = $('.essb_displayed_float').width(); 1089 basicElementWidth = widthOfContainer; 1090 $('.essb_displayed_float').width(widthOfContainer); 1091 } 1092 1093 $('.essb_displayed_float').addClass('essb_fixed'); 1094 1095 } else { 1096 // otherwise remove it 1097 $('.essb_displayed_float').removeClass('essb_fixed'); 1098 if (basicElementWidth != '') { 1099 $('.essb_displayed_float').width(basicElementWidth);
1100 } 1101 } 1102 1103 if (hide_float_active) { 1104 if (percentage >= hide_float_percent && !$('.essb_displayed_float').hasClass('hidden-float')) { 1105 $('.essb_displayed_float').addClass('hidden-float'); 1106 $('.essb_displayed_float').fadeOut(100); 1107 return; 1108 } 1109 if (percentage < hide_float_percent && $('.essb_displayed_float').hasClass('hidden-float')) { 1110 $('.essb_displayed_float').removeClass('hidden-float'); 1111 $('.essb_displayed_float').fadeIn(100); 1112 return; 1113 } 1114 } 1115 } // end: essbFloatingButtons 1116 1117 if (essb.responsiveEventsCanRun($('.essb_displayed_float'))) 1118 $(window).on('scroll', debounce(essbFloatingButtons, 1)); 1119 } 1120 1121 /** 1122 * Display Methods: Sidebar 1123 */ 1124 1125 // Sidebar animation reveal on load 1126 if ($('.essb_sidebar_transition').length) { 1127 $('.essb_sidebar_transition').each(function () { 1128 1129 if (!essb.responsiveEventsCanRun($(this))) return; 1130 1131 if ($(this).hasClass('essb_sidebar_transition_slide')) 1132 $(this).toggleClass('essb_sidebar_transition_slide'); 1133 1134 if ($(this).hasClass('essb_sidebar_transition_fade')) 1135 $(this).toggleClass('essb_sidebar_transition_fade'); 1136 1137 1138 }); 1139 } 1140 1141 /** 1142 * Reposition sidebar at the middle of page 1143 */ 1144 if ($('.essb_sidebar_location_middle').length) { 1145 var essbSidebarRepositionMiddle = function () { 1146 var heightOfSidebar = $('.essb_sidebar_location_middle').outerHeight(), 1147 winHeight = $(window).height(), top = 0; 1148 1149 1150 if (heightOfSidebar > winHeight) top = 0; 1151 else { 1152 top = Math.round((winHeight - heightOfSidebar) / 2); 1153 } 1154 $('.essb_sidebar_location_middle').css({ 'top': top + 'px', 'opacity': '1' }); 1155 }; 1156 1157 essbSidebarRepositionMiddle(); 1158 $(window).on('resize', debounce(essbSidebarRepositionMiddle, 1)); 1159 } 1160 1161 // Sidebar close button 1162 $(".essb_link_sidebar-close a").each(function () { 1163 $(this).on('click', function (event) { 1164 event.preventDefault(); 1165 var links_list = $(this).parent().parent().get(0); 1166 1167 if (!$(links_list).length) return; 1168 1169 $(links_list).find(".essb_item").each(function () { 1170 if (!$(this).hasClass("essb_link_sidebar-close")) 1171 $(this).toggleClass("essb-sidebar-closed-item"); 1172 else 1173 $(this).toggleClass("essb-sidebar-closed-clicked"); 1174 }); 1175 1176 }); 1177 }); 1178 1179 var essb_sidebar_onscroll = function () { 1180 var current_pos = $(window).scrollTop(); 1181 var height = $(document).height() - $(window).height(); 1182 var percentage = current_pos / height * 100; 1183 1184 1185 var element; 1186 if ($(".essb_displayed_sidebar").length) 1187 element = $(".essb_displayed_sidebar"); 1188 1189 if ($(".essb_displayed_sidebar_right").length) 1190 element = $(".essb_displayed_sidebar_right"); 1191 1192 1193 if (!element || typeof (element) == "undefined") return; 1194 1195 var value_disappear = essb_int_value($(element).data('sidebar-disappear-pos') || ''); 1196 var value_appear = essb_int_value($(element).data('sidebar-appear-pos') || ''); 1197 var value_appear_unit = $(element).data('sidebar-appear-unit') || ''; 1198 var value_contenthidden = $(element).data('sidebar-contenthidden') || ''; 1199 if (value_appear_unit == 'px') percentage = current_pos; 1200 1201 var visibleByDisplayCond = true; 1202 1203 if (value_appear > 0 || value_disappear > 0) { 1204 visibleByDisplayCond = false; 1205 if (value_appear && percentage >= value_appear) visibleByDisplayCond = true; 1206 if (value_disappear && percentage <= value_disappear) visibleByDisplayCond = true; 1207 } 1208 1209 // Hiding share buttons when content is visible 1210 if (value_contenthidden == 'yes' && ($('.essb_displayed_top').length || $('.essb_displayed_bottom').length)) { 1211 1212 if (($('.essb_displayed_top').length && isVisibleSelector($('.essb_displayed_top'))) || 1213 ($('.essb_displayed_bottom').length && isVisibleSelector($('.essb_displayed_bottom')))) 1214 element.fadeOut(100); 1215 else { 1216 if (visibleByDisplayCond) element.fadeIn(100); 1217 } 1218 } 1219 1220 if (value_appear > 0 && value_disappear == 0) { 1221 if (percentage >= value_appear && !element.hasClass("active-sidebar")) { 1222 element.fadeIn(100); 1223 element.addClass("active-sidebar"); 1224 return; 1225 } 1226 1227 if (percentage < value_appear && element.hasClass("active-sidebar")) { 1228 element.fadeOut(100); 1229 element.removeClass("active-sidebar"); 1230 return; 1231 } 1232 } 1233 1234 if (value_disappear > 0 && value_appear == 0) { 1235 if (percentage >= value_disappear && !element.hasClass("hidden-sidebar")) { 1236 element.fadeOut(100); 1237 element.addClass("hidden-sidebar"); 1238 return; 1239 } 1240 1241 if (percentage < value_disappear && element.hasClass("hidden-sidebar")) { 1242 element.fadeIn(100); 1243 element.removeClass("hidden-sidebar"); 1244 return; 1245 } 1246 } 1247 1248 if (value_appear > 0 && value_disappear > 0) { 1249 if (percentage >= value_appear && percentage < value_disappear && !element.hasClass("active-sidebar")) { 1250 element.fadeIn(100); 1251 element.addClass("active-sidebar"); 1252 return; 1253 } 1254 1255 if ((percentage < value_appear || percentage >= value_disappear) && element.hasClass("active-sidebar")) { 1256 element.fadeOut(100); 1257 element.removeClass("active-sidebar"); 1258 return; 1259 } 1260 } 1261 }; 1262 1263 if (essb.responsiveEventsCanRun($('.essb_displayed_sidebar'))) { 1264 var essbSidebarContentHidden = $('.essb_displayed_sidebar').data('sidebar-contenthidden') || '', 1265 essbSidebarAppearPos = $('.essb_displayed_sidebar').data('sidebar-appear-pos') || '', 1266 essbSidebarDisappearPos = $('.essb_displayed_sidebar').data('sidebar-disappear-pos') || ''; 1267 if (essbSidebarAppearPos != '' || essbSidebarDisappearPos != '' || essbSidebarContentHidden == 'yes') { 1268 if ($(window).width() > 800) { 1269 $(window).on('scroll', debounce(essb_sidebar_onscroll, 1)); 1270 essb_sidebar_onscroll(); 1271 } 1272 } 1273 } 1274 1275 /** 1276 * Display Method: Post Vertical Float 1277 */ 1278 1279 if ($('.essb_displayed_postfloat').length) { 1280 var top = $('.essb_displayed_postfloat').offset().top - parseFloat($('.essb_displayed_postfloat').css('marginTop').replace(/auto/, 0));
1281 var postfloat_always_onscreen = ($('.essb_displayed_postfloat').data('postfloat-stay') || '').toString() == 'true' ? true : false; 1282 var postfloat_fix_bottom = ($('.essb_displayed_postfloat').data('postfloat-fixbottom') || '').toString() == 'true' ? true : false; 1283 var custom_user_top = $('.essb_displayed_postfloat').data('postfloat-top') || ''; 1284 var postFloatVisibleSelectors = $('.essb_displayed_postfloat').data('postfloat-selectors') || '', 1285 postFloatViewportCheck = [], 1286 postFloatPercentAppear = $('.essb_displayed_postfloat').data('postfloat-percent') || ''; 1287 1288 if (!Number(postFloatPercentAppear) || Number(postFloatPercentAppear) == 0) { 1289 postFloatPercentAppear = ''; 1290 $('.essb_displayed_postfloat').attr('data-postfloat-percent', ''); 1291 } 1292 1293 if (postFloatVisibleSelectors != '') { 1294 postFloatViewportCheck = postFloatVisibleSelectors.split(','); 1295 for (var i = 0; i < postFloatViewportCheck.length; i++) { 1296 if ($(postFloatViewportCheck[i]).length) $(postFloatViewportCheck[i]).addClass('essb-postfloat-monitor'); 1297 } 1298 } 1299 1300 setTimeout(function () { 1301 $('.essb_displayed_postfloat').css({ 'transition': 'all 0.3s linear' }); 1302 if (postFloatPercentAppear == '') $('.essb_displayed_postfloat').css({ 'opacity': '1' }); 1303 }, 100); 1304 1305 if (custom_user_top != '' && Number(custom_user_top) && !isNaN(custom_user_top)) top -= parseInt(custom_user_top); 1306 1307 function essbPostVerticalFloatScroll() { 1308 var y = $(this).scrollTop(), 1309 break_top = 0, 1310 postFloatPercentAppear = $('.essb_displayed_postfloat').data('postfloat-percent') || '', 1311 postFloatAppearMeasure = $('.essb_displayed_postfloat').data('postfloat-percent-m') || ''; 1312 1313 if ($('.essb_break_scroll').length) { 1314 var break_position = $('.essb_break_scroll').position(); 1315 break_top = break_position.top; 1316 var hasCustomBreak = $('.essb_displayed_postfloat').data('postfloat-bottom') || ''; 1317 1318 if (hasCustomBreak && hasCustomBreak != '' && Number(hasCustomBreak) != 0) break_top = Number(break_top) - Number(hasCustomBreak); 1319 } 1320 1321 if (postFloatPercentAppear != '') { 1322 var height = $(document).height() - $(window).height(), 1323 percentage = y / height * 100, 1324 shouldBeVisible = postFloatAppearMeasure == 'px' ? y >= Number(postFloatPercentAppear) : percentage >= Number(postFloatPercentAppear); 1325 1326 if (shouldBeVisible) { 1327 $('.essb_displayed_postfloat').css({ 'opacity': '1' }); 1328 $('.essb_displayed_postfloat').css({ 'transform': 'translateY(0)' }); 1329 } 1330 else { 1331 $('.essb_displayed_postfloat').css({ 'opacity': '0' }); 1332 $('.essb_displayed_postfloat').css({ 'transform': 'translateY(50px)' }); 1333 } 1334 } 1335 1336 if (y >= top) { 1337 $('.essb_displayed_postfloat').addClass('essb_postfloat_fixed'); 1338 1339 var element_position = $('.essb_displayed_postfloat').offset(); 1340 var element_height = $('.essb_displayed_postfloat').outerHeight(); 1341 var element_top = parseInt(element_position.top) + parseInt(element_height); 1342 1343 if (!postfloat_always_onscreen) { 1344 if (element_top > break_top) { 1345 if (!$('.essb_displayed_postfloat').hasClass("essb_postfloat_breakscroll")) { 1346 $('.essb_displayed_postfloat').addClass("essb_postfloat_breakscroll"); 1347 } 1348 } 1349 else { 1350 if ($('.essb_displayed_postfloat').hasClass("essb_postfloat_breakscroll")) { 1351 $('.essb_displayed_postfloat').removeClass("essb_postfloat_breakscroll"); 1352 } 1353 } 1354 } 1355 else { 1356 var isOneVisible = false; 1357 $('.essb-postfloat-monitor').each(function () { 1358 if (isVisibleSelector($(this))) 1359 isOneVisible = true; 1360 }); 1361 1362 if (!isOneVisible) { 1363 if ($('.essb_displayed_postfloat').hasClass("essb_postfloat_breakscroll")) { 1364 $('.essb_displayed_postfloat').removeClass("essb_postfloat_breakscroll"); 1365 } 1366 1367 /** 1368 * Fix the postfloat at the bottom of content 1369 */ 1370 if (postfloat_fix_bottom) { 1371 if (element_top > break_top) { 1372 if (!$('.essb_displayed_postfloat').hasClass('essb_postfloat_absolute')) { 1373 $('.essb_displayed_postfloat').removeClass('essb_postfloat_fixed'); 1374 $('.essb_displayed_postfloat').attr('data-unfixed', element_top); 1375 $('.essb_displayed_postfloat').addClass('essb_postfloat_absolute'); 1376 $('.essb_displayed_postfloat').css({ 'position': 'absolute', 'top': ($('.essb_break_scroll').position().top - element_height - 100) + 'px' }); 1377 } 1378 } 1379 else { 1380 if ($('.essb_displayed_postfloat').hasClass('essb_postfloat_absolute')) { 1381 $('.essb_displayed_postfloat').removeClass('essb_postfloat_absolute'); 1382 $('.essb_displayed_postfloat').removeAttr('data-unfixed'); 1383 $('.essb_displayed_postfloat').css({ 'position': '', 'top': '' }); 1384 $('.essb_displayed_postfloat').addClass('essb_postfloat_fixed'); 1385 } 1386 } 1387 } 1388 } 1389 else { 1390 if (!$('.essb_displayed_postfloat').hasClass("essb_postfloat_breakscroll")) { 1391 $('.essb_displayed_postfloat').addClass("essb_postfloat_breakscroll"); 1392 } 1393 } 1394 } 1395 } 1396 else 1397 // otherwise remove it 1398 $('.essb_displayed_postfloat').removeClass('essb_postfloat_fixed'); 1399 1400 } 1401 1402 if (essb.responsiveEventsCanRun($('.essb_displayed_postfloat'))) 1403 $(window).on('scroll', debounce(essbPostVerticalFloatScroll, 1)); 1404 } 1405 1406 1407 1408 1409 /** 1410 * Display Method: Post Vertical Float 1411 */ 1412 function essb_postfloat_onscroll() { 1413 var current_pos = $(window).scrollTop(); 1414 var height = $(document).height() - $(window).height(); 1415 var percentage = current_pos / height * 100; 1416 1417 var element; 1418 if ($(".essb_displayed_postfloat").length) 1419 element = $(".essb_displayed_postfloat"); 1420 1421 if (!element || typeof (element) == "undefined") { return; } 1422 var value_appear = essb_int_value($(element).data('postfloat-percent') || ''); 1423 1424 if (value_appear > 0) { 1425 if (percentage >= value_appear && !element.hasClass("essb_active_postfloat")) { 1426 element.addClass("essb_active_postfloat"); 1427 return; 1428 } 1429 1430 if (percentage < value_appear && element.hasClass("essb_active_postfloat")) { 1431 element.removeClass("essb_active_postfloat"); 1432 return; 1433 } 1434 } 1435 } 1436 1437 if (essb.responsiveEventsCanRun($('.essb_displayed_postfloat'))) { 1438 if ((essb_settings.postfloat_percent || '') != '' && $(".essb_displayed_postfloat").length) 1439 $(window).on('scroll', debounce(essb_postfloat_onscroll, 1)); 1440 } 1441 1442 /** 1443 * Animated Counters Code 1444 */ 1445 $(".essb_counters .essb_animated").each(function () { 1446 var current_counter = $(this).attr("data-cnt") || ""; 1447 var current_counter_result = $(this).attr("data-cnt-short") || ""; 1448 1449 if ($(this).hasClass("essb_counter_hidden")) return; 1450 1451 $(this).countTo({ 1452 from: 1, 1453 to: current_counter, 1454 speed: 500, 1455 onComplete: function (value) { 1456 $(this).html(current_counter_result); 1457 } 1458 }); 1459 }); 1460 1461 /** 1462 * Display Method: Follow Me 1463 */ 1464 1465 if ($('.essb-followme').length) { 1466 if ($('.essb-followme .essb_links').length) $('.essb-followme .essb_links').removeClass('essb_displayed_followme'); 1467 1468 var dataPosition = $('.essb-followme').attr('data-position') || '', 1469 dataCustomTop = $('.essb-followme').attr('data-top') || '',
1470 dataBackground = $('.essb-followme').attr('data-background') || '', 1471 dataFull = $('.essb-followme').attr('data-full') || '', 1472 dataAvoidLeftMargin = $('.essb-followme').attr('data-avoid-left') || '', 1473 dataFollowmeHide = $('.essb-followme').attr('data-hide') || ''; 1474 1475 1476 if (dataPosition == 'top' && dataCustomTop != '') 1477 $('.essb-followme').css({ 'top': dataCustomTop + 'px' }); 1478 if (dataBackground != '') 1479 $('.essb-followme').css({ 'background-color': dataBackground }); 1480 1481 if (dataFull != '1' && dataPosition != 'left') { 1482 var basicWidth = $('.essb_displayed_followme').width(); 1483 var leftPosition = $('.essb_displayed_followme').position().left; 1484 1485 if (dataAvoidLeftMargin != 'true') 1486 $('.essb-followme .essb_links').attr('style', 'width:' + basicWidth + 'px; margin-left:' + leftPosition + 'px !important;'); 1487 else 1488 $('.essb-followme .essb_links').attr('style', 'width:' + basicWidth + 'px;'); 1489 } 1490 1491 function essb_followme_scroll() { 1492 var isOneVisible = false, 1493 dataFollowmeShowAfter = $('.essb-followme').attr('data-showafter') || ''; 1494 1495 if (dataFollowmeShowAfter != '' && !Number(dataFollowmeShowAfter)) dataFollowmeShowAfter = ''; 1496 1497 $('.essb_displayed_followme').each(function () { 1498 if (isElementInViewport($(this))) 1499 isOneVisible = true; 1500 }); 1501 1502 var current_pos = $(window).scrollTop(); 1503 var height = $(document).height() - $(window).height(); 1504 var percentage = current_pos / height * 100; 1505 1506 if (Number(dataFollowmeShowAfter) > 0 && Number(dataFollowmeShowAfter) > current_pos) isOneVisible = true; 1507 1508 if (!isOneVisible) { 1509 if (!$('.essb-followme').hasClass('active')) $('.essb-followme').addClass('active'); 1510 } 1511 else { 1512 if ($('.essb-followme').hasClass('active')) $('.essb-followme').removeClass('active'); 1513 } 1514 1515 if (dataFollowmeHide != '') { 1516 if (percentage > 95) { 1517 if (!$('.essb-followme').hasClass('essb-followme-hiddenend')) { 1518 $('.essb-followme').addClass('essb-followme-hiddenend'); 1519 $('.essb-followme').slideUp(100); 1520 } 1521 } 1522 else { 1523 if ($('.essb-followme').hasClass('essb-followme-hiddenend')) { 1524 $('.essb-followme').removeClass('essb-followme-hiddenend'); 1525 $('.essb-followme').slideDown(100); 1526 } 1527 } 1528 } 1529 } 1530 1531 $(window).on('scroll', debounce(essb_followme_scroll, 1)); 1532 1533 // execute one time after load 1534 essb_followme_scroll(); 1535 } 1536 1537 if ($('.essb-point').length) { 1538 var essb_point_triggered = false; 1539 var essb_point_trigger_mode = ""; 1540 1541 var essb_point_trigger_open_onscroll = function () { 1542 var current_pos = $(window).scrollTop() + $(window).height() - 200; 1543 1544 var top = $('.essb_break_scroll').offset().top - parseFloat($('.essb_break_scroll').css('marginTop').replace(/auto/, 0)); 1545 1546 if (essb_point_trigger_mode == 'end') { 1547 if (current_pos >= top && !essb_point_triggered) { 1548 if (!$('.essb-point-share-buttons').hasClass('essb-point-share-buttons-active')) { 1549 $('.essb-point-share-buttons').addClass('essb-point-share-buttons-active'); 1550 if (essb_point_mode != 'simple') $('.essb-point').toggleClass('essb-point-open'); 1551 essb_point_triggered = true; 1552 1553 if (essb_point_autoclose > 0) { 1554 setTimeout(function () { 1555 $('.essb-point-share-buttons').removeClass('essb-point-share-buttons-active'); 1556 if (essb_point_mode != 'simple') $('.essb-point').removeClass('essb-point-open'); 1557 }, essb_point_autoclose * 1000) 1558 } 1559 } 1560 } 1561 } 1562 if (essb_point_trigger_mode == 'middle') { 1563 var percentage = current_pos * 100 / top; 1564 if (percentage > 49 && !essb_point_triggered) { 1565 if (!$('.essb-point-share-buttons').hasClass('essb-point-share-buttons-active')) { 1566 $('.essb-point-share-buttons').addClass('essb-point-share-buttons-active'); 1567 if (essb_point_mode != 'simple') $('.essb-point').toggleClass('essb-point-open'); 1568 essb_point_triggered = true; 1569 1570 if (essb_point_autoclose > 0) { 1571 setTimeout(function () { 1572 $('.essb-point-share-buttons').removeClass('essb-point-share-buttons-active'); 1573 if (essb_point_mode != 'simple') $('.essb-point').removeClass('essb-point-open'); 1574 }, essb_point_autoclose * 1000) 1575 } 1576 } 1577 } 1578 } 1579 } 1580 1581 var essb_point_onscroll = $('.essb-point').attr('data-trigger-scroll') || ""; 1582 var essb_point_mode = $('.essb-point').attr('data-point-type') || "simple"; 1583 var essb_point_autoclose = Number($('.essb-point').attr('data-autoclose') || 0) || 0; 1584 1585 if (essb.responsiveEventsCanRun($('.essb-point'))) { 1586 if (essb_point_onscroll == 'end' || essb_point_onscroll == 'middle') { 1587 essb_point_trigger_mode = essb_point_onscroll; 1588 $(window).on('scroll', essb_point_trigger_open_onscroll); 1589 } 1590 } 1591 1592 $(".essb-point").on('click', function () { 1593 1594 $('.essb-point-share-buttons').toggleClass('essb-point-share-buttons-active'); 1595 1596 if (essb_point_mode != 'simple') $('.essb-point').toggleClass('essb-point-open'); 1597 1598 if (essb_point_autoclose > 0) { 1599 setTimeout(function () { 1600 $('.essb-point-share-buttons').removeClass('essb-point-share-buttons-active'); 1601 if (essb_point_mode != 'simple') $('.essb-point').removeClass('essb-point-open'); 1602 }, essb_point_autoclose * 1000) 1603 } 1604 }); 1605 } 1606 1607 /** 1608 * Display Method: Corner Bar 1609 */ 1610 1611 if ($('.essb-cornerbar').length) { 1612 if ($('.essb-cornerbar .essb_links').length) $('.essb-cornerbar .essb_links').removeClass('essb_displayed_cornerbar'); 1613 1614 var dataCornerBarShow = $('.essb-cornerbar').attr('data-show') || '', 1615 dataCornerBarHide = $('.essb-cornerbar').attr('data-hide') || ''; 1616 1617 function essb_cornerbar_scroll() { 1618 var current_pos = $(window).scrollTop(); 1619 var height = $(document).height() - $(window).height(); 1620 var percentage = current_pos / height * 100, 1621 breakPercent = dataCornerBarShow == 'onscroll' ? 5 : 45; 1622 1623 if (dataCornerBarShow == 'onscroll' || dataCornerBarShow == 'onscroll50') { 1624 if (percentage > breakPercent) { 1625 if ($('.essb-cornerbar').hasClass('essb-cornerbar-hidden')) $('.essb-cornerbar').removeClass('essb-cornerbar-hidden'); 1626 } 1627 else { 1628 if (!$('.essb-cornerbar').hasClass('essb-cornerbar-hidden')) $('.essb-cornerbar').addClass('essb-cornerbar-hidden'); 1629 } 1630 } 1631 1632 if (dataCornerBarShow == 'content') { 1633 var isOneVisible = false; 1634 $('.essb_displayed_top').each(function () { 1635 if (isElementInViewport($(this))) 1636 isOneVisible = true; 1637 });
1638 $('.essb_displayed_bottom').each(function () { 1639 if (isElementInViewport($(this))) 1640 isOneVisible = true; 1641 }); 1642 1643 if (!isOneVisible) { 1644 if ($('.essb-cornerbar').hasClass('essb-cornerbar-hidden')) $('.essb-cornerbar').removeClass('essb-cornerbar-hidden'); 1645 } 1646 else { 1647 if (!$('.essb-cornerbar').hasClass('essb-cornerbar-hidden')) $('.essb-cornerbar').addClass('essb-cornerbar-hidden'); 1648 } 1649 } 1650 1651 if (dataCornerBarHide != '') { 1652 if (percentage > 90) { 1653 if (!$('.essb-cornerbar').hasClass('essb-cornerbar-hiddenend')) $('.essb-cornerbar').addClass('essb-cornerbar-hiddenend'); 1654 } 1655 else { 1656 if ($('.essb-cornerbar').hasClass('essb-cornerbar-hiddenend')) $('.essb-cornerbar').removeClass('essb-cornerbar-hiddenend'); 1657 } 1658 } 1659 } 1660 1661 if (essb.responsiveEventsCanRun($('.essb-cornerbar'))) { 1662 if (dataCornerBarHide != '' || dataCornerBarShow != '') 1663 $(window).on('scroll', debounce(essb_cornerbar_scroll, 1)); 1664 1665 if (dataCornerBarShow == 'content') essb_cornerbar_scroll(); 1666 1667 } 1668 1669 1670 } 1671 1672 1673 1674 /** 1675 * Reveal the social followers counter that comes with a transition effect 1676 */ 1677 if ($('.essbfc-container-sidebar').length) { 1678 $(".essbfc-container-sidebar").each(function () { 1679 if ($(this).hasClass("essbfc-container-sidebar-transition")) { 1680 $(this).removeClass("essbfc-container-sidebar-transition"); 1681 } 1682 }); 1683 } 1684 1685 }); 1686 1687 1688})(jQuery);
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.