Skip to content

Commit

Permalink
formslib dates: MDL-16592 Fix problem when trying to select a time wh…
Browse files Browse the repository at this point in the history
…en the calendar is not visible.
  • Loading branch information
tjhunt committed Mar 16, 2009
1 parent a53d4f4 commit 9bad31f
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/javascript-static.js
Expand Up @@ -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".
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 9bad31f

Please sign in to comment.