Commit b45532b0 authored by yuripc's avatar yuripc

remove multiple $(event.target) object creation

parent a50ba907
......@@ -319,27 +319,29 @@
// Bind the change event on the dropdown elements.
$('li input', this.$ul).on('change', $.proxy(function(event) {
var checked = $(event.target).prop('checked') || false;
var isSelectAllOption = $(event.target).val() === this.options.selectAllValue;
var $target = $(event.target);
var checked = $target.prop('checked') || false;
var isSelectAllOption = $target.val() === this.options.selectAllValue;
// Apply or unapply the configured selected class.
if (this.options.selectedClass) {
if (checked) {
$(event.target).parents('li')
$target.parents('li')
.addClass(this.options.selectedClass);
}
else {
$(event.target).parents('li')
$target.parents('li')
.removeClass(this.options.selectedClass);
}
}
// Get the corresponding option.
var value = $(event.target).val();
var value = $target.val();
var $option = this.getOptionByValue(value);
var $optionsNotThis = $('option', this.$select).not($option);
var $checkboxesNotThis = $('input', this.$container).not($(event.target));
var $checkboxesNotThis = $('input', this.$container).not($target);
if (isSelectAllOption) {
if (this.$select[0][0].value === this.options.selectAllValue) {
......@@ -404,19 +406,21 @@
$('li a', this.$ul).on('touchstart click', function(event) {
event.stopPropagation();
var $target = $(event.target);
if (event.shiftKey) {
var checked = $(event.target).prop('checked') || false;
var checked = $target.prop('checked') || false;
if (checked) {
var prev = $(event.target).parents('li:last')
var prev = $target.parents('li:last')
.siblings('li[class="active"]:first');
var currentIdx = $(event.target).parents('li')
var currentIdx = $target.parents('li')
.index();
var prevIdx = prev.index();
if (currentIdx > prevIdx) {
$(event.target).parents("li:last").prevUntil(prev).each(
$target.parents("li:last").prevUntil(prev).each(
function() {
$(this).find("input:first").prop("checked", true)
.trigger("change");
......@@ -424,7 +428,7 @@
);
}
else {
$(event.target).parents("li:last").nextUntil(prev).each(
$target.parents("li:last").nextUntil(prev).each(
function() {
$(this).find("input:first").prop("checked", true)
.trigger("change");
......@@ -434,7 +438,7 @@
}
}
$(event.target).blur();
$target.blur();
});
// Keyboard support.
......
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