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
26
dist/js/select2.amd.full.js
vendored
26
dist/js/select2.amd.full.js
vendored
@ -684,6 +684,21 @@ 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');
|
||||||
|
|
||||||
|
self._attachCloseHandler(container);
|
||||||
|
});
|
||||||
|
|
||||||
|
container.on('close', function () {
|
||||||
|
// When the dropdown is closed, aria-expanded="false"
|
||||||
|
self.$selection.attr('aria-expanded', 'false');
|
||||||
|
self.$selection.removeAttr('aria-activedescendant');
|
||||||
|
|
||||||
|
self.$selection.focus();
|
||||||
|
|
||||||
|
self._detachCloseHandler(container);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
BaseSelection.prototype._attachCloseHandler = function (container) {
|
||||||
$(document.body).on('mousedown.select2.' + container.id, function (e) {
|
$(document.body).on('mousedown.select2.' + container.id, function (e) {
|
||||||
var $target = $(e.target);
|
var $target = $(e.target);
|
||||||
|
|
||||||
@ -703,17 +718,10 @@ define('select2/selection/base',[
|
|||||||
$element.select2('close');
|
$element.select2('close');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
};
|
||||||
|
|
||||||
container.on('close', function () {
|
|
||||||
// When the dropdown is closed, aria-expanded="false"
|
|
||||||
self.$selection.attr('aria-expanded', 'false');
|
|
||||||
self.$selection.removeAttr('aria-activedescendant');
|
|
||||||
|
|
||||||
self.$selection.focus();
|
|
||||||
|
|
||||||
|
BaseSelection.prototype._detachCloseHandler = function (container) {
|
||||||
$(document.body).off('mousedown.select2.' + container.id);
|
$(document.body).off('mousedown.select2.' + container.id);
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
BaseSelection.prototype.destroy = function () {
|
BaseSelection.prototype.destroy = function () {
|
||||||
|
26
dist/js/select2.amd.js
vendored
26
dist/js/select2.amd.js
vendored
@ -684,6 +684,21 @@ 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');
|
||||||
|
|
||||||
|
self._attachCloseHandler(container);
|
||||||
|
});
|
||||||
|
|
||||||
|
container.on('close', function () {
|
||||||
|
// When the dropdown is closed, aria-expanded="false"
|
||||||
|
self.$selection.attr('aria-expanded', 'false');
|
||||||
|
self.$selection.removeAttr('aria-activedescendant');
|
||||||
|
|
||||||
|
self.$selection.focus();
|
||||||
|
|
||||||
|
self._detachCloseHandler(container);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
BaseSelection.prototype._attachCloseHandler = function (container) {
|
||||||
$(document.body).on('mousedown.select2.' + container.id, function (e) {
|
$(document.body).on('mousedown.select2.' + container.id, function (e) {
|
||||||
var $target = $(e.target);
|
var $target = $(e.target);
|
||||||
|
|
||||||
@ -703,17 +718,10 @@ define('select2/selection/base',[
|
|||||||
$element.select2('close');
|
$element.select2('close');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
};
|
||||||
|
|
||||||
container.on('close', function () {
|
|
||||||
// When the dropdown is closed, aria-expanded="false"
|
|
||||||
self.$selection.attr('aria-expanded', 'false');
|
|
||||||
self.$selection.removeAttr('aria-activedescendant');
|
|
||||||
|
|
||||||
self.$selection.focus();
|
|
||||||
|
|
||||||
|
BaseSelection.prototype._detachCloseHandler = function (container) {
|
||||||
$(document.body).off('mousedown.select2.' + container.id);
|
$(document.body).off('mousedown.select2.' + container.id);
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
BaseSelection.prototype.destroy = function () {
|
BaseSelection.prototype.destroy = function () {
|
||||||
|
26
dist/js/select2.full.js
vendored
26
dist/js/select2.full.js
vendored
@ -10219,6 +10219,21 @@ 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');
|
||||||
|
|
||||||
|
self._attachCloseHandler(container);
|
||||||
|
});
|
||||||
|
|
||||||
|
container.on('close', function () {
|
||||||
|
// When the dropdown is closed, aria-expanded="false"
|
||||||
|
self.$selection.attr('aria-expanded', 'false');
|
||||||
|
self.$selection.removeAttr('aria-activedescendant');
|
||||||
|
|
||||||
|
self.$selection.focus();
|
||||||
|
|
||||||
|
self._detachCloseHandler(container);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
BaseSelection.prototype._attachCloseHandler = function (container) {
|
||||||
$(document.body).on('mousedown.select2.' + container.id, function (e) {
|
$(document.body).on('mousedown.select2.' + container.id, function (e) {
|
||||||
var $target = $(e.target);
|
var $target = $(e.target);
|
||||||
|
|
||||||
@ -10238,17 +10253,10 @@ define('select2/selection/base',[
|
|||||||
$element.select2('close');
|
$element.select2('close');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
};
|
||||||
|
|
||||||
container.on('close', function () {
|
|
||||||
// When the dropdown is closed, aria-expanded="false"
|
|
||||||
self.$selection.attr('aria-expanded', 'false');
|
|
||||||
self.$selection.removeAttr('aria-activedescendant');
|
|
||||||
|
|
||||||
self.$selection.focus();
|
|
||||||
|
|
||||||
|
BaseSelection.prototype._detachCloseHandler = function (container) {
|
||||||
$(document.body).off('mousedown.select2.' + container.id);
|
$(document.body).off('mousedown.select2.' + container.id);
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
BaseSelection.prototype.destroy = function () {
|
BaseSelection.prototype.destroy = function () {
|
||||||
|
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
26
dist/js/select2.js
vendored
26
dist/js/select2.js
vendored
@ -1112,6 +1112,21 @@ 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');
|
||||||
|
|
||||||
|
self._attachCloseHandler(container);
|
||||||
|
});
|
||||||
|
|
||||||
|
container.on('close', function () {
|
||||||
|
// When the dropdown is closed, aria-expanded="false"
|
||||||
|
self.$selection.attr('aria-expanded', 'false');
|
||||||
|
self.$selection.removeAttr('aria-activedescendant');
|
||||||
|
|
||||||
|
self.$selection.focus();
|
||||||
|
|
||||||
|
self._detachCloseHandler(container);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
BaseSelection.prototype._attachCloseHandler = function (container) {
|
||||||
$(document.body).on('mousedown.select2.' + container.id, function (e) {
|
$(document.body).on('mousedown.select2.' + container.id, function (e) {
|
||||||
var $target = $(e.target);
|
var $target = $(e.target);
|
||||||
|
|
||||||
@ -1131,17 +1146,10 @@ define('select2/selection/base',[
|
|||||||
$element.select2('close');
|
$element.select2('close');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
};
|
||||||
|
|
||||||
container.on('close', function () {
|
|
||||||
// When the dropdown is closed, aria-expanded="false"
|
|
||||||
self.$selection.attr('aria-expanded', 'false');
|
|
||||||
self.$selection.removeAttr('aria-activedescendant');
|
|
||||||
|
|
||||||
self.$selection.focus();
|
|
||||||
|
|
||||||
|
BaseSelection.prototype._detachCloseHandler = function (container) {
|
||||||
$(document.body).off('mousedown.select2.' + container.id);
|
$(document.body).off('mousedown.select2.' + container.id);
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
BaseSelection.prototype.destroy = function () {
|
BaseSelection.prototype.destroy = function () {
|
||||||
|
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
26
src/js/select2/selection/base.js
vendored
26
src/js/select2/selection/base.js
vendored
@ -45,6 +45,21 @@ 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');
|
||||||
|
|
||||||
|
self._attachCloseHandler(container);
|
||||||
|
});
|
||||||
|
|
||||||
|
container.on('close', function () {
|
||||||
|
// When the dropdown is closed, aria-expanded="false"
|
||||||
|
self.$selection.attr('aria-expanded', 'false');
|
||||||
|
self.$selection.removeAttr('aria-activedescendant');
|
||||||
|
|
||||||
|
self.$selection.focus();
|
||||||
|
|
||||||
|
self._detachCloseHandler(container);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
BaseSelection.prototype._attachCloseHandler = function (container) {
|
||||||
$(document.body).on('mousedown.select2.' + container.id, function (e) {
|
$(document.body).on('mousedown.select2.' + container.id, function (e) {
|
||||||
var $target = $(e.target);
|
var $target = $(e.target);
|
||||||
|
|
||||||
@ -64,17 +79,10 @@ define([
|
|||||||
$element.select2('close');
|
$element.select2('close');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
};
|
||||||
|
|
||||||
container.on('close', function () {
|
|
||||||
// When the dropdown is closed, aria-expanded="false"
|
|
||||||
self.$selection.attr('aria-expanded', 'false');
|
|
||||||
self.$selection.removeAttr('aria-activedescendant');
|
|
||||||
|
|
||||||
self.$selection.focus();
|
|
||||||
|
|
||||||
|
BaseSelection.prototype._detachCloseHandler = function (container) {
|
||||||
$(document.body).off('mousedown.select2.' + container.id);
|
$(document.body).off('mousedown.select2.' + container.id);
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
BaseSelection.prototype.destroy = function () {
|
BaseSelection.prototype.destroy = function () {
|
||||||
|
Loading…
Reference in New Issue
Block a user