You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

29 lines
732 B

import $ from 'jquery';
import {MOBILE_WIDTH} from "../constants";
$(document).ready(function () {
let search = $('.js-search'),
input = search.find('.js-search-input'),
btn = search.find('.js-search-btn');
btn.on('click', function(e){
if ($(window).width() >= MOBILE_WIDTH) {
if (!search.hasClass('open')) {
e.preventDefault();
}
search.addClass('open');
setTimeout(function(){
input.focus();
}, 200);
}
});
search.on('click', function(e){
e.stopPropagation();
});
$(document).on('click', function(){
search.removeClass('open');
input.val('');
});
});