aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-04-19 19:44:34 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-04-19 19:44:34 +0000
commitbb9beadb5220ea8ff120761238fb7d9457b75558 (patch)
tree162ffc2c1ac392ca808eebc3cfd50a5d7c3cb929
parentf9271180b1e82fdf746d315b241efb3ebabd8f35 (diff)
downloadelgg-bb9beadb5220ea8ff120761238fb7d9457b75558.tar.gz
elgg-bb9beadb5220ea8ff120761238fb7d9457b75558.tar.bz2
Added smarter check all checkboxes for ECML admin area.
git-svn-id: http://code.elgg.org/elgg/trunk@5804 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--mod/ecml/views/default/ecml/admin/ecml_admin.php37
1 files changed, 36 insertions, 1 deletions
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('<input type="checkbox" checked="checked" class="check_all">');
+ // 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() {
}
});
});
-</script>
+</script> \ No newline at end of file