From bb9beadb5220ea8ff120761238fb7d9457b75558 Mon Sep 17 00:00:00 2001 From: brettp Date: Mon, 19 Apr 2010 19:44:34 +0000 Subject: Added smarter check all checkboxes for ECML admin area. git-svn-id: http://code.elgg.org/elgg/trunk@5804 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/ecml/views/default/ecml/admin/ecml_admin.php | 37 +++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'mod/ecml/views') diff --git a/mod/ecml/views/default/ecml/admin/ecml_admin.php b/mod/ecml/views/default/ecml/admin/ecml_admin.php index 36ad11f93..0451ad921 100644 --- a/mod/ecml/views/default/ecml/admin/ecml_admin.php +++ b/mod/ecml/views/default/ecml/admin/ecml_admin.php @@ -82,6 +82,41 @@ $(document).ready(function() { // append check all link $('.ecml_check_all').before(''); + // determin initial state of checkall checkbox. + $('.ecml_check_all').each(function() { + var keyword = $(this).hasClass('ecml_keyword'); + var checkbox = $(this).parent().find('input[type=checkbox]'); + var checked; + + // no keywords checked, checkall unchecked + // any keyword checked, checkall unchecked + // all keywords checked, checkall checked + + // if keyword, check the TR + if (keyword) { + checked = true; + $(this).parent().parent().find('input').each(function() { + if (!$(this).hasClass('check_all') && !$(this).attr('disabled')) { + checked = (checked && $(this).attr('checked')); + // can't break... + } + }); + checkbox.attr('checked', checked); + } else { + checked = true; + var rowIndex = $(this).parent().parent().children().index($(this).parent()); + + $('.ecml_admin_table > tbody > tr td:nth-child(' + (rowIndex + 1) + ') input[type=checkbox]').each(function() { + if (!$(this).hasClass('check_all') && !$(this).attr('disabled')) { + checked = (checked && $(this).attr('checked')); + // can't break... + } + }); + checkbox.attr('checked', checked); + } + }); + + // handle checkall boxes $('input.check_all').click(function() { // yoinked from // http://stackoverflow.com/questions/788225/table-row-and-column-number-in-jquery @@ -105,4 +140,4 @@ $(document).ready(function() { } }); }); - + \ No newline at end of file -- cgit v1.2.3