ni_nitdoc: added "more results" entry in quicksearch.
authorAlexandre Terrasa <alexandre@moz-code.org>
Thu, 8 Aug 2013 17:31:49 +0000 (13:31 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Wed, 14 Aug 2013 13:47:10 +0000 (09:47 -0400)
Whenever the number of results for quicksearch reach 10, an entry is added to the quicksearch to show that more results exist and allow user to clic and go to the Search page

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

share/nitdoc/scripts/js-facilities.js
share/nitdoc/styles/main.css

index 4297dd3..a71a0dd 100644 (file)
@@ -84,6 +84,9 @@ $(document).ready(function() {
                                                // Select next result on "Down"\r
                                                case 40:\r
                                                        if(currentIndex < currentTable.find("tr").length - 1) {\r
+                                                               if($(currentTable.find("tr")[currentIndex + 1]).hasClass("overflow")) {\r
+                                                                       break;\r
+                                                               }\r
                                                                $(currentTable.find("tr")[currentIndex]).removeClass("activeSearchResult");\r
                                                                currentIndex++;\r
                                                                $(currentTable.find("tr")[currentIndex]).addClass("activeSearchResult");\r
@@ -100,8 +103,8 @@ $(document).ready(function() {
                                                        if($("#search").val().length == 0)\r
                                                                return false\r
                                \r
-                                                       window.location = "full-index.html#q=" + $("#search").val();\r
-                                                       if(window.location.href.indexOf("full-index.html") > -1) {\r
+                                                       window.location = "search.html#q=" + $("#search").val();\r
+                                                       if(window.location.href.indexOf("search.html") > -1) {\r
                                                                location.reload();\r
                                                        }                               \r
                                                        return false;\r
@@ -146,14 +149,13 @@ $(document).ready(function() {
 \r
                                                        var index = 0;\r
                                                        var regexp = new RegExp("^" + query, "i");\r
+                                                       var overflow = 0;\r
                                                        for(var entry in entries) {\r
-                                                               if(index > 10) {\r
-                                                                       break;\r
-                                                               }\r
                                                                var result = entry.match(regexp);\r
                                                                if(result != null) {\r
                                                                        for(var i = 0; i < entries[entry].length; i++) {\r
                                                                                if(index > 10) {\r
+                                                                                       overflow++;\r
                                                                                        break;\r
                                                                                }\r
                                                                                currentTable.append(\r
@@ -181,6 +183,23 @@ $(document).ready(function() {
                                                                        }\r
                                                                }\r
                                                        }\r
+                                                       if(overflow > 0) {\r
+                                                               currentTable.append(\r
+                                                                       $("<tr class='overflow'>")\r
+                                                                       .append(\r
+                                                                               $("<td colspan='2'>")\r
+                                                                               .append(\r
+                                                                                       $("<a href='#' title='Show all results' data-query='"+ query +"'>" + overflow + " more results for '" + query + "'</a>")\r
+                                                                                       .click(function() {\r
+                                                                                               window.location = "search.html#q=" + $(this).attr("data-query");\r
+                                                                                               if(window.location.href.indexOf("search.html") > -1) {\r
+                                                                                                       location.reload();\r
+                                                                                               }\r
+                                                                                       })\r
+                                                                               )\r
+                                                                       )\r
+                                                               );\r
+                                                       }\r
                                                        \r
                                                        // Initialize table properties\r
                                                        currentTable.attr("id", "searchTable");\r
index 6d1d80a..42ed6ae 100644 (file)
@@ -488,6 +488,11 @@ nav h3 a.fold {
        text-align: right;\r
 }\r
 \r
+#searchTable tr.overflow td {\r
+       text-align: center;\r
+       background-color: #E0E0E0;\r
+}\r
+\r
 textarea {\r
        margin: 10px;\r
        font-family: monospace;\r