1/** 2 * Deps: jquery 3 */ 4jQuery( function($){ 5 $('.custom-dropdown').each( function(){ 6 var $container = jQuery(this); 7 var $selection = $container.find('.dropdown-selection'); 8 var $optionsContainer = $container.find('.dropdown-options'); 9 var $options = $optionsContainer.find('li'); 10 var _activeOption; 11 function setActiveOption(option){ 12 if( _activeOption ){ 13 _activeOption.$el.removeClass('active'); 14 _activeOption.active = false; 15 } 16 option.active = true; 17 option.$el.addClass('active'); 18 $selection.hide().html( option.text ); 19 $selection.fadeIn() 20 _activeOption = option; 21 hideDropdown(); 22 $container.trigger('change', option.value ); 23 } 24 function showDropdown(){ 25 $container.addClass('dropdown-options-visible'); 26 $optionsContainer.fadeIn('fast'); 27 } 28 function hideDropdown(){ 29 $container.removeClass('dropdown-options-visible'); 30 $optionsContainer.fadeOut('fast'); 31 } 32 $selection.on('click', function(){ 33 if ( $optionsContainer.is(':visible') ){ 34 hideDropdown() 35 } else { 36 showDropdown() 37 } 38 }) 39 var options = []; 40 $options.each( function(){ 41 var $option = jQuery(this); 42 options.push({ 43 active: false, 44 $el: $option, 45 $link: $option.find('a'), 46 value: $option.data('value'), 47 text: $option.find('a').text().trim() 48 }); 49 }); 50 jQuery.each( options, function(i, option){ 51 option.$link.on('click', function(e){ 52 e.preventDefault(); 53 setActiveOption( option ); 54 }); 55 }); 56 setActiveOption( options[0] ); 57 }); 58 59 jQuery('.post-list-category-selector.custom-dropdown').on('change', function(e, value){ 60 jQuery('.filtered-post-list').hide().removeClass('active'); 61 var $postList = jQuery('.filtered-post-list.id-'+value); 62 console.log( $postList[0] ); 63 $postList.fadeIn('fast').addClass('active'); 64 }); 65});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.