aboutsummaryrefslogtreecommitdiff
path: root/mod/ecml/views/default
diff options
context:
space:
mode:
Diffstat (limited to 'mod/ecml/views/default')
-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