');\n if (source.length) {\n const temptContent = source.find('.hidden').clone(false);\n content.html(temptContent.html());\n }\n return content.html();\n }\n });\n\n isPopoverConfigured.set(target, true);\n }\n\n if (isPopoverAvailable(target)) {\n jQuery(target).popover('show');\n\n target.addEventListener('mouseleave', hidePopover);\n }\n};\n\nconst hidePopover = e => {\n if (isPopoverConfigured.has(e.target)) {\n jQuery(e.target).popover('hide');\n }\n\n e.target.removeEventListener('mouseleave', hidePopover);\n};\n\n/**\n * Register events for date container.\n */\nconst registerEventListeners = () => {\n document.addEventListener('mouseover', e => {\n const dateContainer = e.target.closest(CalendarSelectors.elements.dateContainer);\n if (!dateContainer) {\n return;\n }\n\n e.preventDefault();\n showPopover(dateContainer);\n });\n\n};\n\nlet listenersRegistered = false;\nif (!listenersRegistered) {\n registerEventListeners();\n listenersRegistered = true;\n}\n"],"file":"popover.min.js"}
\ No newline at end of file
+{"version":3,"sources":["../src/popover.js"],"names":["isPopoverAvailable","dateContainer","window","getComputedStyle","querySelector","CalendarSelectors","elements","dateContent","display","isPopoverConfigured","Map","showPopover","target","has","dateEle","popover","trigger","placement","html","content","source","find","length","temptContent","clone","set","addEventListener","hidePopover","e","closest","isTargetActive","contains","document","activeElement","isTargetHover","matches","removeEventListener","registerEventListeners","showPopoverHandler","preventDefault","listenersRegistered"],"mappings":"2ZAyBA,uDACA,O,yiBAOMA,CAAAA,CAAkB,CAAG,SAACC,CAAD,CAAmB,CAC1C,MAAgH,MAAzG,GAAAC,MAAM,CAACC,gBAAP,CAAwBF,CAAa,CAACG,aAAd,CAA4BC,CAAiB,CAACC,QAAlB,CAA2BC,WAAvD,CAAxB,EAA6FC,OACvG,C,CAEKC,CAAmB,CAAG,GAAIC,CAAAA,G,CAE1BC,CAAW,CAAG,SAAAC,CAAM,CAAI,CAC1B,GAAI,CAACH,CAAmB,CAACI,GAApB,CAAwBD,CAAxB,CAAL,CAAsC,CAClC,GAAME,CAAAA,CAAO,CAAG,cAAOF,CAAP,CAAhB,CACAE,CAAO,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AxB,CAAuC,CACnC,cAAOjC,CAAP,EAAsBc,OAAtB,CAA8B,MAA9B,EACAd,CAAa,CAACmC,mBAAd,CAAkC,YAAlC,CAAgDT,CAAhD,EACA1B,CAAa,CAACmC,mBAAd,CAAkC,UAAlC,CAA8CT,CAA9C,CACH,CACJ,CACJ,C,CAKKU,CAAsB,CAAG,UAAM,CACjC,GAAMC,CAAAA,CAAkB,CAAG,SAACV,CAAD,CAAO,CAC9B,GAAM3B,CAAAA,CAAa,CAAG2B,CAAC,CAAChB,MAAF,CAASiB,OAAT,CAAiBxB,CAAiB,CAACC,QAAlB,CAA2BL,aAA5C,CAAtB,CACA,GAAI,CAACA,CAAL,CAAoB,CAChB,MACH,CAED2B,CAAC,CAACW,cAAF,GACA5B,CAAW,CAACV,CAAD,CACd,CARD,CAUA+B,QAAQ,CAACN,gBAAT,CAA0B,WAA1B,CAAuCY,CAAvC,EACAN,QAAQ,CAACN,gBAAT,CAA0B,SAA1B,CAAqCY,CAArC,CACH,C,CAEGE,CAAmB,G,CACvB,GAAI,CAACA,CAAL,CAA0B,CACtBH,CAAsB,GACtBG,CAAmB,GACtB,C","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 * Javascript popover for the `core_calendar` subsystem.\n *\n * @module core_calendar/popover\n * @copyright 2021 Huong Nguyen
\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since 4.0\n */\n\nimport 'theme_boost/popover';\nimport jQuery from 'jquery';\nimport * as CalendarSelectors from 'core_calendar/selectors';\n\n/**\n * Check if we are allowing to enable the popover or not.\n * @param {Element} dateContainer\n * @returns {boolean}\n */\nconst isPopoverAvailable = (dateContainer) => {\n return window.getComputedStyle(dateContainer.querySelector(CalendarSelectors.elements.dateContent)).display === 'none';\n};\n\nconst isPopoverConfigured = new Map();\n\nconst showPopover = target => {\n if (!isPopoverConfigured.has(target)) {\n const dateEle = jQuery(target);\n dateEle.popover({\n trigger: 'manual',\n placement: 'top',\n html: true,\n content: () => {\n const source = dateEle.find(CalendarSelectors.elements.dateContent);\n const content = jQuery('');\n if (source.length) {\n const temptContent = source.find('.hidden').clone(false);\n content.html(temptContent.html());\n }\n return content.html();\n }\n });\n\n isPopoverConfigured.set(target, true);\n }\n\n if (isPopoverAvailable(target)) {\n jQuery(target).popover('show');\n target.addEventListener('mouseleave', hidePopover);\n target.addEventListener('focusout', hidePopover);\n }\n};\n\nconst hidePopover = e => {\n const target = e.target;\n const dateContainer = e.target.closest(CalendarSelectors.elements.dateContainer);\n if (!dateContainer) {\n return;\n }\n if (isPopoverConfigured.has(dateContainer)) {\n const isTargetActive = target.contains(document.activeElement);\n const isTargetHover = target.matches(':hover');\n if (!isTargetActive && !isTargetHover) {\n jQuery(dateContainer).popover('hide');\n dateContainer.removeEventListener('mouseleave', hidePopover);\n dateContainer.removeEventListener('focusout', hidePopover);\n }\n }\n};\n\n/**\n * Register events for date container.\n */\nconst registerEventListeners = () => {\n const showPopoverHandler = (e) => {\n const dateContainer = e.target.closest(CalendarSelectors.elements.dateContainer);\n if (!dateContainer) {\n return;\n }\n\n e.preventDefault();\n showPopover(dateContainer);\n };\n\n document.addEventListener('mouseover', showPopoverHandler);\n document.addEventListener('focusin', showPopoverHandler);\n};\n\nlet listenersRegistered = false;\nif (!listenersRegistered) {\n registerEventListeners();\n listenersRegistered = true;\n}\n"],"file":"popover.min.js"}
\ No newline at end of file
diff --git a/calendar/amd/src/calendar.js b/calendar/amd/src/calendar.js
index 456ea2350c2..fc9eca40b27 100644
--- a/calendar/amd/src/calendar.js
+++ b/calendar/amd/src/calendar.js
@@ -214,7 +214,6 @@ define([
if (contextId) {
// Bind click events to calendar days.
root.on('click', SELECTORS.DAY, function(e) {
-
var target = $(e.target);
const displayingSmallBlockCalendar = root.parents('aside').data('blockregion') === 'side-pre';
@@ -223,8 +222,9 @@ define([
const url = '?view=day&time=' + dateContainer.data('day-timestamp');
window.location.assign(Config.wwwroot + '/calendar/view.php' + url);
} else {
- if (!target.is(SELECTORS.VIEW_DAY_LINK) &&
- !target.is(SELECTORS.DAY_NUMBER_CIRCLE) && !target.is(SELECTORS.DAY_NUMBER)) {
+ const hasViewDayLink = target.closest(SELECTORS.VIEW_DAY_LINK);
+ const shouldShowNewEventModal = !hasViewDayLink;
+ if (shouldShowNewEventModal) {
var startTime = $(this).attr('data-new-event-timestamp');
eventFormPromise.then(function(modal) {
var wrapper = target.closest(CalendarSelectors.wrapper);
@@ -240,9 +240,9 @@ define([
modal.show();
return;
}).fail(Notification.exception);
- e.preventDefault();
}
}
+ e.preventDefault();
});
}
};
diff --git a/calendar/amd/src/popover.js b/calendar/amd/src/popover.js
index 2435288f894..af77242d8bc 100644
--- a/calendar/amd/src/popover.js
+++ b/calendar/amd/src/popover.js
@@ -60,24 +60,33 @@ const showPopover = target => {
if (isPopoverAvailable(target)) {
jQuery(target).popover('show');
-
target.addEventListener('mouseleave', hidePopover);
+ target.addEventListener('focusout', hidePopover);
}
};
const hidePopover = e => {
- if (isPopoverConfigured.has(e.target)) {
- jQuery(e.target).popover('hide');
+ const target = e.target;
+ const dateContainer = e.target.closest(CalendarSelectors.elements.dateContainer);
+ if (!dateContainer) {
+ return;
+ }
+ if (isPopoverConfigured.has(dateContainer)) {
+ const isTargetActive = target.contains(document.activeElement);
+ const isTargetHover = target.matches(':hover');
+ if (!isTargetActive && !isTargetHover) {
+ jQuery(dateContainer).popover('hide');
+ dateContainer.removeEventListener('mouseleave', hidePopover);
+ dateContainer.removeEventListener('focusout', hidePopover);
+ }
}
-
- e.target.removeEventListener('mouseleave', hidePopover);
};
/**
* Register events for date container.
*/
const registerEventListeners = () => {
- document.addEventListener('mouseover', e => {
+ const showPopoverHandler = (e) => {
const dateContainer = e.target.closest(CalendarSelectors.elements.dateContainer);
if (!dateContainer) {
return;
@@ -85,8 +94,10 @@ const registerEventListeners = () => {
e.preventDefault();
showPopover(dateContainer);
- });
+ };
+ document.addEventListener('mouseover', showPopoverHandler);
+ document.addEventListener('focusin', showPopoverHandler);
};
let listenersRegistered = false;
diff --git a/theme/boost/scss/moodle/calendar.scss b/theme/boost/scss/moodle/calendar.scss
index 3ec2b6e4022..2f174e03c3e 100644
--- a/theme/boost/scss/moodle/calendar.scss
+++ b/theme/boost/scss/moodle/calendar.scss
@@ -246,6 +246,12 @@ $calendarCurrentDateBackground: $primary;
td {
+ a.day:focus {
+ display: inline-block;
+ border-radius: 50%;
+ box-shadow: $input-btn-focus-box-shadow;
+ }
+
.day-number-circle {
display: inline-block;
line-height: 0;
diff --git a/theme/boost/style/moodle.css b/theme/boost/style/moodle.css
index 628d9ba487e..3b750e7100c 100644
--- a/theme/boost/style/moodle.css
+++ b/theme/boost/style/moodle.css
@@ -13280,6 +13280,10 @@ body.dragging .dragging {
.maincalendar .calendarmonth th {
text-align: left;
padding-left: 16px; }
+ .maincalendar .calendarmonth td a.day:focus {
+ display: inline-block;
+ border-radius: 50%;
+ box-shadow: 0 0 0 0.2rem rgba(15, 108, 191, 0.75); }
.maincalendar .calendarmonth td .day-number-circle {
display: inline-block;
line-height: 0;
diff --git a/theme/classic/style/moodle.css b/theme/classic/style/moodle.css
index 9a65a97a6e6..60b00ec974c 100644
--- a/theme/classic/style/moodle.css
+++ b/theme/classic/style/moodle.css
@@ -13280,6 +13280,10 @@ body.dragging .dragging {
.maincalendar .calendarmonth th {
text-align: left;
padding-left: 16px; }
+ .maincalendar .calendarmonth td a.day:focus {
+ display: inline-block;
+ border-radius: 50%;
+ box-shadow: 0 0 0 0.2rem rgba(15, 108, 191, 0.75); }
.maincalendar .calendarmonth td .day-number-circle {
display: inline-block;
line-height: 0;