Commit ddd2fe8a authored by David Stutz's avatar David Stutz

Merge pull request #400 from kayhadrin/fix/avoid-changing-unrelatd-parent-elements

#375, #383: Avoid changing unrelated parent elements.
parents 744aa223 26ac69e6
......@@ -379,11 +379,11 @@
// Apply or unapply the configured selected class.
if (this.options.selectedClass) {
if (checked) {
$target.parents('li')
$target.closest('li')
.addClass(this.options.selectedClass);
}
else {
$target.parents('li')
$target.closest('li')
.removeClass(this.options.selectedClass);
}
}
......@@ -415,7 +415,7 @@
else {
// Unselect all other options and corresponding checkboxes.
if (this.options.selectedClass) {
$($checkboxesNotThis).parents('li').removeClass(this.options.selectedClass);
$($checkboxesNotThis).closest('li').removeClass(this.options.selectedClass);
}
$($checkboxesNotThis).prop('checked', false);
......@@ -426,7 +426,7 @@
}
if (this.options.selectedClass === "active") {
$optionsNotThis.parents("a").css("outline", "");
$optionsNotThis.closest("a").css("outline", "");
}
}
else {
......@@ -456,15 +456,15 @@
var checked = $target.prop('checked') || false;
if (checked) {
var prev = $target.parents('li:last')
var prev = $target.closest('li')
.siblings('li[class="active"]:first');
var currentIdx = $target.parents('li')
var currentIdx = $target.closest('li')
.index();
var prevIdx = prev.index();
if (currentIdx > prevIdx) {
$target.parents("li:last").prevUntil(prev).each(
$target.closest("li").prevUntil(prev).each(
function() {
$(this).find("input:first").prop("checked", true)
.trigger("change");
......@@ -472,7 +472,7 @@
);
}
else {
$target.parents("li:last").nextUntil(prev).each(
$target.closest("li").nextUntil(prev).each(
function() {
$(this).find("input:first").prop("checked", true)
.trigger("change");
......@@ -597,16 +597,16 @@
if ($element.is(':disabled')) {
$checkbox.attr('disabled', 'disabled')
.prop('disabled', true)
.parents('a')
.closest('a')
.attr("tabindex", "-1")
.parents('li')
.closest('li')
.addClass('disabled');
}
$checkbox.prop('checked', selected);
if (selected && this.options.selectedClass) {
$checkbox.parents('li')
$checkbox.closest('li')
.addClass(this.options.selectedClass);
}
},
......@@ -804,7 +804,7 @@
$input.prop('checked', true);
if (this.options.selectedClass) {
$input.parents('li')
$input.closest('li')
.addClass(this.options.selectedClass);
}
}
......@@ -812,7 +812,7 @@
$input.prop('checked', false);
if (this.options.selectedClass) {
$input.parents('li')
$input.closest('li')
.removeClass(this.options.selectedClass);
}
}
......@@ -820,12 +820,12 @@
if ($(element).is(":disabled")) {
$input.attr('disabled', 'disabled')
.prop('disabled', true)
.parents('li')
.closest('li')
.addClass('disabled');
}
else {
$input.prop('disabled', false)
.parents('li')
.closest('li')
.removeClass('disabled');
}
}, this));
......@@ -863,7 +863,7 @@
}
if (this.options.selectedClass) {
$checkbox.parents('li')
$checkbox.closest('li')
.addClass(this.options.selectedClass);
}
......@@ -913,7 +913,7 @@
}
if (this.options.selectedClass) {
$checkbox.parents('li')
$checkbox.closest('li')
.removeClass(this.options.selectedClass);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment