1// BE - Counter - Type = 'Any' or 0 2function beCounter(container, type, loop = true) { 3 $('.be-counter', container).each(function () { 4 var count = $(this).find('.be-counter-count'), 5 plus = $('.be-counter-plus'), 6 minus = $('.be-counter-minus'), 7 min = count.data('min'), 8 max = count.data('max'), 9 anyCounter = $(this).find('.be-counter-any'), 10 andUp = $(this).find('.be-counter-and-up'), 11 exact = $(this).find('.be-counter-exact-toggle-checkbox'), 12 currentCount = count.text(), 13 hiddenInput = $(this).find('input[type=hidden]'); 14 function exactEnabled(enabled) { 15 if (enabled == false) { 16 // Disabled Exact Toggle 17 exact.closest('.be-counter-exact-toggle').addClass('disabled'); 18 exact.prop('checked', false).prop('disabled', true); 19 // Hide 'and up' plus sign when exact toggle is not turned on 20 andUp.addClass('d-none'); 21 } else { 22 // Enable Exact Toggle 23 exact.closest('.be-counter-exact-toggle').removeClass('disabled'); 24 exact.prop('disabled', false); 25 // Show 'and up' plus sign when exact toggle is turned on 26 andUp.removeClass('d-none'); 27 } 28 } 29 // Set .be-counter-any span and hiddenInput on page load 30 // If its empty, return the Type, else fill the currentCount on page load 31 if (currentCount == '') { 32 anyCounter.text(type); 33 hiddenInput.val(type); 34 exactEnabled(false); 35 } else { 36 count.removeClass('d-none'); 37 anyCounter.text(currentCount).addClass('d-none'); 38 hiddenInput.val(currentCount); 39 exactEnabled(true); 40 } 41 if (loop == false && currentCount == '') { 42 $(this).find(minus).addClass('disabled'); 43 } 44 // Counting Up 45 $(this).find(plus).on('click', function () { 46 if (loop == false) { 47 $(this).parent().find(minus).removeClass('disabled'); 48 } 49 if (count.hasClass('d-none')) { 50 anyCounter.addClass('d-none'); 51 count.removeClass('d-none'); 52 currentCount = min - 1; 53 exactEnabled(true); 54 } 55 if (currentCount === min || currentCount >= min - 1 && currentCount < max + 1) { 56 currentCount++; 57 count.text(currentCount); 58 hiddenInput.val(currentCount); 59 } 60 if (currentCount === max + 1) { 61 anyCounter.removeClass('d-none'); 62 count.addClass('d-none'); 63 anyCounter.text(type); 64 hiddenInput.val(type); 65 exactEnabled(false); 66 } 67 if (loop == false) { 68 if (currentCount === max) { 69 $(this).addClass('disabled'); 70 } 71 } 72 }); 73 // Counting Down 74 $(this).find(minus).on('click', function () { 75 if (loop == false) { 76 $(this).parent().find(plus).removeClass('disabled'); 77 } 78 if (count.hasClass('d-none')) { 79 anyCounter.addClass('d-none'); 80 count.removeClass('d-none'); 81 currentCount = max + 1; 82 exactEnabled(true); 83 } 84 if (currentCount <= max + 1 && currentCount > min - 1) { 85 --currentCount; 86 count.text(currentCount); 87 hiddenInput.val(currentCount); 88 } 89 if (currentCount === min - 1) { 90 anyCounter.removeClass('d-none'); 91 count.addClass('d-none'); 92 anyCounter.text(type); 93 hiddenInput.val(type); 94 exactEnabled(false); 95 if (loop == false) { 96 $(this).addClass('disabled'); 97 } 98 } 99 }); 100 }); 101}
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.