Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
caseyjhol committed Oct 20, 2015
2 parents a32813a + 9a6d1b0 commit 2172825
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions js/bootstrap-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -1284,18 +1284,32 @@
}
},

selectAll: function () {
changeAll: function (status) {
if (typeof status === 'undefined') status = true;

this.findLis();
this.$element.find('option:enabled').not('[data-divider], [data-hidden]').prop('selected', true);
this.$lis.not('.divider, .dropdown-header, .disabled, .hidden').addClass('selected');

var $options = this.$element.find('option'),
$lisVisible = this.$lis.not('.divider, .dropdown-header, .disabled, .hidden').toggleClass('selected', status),
lisVisLen = $lisVisible.length,
selectedOptions = [];

for (var i = 0; i < lisVisLen; i++) {
var origIndex = $lisVisible[i].getAttribute('data-original-index');
selectedOptions[selectedOptions.length] = $options.eq(origIndex)[0];
}

$(selectedOptions).prop('selected', status);

this.render(false);
},

selectAll: function () {
return this.changeAll(true);
},

deselectAll: function () {
this.findLis();
this.$element.find('option:enabled').not('[data-divider], [data-hidden]').prop('selected', false);
this.$lis.not('.divider, .dropdown-header, .disabled, .hidden').removeClass('selected');
this.render(false);
return this.changeAll(false);
},

keydown: function (e) {
Expand Down

0 comments on commit 2172825

Please sign in to comment.