$(function(){ // show items based on checbox selection or dropdown selection $(filter).change(function(){ // get selected checkbox values var checkedBoxes = $(filter).find("input:checkbox:checked").map(function(){ return $(this).val(); }).get(); var selections = $(filter).find(".filter-value").map(function(){ return $(this).val(); }).get(); console.log('these are my selections', selections); let selector = $(".source-item"); console.log('active filters: '+checkedBoxes.join(', ')+' on '+selector.length+' items'); //if selections selected if(selections.length) { $(selector).each(function( index ) { let show = false; // hide by default // loop through checkboxes for (let i = 0; i < selections.length; ++i) { let item = $(this); if(selections[i].length){ if(selections[i] == 'all') { show = true; }else { // if selector has classname if(item.hasClass(selections[i])) { show = true; } else { show = false; item.addClass('hide-filtered').removeClass('show-filtered'); //thekeytoitall break; } } // check if to show the item if(show == true) { item.addClass('show-filtered').removeClass('hide-filtered'); } else { item.addClass('hide-filtered').removeClass('show-filtered'); } } } }); } $('table.paginated').trigger('repaginate'); }); /*Dropdown Menu*/ $('.dropdown').click(function () { $(this).attr('tabindex', 1).focus(); $(this).toggleClass('active'); $(this).find('.dropdown-menu').slideToggle(300); }); $('.dropdown').focusout(function () { $(this).removeClass('active'); $(this).find('.dropdown-menu').slideUp(300); }); $('.dropdown .dropdown-menu li').click(function () { $('.dropdown .dropdown-menu li span').removeClass('active'); $(this).find('.filtertag').addClass('active'); //$(this).parents('.dropdown').find('span').text($(this).text()); $(this).parents('.dropdown').find('.select').find('.select-target').text($(this).find('.filtertag').text()); $(this).parents('.dropdown').find('.select').find('.select-target').addClass('selected'); $dropdown = $(this).parents('.dropdown'); $icon = $dropdown.find('.fa-chevron-left:not(".fastay")'); $icon.hide(); $(this).parents('.dropdown').find('input').attr('value', $(this).attr('id')); $(this).parents('.dropdown').find('input').trigger('change'); }); $('.deselect').click(function () { $dropdown = $(this).parents('.dropdown'); $icon = $dropdown.find('.fa-chevron-left'); $icon.show(); $label = $dropdown.find('.select-target'); $input = $dropdown.find('.filter-value'); $('.dropdown .dropdown-menu li span').removeClass('active'); $label.removeClass('selected'); $label.text($label.attr('data-default')); $input.attr('value','all'); $input.trigger('change'); }); }); /*******************************************************************/ /* ftrtch dino */ /* [type: JS] [file:project-ftrlbs-filter] [123.1909] DESIGN*/ /*******************************************************************/ /* 0.2 D>D */ /* db 171 */