1/** 2 * Product page coupon display public side JS file. 3 * 4 * @since 3.5.0 5 * @package Wt_Smart_Coupon 6 */ 7 8( function ( $ ) { 9 'use strict'; 10 11 jQuery(document).ready(function($) { 12 $('.wbte_sc_cpns_pp_copy_btn').on('click', function() { 13 const code = $(this).closest('.wbte_sc_cpns_pp_card_coupon_box').find('.wbte_sc_cpns_pp_code').text(); 14 const $button = $(this); 15 const originalText = $button.text(); 16 17 function copyToClipboard(text) { 18 if ( navigator.clipboard && window.isSecureContext ) { 19 return navigator.clipboard.writeText(text).then(function() { 20 return true; 21 }).catch(function(err) { 22 return false; 23 }); 24 } 25 26 /** Fallback for older browsers */ 27 return new Promise(function(resolve) { 28 try { 29 const textArea = document.createElement('textarea'); 30 textArea.value = text; 31 textArea.style.position = 'fixed'; 32 textArea.style.left = '-999999px'; 33 textArea.style.top = '-999999px'; 34 document.body.appendChild(textArea); 35 textArea.focus(); 36 textArea.select(); 37 38 const successful = document.execCommand('copy'); 39 document.body.removeChild(textArea); 40 resolve(successful); 41 } catch (err) { 42 resolve(false); 43 } 44 }); 45 } 46 47 copyToClipboard(code).then(function(success) { 48 if (success) { 49 $button.find('span').text(WTSmartCouponOBJ.labels.copied); 50 setTimeout(function() { 51 $button.find('span').text(originalText); 52 }, 1500); 53 } 54 }); 55 }); 56 }); 57 58} )( 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.