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

[ADD] Clear search button in shop

See merge request flectra-hq/flectra!72
This commit is contained in:
Parthiv Patel 2018-06-01 12:59:24 +00:00
commit 284c4d305f
2 changed files with 23 additions and 0 deletions

View File

@ -919,6 +919,9 @@ Sitemap: <t t-esc="url_root"/>sitemap.xml
<template id="website_search_box" name="Website Searchbox">
<div class="input-group">
<span class="input-group-btn">
<span class="btn btn-default oe_search_clear_button hidden"><i class="fa fa-close"></i></span>
</span>
<div class="oe_search">
<input type="text" name="search" class="search-query form-control oe_search_box" placeholder="Search..." t-att-value="search" />
</div>

View File

@ -438,6 +438,26 @@ flectra.define('website_sale.website_sale', function (require) {
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) {