From 34809379563a6fc92889965441c56ba29c155947 Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Fri, 15 Jun 2012 22:23:26 +0200 Subject: Filters in backend are now dynamic. If JavaScript is activated in the users browser, filterable tables are filtered immediatly. --- ratatoeskr/js/backend.js | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'ratatoeskr/js/backend.js') diff --git a/ratatoeskr/js/backend.js b/ratatoeskr/js/backend.js index d131bfe..43e2544 100644 --- a/ratatoeskr/js/backend.js +++ b/ratatoeskr/js/backend.js @@ -16,4 +16,42 @@ $(function() $("div.articleeditor-metabar-element-content", self.parent()).show("fast"); } }); + + function filtertable(table, pairs) + { + $.each(pairs, function(idx, pair) + { + input = pair[0]; + column = pair[1]; + + (function(column){input.keyup(function() + { + filterby = $(this).val().toLowerCase(); + $("tbody tr", table).each(function(i) + { + if($("td", this).eq(column).text().toLowerCase().indexOf(filterby) == -1) + $(this).hide() + else + $(this).show(); + }); + });})(column); + }); + } + + $("#articlestable").each(function(i) + { + filtertable( + $("table", this), + [ + [$("input[name=filter_urlname]", this), 1], + [$("input[name=filter_tag]", this), 4], + [$("input[name=filter_section]", this), 5] + ] + ); + }); + + $("#commentstable").each(function(i) + { + filtertable($("table", this), [[$("input[name=filter_article]", this), 7]]); + }); }); \ No newline at end of file -- cgit v1.2.3-54-g00ecf