diff --git a/lang/en/calendar.php b/lang/en/calendar.php index f3ef36f828b..ffc9e2f9fc3 100644 --- a/lang/en/calendar.php +++ b/lang/en/calendar.php @@ -53,6 +53,7 @@ $string['categoryevents'] = 'Category events'; $string['courses'] = 'Courses'; $string['customexport'] = 'Custom range ({$a->timestart} - {$a->timeend})'; $string['daily'] = 'Daily'; +$string['datepicker'] = 'Date picker'; $string['day'] = 'Day'; $string['dayeventsmany'] = '{$a->num} events, {$a->day}'; $string['dayeventsnone'] = 'No events, {$a}'; diff --git a/lib/form/dateselector.php b/lib/form/dateselector.php index 8abfcf5c931..b45414b9346 100644 --- a/lib/form/dateselector.php +++ b/lib/form/dateselector.php @@ -138,9 +138,20 @@ class MoodleQuickForm_date_selector extends MoodleQuickForm_group { } // The YUI2 calendar only supports the gregorian calendar type so only display the calendar image if this is being used. if ($calendartype->get_name() === 'gregorian') { - $image = $OUTPUT->pix_icon('i/calendar', get_string('calendar', 'calendar'), 'moodle'); - $this->_elements[] = $this->createFormElement('link', 'calendar', - null, '#', $image); + $image = $OUTPUT->pix_icon('i/calendar', ''); + $this->_elements[] = $this->createFormElement( + 'button', + 'calendar', + $image, + [ + 'type' => 'button', + 'title' => get_string('datepicker', 'calendar'), + 'aria-label' => get_string('datepicker', 'calendar'), + ], + [ + 'customclassoverride' => 'btn-link btn-sm icon-no-margin', + ], + ); } foreach ($this->_elements as $element){ if (method_exists($element, 'setHiddenLabel')){ diff --git a/lib/form/datetimeselector.php b/lib/form/datetimeselector.php index 1e06f5fa6ad..c94f8d36692 100644 --- a/lib/form/datetimeselector.php +++ b/lib/form/datetimeselector.php @@ -157,9 +157,20 @@ class MoodleQuickForm_date_time_selector extends MoodleQuickForm_group { } // The YUI2 calendar only supports the gregorian calendar type so only display the calendar image if this is being used. if ($calendartype->get_name() === 'gregorian') { - $image = $OUTPUT->pix_icon('i/calendar', get_string('calendar', 'calendar'), 'moodle'); - $this->_elements[] = $this->createFormElement('link', 'calendar', - null, '#', $image); + $image = $OUTPUT->pix_icon('i/calendar', ''); + $this->_elements[] = $this->createFormElement( + 'button', + 'calendar', + $image, + [ + 'type' => 'button', + 'title' => get_string('datepicker', 'calendar'), + 'aria-label' => get_string('datepicker', 'calendar'), + ], + [ + 'customclassoverride' => 'btn-link btn-sm icon-no-margin', + ], + ); } foreach ($this->_elements as $element){ if (method_exists($element, 'setHiddenLabel')){ diff --git a/lib/form/yui/build/moodle-form-dateselector/moodle-form-dateselector-debug.js b/lib/form/yui/build/moodle-form-dateselector/moodle-form-dateselector-debug.js index ace194f94dc..c76a2835228 100644 --- a/lib/form/yui/build/moodle-form-dateselector/moodle-form-dateselector-debug.js +++ b/lib/form/yui/build/moodle-form-dateselector/moodle-form-dateselector-debug.js @@ -240,7 +240,7 @@ CALENDAR.prototype = { }, this); // Loop through the input fields. - var inputs = this.get('node').all('input, a'); + var inputs = this.get('node').all('input, button'); inputs.each(function(node) { // Check if the current node is a calendar image field. if (node.get('name').match(/\[calendar\]/)) { @@ -381,10 +381,10 @@ CALENDAR.prototype = { toggle_calendar_image: function() { // If the enable checkbox is not checked, disable the calendar image and prevent focus. if (!this.enablecheckbox.get('checked')) { - this.calendarimage.addClass('disabled'); + this.calendarimage.setAttribute('disabled'); this.release_calendar(); } else { - this.calendarimage.removeClass('disabled'); + this.calendarimage.removeAttribute('disabled'); } } }; diff --git a/lib/form/yui/build/moodle-form-dateselector/moodle-form-dateselector-min.js b/lib/form/yui/build/moodle-form-dateselector/moodle-form-dateselector-min.js index 8c16c43bd61..9afe3fae831 100644 --- a/lib/form/yui/build/moodle-form-dateselector/moodle-form-dateselector-min.js +++ b/lib/form/yui/build/moodle-form-dateselector/moodle-form-dateselector-min.js @@ -1,2 +1,2 @@ -YUI.add("moodle-form-dateselector",function(n,e){var t,o;n.mix(n.Node.prototype,{firstOptionValue:function(){return"select"===this.get("nodeName").toLowerCase()&&this.one("option").get("value")},lastOptionValue:function(){return"select"===this.get("nodeName").toLowerCase()&&this.all("option").item(this.optionSize()-1).get("value")},optionSize:function(){return"select"===this.get("nodeName").toLowerCase()&&parseInt(this.all("option").size(),10)},selectedOptionValue:function(){return"select"===this.get("nodeName").toLowerCase()&&this.all("option").item(this.get("selectedIndex")).get("value")}}),M.form=M.form||{},M.form.dateselector={panel:null,calendar:null,currentowner:null,hidetimeout:null,repositiontimeout:null,init_date_selectors:function(e){null===this.panel&&this.initPanel(e),n.all(".fdate_time_selector").each(function(){e.node=this,new t(e)}),n.all(".fdate_selector").each(function(){e.node=this,new t(e)})},initPanel:function(e){this.panel=new n.Overlay({visible:!1,bodyContent:n.Node.create('
'),id:"dateselector-calendar-panel",constrain:!0}),this.panel.render(document.body),this.panel.on("focus",function(){var e,t=0;n.all(" [role=dialog], [role=menubar], .moodle-has-zindex").each(function(e){e=this.findZIndex(e);t'),id:"dateselector-calendar-panel",constrain:!0}),this.panel.render(document.body),this.panel.on("focus",function(){var e,t=0;n.all(" [role=dialog], [role=menubar], .moodle-has-zindex").each(function(e){e=this.findZIndex(e);t