2020-01-04 18:07:19 +01:00
|
|
|
function nestedCheckbox_change(e) {
|
|
|
|
checkbox = e.target;
|
|
|
|
//Apply children
|
|
|
|
if (!checkbox.indeterminate) {
|
|
|
|
var ul = $(checkbox).parent("li").next("ul")
|
|
|
|
if (ul.length != 0) {
|
|
|
|
ul.children("li").children("input[type=checkbox]").prop("checked", checkbox.checked);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//Apply parent
|
|
|
|
var ul=$(checkbox).parent("li").parent("ul")
|
|
|
|
var checkbox=$(ul).prev("li").children("input[type=checkbox]")
|
|
|
|
checkboxes=ul.children("li").children("input[type=checkbox]")
|
|
|
|
var checkeds=Array.from(checkboxes).map(el=>el.checked)
|
2020-01-09 11:12:46 +01:00
|
|
|
var scheckeds=Array.from(new Set(checkeds))
|
|
|
|
if (scheckeds.length>1) {
|
|
|
|
checkbox.prop("checked",false);
|
2020-01-04 18:07:19 +01:00
|
|
|
checkbox.prop("indeterminate",true);
|
|
|
|
}
|
|
|
|
else{
|
2020-01-09 11:12:46 +01:00
|
|
|
checkbox.prop("indeterminate",false);
|
|
|
|
checkbox.prop("checked",scheckeds[0]);
|
2020-01-04 18:07:19 +01:00
|
|
|
}
|
|
|
|
}
|