1"use strict"; 2var woof_sku_do_submit = false; 3function woof_init_sku() { 4 woof_sku_check_reset(); 5 jQuery('.woof_show_sku_search').keyup(function (e) { 6 7 let parent = this.parentNode; 8 let woof_sku_autocomplete = parseInt(parent.dataset.autocomplete); 9 let woof_sku_autocomplete_items = parseInt(parent.dataset.autocomplete_items); 10 11 var val = jQuery(this).val(); 12 val = val.replace(' ', ''); 13 var uid = jQuery(this).data('uid'); 14 15 if (e.keyCode == 13) { 16 woof_sku_do_submit = true; 17 woof_sku_direct_search('woof_sku', val); 18 return true; 19 } 20 21 //save new word into woof_current_values 22 if (woof_autosubmit) { 23 woof_current_values['woof_sku'] = val; 24 } else { 25 woof_sku_direct_search('woof_sku', val); 26 } 27 28 29 //if (woof_is_mobile == 1) { 30 if (val.length > 0) { 31 jQuery('.woof_sku_search_go.' + uid).show(222); 32 jQuery('.woof_sku_search_reset.' + uid).show(222); 33 } else { 34 jQuery('.woof_sku_search_go.' + uid).hide(); 35 jQuery('.woof_sku_search_reset.' + uid).hide(); 36 } 37 //} 38 39 40 //http://easyautocomplete.com/examples 41 if (val.length >= 3 && woof_sku_autocomplete) { 42 var input_id = jQuery(this).attr('id'); 43 var nonce = jQuery('.woof_sku_search_nonce').val() 44 var options = { 45 url: function (phrase) { 46 return woof_ajaxurl; 47 }, 48 //theme: "square", 49 getValue: function (element) { 50 return element.name; 51 }, 52 ajaxSettings: { 53 dataType: "json", 54 method: "POST", 55 data: { 56 action: "woof_sku_autocomplete",
57 dataType: "json", 58 woof_sku_search_nonce: nonce 59 } 60 }, 61 preparePostData: function (data) { 62 data.phrase = jQuery("#" + input_id).val(); 63 return data; 64 }, 65 template: { 66 type: "description", 67 fields: { 68 69 description: "type" 70 } 71 }, 72 list: { 73 maxNumberOfElements: woof_sku_autocomplete_items, 74 onChooseEvent: function () { 75 woof_sku_do_submit = true; 76 woof_sku_direct_search('woof_sku', jQuery("#" + input_id).val()); 77 return true; 78 }, 79 showAnimation: { 80 type: "fade", //normal|slide|fade 81 time: 333, 82 callback: function () { 83 } 84 }, 85 hideAnimation: { 86 type: "slide", //normal|slide|fade 87 time: 333, 88 callback: function () { 89 } 90 } 91 92 }, 93 requestDelay: 400 94 }; 95 try { 96 jQuery("#" + input_id).easyAutocomplete(options); 97 } catch (e) { 98 console.log(e); 99 } 100 jQuery("#" + input_id).focus(); 101 } 102 }); 103 //+++ 104 jQuery('body').on('click', '.woof_sku_search_go', function () { 105 var uid = jQuery(this).data('uid'); 106 woof_sku_do_submit = true; 107 var val = jQuery('.woof_show_sku_search.' + uid).val(); 108 val = val.replace(' ', ''); 109 woof_sku_direct_search('woof_sku', val); 110 }); 111 jQuery('body').on('click', '.woof_sku_search_reset', function () { 112 var uid = jQuery(this).data('uid'); 113 jQuery('.woof_show_sku_search.' + uid).val(""); 114 if (typeof woof_current_values['woof_sku'] != 'undefined') { 115 delete woof_current_values['woof_sku']; 116 } 117 woof_sku_check_reset(); 118 119 let woof_sku_reset_behavior = parseInt(this.dataset.reset_behavior); 120 121 if (woof_sku_reset_behavior) { 122 woof_submit_link(woof_get_submit_link()); 123 } 124 }); 125} 126 127function woof_sku_check_reset() { 128 var all_sku = jQuery('.woof_show_sku_search'); 129 jQuery.each(all_sku, function (index, input) { 130 var val = jQuery(input).val(); 131 var uid = jQuery(input).data('uid'); 132 if (val.length > 0) { 133 jQuery('.woof_sku_search_reset.' + uid).show(222); 134 } else { 135 jQuery('.woof_sku_search_reset.' + uid).hide(); 136 } 137 }); 138} 139 140function woof_sku_direct_search(name, slug) { 141 142 jQuery.each(woof_current_values, function (index, value) { 143 if (index == name) { 144 delete woof_current_values[name]; 145 return; 146 } 147 }); 148 149 if (slug != 0) { 150 woof_current_values[name] = slug; 151 } 152 153 woof_ajax_page_num = 1; 154 if (woof_autosubmit || woof_sku_do_submit) { 155 woof_sku_do_submit = false; 156 woof_submit_link(woof_get_submit_link()); 157 } 158} 159 160
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.