ni_nitdoc: added "more results" entry in quicksearch.
[nit.git] / share / nitdoc / scripts / js-facilities.js
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