1jQuery(document).on('updated_checkout', function() { 2 searchable_selectbox(); 3}); 4 5jQuery(document).ready(function() { 6 searchable_selectbox(); 7}); 8 9function searchable_selectbox(selectbox = null) { 10 11 if (!selectbox) { 12 $selectBox = jQuery('.parcel-machine-select-box-searchable'); 13 } else { 14 $selectBox = selectbox; 15 } 16 17 $json = { 18 placeholder: MC_PARCELMACHINE_SEARCHABLE_JS[0]['placeholder'], 19 width: '100%', 20 dropdownAutoWidth: true, 21 containerCssClass: 'parcel-machine-select-box', 22 dropdownCssClass: 'makecommerce-selectbox-dropdown' 23 } 24 25 //It seems that some plugins or themes forcibly remove selectWoo 26 //Check if selectWoo 27 try { 28 if (typeof $selectBox.selectWoo === "function") { 29 $selectBox.selectWoo($json); 30 focus($selectBox); 31 32 } else { 33 //selectWoo didnt exist, try select2 or do nothing 34 if (typeof $selectBox.select2 === "function") { 35 $selectBox.select2($json); 36 focus($selectBox); 37 } 38 } 39 40 function focus($selectBox) { 41 $selectBox.on('select2:open', function (e) { 42 //this is ran using timeout because otherwise another event defocuses the element, most likely the click itself. 43 $searchField = jQuery('.select2-container--open').find('input.select2-search__field')[0]; 44 setTimeout(function() { jQuery($searchField).focus(); }, 1); 45 }); 46 } 47 } catch {} 48}
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.