Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-30438 Lesson Module: fixed input text editable capability after c…

…hecking/unchecking unmask option
  • Loading branch information...
commit 3bd18935d7201334c3986e03109fe861b1739587 1 parent 41e2a95
@rwijaya rwijaya authored
Showing with 40 additions and 28 deletions.
  1. +40 −28 lib/javascript-static.js
View
68 lib/javascript-static.js
@@ -1063,34 +1063,46 @@ function findChildNodes(start, tagName, elementClass, elementID, elementName) {
}
function unmaskPassword(id) {
- var pw = document.getElementById(id);
- var chb = document.getElementById(id+'unmask');
-
- 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);
+ var pw = document.getElementById(id);
+ var chb = document.getElementById(id+'unmask');
+
+ // 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 to allow other browsers to function properly.
+ if (Y.UA.ie == 0 || Y.UA.ie >= 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);
+ }
}
function filterByParent(elCollection, parentFinder) {
Please sign in to comment.
Something went wrong with that request. Please try again.