From: <gi...@ma...> - 2011-03-06 03:31:16
|
The branch, master has been updated via 8e6efc67576233238edeb53f4d9fad4a208a4949 (commit) from f2c2f0608d5ef6e7a870bfc86c367cbf135048c3 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 8e6efc67576233238edeb53f4d9fad4a208a4949 Author: David Hicks <hic...@op...> Date: Sun Mar 6 14:25:47 2011 +1100 Improve JavaScript "check all" functionality on forms The "check all" aka "select all" checkboxes should reflect the current state of the checkboxes they're linked to. If a user clicks on "Select All" on view_all_bug_page and then proceeds to uncheck some of the issues one by one, the "Select All" checkbox should no longer be checked. It should be noted that jQuery doesn't correctly handle addition/modification/removal of attributes for documents served as Content-Type: application/xhtml+xml. jQuery bug #4283 provides further information at http://bugs.jquery.com/ticket/4283. ----------------------------------------------------------------------- Summary of changes: javascript/common.js | 28 +++++++++++++++++++++++++--- 1 files changed, 25 insertions(+), 3 deletions(-) ----------------------------------------------------------------------- commit 8e6efc67576233238edeb53f4d9fad4a208a4949 Author: David Hicks <hic...@op...> Date: Sun Mar 6 14:25:47 2011 +1100 Improve JavaScript "check all" functionality on forms The "check all" aka "select all" checkboxes should reflect the current state of the checkboxes they're linked to. If a user clicks on "Select All" on view_all_bug_page and then proceeds to uncheck some of the issues one by one, the "Select All" checkbox should no longer be checked. It should be noted that jQuery doesn't correctly handle addition/modification/removal of attributes for documents served as Content-Type: application/xhtml+xml. jQuery bug #4283 provides further information at http://bugs.jquery.com/ticket/4283. diff --git a/javascript/common.js b/javascript/common.js index 183a9f4..f99d072 100644 --- a/javascript/common.js +++ b/javascript/common.js @@ -86,10 +86,32 @@ $(document).ready( function() { $('input.autofocus:first, select.autofocus:first, textarea.autofocus:first').focus(); - $('input[type=checkbox].check_all').click(function() { - var matchingName = $(this).attr('name').replace(/_all$/, ''); - $(this).closest('form').find('input[type=checkbox][name=' + matchingName + '\[\]]').attr('checked', this.checked); + /* + * jQuery bug http://bugs.jquery.com/ticket/4283 prevents the check_all + * functionality from working when the Content-Type is set to + * application/xhtml+xml. + */ + var checkAllSelectors = ''; + $(':checkbox.check_all').each(function() { + var baseFieldName = $(this).attr('name').replace(/_all$/, ''); + if (checkAllSelectors.length > 0) { + checkAllSelectors += ', '; + } + checkAllSelectors += ':checkbox[name="' + baseFieldName + '[]"]'; }); + if (checkAllSelectors.length > 0) { + $(checkAllSelectors).click(function() { + var fieldName = $(this).attr('name').replace(/\[\]/g, ''); + var checkedCount = $(this).closest('form').find(':checkbox[name="' + fieldName + '[]"]:checked').length; + var totalCount = $(this).closest('form').find(':checkbox[name="' + fieldName + '[]"]').length; + var allSelected = checkedCount == totalCount; + $(this).closest('form').find(':checkbox[name=' + fieldName + '_all]').attr('checked', allSelected); + }); + $(':checkbox.check_all').click(function() { + var baseFieldName = $(this).attr('name').replace(/_all$/, ''); + $(this).closest('form').find(':checkbox[name="' + baseFieldName + '[]"]').attr('checked', $(this).is(':checked')); + }); + } var stopwatch = { timerID: null, ----------------------------------------------------------------------- -- Mantis Bug Tracker |