diff --git a/calendar/amd/build/calendar_mini.min.js.map b/calendar/amd/build/calendar_mini.min.js.map index 3137c7d1cfd..8fd42939090 100644 --- a/calendar/amd/build/calendar_mini.min.js.map +++ b/calendar/amd/build/calendar_mini.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/calendar_mini.js"],"names":["define","$","CalendarSelectors","CalendarEvents","CalendarViewManager","registerCalendarEventListeners","root","body","namespace","attr","on","created","reloadMonth","deleted","updated","eventMoved","e","data","is","reloadCurrentMonth","off","registerEventListeners","filterChanged","daysWithEvent","find","eventType","type","toggleClass","hidden","elements","courseSelector","selectElement","courseId","val","init","loadOnInit"],"mappings":"AA2BAA,OAAM,+BAAC,CACH,QADG,CAEH,yBAFG,CAGH,sBAHG,CAIH,4BAJG,CAAD,CAMN,SACIC,CADJ,CAEIC,CAFJ,CAGIC,CAHJ,CAIIC,CAJJ,CAKE,IAQMC,CAAAA,CAA8B,CAAG,SAASC,CAAT,CAAe,IAC5CC,CAAAA,CAAI,CAAGN,CAAC,CAAC,MAAD,CADoC,CAE5CO,CAAS,CAAG,IAAMF,CAAI,CAACG,IAAL,CAAU,IAAV,CAF0B,CAIhDF,CAAI,CAACG,EAAL,CAAQP,CAAc,CAACQ,OAAf,CAAyBH,CAAjC,CAA4CF,CAA5C,CAAkDM,CAAlD,EACAL,CAAI,CAACG,EAAL,CAAQP,CAAc,CAACU,OAAf,CAAyBL,CAAjC,CAA4CF,CAA5C,CAAkDM,CAAlD,EACAL,CAAI,CAACG,EAAL,CAAQP,CAAc,CAACW,OAAf,CAAyBN,CAAjC,CAA4CF,CAA5C,CAAkDM,CAAlD,EACAL,CAAI,CAACG,EAAL,CAAQP,CAAc,CAACY,UAAf,CAA4BP,CAApC,CAA+CF,CAA/C,CAAqDM,CAArD,CACH,CAhBH,CAuBMA,CAAW,CAAG,SAASI,CAAT,CAAY,IACtBV,CAAAA,CAAI,CAAGU,CAAC,CAACC,IADa,CAEtBV,CAAI,CAAGN,CAAC,CAAC,MAAD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AACe,kBAApB,CAAuCb,CAAvC,CAA6C0B,CAA7C,CAFiB,IAEjB,CACH,CAND,IAMO,CACH/B,CAAC,CAAC,MAAD,CAAD,CAAUmB,GAAV,CAAc,SAAWZ,CAAzB,CACH,CACJ,CAVD,CAYH,CA5DH,CA8DE,MAAO,CACH0B,IAAI,CAAE,cAAS5B,CAAT,CAAe6B,CAAf,CAA2B,CAC7B7B,CAAI,CAAGL,CAAC,CAACK,CAAD,CAAR,CAEAF,CAAmB,CAAC8B,IAApB,CAAyB5B,CAAzB,EACAe,CAAsB,CAACf,CAAD,CAAtB,CACAD,CAA8B,CAACC,CAAD,CAA9B,CAEA,GAAI6B,CAAJ,CAAgB,CAGZ/B,CAAmB,CAACe,kBAApB,CAAuCb,CAAvC,CACH,CAEJ,CAdE,CAgBV,CAzFK,CAAN","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * This module is the highest level module for the calendar. It is\n * responsible for initialising all of the components required for\n * the calendar to run. It also coordinates the interaction between\n * components by listening for and responding to different events\n * triggered within the calendar UI.\n *\n * @module core_calendar/calendar\n * @package core_calendar\n * @copyright 2017 Andrew Nicols \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core_calendar/selectors',\n 'core_calendar/events',\n 'core_calendar/view_manager',\n],\nfunction(\n $,\n CalendarSelectors,\n CalendarEvents,\n CalendarViewManager\n) {\n\n /**\n * Listen to and handle any calendar events fired by the calendar UI.\n *\n * @method registerCalendarEventListeners\n * @param {object} root The calendar root element\n */\n var registerCalendarEventListeners = function(root) {\n var body = $('body');\n var namespace = '.' + root.attr('id');\n\n body.on(CalendarEvents.created + namespace, root, reloadMonth);\n body.on(CalendarEvents.deleted + namespace, root, reloadMonth);\n body.on(CalendarEvents.updated + namespace, root, reloadMonth);\n body.on(CalendarEvents.eventMoved + namespace, root, reloadMonth);\n };\n\n /**\n * Reload the month view in this month.\n *\n * @param {EventFacade} e\n */\n var reloadMonth = function(e) {\n var root = e.data;\n var body = $('body');\n var namespace = '.' + root.attr('id');\n\n if (root.is(':visible')) {\n CalendarViewManager.reloadCurrentMonth(root);\n } else {\n // The root has been removed.\n // Remove all events in the namespace.\n body.off(CalendarEvents.created + namespace);\n body.off(CalendarEvents.deleted + namespace);\n body.off(CalendarEvents.updated + namespace);\n body.off(CalendarEvents.eventMoved + namespace);\n }\n };\n\n var registerEventListeners = function(root) {\n $('body').on(CalendarEvents.filterChanged, function(e, data) {\n var daysWithEvent = root.find(CalendarSelectors.eventType[data.type]);\n\n daysWithEvent.toggleClass('calendar_event_' + data.type, !data.hidden);\n });\n\n var namespace = '.' + root.attr('id');\n $('body').on('change' + namespace, CalendarSelectors.elements.courseSelector, function() {\n if (root.is(':visible')) {\n var selectElement = $(this);\n var courseId = selectElement.val();\n var categoryId = null;\n\n CalendarViewManager.reloadCurrentMonth(root, courseId, categoryId);\n } else {\n $('body').off('change' + namespace);\n }\n });\n\n };\n\n return {\n init: function(root, loadOnInit) {\n root = $(root);\n\n CalendarViewManager.init(root);\n registerEventListeners(root);\n registerCalendarEventListeners(root);\n\n if (loadOnInit) {\n // The calendar hasn't yet loaded it's events so we\n // should load them as soon as we've initialised.\n CalendarViewManager.reloadCurrentMonth(root);\n }\n\n }\n };\n});\n"],"file":"calendar_mini.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/calendar_mini.js"],"names":["define","$","CalendarSelectors","CalendarEvents","CalendarViewManager","registerCalendarEventListeners","root","body","namespace","attr","on","created","reloadMonth","deleted","updated","eventMoved","e","data","is","reloadCurrentMonth","off","registerEventListeners","filterChanged","daysWithEvent","find","eventType","type","toggleClass","hidden","elements","courseSelector","selectElement","courseId","val","init","loadOnInit"],"mappings":"AA2BAA,OAAM,+BAAC,CACH,QADG,CAEH,yBAFG,CAGH,sBAHG,CAIH,4BAJG,CAAD,CAMN,SACIC,CADJ,CAEIC,CAFJ,CAGIC,CAHJ,CAIIC,CAJJ,CAKE,IAQMC,CAAAA,CAA8B,CAAG,SAASC,CAAT,CAAe,IAC5CC,CAAAA,CAAI,CAAGN,CAAC,CAAC,MAAD,CADoC,CAE5CO,CAAS,CAAG,IAAMF,CAAI,CAACG,IAAL,CAAU,IAAV,CAF0B,CAIhDF,CAAI,CAACG,EAAL,CAAQP,CAAc,CAACQ,OAAf,CAAyBH,CAAjC,CAA4CF,CAA5C,CAAkDM,CAAlD,EACAL,CAAI,CAACG,EAAL,CAAQP,CAAc,CAACU,OAAf,CAAyBL,CAAjC,CAA4CF,CAA5C,CAAkDM,CAAlD,EACAL,CAAI,CAACG,EAAL,CAAQP,CAAc,CAACW,OAAf,CAAyBN,CAAjC,CAA4CF,CAA5C,CAAkDM,CAAlD,EACAL,CAAI,CAACG,EAAL,CAAQP,CAAc,CAACY,UAAf,CAA4BP,CAApC,CAA+CF,CAA/C,CAAqDM,CAArD,CACH,CAhBH,CAuBMA,CAAW,CAAG,SAASI,CAAT,CAAY,IACtBV,CAAAA,CAAI,CAAGU,CAAC,CAACC,IADa,CAEtBV,CAAI,CAAGN,CAAC,CAAC,MAAD,CAFc,CAGtBO,CAAS,CAAG,IAAMF,CAAI,CAACG,IAAL,CAAU,IAAV,CAHI,CAK1B,GAAIH,CAAI,CAACY,EAAL,CAAQ,UAAR,CAAJ,CAAyB,CACrBd,CAAmB,CAACe,kBAApB,CAAuCb,CAAvC,CACH,CAFD,IAEO,CAGHC,CAAI,CAACa,GAAL,CAASjB,CAAc,CAACQ,OAAf,CAAyBH,CAAlC,EACAD,CAAI,CAACa,GAAL,CAASjB,CAAc,CAAC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B,CAAC8B,IAApB,CAAyB5B,CAAzB,EACAe,CAAsB,CAACf,CAAD,CAAtB,CACAD,CAA8B,CAACC,CAAD,CAA9B,CAEA,GAAI6B,CAAJ,CAAgB,CAGZ/B,CAAmB,CAACe,kBAApB,CAAuCb,CAAvC,CACH,CAEJ,CAdE,CAgBV,CAzFK,CAAN","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * This module is the highest level module for the calendar. It is\n * responsible for initialising all of the components required for\n * the calendar to run. It also coordinates the interaction between\n * components by listening for and responding to different events\n * triggered within the calendar UI.\n *\n * @module core_calendar/calendar_mini\n * @package core_calendar\n * @copyright 2017 Andrew Nicols \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core_calendar/selectors',\n 'core_calendar/events',\n 'core_calendar/view_manager',\n],\nfunction(\n $,\n CalendarSelectors,\n CalendarEvents,\n CalendarViewManager\n) {\n\n /**\n * Listen to and handle any calendar events fired by the calendar UI.\n *\n * @method registerCalendarEventListeners\n * @param {object} root The calendar root element\n */\n var registerCalendarEventListeners = function(root) {\n var body = $('body');\n var namespace = '.' + root.attr('id');\n\n body.on(CalendarEvents.created + namespace, root, reloadMonth);\n body.on(CalendarEvents.deleted + namespace, root, reloadMonth);\n body.on(CalendarEvents.updated + namespace, root, reloadMonth);\n body.on(CalendarEvents.eventMoved + namespace, root, reloadMonth);\n };\n\n /**\n * Reload the month view in this month.\n *\n * @param {EventFacade} e\n */\n var reloadMonth = function(e) {\n var root = e.data;\n var body = $('body');\n var namespace = '.' + root.attr('id');\n\n if (root.is(':visible')) {\n CalendarViewManager.reloadCurrentMonth(root);\n } else {\n // The root has been removed.\n // Remove all events in the namespace.\n body.off(CalendarEvents.created + namespace);\n body.off(CalendarEvents.deleted + namespace);\n body.off(CalendarEvents.updated + namespace);\n body.off(CalendarEvents.eventMoved + namespace);\n }\n };\n\n var registerEventListeners = function(root) {\n $('body').on(CalendarEvents.filterChanged, function(e, data) {\n var daysWithEvent = root.find(CalendarSelectors.eventType[data.type]);\n\n daysWithEvent.toggleClass('calendar_event_' + data.type, !data.hidden);\n });\n\n var namespace = '.' + root.attr('id');\n $('body').on('change' + namespace, CalendarSelectors.elements.courseSelector, function() {\n if (root.is(':visible')) {\n var selectElement = $(this);\n var courseId = selectElement.val();\n var categoryId = null;\n\n CalendarViewManager.reloadCurrentMonth(root, courseId, categoryId);\n } else {\n $('body').off('change' + namespace);\n }\n });\n\n };\n\n return {\n init: function(root, loadOnInit) {\n root = $(root);\n\n CalendarViewManager.init(root);\n registerEventListeners(root);\n registerCalendarEventListeners(root);\n\n if (loadOnInit) {\n // The calendar hasn't yet loaded it's events so we\n // should load them as soon as we've initialised.\n CalendarViewManager.reloadCurrentMonth(root);\n }\n\n }\n };\n});\n"],"file":"calendar_mini.min.js"} \ No newline at end of file diff --git a/calendar/amd/src/calendar_mini.js b/calendar/amd/src/calendar_mini.js index 30f0385c753..e419a255d3e 100644 --- a/calendar/amd/src/calendar_mini.js +++ b/calendar/amd/src/calendar_mini.js @@ -20,7 +20,7 @@ * components by listening for and responding to different events * triggered within the calendar UI. * - * @module core_calendar/calendar + * @module core_calendar/calendar_mini * @package core_calendar * @copyright 2017 Andrew Nicols * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later diff --git a/calendar/classes/external/day_exporter.php b/calendar/classes/external/day_exporter.php index 7e888b84d44..377d2cd6e2c 100644 --- a/calendar/classes/external/day_exporter.php +++ b/calendar/classes/external/day_exporter.php @@ -126,6 +126,10 @@ class day_exporter extends exporter { 'type' => PARAM_URL, 'optional' => true, ], + 'viewdaylinktitle' => [ + 'type' => PARAM_RAW, + 'optional' => true, + ], 'events' => [ 'type' => calendar_event_exporter::read_properties_definition(), 'multiple' => true, @@ -183,6 +187,10 @@ class day_exporter extends exporter { 'viewdaylink' => $this->url->out(false), ]; + if ($viewdaylinktitle = $this->get_view_link_title()) { + $return['viewdaylinktitle'] = $viewdaylinktitle; + } + $cache = $this->related['cache']; $eventexporters = array_map(function($event) use ($cache, $output) { @@ -267,4 +275,22 @@ class day_exporter extends exporter { 'time' => $this->calendar->time, ]); } + + /** + * Get the title for view link. + * + * @return string + */ + protected function get_view_link_title() { + $title = null; + + $userdate = userdate($this->data[0], get_string('strftimedayshort')); + if ($this->data['istoday']) { + $title = get_string('todayplustitle', 'calendar', $userdate); + } else if (count($this->related['events'])) { + $title = get_string('eventsfor', 'calendar', $userdate); + } + + return $title; + } } diff --git a/calendar/renderer.php b/calendar/renderer.php index a078c02bebb..0679979dc62 100644 --- a/calendar/renderer.php +++ b/calendar/renderer.php @@ -292,13 +292,15 @@ class core_calendar_renderer extends plugin_renderer_base { $courseurl = new moodle_url($returnurl); $courseurl->remove_params('course'); - if ($label === null) { + $labelattributes = []; + if (empty($label)) { $label = get_string('listofcourses'); + $labelattributes['class'] = 'sr-only'; } - $select = html_writer::label($label, 'course', false, ['class' => 'mr-1']); + $select = html_writer::label($label, 'course', false, $labelattributes); $select .= html_writer::select($courseoptions, 'course', $selected, false, - ['class' => 'cal_courses_flt mr-auto']); + ['class' => 'cal_courses_flt ml-1 mr-auto', 'id' => 'course']); return $select; } diff --git a/calendar/templates/minicalendar_day_link.mustache b/calendar/templates/minicalendar_day_link.mustache index 5438bd53957..87723565109 100644 --- a/calendar/templates/minicalendar_day_link.mustache +++ b/calendar/templates/minicalendar_day_link.mustache @@ -34,7 +34,7 @@ }} data-toggle="popover"{{! }} data-html="true"{{! }} data-region="mini-day-link"{{! - }} data-trigger="hover"{{! + }} data-trigger="hover focus"{{! }} data-placement="top"{{! }} data-year="{{year}}"{{! }} data-month="{{date.mon}}"{{! @@ -42,6 +42,7 @@ }} data-categoryid="{{categoryid}}"{{! }} data-title="{{$title}}{{title}}{{/title}}"{{! }} data-alternate="{{$nocontent}}{{/nocontent}}"{{! + }} aria-label="{{viewdaylinktitle}}"{{! }}>{{$day}}{{day}}{{/day}}