]> git.mjollnir.org Git - s9y.git/commitdiff
Patch by Lars to improve quicksearch usability
authorgarvinhicking <garvinhicking>
Fri, 26 Jan 2007 08:27:36 +0000 (08:27 +0000)
committergarvinhicking <garvinhicking>
Fri, 26 Jan 2007 08:27:36 +0000 (08:27 +0000)
docs/NEWS
plugins/serendipity_event_livesearch/serendipity_event_livesearch.js
plugins/serendipity_event_livesearch/serendipity_event_livesearch.php

index 0efadfdcfa6dd89c9737773b5e8c73aca207f04c..bc4488567ce67076932f2fb08aed195428ce763c 100644 (file)
--- 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)
 
index b4672cc11047fe43c59fe8db0a936edc7f14024c..5be65938946d9956bc1d18aaf633f1161599ebeb 100644 (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;
+        }
     }
 }
 
index dadd4e71fb827506f574019c781382493993f929..24d5819fdacbefc1dde67260d6ced838417e9177 100644 (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;