with class select-all, and insert the check all checkbox.
+ $table.find('th.select-all').prepend($('').attr('title', strings.selectAll)).on('click', function (event) {
+ if ($(event.target).is('input[type="checkbox"]')) {
+ // Loop through all checkboxes and set their state to the select all
+ // checkbox' state.
+ checkboxes.each(function () {
+ var $checkbox = $(this);
+ var stateChanged = $checkbox.prop('checked') !== event.target.checked;
+
+ /**
+ * @checkbox {HTMLElement}
+ */
+ if (stateChanged) {
+ $checkbox.prop('checked', event.target.checked).trigger('change');
+ }
+ // Either add or remove the selected class based on the state of the
+ // check all checkbox.
+
+ /**
+ * @checkbox {HTMLElement}
+ */
+ $checkbox.closest('tr').toggleClass('selected', this.checked);
+ });
+ // Update the title and the state of the check all box.
+ updateSelectAll(event.target.checked);
+ }
- $table.find('th.select-all').each(function() {
- var $this = $(this);
-
- var $selectAllCheckbox = $('').attr('title', strings.selectAll).uniqueId();
- var $selectAllLabel = $('