diff options
author | Dan McGee <dan@archlinux.org> | 2012-09-15 16:13:58 +0200 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2012-09-15 16:13:58 +0200 |
commit | dfbf7cdd4c273f2b1f3c1c79b97149d37e63e028 (patch) | |
tree | 7f9b1ccbaa969c2af34791217f29f11bf94d485c | |
parent | 59c353e22c5a9d1fda347e82f0734cf78bc7d387 (diff) | |
download | archweb-dfbf7cdd4c273f2b1f3c1c79b97149d37e63e028.tar.gz archweb-dfbf7cdd4c273f2b1f3c1c79b97149d37e63e028.tar.xz |
Make todolist filtering functions more generic
This will allow us to use them elsewhere in a future commit.
Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r-- | sitestatic/archweb.js | 14 | ||||
-rw-r--r-- | templates/todolists/view.html | 7 |
2 files changed, 12 insertions, 9 deletions
diff --git a/sitestatic/archweb.js b/sitestatic/archweb.js index c274a67..783f75c 100644 --- a/sitestatic/archweb.js +++ b/sitestatic/archweb.js @@ -293,17 +293,17 @@ function todolist_flag() { return false; } -function filter_todolist() { +function filter_pkgs_list(filter_ele, tbody_ele) { /* start with all rows, and then remove ones we shouldn't show */ - var rows = $('#dev-todo-pkglist tbody').children(); + var rows = $(tbody_ele).children(); var all_rows = rows; /* apply the filters, cheaper ones first */ if ($('#id_mine_only').is(':checked')) { rows = rows.filter('.mine'); } /* apply arch and repo filters */ - $('#todolist_filter .arch_filter').add( - '#todolist_filter .repo_filter').each(function() { + $(filter_ele + ' .arch_filter').add( + filter_ele + ' .repo_filter').each(function() { if (!$(this).is(':checked')) { rows = rows.not('.' + $(this).val()); } @@ -319,10 +319,12 @@ function filter_todolist() { /* make sure we update the odd/even styling from sorting */ $('.results').trigger('applyWidgets', [false]); } -function filter_todolist_reset() { +function filter_pkgs_reset(callback) { $('#id_incomplete').removeAttr('checked'); $('#id_mine_only').removeAttr('checked'); - filter_todolist(); + $('.arch_filter').attr('checked', 'checked'); + $('.repo_filter').attr('checked', 'checked'); + callback(); } /* signoffs.html */ diff --git a/templates/todolists/view.html b/templates/todolists/view.html index c22bfec..eff81aa 100644 --- a/templates/todolists/view.html +++ b/templates/todolists/view.html @@ -106,10 +106,11 @@ $(document).ready(function() { headers: { 5: { sorter: 'todostatus' } } }); $('a.status-link').click(todolist_flag); - $('#todolist_filter input').change(filter_todolist); - $('#criteria_reset').click(filter_todolist_reset); + filter_func = function() { filter_pkgs_list('#todolist_filter', '#dev-todo-pkglist tbody'); }; + $('#todolist_filter input').change(filter_func); + $('#criteria_reset').click(function() { filter_pkgs_reset(filter_func); }); // fire function on page load to ensure the current form selections take effect - filter_todolist(); + filter_func(); }); </script> {% endblock %} |