summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandi <andi@splitbrain.org>2005-05-17 22:17:19 +0200
committerandi <andi@splitbrain.org>2005-05-17 22:17:19 +0200
commit32c04430626da6095e213cfe6effafa577f9e3ab (patch)
tree0bf6fcbd9586d33ca2fc4bb5d478d58a11b59b6b
parentf330ee2babdb79935de1bf551f415518ddb73de6 (diff)
downloadrpg-32c04430626da6095e213cfe6effafa577f9e3ab.tar.gz
rpg-32c04430626da6095e213cfe6effafa577f9e3ab.tar.bz2
some ajax quicksearch tweaking
added a half second delay before the suggstions appear, moved the postion to appear besides the browsers autocomplete... I'm still not sure if this is useful at all. darcs-hash:20050517201719-9977f-6e71a415dd08a84af38bd3643860beb7002088f5.gz
-rw-r--r--ajax.php4
-rw-r--r--inc/template.php25
-rw-r--r--tpl/default/design.css2
3 files changed, 27 insertions, 4 deletions
diff --git a/ajax.php b/ajax.php
index 7af88d835..26bccc4d0 100644
--- a/ajax.php
+++ b/ajax.php
@@ -30,6 +30,7 @@ if(function_exists($call)){
*/
function ajax_qsearch(){
global $conf;
+ global $lang;
$query = cleanID($_REQUEST['q']);
if(empty($query)) return;
@@ -41,6 +42,9 @@ function ajax_qsearch(){
$data = array();
search($data,$conf['datadir'],'search_qsearch',array(query => $query),$nsdir);
+ if(!count($data)) return;
+
+ print '<b>'.$lang['quickhits'].'</b>';
print html_buildlist($data,'qsearch','html_list_index');
}
diff --git a/inc/template.php b/inc/template.php
index 0720a12f6..2baa6f77e 100644
--- a/inc/template.php
+++ b/inc/template.php
@@ -331,7 +331,7 @@ function tpl_actionlink($type,$pre='',$suf=''){
*/
function tpl_searchform(){
global $lang;
- print '<form action="'.wl().'" accept-charset="utf-8" class="search" onsubmit="return svchk()">';
+ print '<form action="'.wl().'" accept-charset="utf-8" class="search" name="search" onsubmit="return svchk()">';
//FIXME this should be moved somewhere else
?>
@@ -340,17 +340,36 @@ function tpl_searchform(){
ajax = new sack('<?=DOKU_BASE?>ajax.php');
ajax.AjaxFailedAlert = '';
- function ajax_qsearch(value){
+ var qr = null;
+ function ajax_runqsearch(){
+ ajax_stopqsearch();
+ qr = window.setTimeout('ajax_qsearch()',500);
+ }
+
+ function ajax_stopqsearch(){
+ document.getElementById('ajax_qsearch').innerHTML = '';
+ if(qr != null){
+ window.clearTimeout(qr);
+ qr = null;
+ }
+ }
+
+ function ajax_qsearch(){
+ var value = document.search.id.value;
+ if(value=='') return;
ajax.element = 'ajax_qsearch';
ajax.encodeURIString = false;
var call = 'call=qsearch&q=';
call += encodeURI(value);
ajax.runAJAX(call);
+
+ ajax_stopqsearch()
}
</script>
<?php
print '<input type="hidden" name="do" value="search" />';
- print '<input type="text" accesskey="f" name="id" class="edit" onkeyup="ajax_qsearch(this.value)" />';
+ #print '<input type="text" accesskey="f" name="id" class="edit" autocomplete="off" onkeyup="ajax_qsearch(this.value)" />';
+ print '<input type="text" accesskey="f" name="id" class="edit" onkeypress="ajax_runqsearch()" />';
print '<input type="submit" value="'.$lang['btn_search'].'" class="button" />';
print '<div id="ajax_qsearch" class="ajax_qsearch"></div>';
print '</form>';
diff --git a/tpl/default/design.css b/tpl/default/design.css
index 73914d3f9..3e743f20e 100644
--- a/tpl/default/design.css
+++ b/tpl/default/design.css
@@ -596,9 +596,9 @@ div.acladmin table{
div.ajax_qsearch {
position:absolute;
+ right:225px;;
text-align:left;
width: 200px;
background-color: #ff9;
opacity: 0.9;
- -moz-border-radius: 15px;
}