1
0
mirror of synced 2024-11-25 22:36:03 +03:00

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:
Kevin Brown 2014-11-25 14:03:21 -05:00
parent 85593de1fa
commit be3414f6fe
7 changed files with 143 additions and 103 deletions

View File

@ -684,6 +684,21 @@ define('select2/selection/base',[
// When the dropdown is open, 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) {
var $target = $(e.target);
@ -703,17 +718,10 @@ define('select2/selection/base',[
$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);
});
};
BaseSelection.prototype.destroy = function () {

View File

@ -684,6 +684,21 @@ define('select2/selection/base',[
// When the dropdown is open, 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) {
var $target = $(e.target);
@ -703,17 +718,10 @@ define('select2/selection/base',[
$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);
});
};
BaseSelection.prototype.destroy = function () {

View File

@ -10219,6 +10219,21 @@ define('select2/selection/base',[
// When the dropdown is open, 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) {
var $target = $(e.target);
@ -10238,17 +10253,10 @@ define('select2/selection/base',[
$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);
});
};
BaseSelection.prototype.destroy = function () {

File diff suppressed because one or more lines are too long

26
dist/js/select2.js vendored
View File

@ -1112,6 +1112,21 @@ define('select2/selection/base',[
// When the dropdown is open, 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) {
var $target = $(e.target);
@ -1131,17 +1146,10 @@ define('select2/selection/base',[
$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);
});
};
BaseSelection.prototype.destroy = function () {

File diff suppressed because one or more lines are too long

View File

@ -45,6 +45,21 @@ define([
// When the dropdown is open, 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) {
var $target = $(e.target);
@ -64,17 +79,10 @@ define([
$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);
});
};
BaseSelection.prototype.destroy = function () {