MDL-30438 Lesson Module: fixed input text editable capability after checking/unchecking unmask option for all browsers except IE8 or lower
This commit is contained in:
+45
-25
@@ -1022,34 +1022,54 @@ function findChildNodes(start, tagName, elementClass, elementID, elementName) {
|
||||
}
|
||||
|
||||
function unmaskPassword(id) {
|
||||
var pw = document.getElementById(id);
|
||||
var chb = document.getElementById(id+'unmask');
|
||||
var pw = document.getElementById(id);
|
||||
var chb = document.getElementById(id+'unmask');
|
||||
var IEbrowser = navigator.userAgent.toLowerCase().indexOf('msie');
|
||||
var IEversion = 0;
|
||||
|
||||
try {
|
||||
// first try IE way - it can not set name attribute later
|
||||
if (chb.checked) {
|
||||
var newpw = document.createElement('<input type="text" autocomplete="off" name="'+pw.name+'">');
|
||||
} else {
|
||||
var newpw = document.createElement('<input type="password" autocomplete="off" name="'+pw.name+'">');
|
||||
if (IEbrowser != -1) {
|
||||
var position = navigator.userAgent.indexOf("MSIE") + 5;
|
||||
var end = navigator.userAgent.search("; Windows");
|
||||
IEversion = parseInt(navigator.userAgent.substring(position,end));
|
||||
}
|
||||
newpw.attributes['class'].nodeValue = pw.attributes['class'].nodeValue;
|
||||
} catch (e) {
|
||||
var newpw = document.createElement('input');
|
||||
newpw.setAttribute('autocomplete', 'off');
|
||||
newpw.setAttribute('name', pw.name);
|
||||
if (chb.checked) {
|
||||
newpw.setAttribute('type', 'text');
|
||||
} else {
|
||||
newpw.setAttribute('type', 'password');
|
||||
|
||||
// MDL-30438 - The capability to changing the value of input type is not supported by IE8 or lower.
|
||||
// Replacing existing child with a new one, removed all yui properties for the node. Therefore, this
|
||||
// functionality won't work in IE8 or lower.
|
||||
// This is a temporary fixed for 2.4 or lower branches to allow other browsers to function properly.
|
||||
if (IEbrowser == -1 || (IEversion >= 9)) {
|
||||
if (chb.checked) {
|
||||
pw.type = "text";
|
||||
} else {
|
||||
pw.type = "password";
|
||||
}
|
||||
} else { //IE Browser version 8 or lower
|
||||
try {
|
||||
// first try IE way - it can not set name attribute later
|
||||
if (chb.checked) {
|
||||
var newpw = document.createElement('<input type="text" autocomplete="off" name="'+pw.name+'">');
|
||||
} else {
|
||||
var newpw = document.createElement('<input type="password" autocomplete="off" name="'+pw.name+'">');
|
||||
}
|
||||
newpw.attributes['class'].nodeValue = pw.attributes['class'].nodeValue;
|
||||
} catch (e) {
|
||||
var newpw = document.createElement('input');
|
||||
newpw.setAttribute('autocomplete', 'off');
|
||||
newpw.setAttribute('name', pw.name);
|
||||
if (chb.checked) {
|
||||
newpw.setAttribute('type', 'text');
|
||||
} else {
|
||||
newpw.setAttribute('type', 'password');
|
||||
}
|
||||
newpw.setAttribute('class', pw.getAttribute('class'));
|
||||
}
|
||||
newpw.id = pw.id;
|
||||
newpw.size = pw.size;
|
||||
newpw.onblur = pw.onblur;
|
||||
newpw.onchange = pw.onchange;
|
||||
newpw.value = pw.value;
|
||||
pw.parentNode.replaceChild(newpw, pw);
|
||||
}
|
||||
newpw.setAttribute('class', pw.getAttribute('class'));
|
||||
}
|
||||
newpw.id = pw.id;
|
||||
newpw.size = pw.size;
|
||||
newpw.onblur = pw.onblur;
|
||||
newpw.onchange = pw.onchange;
|
||||
newpw.value = pw.value;
|
||||
pw.parentNode.replaceChild(newpw, pw);
|
||||
}
|
||||
|
||||
function filterByParent(elCollection, parentFinder) {
|
||||
|
||||
Reference in New Issue
Block a user