Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix template.liGroup , added indeterminate option for group checkboxes #1115

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions dist/js/bootstrap-multiselect.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,9 @@
filterClearBtn: '<span class="input-group-btn"><button class="btn btn-default multiselect-clear-filter" type="button"><i class="glyphicon glyphicon-remove-circle"></i></button></span>',
li: '<li><a tabindex="0"><label></label></a></li>',
divider: '<li class="multiselect-item divider"></li>',
liGroup: '<li class="multiselect-item multiselect-group"><label></label></li>',
resetButton: '<li class="multiselect-reset text-center"><div class="input-group"><a class="btn btn-default btn-block"></a></div></li>'
liGroup: '<li class="multiselect-item multiselect-group"><a href="javascript:void(0);"><label><b></b></label></a></li>',
liGroupCaret: '<span class="caret-container"><b class="caret"></b></span>'
}
},

Expand Down Expand Up @@ -945,7 +946,8 @@
createOptgroup: function(group) {
var label = $(group).attr("label");
var value = $(group).attr("value");
var $li = $('<li class="multiselect-item multiselect-group"><a href="javascript:void(0);"><label><b></b></label></a></li>');
var ipclass = $(group).attr("class");
var $li = $(this.options.templates.liGroup);

var classes = this.options.optionClass(group);
$li.addClass(classes);
Expand All @@ -958,11 +960,11 @@
}

if (this.options.enableCollapsibleOptGroups && this.options.multiple) {
$('a', $li).append('<span class="caret-container"><b class="caret"></b></span>');
$('a', $li).append(this.options.templates.liGroupCaret);
}

if (this.options.enableClickableOptGroups && this.options.multiple) {
$('a label', $li).prepend('<input type="checkbox" value="' + value + '"/>');
$('a label', $li).prepend('<input type="checkbox" value="' + value + '" class="' + ipclass + '"/>');
}

if ($(group).is(':disabled')) {
Expand Down Expand Up @@ -1617,14 +1619,19 @@
.not('.disabled');

var checked = true;
var checkedCount = 0;
$options.each(function() {
var $input = $('input', this);

if (!$input.prop('checked')) {
checked = false;
} else {
checkedCount++;
}
});

$('input', this).prop('indeterminate', (!checked && checkedCount > 0));

if (selectedClass) {
if (checked) {
$(this).addClass(selectedClass);
Expand Down