Patch by Lars to improve quicksearch usability

This commit is contained in:
Garvin Hicking 2007-01-26 08:27:36 +00:00
parent a0ef54e7ad
commit 6f2dcc79d4
3 changed files with 27 additions and 14 deletions

View File

@ -3,6 +3,12 @@
Version 1.2 ()
------------------------------------------------------------------------
* Improve Livesearch-Plugin to abort search on outside-of-box
click, fetch proper "not found" message on zero results
(Lars Strojny)
* Change bbCode plugin to use "white-space: pre". Thanks to jtb!
* Moved drag+drop and YahooUI library into templates/default/ to
be used in shared installation environments (garvinhicking)

View File

@ -55,7 +55,8 @@ function liveSearchInit() {
document.getElementById('searchform').setAttribute('autocomplete','off');
document.getElementById('serendipityQuickSearchTermField').setAttribute('autocomplete','off');
}
document.getElementById('serendipityQuickSearchTermField').style.border = '1px solid green';
document.onclick = liveSearchKeyPress
}
function liveSearchKeyPress(event) {
@ -87,14 +88,14 @@ function liveSearchKeyPress(event) {
}
if (!isIE) { event.preventDefault(); }
}
//ESC
else if (event.keyCode == 27) {
//ESC or mouse click
else if (event.keyCode == 27 || (event.clientX)) {
highlight = document.getElementById("LSHighlight");
if (highlight) {
highlight.removeAttribute("id");
}
document.getElementById("LSResult").style.display = "none";
} else {
} else {
liveSearchStart();
}
}
@ -108,7 +109,7 @@ function liveSearchStart() {
function liveSearchDoSearch() {
v = document.getElementById('serendipityQuickSearchTermField').value;
if (liveSearchLast != v && v.length > 3) {
if (liveSearchReq && liveSearchReq.readyState < 4) {
if (liveSearchReq && liveSearchReq.readyState < 3) {
liveSearchReq.abort();
}
@ -142,7 +143,12 @@ function liveSearchProcessReqChange() {
if (liveSearchReq.readyState == 4) {
var res = document.getElementById("LSResult");
res.style.display = "block";
res.firstChild.innerHTML = liveSearchReq.responseText;
rawResult = liveSearchReq.responseText.replace(/<[^>]+>/g, '')
if (parseInt(rawResult) == 1) {
res.firstChild.innerHTML = notfoundtext
} else {
res.firstChild.innerHTML = liveSearchReq.responseText;
}
}
}

View File

@ -61,6 +61,7 @@ class serendipity_event_livesearch extends serendipity_event
position: absolute;
margin-left: 4px;
margin-top: 4px;
background-color: #fff7e8;
}
#LSShadow {
@ -73,26 +74,25 @@ class serendipity_event_livesearch extends serendipity_event
}
#LSHighlight {
background-color: #80FF80;
background-color: #bdd2ec;
color: black;
}
.serendipity_livesearch_row {
margin: 0px;
line-height: 1.2em;
padding-top: 0.2em;
padding-bottom: 0.2em;
padding-top: 0.5em;
padding-bottom: 0.5em;
padding-left: 1.5em;
padding-right: 1.5em;
text-indent: -1em;
padding-left: 1em;
line-height: 1.2em;
padding-right: 1em;
line-height: 1.4em;
}
.serendipity_livesearch_result {
position: relative;
bottom: 2px;
right: 2px;
border: 1px solid black;
right: 2px;
padding: 2px;
}
<?php
@ -108,6 +108,7 @@ class serendipity_event_livesearch extends serendipity_event
echo '<script type="text/javascript">
lsbase = "' . $serendipity['baseURL'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . 'plugin/ls' . ($serendipity['rewrite'] == 'none' ? '_&' : '?') . '";
waittext = "' . PLUGIN_EVENT_LIVESEARCH_WAIT . '";
notfoundtext = "' . PLUGIN_EVENT_LIVESEARCH_NOTFOUND . '";
addLoadEvent(liveSearchInit);
</script>';
break;