From c2781f5a1d81a3362035bde4d0d5d6f320a7bd16 Mon Sep 17 00:00:00 2001 From: Felix Mulder Date: Mon, 14 Mar 2016 19:28:41 +0100 Subject: Change behavior of clear-button on input fields This commit changes the behavior to only remove the "x" if there is no input in the input field. The old behavior was to bind the blur event to be fired later - but this had the drawback of not working properly on fast hardware as the timeout would actually beat the click event. --- .../scala/tools/nsc/doc/html/resource/lib/template.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'src/scaladoc/scala/tools/nsc/doc/html/resource/lib/template.js') diff --git a/src/scaladoc/scala/tools/nsc/doc/html/resource/lib/template.js b/src/scaladoc/scala/tools/nsc/doc/html/resource/lib/template.js index ae39f83852..5f42dfa114 100644 --- a/src/scaladoc/scala/tools/nsc/doc/html/resource/lib/template.js +++ b/src/scaladoc/scala/tools/nsc/doc/html/resource/lib/template.js @@ -147,10 +147,10 @@ $(document).ready(function() { }); $("#memberfilter > .clear").click(function() { $("#memberfilter input").attr("value", ""); + $(this).hide(); filter(); }); $(document).keydown(function(event) { - if (event.keyCode == 9) { // tab $("#index-input", window.parent.document).focus(); input.attr("value", ""); @@ -162,8 +162,7 @@ $(document).ready(function() { if ($(this).hasClass("in")) { $(this).removeClass("in"); $(this).addClass("out"); - } - else if ($(this).hasClass("out")) { + } else if ($(this).hasClass("out")) { $(this).removeClass("out"); $(this).addClass("in"); } @@ -174,8 +173,7 @@ $(document).ready(function() { if ($(this).hasClass("in")) { $(this).removeClass("in"); $(this).addClass("out"); - } - else if ($(this).hasClass("out")) { + } else if ($(this).hasClass("out")) { $(this).removeClass("out"); $(this).addClass("in"); } @@ -307,14 +305,11 @@ $(document).ready(function() { exposeMember(jqElem); } - $("#mbrsel-input").on("focus", function() { - $("#memberfilter > .clear").show(); - }); - - $("#mbrsel-input").on("blur", function() { - setTimeout(function() { + $("#mbrsel-input").on("input", function() { + if ($(this).val().length > 0) + $("#memberfilter > .clear").show(); + else $("#memberfilter > .clear").hide(); - }, 10); }); }); -- cgit v1.2.3