Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $('.shop2-filter__item').each(function () {
- let $this = $(this);
- let $checkbox = $this.find('.shop2-filter__checkbox');
- let $search = $this.find('.gr-multiselect_js .gr-multiselect__search');
- let $search2 = $this.find('.gr-multiselect-2_js .gr-multiselect-2__search');
- let searchWidth = $search.outerWidth();
- $search.on("keyup", function () {
- filtrate($(this).val().toLowerCase(), $checkbox, 'gr-multiselect_hide_item');
- let thisLength = $(this).val().length;
- $(this).css({
- "width": searchWidth + (thisLength * 10)
- });
- });
- if ($checkbox.length > shop2.my.gr_filter_multiselect_count) {
- let $container = $(this).find('.gr-multiselect-2__container');
- $container.addClass('show_multi_search');
- };
- $search2.on("keyup", function () {
- if ($(this).val() != "") {
- $(this).addClass('active');
- } else {
- $(this).removeClass('active');
- };
- filtrate($(this).val().toLowerCase(), $checkbox, 'gr-multiselect-2_hide_item');
- });
- });
- function filtrate(searched, $context, hideClass) {
- $context.removeClass(hideClass);
- $context.each(function () {
- var isHidden = $(this).data('content').toString().toLowerCase().indexOf(searched) > -1;
- if (!isHidden) {
- $(this).addClass(hideClass);
- };
- });
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement