Browse files

MDL-39581 forms: prevent calendar popup from changing multiple date e…

…lements
  • Loading branch information...
1 parent b55248d commit edc4670b4cd9768beb53f63801b29afa8c0ff918 @markn86 markn86 committed May 9, 2013
Showing with 11 additions and 3 deletions.
  1. +11 −3 lib/form/yui/dateselector/dateselector.js
View
14 lib/form/yui/dateselector/dateselector.js
@@ -97,7 +97,7 @@ YUI.add('moodle-form-dateselector', function(Y) {
focus_event : function(e) {
M.form.dateselector.cancel_any_timeout();
// If the current owner is set, then the pop-up is currently being displayed, so hide it.
- if (M.form.dateselector.currentowner) {
+ if (M.form.dateselector.currentowner == this) {
this.release_calendar();
} else if ((this.enablecheckbox == null)
|| (this.enablecheckbox.get('checked'))) { // Must be hidden. If the field is enabled display the pop-up.
@@ -116,8 +116,16 @@ YUI.add('moodle-form-dateselector', function(Y) {
},
claim_calendar : function() {
M.form.dateselector.cancel_any_timeout();
- this.connect_handlers();
- this.set_date_from_selects();
+ if (M.form.dateselector.currentowner == this) {
+ return;
+ }
+ if (M.form.dateselector.currentowner) {
+ M.form.dateselector.currentowner.release_calendar();
+ }
+ if (M.form.dateselector.currentowner != this) {
+ this.connect_handlers();
+ this.set_date_from_selects();
+ }
M.form.dateselector.currentowner = this;
M.form.dateselector.calendar.cfg.setProperty('mindate', new Date(this.yearselect.firstOptionValue(), 0, 1));
M.form.dateselector.calendar.cfg.setProperty('maxdate', new Date(this.yearselect.lastOptionValue(), 11, 31));

0 comments on commit edc4670

Please sign in to comment.