Advertisement
mspotilas

clear button for CSE search results 2015

Sep 18th, 2015
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   // clear button for CSE search results / MS-potilas 2015
  2.   function showhidex() { if($("#cse-search-form input.gsc-input")[0].value != "") window.setTimeout(function(){ $("#cseclr").show();}, 250); else $("#cseclr").hide(); }
  3.   $(window).load(function() { window.setTimeout(function() {
  4.     var xele=$("<a href='javascript:void()' onclick='customSearchControl.clearAllResults();$(&quot;#cseclr&quot;).hide();' id='cseclr' style='display:none;position:absolute;right:9px;top:1px;'><img title='Clear search results' src='http://www.google.com/uds/css/clear.gif' style='border:1px solid #eee;'/></a>");
  5.     $("#cse").before(xele);
  6.     $('#cse-search-form input.gsc-input').bind("enterKey",showhidex);
  7.     $('#cse-search-form input.gsc-input').keyup(function(e){ if(e.keyCode == 13) $(this).trigger("enterKey"); });
  8.     $("#cse-search-form .gsc-clear-button").click(function() { $("#cseclr").hide(); });
  9.     $("#cse-search-form input.gsc-search-button").click(showhidex);
  10.     if(searchPhrase != "") $("#cseclr").show();
  11.   }, 500); });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement