From 6f2dcc79d486922e60e3290f8953d8c686694da4 Mon Sep 17 00:00:00 2001 From: Garvin Hicking Date: Fri, 26 Jan 2007 08:27:36 +0000 Subject: [PATCH] Patch by Lars to improve quicksearch usability --- docs/NEWS | 6 ++++++ .../serendipity_event_livesearch.js | 18 ++++++++++++------ .../serendipity_event_livesearch.php | 17 +++++++++-------- 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/docs/NEWS b/docs/NEWS index 0efadfdc..bc448856 100644 --- a/docs/NEWS +++ b/docs/NEWS @@ -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) diff --git a/plugins/serendipity_event_livesearch/serendipity_event_livesearch.js b/plugins/serendipity_event_livesearch/serendipity_event_livesearch.js index b4672cc1..5be65938 100644 --- a/plugins/serendipity_event_livesearch/serendipity_event_livesearch.js +++ b/plugins/serendipity_event_livesearch/serendipity_event_livesearch.js @@ -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; + } } } diff --git a/plugins/serendipity_event_livesearch/serendipity_event_livesearch.php b/plugins/serendipity_event_livesearch/serendipity_event_livesearch.php index dadd4e71..24d5819f 100644 --- a/plugins/serendipity_event_livesearch/serendipity_event_livesearch.php +++ b/plugins/serendipity_event_livesearch/serendipity_event_livesearch.php @@ -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; } 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); '; break;