|
897 | 897 | * Event handler for when selecting/deselecting all files |
898 | 898 | */ |
899 | 899 | _onClickSelectAll: function(e) { |
900 | | - var checked = $(e.target).prop('checked'); |
| 900 | + var hiddenFiles = this.$fileList.find('tr.hidden'); |
| 901 | + var checked = e.target.checked; |
| 902 | + |
| 903 | + if (hiddenFiles.length > 0) { |
| 904 | + // set indeterminate alongside checked |
| 905 | + e.target.indeterminate = checked; |
| 906 | + } else { |
| 907 | + e.target.indeterminate = false |
| 908 | + } |
| 909 | + |
901 | 910 | // Select only visible checkboxes to filter out unmatched file in search |
902 | 911 | this.$fileList.find('td.selection > .selectCheckBox:visible').prop('checked', checked) |
903 | 912 | .closest('tr').toggleClass('selected', checked); |
|
907 | 916 | // a search will automatically hide the unwanted rows |
908 | 917 | // let's only select the matches |
909 | 918 | var fileData = this.files[i]; |
910 | | - var fileRow = this.$fileList.find('[data-id=' + fileData.id + ']'); |
| 919 | + var fileRow = this.$fileList.find('tr[data-id=' + fileData.id + ']'); |
911 | 920 | // do not select already selected ones |
912 | 921 | if (!fileRow.hasClass('hidden') && _.isUndefined(this._selectedFiles[fileData.id])) { |
913 | 922 | this._selectedFiles[fileData.id] = fileData; |
|
917 | 926 | } else { |
918 | 927 | // if we have some hidden row, then we're in a search |
919 | 928 | // Let's only deselect the visible ones |
920 | | - var hiddenFiles = this.$fileList.find('tr.hidden'); |
921 | 929 | if (hiddenFiles.length > 0) { |
922 | 930 | var visibleFiles = this.$fileList.find('tr:not(.hidden)'); |
923 | 931 | var self = this; |
|
3260 | 3268 | }, |
3261 | 3269 |
|
3262 | 3270 | /** |
3263 | | - * Returns whether all files are selected |
3264 | | - * @return true if all files are selected, false otherwise |
| 3271 | + * Are all files selected? |
| 3272 | + * |
| 3273 | + * @returns {Boolean} all files are selected |
3265 | 3274 | */ |
3266 | 3275 | isAllSelected: function() { |
3267 | | - return this.$el.find('.select-all').prop('checked'); |
| 3276 | + var checkbox = this.$el.find('.select-all') |
| 3277 | + var checked = checkbox.prop('checked') |
| 3278 | + var indeterminate = checkbox.prop('indeterminate') |
| 3279 | + return checked && !indeterminate; |
3268 | 3280 | }, |
3269 | 3281 |
|
3270 | 3282 | /** |
|
0 commit comments