with IE, with love, AGAAAINNNN

This commit is contained in:
Thomas NOËL 2013-11-22 10:16:20 +01:00
parent 21db9e2866
commit 336af6fd74
1 changed files with 22 additions and 1 deletions

View File

@ -1,3 +1,11 @@
/* IE8 */
if(!document.getElementsByClassName) {
document.getElementsByClassName = function(className) {
return this.querySelectorAll("." + className);
};
Element.prototype.getElementsByClassName = document.getElementsByClassName;
}
/* dirty hack pour éviter le double-clic sur un submit */
var submit_buttons = document.getElementsByClassName('submit-button')[0];
@ -14,7 +22,20 @@ if (submit_buttons) {
var wcs_passwords = document.getElementsByClassName('wcs-password');
if (wcs_passwords) {
for(var i=0; i<wcs_passwords.length; i++) {
wcs_passwords[i].getElementsByTagName('input')[0].type = 'password';
input = wcs_passwords[i].getElementsByTagName('input')[0];
try {
input.type = 'password';
} catch (e) { /* IE => on remplace le input complet */
var inp = document.createElement('input');
inp.type='password';
var attributes = ['id', 'name', 'size'];
for(i=0;i<attributes.length;i++){
inp[attributes[i]] = input[attributes[i]];
}
var par = input.parentNode;
par.insertBefore(inp,input);
par.removeChild(input);
}
}
}