1/** 2 * Public-facing JavaScript for OneCMS Social Share 3 * 4 * @since 2.1.0 5 */ 6(function($) { 7 'use strict'; 8 9 /** 10 * Initialize the social share functionality 11 * WPB-6870: Made globally accessible for Ajax Load More callback 12 */ 13 window.initSocialShare = function() { 14 try { 15 if (window.ITM_enablePjax) { 16 console.log('initSocialShare : is called for pjax site......'); 17 }else { 18 console.log('initSocialShare : is NOT pjax site...'); 19 } 20 } 21 catch(e) { console.log('initSocialShare : in catch.....'); } 22 23 // Make the social share wrapper visible after a short delay 24 // Using requestAnimationFrame for better performance and smoother animations 25 requestAnimationFrame(function() { 26 // Use a second frame to ensure the element is ready in the DOM 27 requestAnimationFrame(function() { 28 $('.ocss-wrapper').addClass('ocss-visible'); 29 }); 30 }); 31 32 // Set up intersection observer for scroll-tr
32iggered animations 33 if ('IntersectionObserver' in window) { 34 const observer = new IntersectionObserver(function(entries) { 35 entries.forEach(function(entry) { 36 if (entry.isIntersecting) { 37 entry.target.classList.add('slide-in'); 38 } 39 }); 40 }, { threshold: 0.1 }); 41 42 document.querySelectorAll('.ocss-vertical-floating').forEach(function(el) { 43 observer.observe(el); 44 }); 45 } 46 } 47 48 /** 49 * Copy page URL to clipboard 50 * This function is called from the HTML via onclick 51 */ 52 window.copyPageURL = function(el, event) { 53 if (event) event.preventDefault(); // Prevent default link behavior 54 55 const url = el.getAttribute('data-url'); 56 57 if (navigator.clipboard && window.isSecureContext) { 58 // Use Clipboard API if available and in secure context 59 navigator.clipboard.writeText(url) 60 .then(function() { 61 showCopyTooltip(el); 62 }) 63 .catch(function() { 64 fallbackCopyToClipboard(url); 65 }); 66 } else { 67 // Fallback for older browsers or non-secure contexts 68 fallbackCopyToClipboard(url); 69 showCopyTooltip(el); 70 } 71 }; 72 73 /** 74 * Print page 75 * This function is called from the HTML via onclick 76 */ 77 window.printPage = function() { 78 jQuery('.sharify-container, .ocss-wrapper, .jeg_share_bottom_container').hide(); //in case of floating. 79 window.print(); 80 jQuery('.sharify-container, .ocss-wrapper, .jeg_share_bottom_container').show(); 81 }; 82 83 /** 84 * Show the "Copied!" tooltip 85 */ 86 function showCopyTooltip(el) { 87 el.classList.add('show-tooltip'); 88 setTimeout(function() { 89 el.classList.remove('show-tooltip'); 90 }, 1500); 91 } 92 93 /** 94 * Fallback method for copying to clipboard 95 */ 96 function fallbackCopyToClipboard(text) { 97 // Create temporary input element 98 const textArea = document.createElement('textarea'); 99 textArea.value = text; 100 101 // Make the textarea out of viewport 102 textArea.style.position = 'fixed'; 103 textArea.style.left = '-999999px'; 104 textArea.style.top = '-999999px'; 105 document.body.appendChild(textArea); 106 107 // Select and copy 108 textArea.focus(); 109 textArea.select(); 110 111 try { 112 document.execCommand('copy'); 113 } catch (err) { 114 console.error('Failed to copy: ', err); 115 // Show a prompt as last resort 116 window.prompt('Copy this link:', text); 117 } 118 119 // Remove the textarea 120 document.body.removeChild(textArea); 121 } 122 123 // Initialize when DOM is ready 124 $(document).ready(function() { 125 initSocialShare(); 126 }); 127 128})(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.