From edd450502f74dcbe8175dfddee8b50d14424a390 Mon Sep 17 00:00:00 2001 From: hukl Date: Sat, 13 Jun 2009 15:42:13 +0200 Subject: added js search widget with clickable results that will take the user to the brand new "show" version of the page. so the user doesn't create new revisions and locks all the time when he / she only wants to take a look at it. --- public/javascripts/admin_search.js | 62 +++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 25 deletions(-) (limited to 'public/javascripts/admin_search.js') diff --git a/public/javascripts/admin_search.js b/public/javascripts/admin_search.js index d645cca..ba52bb5 100644 --- a/public/javascripts/admin_search.js +++ b/public/javascripts/admin_search.js @@ -1,28 +1,40 @@ admin_search = { - initialize : function() { - $("#search_term").bind("keyup", function() { - if ($(this).attr("value")) { - $.ajax({ - type: "GET", - url: "/admin/search", - data: "search_term=" + $(this).attr("value"), - dataType: "json", - success : function(results) { - admin_search.show_results(results); - } - }); - } - else { - $('#results').empty(); - } - }); - }, - - show_results : function(results) { - $('#results').empty(); - for (result in results) { - $('#results').append("

" + results[result].title + "

"); + display_toggle : function() { + if ($('#search_widget').css("display") != "none") { + $('#search_widget').fadeOut(); } - } -} \ No newline at end of file + else { + $('#search_widget').fadeIn(); + $('#search_term').attr("value", ""); + $('#search_term').focus(); + } + + $("#search_term").bind("keyup", function() { + if ($(this).attr("value")) { + $.ajax({ + type: "GET", + url: "/admin/search", + data: "search_term=" + $(this).attr("value"), + dataType: "json", + success : function(results) { + admin_search.show_results(results); + } + }); + } + else { + $('#search_results').slideUp(); + $('#search_results').empty(); + } + }); + }, + + show_results : function(results) { + $('#search_results').empty(); + for (result in results) { + $('#search_results').append("

" + results[result].title + "

"); + } + $('#search_results').slideDown(); + } + + } \ No newline at end of file -- cgit v1.3