[4.x] Treeselect fixes (#42895)

* Treeselect fixes

* Only toggle if checkbox isn't disabled

* Fix eol

---------
This commit is contained in:
Lodder 2024-03-04 15:47:26 +00:00 committed by GitHub
parent f8c67be561
commit 3ad2ab910b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 5 deletions

View File

@ -17,7 +17,8 @@
"name": "joomla.treeselectmenu",
"type": "script",
"dependencies": [
"jquery"
"jquery",
"bootstrap.dropdown"
],
"uri": "legacy/treeselectmenu.min.js",
"attributes": {

View File

@ -77,13 +77,23 @@ jQuery(function($)
// Checks all checkboxes the tree
$('#treeCheckAll').click(function()
{
$('.treeselect input').attr('checked', 'checked');
$('.treeselect input').each(function() {
var self = $(this);
if (!self.prop('disabled')) {
self.prop('checked', true);
}
});
});
// Unchecks all checkboxes the tree
$('#treeUncheckAll').click(function()
{
$('.treeselect input').attr('checked', false);
$('.treeselect input').each(function() {
var self = $(this);
if (!self.prop('disabled')) {
self.prop('checked', false);
}
});
});
// Checks all checkboxes the tree
@ -102,11 +112,21 @@ jQuery(function($)
// Take care of children check/uncheck all
$('a.checkall').click(function()
{
$(this).parents().eq(4).find('ul.treeselect-sub input').attr('checked', 'checked');
$(this).parents().eq(4).find('input').each(function() {
var self = $(this);
if (!self.prop('disabled')) {
self.prop('checked', true);
}
});
});
$('a.uncheckall').click(function()
{
$(this).parents().eq(4).find('ul.treeselect-sub input').attr('checked', false);
$(this).parents().eq(4).find('input').each(function() {
var self = $(this);
if (!self.prop('disabled')) {
self.prop('checked', false);
}
});
});
// Take care of children toggle all