diff options
| author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2005-08-24 16:12:25 +0000 |
|---|---|---|
| committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2005-08-24 16:12:25 +0000 |
| commit | 86e2b120396073ff81d74ff45e700ac24f4ea6da (patch) | |
| tree | d10299551fc4060140f6fcbb986957ce9f8d9a78 /wp-inst/wp-admin/admin-functions.php | |
| parent | 6527622aa4b6bfe0217dd22d11587c34a5b65ea3 (diff) | |
| download | wordpress-mu-86e2b120396073ff81d74ff45e700ac24f4ea6da.tar.gz wordpress-mu-86e2b120396073ff81d74ff45e700ac24f4ea6da.tar.xz wordpress-mu-86e2b120396073ff81d74ff45e700ac24f4ea6da.zip | |
Category searching:
1. backspace and escape close search
2. losing focus closes search after 2 second delay
3. check for carriage return so empty search doesn't go through!
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@222 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-inst/wp-admin/admin-functions.php')
| -rw-r--r-- | wp-inst/wp-admin/admin-functions.php | 53 |
1 files changed, 42 insertions, 11 deletions
diff --git a/wp-inst/wp-admin/admin-functions.php b/wp-inst/wp-admin/admin-functions.php index b98772d..d6f4e71 100644 --- a/wp-inst/wp-admin/admin-functions.php +++ b/wp-inst/wp-admin/admin-functions.php @@ -1431,6 +1431,7 @@ function AJAX_search_box( $get_url, $search_field = 'newvalue', $search_results_ valBox = document.getElementById("<?php echo $search_field ?>"); displayBox = document.getElementById("<?php echo $search_results_field ?>"); addEvent(valBox, 'keyup', doTest, false); + addEvent(valBox, 'blur', onblurnewcat, false); keyPressDelay = ''; xmlhttp=false; @@ -1450,30 +1451,60 @@ function AJAX_search_box( $get_url, $search_field = 'newvalue', $search_results_ } addLoadEvent( init_ajax_searchbox ); - function doTest() { + function onblurnewcat() { + setTimeout('closeSearchResults()',2000); + } + function closeSearchResults() { + displayBox.style.display = 'none'; + } + + function doTest(e) { + if (!e) { + if (window.event) { + e = window.event; + } else { + return; + } + } + if (e.keyCode == 8) { + displayBox.style.display = 'none'; + } + if (e.keyCode == 27) { + displayBox.style.display = 'none'; + return; + } if (keyPressDelay) { window.clearTimeout(keyPressDelay); } if(valBox.value.length > 2) { keyPressDelay = window.setTimeout('doSearch()',800); + } else { + displayBox.style.display = 'none'; } + } function doSearch() { - xmlhttp.open("GET","<?php echo $get_url ?>"+valBox.value,true); - xmlhttp.onreadystatechange=function() { - if (xmlhttp.readyState==4) { - if( xmlhttp.responseText != '' ) { - displayBox.style.display = ''; - displayBox.innerHTML = xmlhttp.responseText; - } else { - valBox.focus(); - displayBox.style.display = 'none'; + if(valBox.value.length > 2 && displayBox.style.display == 'none' ) { + xmlhttp.open("GET","<?php echo $get_url ?>"+valBox.value,true); + xmlhttp.onreadystatechange=function() { + if (xmlhttp.readyState==4) { + if( xmlhttp.responseText != '' ) { + displayBox.style.display = 'table'; + displayBox.innerHTML = xmlhttp.responseText; + if( displayBox.innerWidth ) { + displayBox.width=displayBox.innerWidth; + displayBox.height=displayBox.innerHeight; + } + } else { + valBox.focus(); + displayBox.style.display = 'none'; + } } } + xmlhttp.send(null); } - xmlhttp.send(null); } </script> <?php |
