Browse files

see MDL-8886.

fixes bug that meant :

       $mform->disabledIf('studentfeedbackurl', 'studentfeedback', 'eq', 0);
       $mform->disabledIf('studentfeedbackurl', 'studentfeedback', 'eq', 3);
       $mform->disabledIf('studentfeedbackurl', 'studentfeedback', 'eq', 4);

didn't work.
  • Loading branch information...
1 parent 9b6cf38 commit 8eb102ff1cd3b0177c9ff7896f41fcfa085ac157 jamiesensei committed Apr 6, 2007
Showing with 62 additions and 0 deletions.
  1. +62 −0 lib/javascript-static.js
View
62 lib/javascript-static.js
@@ -72,6 +72,68 @@ function unlockoption(form,item) {
}
}
+
+function lockoptionsall(formid) {
+ var form = document.forms[formid];
+ var dependons = eval(formid+'items');
+ var tolock = Array();
+ for (var dependon in dependons) {
+ var master = form[dependon];
+ for (var condition in dependons[dependon]) {
+ for (var value in dependons[dependon][condition]) {
+ var lock;
+ switch (condition) {
+ case 'notchecked':
+ lock = !master.checked; break;
+ case 'checked':
+ lock = master.checked; break;
+ case 'noitemselected':
+ lock = master.selectedIndex==-1; break;
+ case 'eq':
+ lock = master.value==value; break;
+ default:
+ lock = master.value!=value; break;
+ }
+ for (var ei in dependons[dependon][condition][value]) {
+ var eltolock = dependons[dependon][condition][value][ei];
+ if (tolock[eltolock] != null){
+ tolock[eltolock] =
+ lock || tolock[eltolock];
+ } else {
+ tolock[eltolock] = lock;
+ }
+ }
+ }
+ }
+ }
+ for (var el in tolock){
+ var formelement = form[el];
+ formelement.disabled = tolock[el];
+ }
+ return true;
+}
+
+function lockoptionsallsetup(formid) {
+ var form = document.forms[formid];
+ var dependons = eval(formid+'items');
+ for (var dependon in dependons) {
+ var master = form[dependon];
+ master.onclick = function() {return lockoptionsall(this.form.getAttribute('id'));};
+ master.onblur = function() {return lockoptionsall(this.form.getAttribute('id'));};
+ master.onchange = function() {return lockoptionsall(this.form.getAttribute('id'));};
+ }
+ for (var i = 0; i < form.elements.length; i++){
+ var formelement = form.elements[i];
+ if (formelement.type=='reset') {
+ formelement.onclick = function() {this.form.reset();return lockoptionsall(this.form.getAttribute('id'));};
+ formelement.onblur = function() {this.form.reset();return lockoptionsall(this.form.getAttribute('id'));};
+ formelement.onchange = function() {this.form.reset();return lockoptionsall(this.form.getAttribute('id'));};
+ }
+ }
+ return lockoptionsall(formid);
+}
+
+
function submitFormById(id) {
var theform = document.getElementById(id);
if(!theform) {

0 comments on commit 8eb102f

Please sign in to comment.