1(function ($) { 2 'use strict'; 3 4 const $button = $('.whatsapp-form-button'); 5 const $popup = $('.whatsapp-form-popup'); 6 const $close = $('.whatsapp-form-close'); 7 8 const formatSlug = (slug) => { 9 return slug 10 .split('-') 11 .map(word => word.charAt(0).toUpperCase() + word.slice(1)) 12 .join(' '); 13 }; 14 15 const buildWhatsAppUrl = (whatsappNumber, initialMessage) => { 16 const slug = window.location.pathname.split('/').filter(Boolean).pop(); 17 const message = slug 18 ? `${initialMessage}: ${formatSlug(slug)}` 19 : initialMessage; 20 21 return `https://api.whatsapp.com/send?phone=${whatsappNumber}&text=${encodeURIComponent(message)}`; 22 }; 23 24 const openWhatsApp = (url, newWindow = false) => { 25 if (newWindow) { 26 window.open(url, '_blank', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=700'); 27 } else { 28 window.location.href = url; 29 } 30 }; 31 32 $button.on('click', () => $popup.addClass('active')); 33 $close.on('click', () => $popup.removeClass('active')); 34 35 $(document).on('click', (e) => { 36 if (!$(e.target).closest('.whatsapp-form-container').length) { 37 $popup.removeClass('active'); 38 } 39 }); 40 41 $(document).on('keydown', (e) => { 42 if (e.key === 'Escape') $popup.removeClass('active'); 43 }); 44 45 $(document).on('wpcf7mailsent', function (e) { 46 if (!$(e.target).closest('.whatsapp-form-content').length) return; 47 48 const { whatsappNumber, initialMessage } = whatsappForm; 49 if (whatsappNumber) { 50 openWhatsApp(buildWhatsAppUrl(whatsappNumber, initialMessage), true); 51 } 52 }); 53 54 $(document).on('wpformsAjaxSubmitSuccess', function (e, response) { 55 if (!$(e.target).closest('.whatsapp-form-content').length || !response.success) return; 56 57 const { whatsappNumber, initialMessage } = whatsappForm; 58 if (whatsappNumber) { 59 openWhatsApp(buildWhatsAppUrl(whatsappNumber, initialMessage)); 60 } 61 }); 62 63})(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.