1301searchboxInfo.setAttribute('tabindex', -1);1302searchboxWrapper.appendChild(searchboxInfo);13031304return searchboxWrapper;1305},13061307searchboxInit: function (searchboxId, searchboxType) {1308var searchbox = document.getElementById(searchboxId);1309var searchInput = searchbox.querySelector('.searchbox-input');1310var inputWrapper = searchInput.closest('.t-input-block');1311var that = this;1312
var changeTimeout; 'paste keyup'.split(' ').forEach(function (eventName) { searchInput.addEventListener( eventName, function (event) { if (!(event.keyCode >= 33 && event.keyCode <= 40)) { clearTimeout(changeTimeout); if (that.deliveryState.searchboxes[searchboxId]) { that.deliveryState.searchboxes[searchboxId].address = null; } if (that.deliveryState.searchboxes[searchboxId] && searchboxType !== 'pickup') { that.deliveryState.searchboxes[searchboxId].autocompleteAddress = null; } if (searchInput.value !== '' && !inputWrapper.classList.contains('active')) { inputWrapper.classList.add('active'); } changeTimeout = setTimeout(function () { that.changeSearchboxInputHandler(event, searchbox, searchboxType); changeTimeout = null; }, 500); } }, false ); }); var clicked = false; var timeout; // The touchpad on Windows sends only the mousdown event 'click mousedown keyup'.split(' ').forEach(function (eventName) { searchInput.addEventListener( eventName, function (event) { if (!clicked) { clicked = true; clearTimeout(timeout); timeout = setTimeout(function () { that.clickSearchboxInputHandler(event, searchbox, searchboxType); }, 150); } setTimeout(function () { clicked = false; }, 200); }, false ); }); searchInput.addEventListener( 'blur', function (event) { var relatedTarget = event.relatedTarget; if (!relatedTarget || !relatedTarget.classList.contains('searchbox-list')) { clearTimeout(changeTimeout); that.focusoutSearchboxInputHandler(searchbox, searchboxType); } }, false ); }, clickSearchboxInputHandler: function (event, searchbox, searchboxType) { var searchInput = searchbox.querySelector('.searchbox-input'); var inputWrapper = searchInput.closest('.t-input-block'); if (searchInput.value !== '' && !inputWrapper.classList.contains('active')) { inputWrapper.classList.add('active'); } var searchList = searchbox.querySelector('.searchbox-list'); var searchListItems = searchbox.querySelectorAll('.searchbox-list-item'); if (searchListItems.length) { searchList.style.display = ''; return; } if (searchInput.classList.contains('load')) { return; } var isAddressStrong; var serviceId = parseInt(searchInput.getAttribute('data-service-id'), 10);