diff -Naurw moodle-clean/moodle/lib/form/dateselector.php moodle-dev/lib/form/dateselector.php --- moodle-clean/moodle/lib/form/dateselector.php 2007-04-14 03:10:30.000000000 +0100 +++ moodle-dev/lib/form/dateselector.php 2009-02-06 10:42:24.000000000 +0000 @@ -76,9 +76,11 @@ for ($i=$this->_options['startyear']; $i<=$this->_options['stopyear']; $i++) { $years[$i] = $i; } - $this->_elements[] =& MoodleQuickForm::createElement('select', 'day', get_string('day', 'form'), $days, $this->getAttributes(), true); - $this->_elements[] =& MoodleQuickForm::createElement('select', 'month', get_string('month', 'form'), $months, $this->getAttributes(), true); - $this->_elements[] =& MoodleQuickForm::createElement('select', 'year', get_string('year', 'form'), $years, $this->getAttributes(), true); + global$CFG; + $randid=rand(); + $this->_elements[] =& MoodleQuickForm::createElement('select', 'day', get_string('day', 'form'), $days, $this->getAttributes().'id="'.$randid.'day"', true); + $this->_elements[] =& MoodleQuickForm::createElement('select', 'month', get_string('month', 'form'), $months, $this->getAttributes().'id="'.$randid.'month" onChange="WeekDays('.$randid.')"', true); + $this->_elements[] =& MoodleQuickForm::createElement('select', 'year', get_string('year', 'form'), $years, $this->getAttributes().'id="'.$randid.'year" onChange="WeekDays('.$randid.')"', true); // If optional we add a checkbox which the user can use to turn if on if($this->_options['optional']) { $this->_elements[] =& MoodleQuickForm::createElement('checkbox', 'off', null, get_string('disable'), $this->getAttributes(), true); @@ -88,6 +90,9 @@ $element->setHiddenLabel(true); } } + require_js('yui_yahoo'); + require_js('yui_event'); + require_js($CFG->wwwroot.'/lib/form/weekdays.js.php'); } diff -Naurw moodle-clean/moodle/lib/form/datetimeselector.php moodle-dev/lib/form/datetimeselector.php --- moodle-clean/moodle/lib/form/datetimeselector.php 2007-08-09 17:56:36.000000000 +0100 +++ moodle-dev/lib/form/datetimeselector.php 2009-02-06 10:42:28.000000000 +0000 @@ -81,9 +81,11 @@ for ($i=0; $i<60; $i+=$this->_options['step']) { $minutes[$i] = sprintf("%02d",$i); } - $this->_elements[] =& MoodleQuickForm::createElement('select', 'day', get_string('day', 'form'), $days, $this->getAttributes(), true); - $this->_elements[] =& MoodleQuickForm::createElement('select', 'month', get_string('month', 'form'), $months, $this->getAttributes(), true); - $this->_elements[] =& MoodleQuickForm::createElement('select', 'year', get_string('year', 'form'), $years, $this->getAttributes(), true); + global$CFG; + $randid=rand(); + $this->_elements[] =& MoodleQuickForm::createElement('select', 'day', get_string('day', 'form'), $days, $this->getAttributes().'id="'.$randid.'day"', true); + $this->_elements[] =& MoodleQuickForm::createElement('select', 'month', get_string('month', 'form'), $months, $this->getAttributes().'id="'.$randid.'month" onChange="WeekDays('.$randid.')"', true); + $this->_elements[] =& MoodleQuickForm::createElement('select', 'year', get_string('year', 'form'), $years, $this->getAttributes().'id="'.$randid.'year" onChange="WeekDays('.$randid.')"', true); if (right_to_left()) { // Switch order of elements for Right-to-Left $this->_elements[] =& MoodleQuickForm::createElement('select', 'minute', get_string('minute', 'form'), $minutes, $this->getAttributes(), true); $this->_elements[] =& MoodleQuickForm::createElement('select', 'hour', get_string('hour', 'form'), $hours, $this->getAttributes(), true); @@ -100,6 +102,9 @@ $element->setHiddenLabel(true); } } + require_js('yui_yahoo'); + require_js('yui_event'); + require_js($CFG->wwwroot.'/lib/form/weekdays.js.php'); } diff -Naurw moodle-clean/moodle/lib/form/weekdays.js.php moodle-dev/lib/form/weekdays.js.php --- moodle-clean/moodle/lib/form/weekdays.js.php 1970-01-01 01:00:00.000000000 +0100 +++ moodle-dev/lib/form/weekdays.js.php 2009-02-06 10:50:45.000000000 +0000 @@ -0,0 +1,54 @@ +function WeekDays(randid){ + DaysObject=document.getElementById(randid+"day"); + MonthObject=document.getElementById(randid+"month"); + YearObject=document.getElementById(randid+"year"); + + month=(MonthObject.selectedIndex +1); + year=YearObject.options[YearObject.selectedIndex].value; + + var day=DaysObject.selectedIndex+1; + var currentDay = DaysObject.selectedIndex; + var month=MonthObject.selectedIndex; + var year=YearObject.options[YearObject.selectedIndex].value; + + //wipe current list + for (j = DaysObject.options.length; j >= 0; j--) { + DaysObject.options[j] = null; + } + + var i=new Date(); + i.setDate(1); + i.setMonth(month); + i.setYear(year); + + while (i.getMonth()==month){ + + DaysObject.options[i.getDate()-1] = new Option(week[i.getDay()]+" "+i.getDate(),i.getDate()); + i.setTime(i.getTime() + 86400000); + } + DaysObject.selectedIndex = currentDay; + + + +} +function WeekDaysInit(){ + allFieldsets=document.getElementsByTagName("fieldset"); + for (i = allFieldsets.length-1; i >= 0; i--) { + if((allFieldsets[i].className.indexOf('fdate_time_selector')!=-1)||(allFieldsets[i].className.indexOf('fdate_selector')!=-1)){ + randId=allFieldsets[i].childNodes[1].id.substr(0,allFieldsets[i].childNodes[1].id.length-3); + WeekDays(randId); + } + } + +} +YAHOO.util.Event.onDOMReady(WeekDaysInit);