1(function () { 2 document.addEventListener('DOMContentLoaded', function () { 3 document.querySelectorAll('.js-filter-blog').forEach(function (filterBlog) { 4 new FilterBlog(filterBlog); 5 }); 6 }); 7 8 9 class FilterBlog { 10 constructor($container) { 11 this.$categorySelect = $container.querySelector('.js-filter-blog__category'); 12 this.$sortSelect = $container.querySelector('.js-filter-blog__sort'); 13 14 this.onCategorySelect = this.onCategorySelect.bind(this); 15 this.onSortSelect = this.onSortSelect.bind(this); 16 17 this.events(); 18 } 19 20 events() { 21 this.$categorySelect.addEventListener('change', this.onCategorySelect); 22 this.$sortSelect.addEventListener('change', this.onSortSelect); 23 } 24 25 onCategorySelect(e) { 26 this.onChangeCategory(e.target.value); 27 } 28 29 onSortSelect(e) { 30 this.onChangeSort(e.target.value); 31 } 32 33 onChangeCategory(value) { 34 const $option = this.$categorySelect.querySelector('option[value="' + value + '"]'); 35 if ($option) { 36 document.location.href = $option.dataset.url; 37 } 38 } 39 40 onChangeSort(value) { 41 document.location.href = document.location.pathname + '?sort=' + value; 42 } 43 } 44 45})();
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.