Merge branch 'master-clear-search' into 'master'

[FIX] clear search button work anywhere on website page

See merge request flectra-hq/flectra!73
This commit is contained in:
Parthiv Patel 2018-06-05 06:04:33 +00:00
commit 9bcdd406a3

View File

@ -1,3 +1,33 @@
flectra.define('website_sale.clear_search', function (require) {
"use strict";
require('web.dom_ready');
var $search_box = $('.oe_search_box');
var _clear_search_btn = function (e){
var $search_clear_btn = $('.oe_search_clear_button');
if($(e).val().trim()){
$search_clear_btn.removeClass('hidden');
}else{
$search_clear_btn.addClass('hidden');
}
};
_clear_search_btn($search_box);
$search_box.on('keyup', function (event) {
_clear_search_btn(this);
});
$('.oe_search_clear_button').on('click', function (e) {
var $form = $(this).parents('form');
$form.find('.oe_search_box').val('');
if(window.location.pathname != '/'){
$form.trigger('submit');
}
});
});
flectra.define('website_sale.cart', function (require) { flectra.define('website_sale.cart', function (require) {
"use strict"; "use strict";
@ -438,26 +468,6 @@ flectra.define('website_sale.website_sale', function (require) {
window.location = oldurl + '&' + search.attr('name') + '=' + encodeURIComponent(search.val()); window.location = oldurl + '&' + search.attr('name') + '=' + encodeURIComponent(search.val());
} }
}); });
var $search_box = $('.oe_website_sale .oe_search_box');
var _clear_search_btn = function (e){
var $search_clear_btn = $('.oe_website_sale .oe_search_clear_button');
if($(e).val().trim()){
$search_clear_btn.removeClass('hidden');
}else{
$search_clear_btn.addClass('hidden');
}
};
_clear_search_btn($search_box);
$search_box.on('keyup', function (event) {
_clear_search_btn(this);
});
$('.oe_website_sale .oe_search_clear_button').on('click', function (e) {
$('.oe_website_sale .oe_search_box').val('');
$('.oe_website_sale .o_website_sale_search').trigger('submit');
});
} }
if ($(".checkout_autoformat").length) { if ($(".checkout_autoformat").length) {