WIP: JS Tree
* simplifies js for single-select radio tree
This commit is contained in:
parent
b65dae5b95
commit
a334fff54d
@ -12,24 +12,16 @@
|
||||
element = $(element);
|
||||
var cssClass = "badge rlp-r"
|
||||
|
||||
var directParent = element.closest(".tree-element-children")
|
||||
var root = element.parents(".tree-element-children")
|
||||
// Find all already tagged input elements and reset them to be untagged
|
||||
var allTaggedInputs = $("#tree-root").find(".badge.rlp-r")
|
||||
allTaggedInputs.removeClass(cssClass)
|
||||
|
||||
var otherCheckedInputsOfParent = directParent.find('.tree-input:checked');
|
||||
var otherCheckedInputsOfRoot = root.find('.tree-input:checked');
|
||||
|
||||
if(otherCheckedInputsOfParent.length == 0){
|
||||
var parentLabel = directParent.siblings(".tree-label");
|
||||
parentLabel.removeClass(cssClass)
|
||||
if(otherCheckedInputsOfRoot.length == 0){
|
||||
var rootLabel = root.siblings(".tree-label")
|
||||
rootLabel.removeClass(cssClass)
|
||||
}
|
||||
}else{
|
||||
var rootAndParentLabel = root.siblings(".tree-label");
|
||||
rootAndParentLabel.addClass(cssClass);
|
||||
}
|
||||
// Find all parents of selected element
|
||||
var parentElements = element.parents(".tree-element-children")
|
||||
|
||||
// Tag parents of element
|
||||
var parentLabels = parentElements.siblings(".tree-label");
|
||||
parentLabels.addClass(cssClass);
|
||||
}
|
||||
|
||||
function changeHandler(event){
|
||||
|
Loading…
Reference in New Issue
Block a user