1(function ($) { 2 'use strict'; 3 4 var WORD_THRESHOLD = 60; 5 6 $(function () { 7 $('.naviga-scoreboard, .naviga-factbox').each(function () { 8 var $box = $(this); 9 10 // Avoid double-initialising 11 if ($box.data('scoreboard-init')) return; 12 $box.data('scoreboard-init', true); 13 14 // Count words in the box text (strip HTML) 15 var wordCount = $.trim($box.text()).split(/\s+/).length; 16 17 // Short factboxes (< 60 words) â show full width, no collapse 18 if (wordCount < WORD_THRESHOLD) { 19 $box.addClass('naviga-scoreboard--short naviga-scoreboard--open'); 20 $box.attr('aria-expanded', 'true'); 21 return; 22 } 23 24 // Long factboxes â collapsed with Expand button 25 var $expandBtn = $('<button class="factbox-expand-btn" aria-label="Expand factbox">Expand</button>'); 26 var $closeBtn = $('<button class="factbox-close-btn" aria-label="Close factbox">Close</button>'); 27 28 $box.append($expandBtn); 29 $box.append($closeBtn); 30 31 $expandBtn.on('click', function (e) { 32 e.stopPropagation(); 33 $box.addClass('naviga-scoreboard--open'); 34 $box.attr('aria-expanded', 'true'); 35 }); 36 37 $closeBtn.on('click', function (e) { 38 e.stopPropagation(); 39 $box.removeClass('naviga-scoreboard--open'); 40 $box.attr('aria-expanded', 'false'); 41 }); 42 }); 43 }); 44 45}(jQuery));
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.