]> git.mjollnir.org Git - moodle.git/commitdiff
formslib dates: MDL-16592 Fix problem when trying to select a time when the calendar...
authortjhunt <tjhunt>
Mon, 16 Mar 2009 02:27:08 +0000 (02:27 +0000)
committertjhunt <tjhunt>
Mon, 16 Mar 2009 02:27:08 +0000 (02:27 +0000)
lib/javascript-static.js

index e197e2114d7c1360009ca6ebf32a7dbb737e49ce..8b60764308091cc51c8472e66795e139a0a3a8b1 100644 (file)
@@ -349,7 +349,7 @@ function init_date_selectors(firstdayofweek) {
 }
 
 /**
- * Constructor for a JavaScritp object that connects to a fdate_time_selector
+ * Constructor for a JavaScript object that connects to a fdate_time_selector
  * or a fdate_selector in a Moodle form, and shows a popup calendar whenever
  * that element has keyboard focus.
  * @param el the fieldset class="fdate_time_selector" or "fdate_selector".
@@ -383,21 +383,22 @@ function date_selector_calendar(el, firstdayofweek) {
     this.fieldset = el;
     var controls = el.getElementsByTagName('select');
     for (var i = 0; i < controls.length; i++) {
-        YAHOO.util.Event.addFocusListener(controls[i], this.focus_event, this);
-        YAHOO.util.Event.addBlurListener(controls[i], this.blur_event, this);
         if (/\[year\]$/.test(controls[i].name)) {
             this.yearselect = controls[i];
-        }
-        if (/\[month\]$/.test(controls[i].name)) {
+        } else if (/\[month\]$/.test(controls[i].name)) {
             this.monthselect = controls[i];
-        }
-        if (/\[day\]$/.test(controls[i].name)) {
+        } else if (/\[day\]$/.test(controls[i].name)) {
             this.dayselect = controls[i];
+        } else {
+            YAHOO.util.Event.addFocusListener(controls[i], this.cancel_any_timeout, this);
+            YAHOO.util.Event.addBlurListener(controls[i], this.blur_event, this);
         }
     }
     if (!(this.yearselect && this.monthselect && this.dayselect)) {
         throw 'Failed to initialise calendar.';
     }
+    YAHOO.util.Event.addFocusListener([this.yearselect, this.monthselect, this.dayselect], this.focus_event, this);
+    YAHOO.util.Event.addBlurListener([this.yearselect, this.monthselect, this.dayselect], this.blur_event, this);
 
     this.enablecheckbox = el.getElementsByTagName('input')[0];
     if (this.enablecheckbox) {
@@ -446,7 +447,7 @@ date_selector_calendar.prototype.focus_event = function(e, me) {
 }
 
 date_selector_calendar.prototype.blur_event = function(e, me) {
-    date_selector_calendar.hidetimeout = setTimeout(function() {me.release_calendar()}, 200);
+    date_selector_calendar.hidetimeout = setTimeout(function() {me.release_calendar();}, 200);
 }
 
 date_selector_calendar.prototype.handle_select_change = function(e, me) {