summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2005-08-24 16:12:25 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2005-08-24 16:12:25 +0000
commit86e2b120396073ff81d74ff45e700ac24f4ea6da (patch)
treed10299551fc4060140f6fcbb986957ce9f8d9a78
parent6527622aa4b6bfe0217dd22d11587c34a5b65ea3 (diff)
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
-rw-r--r--wp-inst/wp-admin/admin-functions.php53
-rw-r--r--wp-inst/wp-admin/admin-header.php13
-rw-r--r--wp-inst/wp-admin/edit-form-advanced.php1
-rw-r--r--wp-inst/wp-admin/wpmu-edit.php5
4 files changed, 59 insertions, 13 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
diff --git a/wp-inst/wp-admin/admin-header.php b/wp-inst/wp-admin/admin-header.php
index 6db9421..4dd69d8 100644
--- a/wp-inst/wp-admin/admin-header.php
+++ b/wp-inst/wp-admin/admin-header.php
@@ -127,8 +127,21 @@ function newCatAddIn() {
newcatSub.value = '+';
newcatSub.setAttribute('onclick', 'ajaxNewCat();');
+ var searchResult = document.createElement( 'div' );
+ searchResult.type = 'div';
+ searchResult.name = 'searchresults';
+ searchResult.id = 'searchresults';
+ searchResult.style.display = 'none';
+ searchResult.style.overflow = 'auto';
+ searchResult.style.border = '1px solid #ccc';
+ searchResult.style.background = '#eee';
+ searchResult.style.margin = '5px';
+ searchResult.style.padding = '5px';
+
+
ajaxcat.appendChild(newcat);
ajaxcat.appendChild(newcatSub);
+ ajaxcat.appendChild(searchResult);
document.getElementById('categorychecklist').parentNode.appendChild(ajaxcat);
}
diff --git a/wp-inst/wp-admin/edit-form-advanced.php b/wp-inst/wp-admin/edit-form-advanced.php
index 7196162..3524c53 100644
--- a/wp-inst/wp-admin/edit-form-advanced.php
+++ b/wp-inst/wp-admin/edit-form-advanced.php
@@ -85,7 +85,6 @@ addLoadEvent(focusit);
<h3 class="dbx-handle"><?php _e('Categories') ?></h3>
<div class="dbx-content"><div id="categorychecklist"><?php dropdown_categories(get_settings('default_category')); ?></div></div>
<?php if ( current_user_can('manage_categories') ) : ?>
- <div style='display:none; height: 60px; width: 100px; overflow: auto; border: 1px solid #ccc; background: #eee; margin: 5px; padding: 5px;' id="searchresults"><?php _e( 'Search Results' ) ?></div>
<?php AJAX_search_box( "wpmu-edit.php?action=searchcategories&search=", "newcat", "searchresults" ); ?>
<?php endif; ?>
</fieldset>
diff --git a/wp-inst/wp-admin/wpmu-edit.php b/wp-inst/wp-admin/wpmu-edit.php
index 23ecd5f..72950cf 100644
--- a/wp-inst/wp-admin/wpmu-edit.php
+++ b/wp-inst/wp-admin/wpmu-edit.php
@@ -34,10 +34,13 @@ switch( $_GET[ 'action' ] ) {
$query = "SELECT cat_name FROM " . $wpdb->sitecategories . " WHERE cat_name LIKE '%" . $search . "%' limit 0,10";
$cats = $wpdb->get_results( $query );
if( is_array( $cats ) ) {
+ print "<table>";
+ print "<tr><td>ESC to cancel</td></tr>";
while( list( $key, $val ) = each( $cats ) )
{
- print '<span onclick="javascript:return update_AJAX_search_box(\'' . $val->cat_name . '\');"><a>' . $val->cat_name . '</a></span><br>';
+ print '<tr><td><span onclick="javascript:return update_AJAX_search_box(\'' . $val->cat_name . '\');"><a>' . $val->cat_name . '</a></span></td></tr>';
}
+ print "</table>";
}
exit;
break;