Prevent some errors on IE <=8

This commit is contained in:
Amauri CHAMPEAUX 2015-02-27 19:38:01 +01:00
parent 3739c53542
commit b312edc1c2
1 changed files with 22 additions and 12 deletions

View File

@ -17,15 +17,19 @@ var tarteaucitron = {
"idprocessed": [],
"state": [],
"launch": [],
"parameters": {},
"isAjax": false,
"init": function (params) {
"use strict";
var origOpen = XMLHttpRequest.prototype.open;
var origOpen;
tarteaucitron.parameters = params;
if (alreadyLaunch === 0) {
alreadyLaunch = 1;
if (window.addEventListener) {
window.addEventListener("load", tarteaucitron.load(params), false);
window.addEventListener("load", function () {
tarteaucitron.load();
}, false);
window.addEventListener("keydown", function (evt) {
if (evt.keyCode === 27) {
tarteaucitron.userInterface.closePanel();
@ -37,7 +41,9 @@ var tarteaucitron = {
}
}, false);
} else {
window.attachEvent("onload", tarteaucitron.load(params));
window.attachEvent("onload", function () {
tarteaucitron.load();
});
window.attachEvent("onkeydown", function (evt) {
if (evt.keyCode === 27) {
tarteaucitron.userInterface.closePanel();
@ -51,6 +57,7 @@ var tarteaucitron = {
}
if (typeof XMLHttpRequest !== 'undefined') {
origOpen = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function () {
if (window.addEventListener) {
@ -71,7 +78,7 @@ var tarteaucitron = {
}
}
},
"load": function (params) {
"load": function () {
"use strict";
var cdn = tarteaucitron.cdn,
language = tarteaucitron.getLanguage(),
@ -84,7 +91,8 @@ var tarteaucitron = {
"orientation": "top",
"removeCredit": false,
"showAlertSmall": true
};
},
params = tarteaucitron.parameters;
// Step 0: get params
if (params !== undefined) {
@ -488,13 +496,15 @@ var tarteaucitron = {
store = [],
i;
Array.prototype.map.call(main.children, Object).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;
}).forEach(function (element) {
main.appendChild(element);
});
if (typeof Array.prototype.map === 'function') {
Array.prototype.map.call(main.children, Object).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;
}).forEach(function (element) {
main.appendChild(element);
});
}
}
},
"cookie": {