Sha256: f5fbc896367af01fc22dd483c9aa9eaa77e968c0b8a34ebce1da17e36385122a
Contents?: true
Size: 1.33 KB
Versions: 31
Compression:
Stored size: 1.33 KB
Contents
function navbar_search(query_string){ $.get( {url : window.location.origin + "/search/authenticated_user_search", data: { query: {query_string: query_string} }, beforeSend: function(){ //clear_search_results(); }, success : function( data ) {}, dataType : "script" }); } $(document).on('keyup', '#search',function(event){ navbar_search($(this).val()); }); /* Clear the search result if focus out from the title. */ $(document).on('click','body',function(event){ if(event.target.id === 'search'){ } else if(event.target.id === 'search_title'){ } else{ $(".search_result").remove(); } }); /* Highlight Autocomplete Matching Text */ var highlight = function() { var strings = $("#search").val().split(/\s+/); $(".search_result").mark(strings); /** $.each(strings,function(index,string){ $(".search_result").each(function () { // this is not going to be easy. var matchStart = $(this).html().toLowerCase().indexOf("" + string.toLowerCase() + ""); var matchEnd = matchStart + string.length - 1; var beforeMatch = $(this).html().slice(0, matchStart); var matchText = $(this).html().slice(matchStart, matchEnd + 1); var afterMatch = $(this).html().slice(matchEnd + 1); $(this).html(beforeMatch + "<span class='yellow'>" + matchText + "</span>" + afterMatch); }); }); **/ }
Version data entries
31 entries across 31 versions & 1 rubygems