1/** 2 * URL attribute link handler â shared across all widgets that use AttributeRenderer. 3 * 4 * AttributeRenderer::render() emits <a class="wiz-url-link" data-wiz-href="..."> for 5 * attributes of type "url". This file provides the click behaviour: 6 * - validates protocol (http / https only) 7 * - shows a GlobalScripts.showPopUp warning for invalid / empty URLs 8 * - opens valid URLs in a new tab (noopener, noreferrer) 9 * 10 * Delegated on `document` so it works for both server-rendered HTML and content 11 * dynamically injected by AJAX (e.g. QuickView modal via jQuery .replaceWith()). 12 * 13 * Enqueued globally via helpers/script-loader.php. 14 * Depends on: jquery, global-scripts-js (GlobalScripts.showPopUp). 15 */ 16(function ($) { 17 'use strict'; 18 19 $(document).on('click', '[data-wiz-href]', function (e) { 20 e.preventDefault(); 21 22 const raw = $(this).data('wiz-href') || ''; 23 let trimmed = String(raw).trim(); 24 25 if (!trimmed) { 26 if (typeof GlobalScripts !== 'undefined' && typeof GlobalScripts.showPopUp === 'function') { 27 GlobalScripts.showPopUp('Invalid URL', 'warning'); 28 } 29 return; 30 } 31 32 // If no protocol scheme present, assume https:// (handles www.example.com, example.com, etc.) 33 if (!trimmed.includes('://')) { 34 trimmed = 'https://' + trimmed; 35 } 36 37 try { 38 const parsed = new URL(trimmed); 39 const validProtocols = ['http:', 'https:']; 40 41 if (validProtocols.indexOf(parsed.protocol) === -1) { 42 if (typeof GlobalScripts !== 'undefined' && typeof GlobalScripts.showPopUp === 'function') { 43 GlobalScripts.showPopUp('Invalid URL', 'warning'); 44 } 45 return; 46 } 47 } catch (ex) { 48 if (typeof GlobalScripts !== 'undefined' && typeof GlobalScripts.showPopUp === 'function') { 49 GlobalScripts.showPopUp('Invalid URL', 'warning'); 50 } 51 return; 52 } 53 54 window.open(trimmed, '_blank', 'noopener,noreferrer'); 55 }); 56 57}(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.