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 for all browsers except IE8 or lower
  • Loading branch information...
commit 1d19d5c21911d07d4314415aa0a6fe1c8d4da53c 1 parent f119252
@rwijaya rwijaya authored
Showing with 48 additions and 28 deletions.
  1. +48 −28 lib/javascript-static.js
View
76 lib/javascript-static.js
@@ -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');
-
- 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');
+ var IEbrowser = navigator.userAgent.toLowerCase().indexOf('msie');
+ var IEversion = 0;
+
+ if (IEbrowser != -1) {
+ var position = navigator.userAgent.indexOf("MSIE") + 5;
+ var end = navigator.userAgent.search("; Windows");
+ IEversion = parseInt(navigator.userAgent.substring(position,end));
+ }
+
+ // 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);
+ }
}
function filterByParent(elCollection, parentFinder) {
Please sign in to comment.
Something went wrong with that request. Please try again.