summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 52b15cc)
raw | patch | inline | side by side (parent: 52b15cc)
author | Florian Forster <ff@octo.it> | |
Mon, 21 Jun 2010 13:29:23 +0000 (15:29 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Mon, 21 Jun 2010 13:29:23 +0000 (15:29 +0200) |
share/collection.js | patch | blob | history | |
share/style.css | patch | blob | history |
diff --git a/share/collection.js b/share/collection.js
index 026d434cc46cf08b08091b879738bca9101f7b4d..99684524192ad31a08f0e67a9be5326134b9eef1 100644 (file)
--- a/share/collection.js
+++ b/share/collection.js
function format_instance(inst)
{
- return ("<li class=\"instance\"><a href=\"" + location.pathname + "?action=graph;" + inst.params + "\">" + inst.description + "</a></li>");
+ return ("<li class=\"instance\"><a href=\"" + location.pathname
+ + "?action=show_graph;" + inst.params + "\">" + inst.description
+ + "</a></li>");
}
function format_instance_list(instances)
return ("<li class=\"graph\">" + graph.title + format_instance_list (graph.instances) + "</li>");
}
+function update_search_suggestions ()
+{
+ var term = $("#search-input").val ();
+ if (term.length < 2)
+ {
+ $("#search-suggest").hide ();
+ return (true);
+ }
+
+ $("#search-suggest").show ();
+ $.getJSON ("collection.fcgi",
+ { "action": "search_json", "q": term},
+ function(data)
+ {
+ var i;
+ $("#search-suggest").html ("");
+ for (i = 0; i < data.length; i++)
+ {
+ var graph = data[i];
+ $("#search-suggest").append (format_graph (graph));
+ }
+ }
+ );
+} /* update_search_suggestions */
+
$(document).ready(function() {
- $("#search-input").keyup (function()
+ /* $("#layout-middle-right").html ("<ul id=\"search-suggest\" class=\"graph_list\"></ul>"); */
+ $("#search-form").append ("<ul id=\"search-suggest\" class=\"graph_list\"></ul>");
+ $("#search-suggest").hide ();
+
+ $("#search-input").blur (function()
+ {
+ $("#search-suggest").hide ();
+ });
+
+ $("#search-input").focus (function()
{
var term = $("#search-input").val ();
- $.getJSON ("collection.fcgi",
- { "action": "search_json", "q": term},
- function(data)
- {
- var i;
- $("#search-output").html ("");
- for (i = 0; i < data.length; i++)
- {
- var graph = data[i];
- $("#search-output").append (format_graph (graph));
- }
- });
+ if (term.length < 2)
+ {
+ $("#search-suggest").hide ();
+ }
+ else
+ {
+ $("#search-suggest").show ();
+ }
+ });
+
+ $("#search-input").keyup (function()
+ {
+ update_search_suggestions ();
});
});
diff --git a/share/style.css b/share/style.css
index d5b1161a24596771990a660897601498c29ae888..740ae3365f2dd85b847630c57a9b918e0cd466c2 100644 (file)
--- a/share/style.css
+++ b/share/style.css
vertical-align: top;
}
-ul.graph_list
+#search-form
+{
+ position: relative;
+}
+
+#search-suggest
+{
+ position: absolute;
+}
+
+#search-output ul.graph_list
{
margin: 0;
padding: 1ex;
}
-li.graph
+#search-output li.graph
{
display: block;
border: 1px solid gray;
background-color: rgb(245,245,255);
}
-ul.instance_list
+#search-output ul.instance_list
{
margin: 0;
padding: 1ex;
background-color: rgb(252,252,252);
}
-li.instance
+#search-output li.instance
{
display: block;