Merge pull request #208 from nstCactus/master

Fix an incompatibility with prototype.js < 1.7.3.0
This commit is contained in:
Amauri CHAMPEAUX 2018-09-11 10:53:10 +02:00 committed by GitHub
commit aab06d91ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 11 deletions

View File

@ -385,7 +385,7 @@ var tarteaucitron = {
// create a wrapper container at the same level than tarteaucitron so we can add an aria-hidden when tarteaucitron is opened
var wrapper = document.createElement('div');
wrapper.id = "contentWrapper";
while (document.body.firstChild)
{
wrapper.appendChild(document.body.firstChild);
@ -456,7 +456,7 @@ var tarteaucitron = {
// create wrapper container
var wrapper = document.createElement('div');
wrapper.id = "contentWrapper";
while (document.body.firstChild)
{
wrapper.appendChild(document.body.firstChild);
@ -763,7 +763,7 @@ var tarteaucitron = {
}
document.getElementById('contentWrapper').setAttribute("aria-hidden", "false");
document.getElementsByTagName('body')[0].classList.remove('modal-open');
},
"focusTrap": function() {
"use strict";
@ -781,23 +781,23 @@ var tarteaucitron = {
if (focusableEls[i].offsetHeight > 0) {
filtered.push(focusableEls[i]);
}
}
}
firstFocusableEl = filtered[0];
firstFocusableEl = filtered[0];
lastFocusableEl = filtered[filtered.length - 1];
//loop focus inside tarteaucitron
document.getElementById('tarteaucitron').addEventListener("keydown", function (evt) {
if ( evt.key === 'Tab' || evt.keyCode === 9 ) {
if ( evt.shiftKey ) /* shift + tab */ {
if (document.activeElement === firstFocusableEl) {
lastFocusableEl.focus();
evt.preventDefault();
}
} else /* tab */ {
if (document.activeElement === lastFocusableEl) {
if (document.activeElement === lastFocusableEl) {
firstFocusableEl.focus();
evt.preventDefault();
}
@ -879,9 +879,10 @@ var tarteaucitron = {
allDivs = main.childNodes;
if (typeof Array.prototype.map === 'function') {
//Array.prototype.map.call(main.children, Object).sort(function (a, b) {
var mainChildren = Array.from(main.children);
mainChildren.sort(function (a, b) {
var mainChildren = Array.from(main.children);
mainChildren.sort(function (a, b) {
if (tarteaucitron.services[a.id.replace(/Line/g, '')].name > tarteaucitron.services[b.id.replace(/Line/g, '')].name) { return 1; }
if (tarteaucitron.services[a.id.replace(/Line/g, '')].name < tarteaucitron.services[b.id.replace(/Line/g, '')].name) { return -1; }
return 0;