Moved the body click handlers out
This should allow us to start working on the body mask handler, and make future implementations easier to work with.
This commit is contained in:
parent
85593de1fa
commit
be3414f6fe
48
dist/js/select2.amd.full.js
vendored
48
dist/js/select2.amd.full.js
vendored
@ -684,25 +684,7 @@ define('select2/selection/base',[
|
|||||||
// When the dropdown is open, aria-expanded="true"
|
// When the dropdown is open, aria-expanded="true"
|
||||||
self.$selection.attr('aria-expanded', 'true');
|
self.$selection.attr('aria-expanded', 'true');
|
||||||
|
|
||||||
$(document.body).on('mousedown.select2.' + container.id, function (e) {
|
self._attachCloseHandler(container);
|
||||||
var $target = $(e.target);
|
|
||||||
|
|
||||||
var $select = $target.closest('.select2');
|
|
||||||
|
|
||||||
var $all = $('.select2.select2-container--open');
|
|
||||||
|
|
||||||
$all.each(function () {
|
|
||||||
var $this = $(this);
|
|
||||||
|
|
||||||
if (this == $select[0]) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var $element = $this.data('element');
|
|
||||||
|
|
||||||
$element.select2('close');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
container.on('close', function () {
|
container.on('close', function () {
|
||||||
@ -712,10 +694,36 @@ define('select2/selection/base',[
|
|||||||
|
|
||||||
self.$selection.focus();
|
self.$selection.focus();
|
||||||
|
|
||||||
$(document.body).off('mousedown.select2.' + container.id);
|
self._detachCloseHandler(container);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
BaseSelection.prototype._attachCloseHandler = function (container) {
|
||||||
|
$(document.body).on('mousedown.select2.' + container.id, function (e) {
|
||||||
|
var $target = $(e.target);
|
||||||
|
|
||||||
|
var $select = $target.closest('.select2');
|
||||||
|
|
||||||
|
var $all = $('.select2.select2-container--open');
|
||||||
|
|
||||||
|
$all.each(function () {
|
||||||
|
var $this = $(this);
|
||||||
|
|
||||||
|
if (this == $select[0]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var $element = $this.data('element');
|
||||||
|
|
||||||
|
$element.select2('close');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
BaseSelection.prototype._detachCloseHandler = function (container) {
|
||||||
|
$(document.body).off('mousedown.select2.' + container.id);
|
||||||
|
};
|
||||||
|
|
||||||
BaseSelection.prototype.destroy = function () {
|
BaseSelection.prototype.destroy = function () {
|
||||||
// Unbind the dropdown click handler if it exists
|
// Unbind the dropdown click handler if it exists
|
||||||
$(document.body).off('.select2.' + this.container.id);
|
$(document.body).off('.select2.' + this.container.id);
|
||||||
|
48
dist/js/select2.amd.js
vendored
48
dist/js/select2.amd.js
vendored
@ -684,25 +684,7 @@ define('select2/selection/base',[
|
|||||||
// When the dropdown is open, aria-expanded="true"
|
// When the dropdown is open, aria-expanded="true"
|
||||||
self.$selection.attr('aria-expanded', 'true');
|
self.$selection.attr('aria-expanded', 'true');
|
||||||
|
|
||||||
$(document.body).on('mousedown.select2.' + container.id, function (e) {
|
self._attachCloseHandler(container);
|
||||||
var $target = $(e.target);
|
|
||||||
|
|
||||||
var $select = $target.closest('.select2');
|
|
||||||
|
|
||||||
var $all = $('.select2.select2-container--open');
|
|
||||||
|
|
||||||
$all.each(function () {
|
|
||||||
var $this = $(this);
|
|
||||||
|
|
||||||
if (this == $select[0]) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var $element = $this.data('element');
|
|
||||||
|
|
||||||
$element.select2('close');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
container.on('close', function () {
|
container.on('close', function () {
|
||||||
@ -712,10 +694,36 @@ define('select2/selection/base',[
|
|||||||
|
|
||||||
self.$selection.focus();
|
self.$selection.focus();
|
||||||
|
|
||||||
$(document.body).off('mousedown.select2.' + container.id);
|
self._detachCloseHandler(container);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
BaseSelection.prototype._attachCloseHandler = function (container) {
|
||||||
|
$(document.body).on('mousedown.select2.' + container.id, function (e) {
|
||||||
|
var $target = $(e.target);
|
||||||
|
|
||||||
|
var $select = $target.closest('.select2');
|
||||||
|
|
||||||
|
var $all = $('.select2.select2-container--open');
|
||||||
|
|
||||||
|
$all.each(function () {
|
||||||
|
var $this = $(this);
|
||||||
|
|
||||||
|
if (this == $select[0]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var $element = $this.data('element');
|
||||||
|
|
||||||
|
$element.select2('close');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
BaseSelection.prototype._detachCloseHandler = function (container) {
|
||||||
|
$(document.body).off('mousedown.select2.' + container.id);
|
||||||
|
};
|
||||||
|
|
||||||
BaseSelection.prototype.destroy = function () {
|
BaseSelection.prototype.destroy = function () {
|
||||||
// Unbind the dropdown click handler if it exists
|
// Unbind the dropdown click handler if it exists
|
||||||
$(document.body).off('.select2.' + this.container.id);
|
$(document.body).off('.select2.' + this.container.id);
|
||||||
|
48
dist/js/select2.full.js
vendored
48
dist/js/select2.full.js
vendored
@ -10219,25 +10219,7 @@ define('select2/selection/base',[
|
|||||||
// When the dropdown is open, aria-expanded="true"
|
// When the dropdown is open, aria-expanded="true"
|
||||||
self.$selection.attr('aria-expanded', 'true');
|
self.$selection.attr('aria-expanded', 'true');
|
||||||
|
|
||||||
$(document.body).on('mousedown.select2.' + container.id, function (e) {
|
self._attachCloseHandler(container);
|
||||||
var $target = $(e.target);
|
|
||||||
|
|
||||||
var $select = $target.closest('.select2');
|
|
||||||
|
|
||||||
var $all = $('.select2.select2-container--open');
|
|
||||||
|
|
||||||
$all.each(function () {
|
|
||||||
var $this = $(this);
|
|
||||||
|
|
||||||
if (this == $select[0]) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var $element = $this.data('element');
|
|
||||||
|
|
||||||
$element.select2('close');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
container.on('close', function () {
|
container.on('close', function () {
|
||||||
@ -10247,10 +10229,36 @@ define('select2/selection/base',[
|
|||||||
|
|
||||||
self.$selection.focus();
|
self.$selection.focus();
|
||||||
|
|
||||||
$(document.body).off('mousedown.select2.' + container.id);
|
self._detachCloseHandler(container);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
BaseSelection.prototype._attachCloseHandler = function (container) {
|
||||||
|
$(document.body).on('mousedown.select2.' + container.id, function (e) {
|
||||||
|
var $target = $(e.target);
|
||||||
|
|
||||||
|
var $select = $target.closest('.select2');
|
||||||
|
|
||||||
|
var $all = $('.select2.select2-container--open');
|
||||||
|
|
||||||
|
$all.each(function () {
|
||||||
|
var $this = $(this);
|
||||||
|
|
||||||
|
if (this == $select[0]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var $element = $this.data('element');
|
||||||
|
|
||||||
|
$element.select2('close');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
BaseSelection.prototype._detachCloseHandler = function (container) {
|
||||||
|
$(document.body).off('mousedown.select2.' + container.id);
|
||||||
|
};
|
||||||
|
|
||||||
BaseSelection.prototype.destroy = function () {
|
BaseSelection.prototype.destroy = function () {
|
||||||
// Unbind the dropdown click handler if it exists
|
// Unbind the dropdown click handler if it exists
|
||||||
$(document.body).off('.select2.' + this.container.id);
|
$(document.body).off('.select2.' + this.container.id);
|
||||||
|
2
dist/js/select2.full.min.js
vendored
2
dist/js/select2.full.min.js
vendored
File diff suppressed because one or more lines are too long
48
dist/js/select2.js
vendored
48
dist/js/select2.js
vendored
@ -1112,25 +1112,7 @@ define('select2/selection/base',[
|
|||||||
// When the dropdown is open, aria-expanded="true"
|
// When the dropdown is open, aria-expanded="true"
|
||||||
self.$selection.attr('aria-expanded', 'true');
|
self.$selection.attr('aria-expanded', 'true');
|
||||||
|
|
||||||
$(document.body).on('mousedown.select2.' + container.id, function (e) {
|
self._attachCloseHandler(container);
|
||||||
var $target = $(e.target);
|
|
||||||
|
|
||||||
var $select = $target.closest('.select2');
|
|
||||||
|
|
||||||
var $all = $('.select2.select2-container--open');
|
|
||||||
|
|
||||||
$all.each(function () {
|
|
||||||
var $this = $(this);
|
|
||||||
|
|
||||||
if (this == $select[0]) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var $element = $this.data('element');
|
|
||||||
|
|
||||||
$element.select2('close');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
container.on('close', function () {
|
container.on('close', function () {
|
||||||
@ -1140,10 +1122,36 @@ define('select2/selection/base',[
|
|||||||
|
|
||||||
self.$selection.focus();
|
self.$selection.focus();
|
||||||
|
|
||||||
$(document.body).off('mousedown.select2.' + container.id);
|
self._detachCloseHandler(container);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
BaseSelection.prototype._attachCloseHandler = function (container) {
|
||||||
|
$(document.body).on('mousedown.select2.' + container.id, function (e) {
|
||||||
|
var $target = $(e.target);
|
||||||
|
|
||||||
|
var $select = $target.closest('.select2');
|
||||||
|
|
||||||
|
var $all = $('.select2.select2-container--open');
|
||||||
|
|
||||||
|
$all.each(function () {
|
||||||
|
var $this = $(this);
|
||||||
|
|
||||||
|
if (this == $select[0]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var $element = $this.data('element');
|
||||||
|
|
||||||
|
$element.select2('close');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
BaseSelection.prototype._detachCloseHandler = function (container) {
|
||||||
|
$(document.body).off('mousedown.select2.' + container.id);
|
||||||
|
};
|
||||||
|
|
||||||
BaseSelection.prototype.destroy = function () {
|
BaseSelection.prototype.destroy = function () {
|
||||||
// Unbind the dropdown click handler if it exists
|
// Unbind the dropdown click handler if it exists
|
||||||
$(document.body).off('.select2.' + this.container.id);
|
$(document.body).off('.select2.' + this.container.id);
|
||||||
|
4
dist/js/select2.min.js
vendored
4
dist/js/select2.min.js
vendored
File diff suppressed because one or more lines are too long
48
src/js/select2/selection/base.js
vendored
48
src/js/select2/selection/base.js
vendored
@ -45,25 +45,7 @@ define([
|
|||||||
// When the dropdown is open, aria-expanded="true"
|
// When the dropdown is open, aria-expanded="true"
|
||||||
self.$selection.attr('aria-expanded', 'true');
|
self.$selection.attr('aria-expanded', 'true');
|
||||||
|
|
||||||
$(document.body).on('mousedown.select2.' + container.id, function (e) {
|
self._attachCloseHandler(container);
|
||||||
var $target = $(e.target);
|
|
||||||
|
|
||||||
var $select = $target.closest('.select2');
|
|
||||||
|
|
||||||
var $all = $('.select2.select2-container--open');
|
|
||||||
|
|
||||||
$all.each(function () {
|
|
||||||
var $this = $(this);
|
|
||||||
|
|
||||||
if (this == $select[0]) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var $element = $this.data('element');
|
|
||||||
|
|
||||||
$element.select2('close');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
container.on('close', function () {
|
container.on('close', function () {
|
||||||
@ -73,10 +55,36 @@ define([
|
|||||||
|
|
||||||
self.$selection.focus();
|
self.$selection.focus();
|
||||||
|
|
||||||
$(document.body).off('mousedown.select2.' + container.id);
|
self._detachCloseHandler(container);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
BaseSelection.prototype._attachCloseHandler = function (container) {
|
||||||
|
$(document.body).on('mousedown.select2.' + container.id, function (e) {
|
||||||
|
var $target = $(e.target);
|
||||||
|
|
||||||
|
var $select = $target.closest('.select2');
|
||||||
|
|
||||||
|
var $all = $('.select2.select2-container--open');
|
||||||
|
|
||||||
|
$all.each(function () {
|
||||||
|
var $this = $(this);
|
||||||
|
|
||||||
|
if (this == $select[0]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var $element = $this.data('element');
|
||||||
|
|
||||||
|
$element.select2('close');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
BaseSelection.prototype._detachCloseHandler = function (container) {
|
||||||
|
$(document.body).off('mousedown.select2.' + container.id);
|
||||||
|
};
|
||||||
|
|
||||||
BaseSelection.prototype.destroy = function () {
|
BaseSelection.prototype.destroy = function () {
|
||||||
// Unbind the dropdown click handler if it exists
|
// Unbind the dropdown click handler if it exists
|
||||||
$(document.body).off('.select2.' + this.container.id);
|
$(document.body).off('.select2.' + this.container.id);
|
||||||
|
Loading…
Reference in New Issue
Block a user