| 1 |
//
|
| 2 |
// Add multi-select toggling for nested treeviews
|
| 3 |
//
|
| 4 |
/*
|
| 5 |
DIV.tree-branch
|
| 6 |
LABEL.tree-branch-label
|
| 7 |
checkbox.tree-branch-toggle
|
| 8 |
DIV.tree-content
|
| 9 |
LABEL
|
| 10 |
checkbox.tree-leaf
|
| 11 |
LABEL
|
| 12 |
checkbox.tree-item
|
| 13 |
|
| 14 |
*/
|
| 15 |
|
| 16 |
/**
|
| 17 |
* Attach an event to each tree-branch-toggle - the representative toggle for a branch.
|
| 18 |
* Onset, toggle all child elements of that branch
|
| 19 |
*/
|
| 20 |
|
| 21 |
if (Drupal.jsEnabled) {
|
| 22 |
$(document).ready(function() {
|
| 23 |
$('.tree-branch-toggle').change(
|
| 24 |
function(e){
|
| 25 |
var checked = $(this).attr("checked");
|
| 26 |
// find current container
|
| 27 |
parentElem = $(this).parent();
|
| 28 |
while(! $(parentElem).is(".tree-branch") && (parentElem = $(parentElem).parent())) { /* loop */ }
|
| 29 |
if($(parentElem).is(".tree-branch")){
|
| 30 |
// now set every child
|
| 31 |
$('input:checkbox', parentElem).attr("checked", checked ? true : false);
|
| 32 |
}
|
| 33 |
}
|
| 34 |
) // each label
|
| 35 |
}) // ready func
|
| 36 |
} // JS OK
|