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