1(function ($) { 2 $(function () { 3 var delay = (function () { 4 var timer = 0; 5 return function (cb, ms) { 6 clearTimeout(timer); 7 timer = setTimeout(cb, ms); 8 }; 9 })(); 10 11 $(document).on('submit', '.spine-search-form-container', function (e) { 12 e.preventDefault(); 13 e.stopImmediatePropagation(); 14 var keyword = $(this).find('input').val(); 15 16 if (keyword) { 17 window.location.href = $(this).attr('action') + 'define/' + keyword + '/'; 18 } 19 }); 20 21 $(document).on('keyup', '.spine-search-form-container input[name=s]', function () { 22 delay(function () { 23 userInput(); 24 }, 500); 25 }); 26 27 function userInput() { 28 var el = $('.spine-search-form-container input[name=s]'); 29 var minLength = 2; 30 var keyword = el.val(); 31 var keywordLen = keyword.length; 32 if (keywordLen >= minLength) { 33 $.post(ajaxObject.ajax_url, {action: 'def_search_suggest', word: keyword}).done(function (data) { 34 var results = JSON.parse(data); 35 $('.results__suggestions').empty(); 36 var resultDivOpening = '<div class="results__suggestions-item">'; 37 var resultDivClosing = '</div>'; 38 if (results.success === true) { 39 $(results.results).each(function (key, value) { 40 var resultDivOpening = '<div class="results__suggestions-item" data-encoded="' + Object.keys(value) + '">'; 41 $('.results__suggestions').append(resultDivOpening + Object.values(value) + resultDivClosing); 42 }); 43 $('.results__suggestions-item').on('click', function () { 44 var text = $(this).html(); 45 $('.js-val').val(text); 46 var nurl = "/define/" + $(this).attr('data-encoded') + '/'; 47 window.location.href = nurl; 48 }); 49 } 50 }); 51 } else { 52 $('.results__suggestions').html(''); 53 } 54 } 55 56 $('.spine-search-form-container input[name=s]').on('blur', function () { 57 $('.results__suggestions').fadeOut(500); 58 }).on('focus', function () { 59 $('.results__suggestions').show(); 60 }); 61 $(document).on('click', '.jq-search-definitions', function () { 62 var input = $(this).closest('form').find('input'); 63 if (input.val()) { 64 window.location.href = $(this).data('action') + '/' + input.val(); 65 } 66 return false; 67 }); 68 69 $(document).on('click', '.jq-search-and-translate', function () { 70 var form = $(this).closest('form'), 71 input = form.find('input'), 72 from = form.find('.dropdown-menu.from').data('selected'), 73 to = form.find('.dropdown-menu.to').data('selected'); 74 75 if (input.val() && from && to) { 76 window.location.href = $(this).data('action') + '/' + input.val() + '/' + from + '/' + to; 77 } 78 return false; 79 }); 80 81 $(document).on('click', '.spine-search-form-container .dropdown-menu a', function () { 82 var dropdown = $(this).closest('.dropdown-menu'), 83 selectedLang = $(this).data('iso'); 84 85 dropdown.parent().find('button').text(selectedLang).trigger('click'); 86 dropdown.data('selected', selectedLang.toLowerCase()); 87 return false; 88 }); 89 90 $('.jq-switch-language').on('click', function () { 91 var fromL = $('.dropdown-menu.from').data('selected'); 92 var toL = $('.dropdown-menu.to').data('selected'); 93 $('.dropdown-menu.from li a[data-iso="' + toL + '"]').click(); 94 $('.dropdown-menu.to li a[data-iso="' + fromL + '"]').click(); 95 }); 96 97 var bodyHeight = 0; 98 99 setInterval(function () { 100 if (bodyHeight > 0 && bodyHeight != $('body').height()) { 101 $(window).scroll(); 102 } 103 bodyHeight = $('body').height(); 104 }, 300); 105 }); 106})(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.