1$(document).on('ready', function () { 2 addShowAllCategories(); 3 showAllCategoriesHandler(); 4}) 5 6function addShowAllCategories() { 7 $catWidth = $('.video-categories').width(); 8 $catItems = Array.from($('.video-categories a')); 9 $itemsWidth = 0 10 11 for (let i = 0; i < $catItems.length; i++) { 12 $item = $catItems[i]; 13 $itemWidth = $item.clientWidth; 14 $itemsWidth += $itemWidth + 4; 15 $nextItemWidth = $catItems[i + 1].clientWidth; 16 17 if ($itemsWidth > $catWidth - 30) { 18 $($catItems[i - 1]).after('<button type="button" class="add-more">+</button>') 19 break; 20 } else if (($itemsWidth + $nextItemWidth + 30) > $catWidth) { 21 $($catItems[i]).after('<button type="button" class="add-more">+</button>') 22 break; 23 } 24 } 25} 26 27function showAllCategoriesHandler() { 28 $(document).on('click', '.add-more', function (e) { 29 $this = e.target; 30 $parent = $('.video-categories'); 31 32 if ($parent.hasClass('open')) { 33 $this.remove(); 34 $parent.removeClass('open'); 35 addShowAllCategories(); 36 } else { 37 $this.remove(); 38 $parent.addClass('open'); 39 $parent.append('<button type="button" class="add-more">-</button>') 40 } 41 }) 42}
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.