diff --git a/calendar/amd/build/calendar.min.js b/calendar/amd/build/calendar.min.js index ab7b58dc896..cb7a44325a9 100644 --- a/calendar/amd/build/calendar.min.js +++ b/calendar/amd/build/calendar.min.js @@ -1,2 +1,2 @@ -define ("core_calendar/calendar",["jquery","core/ajax","core/str","core/templates","core/notification","core/custom_interaction_events","core/modal_events","core/modal_factory","core_calendar/modal_event_form","core_calendar/summary_modal","core_calendar/repository","core_calendar/events","core_calendar/view_manager","core_calendar/crud","core_calendar/selectors","core/config"],function(a,b,c,d,f,g,h,i,j,k,l,m,n,o,p,q){var r={ROOT:"[data-region='calendar']",DAY:"[data-region='day']",NEW_EVENT_BUTTON:"[data-action='new-event-button']",DAY_CONTENT:"[data-region='day-content']",LOADING_ICON:".loading-icon",VIEW_DAY_LINK:"[data-action='view-day-link']",CALENDAR_MONTH_WRAPPER:".calendarwrapper",TODAY:".today",DAY_NUMBER_CIRCLE:".day-number-circle",DAY_NUMBER:".day-number"},s=function(b,c,e,g){var h=null,i=g.attr("data-day-timestamp");if(e){h=e.attr("data-day-timestamp")}if(!e||h!=i){d.render("core/loading",{}).then(function(a,b){g.find(r.DAY_CONTENT).addClass("hidden");d.appendNodeContents(g,a,b);if(e){e.find(r.DAY_CONTENT).addClass("hidden");d.appendNodeContents(e,a,b)}}).then(function(){return l.updateEventStartDay(c,i)}).then(function(){a("body").trigger(m.eventMoved,[c,e,g])}).always(function(){var a=g.find(r.LOADING_ICON);g.find(r.DAY_CONTENT).removeClass("hidden");d.replaceNode(a,"","");if(e){var b=e.find(r.LOADING_ICON);e.find(r.DAY_CONTENT).removeClass("hidden");d.replaceNode(b,"","")}}).fail(f.exception)}},t=function(b,c){var d=a("body");d.on(m.created,function(){n.reloadCurrentMonth(b)});d.on(m.deleted,function(){n.reloadCurrentMonth(b)});d.on(m.updated,function(){n.reloadCurrentMonth(b)});d.on(m.editActionEvent,function(a,b){window.location.assign(b)});d.on(m.moveEvent,s);d.on(m.eventMoved,function(){n.reloadCurrentMonth(b)});o.registerEditListeners(b,c)},u=function(b){var c=document.getElementById(p.fullCalendarView);b.on("click",r.VIEW_DAY_LINK,function(d){var e=a(d.target).closest(r.VIEW_DAY_LINK),g=e.data("year"),h=e.data("month"),i=e.data("day"),j=e.data("courseid"),k=e.data("categoryid"),l="?view=day&time="+e.data("timestamp");if(c){n.refreshDayContent(b,g,h,i,j,k,b,"core_calendar/calendar_day").then(function(){d.preventDefault();return n.updateUrl(l)}).fail(f.exception)}else{window.location.assign(q.wwwroot+"/calendar/view.php"+l)}});b.on("change",p.elements.courseSelector,function(){var c=a(this),d=c.val();n.reloadCurrentMonth(b,d,null).then(function(){return b.find(p.elements.courseSelector).val(d)}).fail(f.exception)});var d=o.registerEventFormModal(b),e=a(r.CALENDAR_MONTH_WRAPPER).data("context-id");t(b,d);if(e){b.on("click",r.DAY,function(g){var e=a(g.target),h="side-pre"===b.parents("aside").data("blockregion");if(!c&&h){var i=e.closest(r.DAY),j="?view=day&time="+i.data("day-timestamp");window.location.assign(q.wwwroot+"/calendar/view.php"+j)}else{if(!e.is(r.VIEW_DAY_LINK)&&!e.is(r.DAY_NUMBER_CIRCLE)&&!e.is(r.DAY_NUMBER)){var k=a(this).attr("data-new-event-timestamp");d.then(function(a){var b=e.closest(p.wrapper);a.setCourseId(b.data("courseid"));var c=b.data("categoryid");if("undefined"!=typeof c){a.setCategoryId(c)}a.setContextId(b.data("contextId"));a.setStartTime(k);a.show()}).fail(f.exception);g.preventDefault()}}})}};return{init:function init(b){b=a(b);n.init(b);u(b)}}}); +define ("core_calendar/calendar",["jquery","core/ajax","core/str","core/templates","core/notification","core/custom_interaction_events","core/modal_events","core/modal_factory","core_calendar/modal_event_form","core_calendar/summary_modal","core_calendar/repository","core_calendar/events","core_calendar/view_manager","core_calendar/crud","core_calendar/selectors","core/config"],function(a,b,c,d,f,g,h,i,j,k,l,m,n,o,p,q){var r={ROOT:"[data-region='calendar']",DAY:"[data-region='day']",NEW_EVENT_BUTTON:"[data-action='new-event-button']",DAY_CONTENT:"[data-region='day-content']",LOADING_ICON:".loading-icon",VIEW_DAY_LINK:"[data-action='view-day-link']",CALENDAR_MONTH_WRAPPER:".calendarwrapper",TODAY:".today",DAY_NUMBER_CIRCLE:".day-number-circle",DAY_NUMBER:".day-number"},s=function(b,c,e,g){var h=null,i=g.attr("data-day-timestamp");if(e){h=e.attr("data-day-timestamp")}if(!e||h!=i){d.render("core/loading",{}).then(function(a,b){g.find(r.DAY_CONTENT).addClass("hidden");d.appendNodeContents(g,a,b);if(e){e.find(r.DAY_CONTENT).addClass("hidden");d.appendNodeContents(e,a,b)}}).then(function(){return l.updateEventStartDay(c,i)}).then(function(){a("body").trigger(m.eventMoved,[c,e,g])}).always(function(){var a=g.find(r.LOADING_ICON);g.find(r.DAY_CONTENT).removeClass("hidden");d.replaceNode(a,"","");if(e){var b=e.find(r.LOADING_ICON);e.find(r.DAY_CONTENT).removeClass("hidden");d.replaceNode(b,"","")}}).fail(f.exception)}},t=function(b,c){var d=a("body");d.on(m.created,function(){n.reloadCurrentMonth(b)});d.on(m.deleted,function(){n.reloadCurrentMonth(b)});d.on(m.updated,function(){n.reloadCurrentMonth(b)});d.on(m.editActionEvent,function(a,b){window.location.assign(b)});d.on(m.moveEvent,s);d.on(m.eventMoved,function(){n.reloadCurrentMonth(b)});o.registerEditListeners(b,c)},u=function(b){var c=document.getElementById(p.fullCalendarView);b.on("click",r.VIEW_DAY_LINK,function(d){var e=a(d.target).closest(r.VIEW_DAY_LINK),g=e.data("year"),h=e.data("month"),i=e.data("day"),j=e.data("courseid"),k=e.data("categoryid"),l="?view=day&time="+e.data("timestamp");if(c){n.refreshDayContent(b,g,h,i,j,k,b,"core_calendar/calendar_day").then(function(){d.preventDefault();return n.updateUrl(l)}).fail(f.exception)}else{window.location.assign(q.wwwroot+"/calendar/view.php"+l)}});b.on("change",p.elements.courseSelector,function(){var c=a(this),d=c.val();n.reloadCurrentMonth(b,d,null).then(function(){return b.find(p.elements.courseSelector).val(d)}).fail(f.exception)});var d=o.registerEventFormModal(b),e=a(r.CALENDAR_MONTH_WRAPPER).data("context-id");t(b,d);if(e){b.on("click",r.DAY,function(g){var e=a(g.target),h="side-pre"===b.parents("aside").data("blockregion");if(!c&&h){var i=e.closest(r.DAY),j="?view=day&time="+i.data("day-timestamp");window.location.assign(q.wwwroot+"/calendar/view.php"+j)}else{var k=e.closest(r.VIEW_DAY_LINK);if(!k){var l=a(this).attr("data-new-event-timestamp");d.then(function(a){var b=e.closest(p.wrapper);a.setCourseId(b.data("courseid"));var c=b.data("categoryid");if("undefined"!=typeof c){a.setCategoryId(c)}a.setContextId(b.data("contextId"));a.setStartTime(l);a.show()}).fail(f.exception)}}g.preventDefault()})}};return{init:function init(b){b=a(b);n.init(b);u(b)}}}); //# sourceMappingURL=calendar.min.js.map diff --git a/calendar/amd/build/calendar.min.js.map b/calendar/amd/build/calendar.min.js.map index a59054c16b0..0de1056fc59 100644 --- a/calendar/amd/build/calendar.min.js.map +++ b/calendar/amd/build/calendar.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/calendar.js"],"names":["define","$","Ajax","Str","Templates","Notification","CustomEvents","ModalEvents","ModalFactory","ModalEventForm","SummaryModal","CalendarRepository","CalendarEvents","CalendarViewManager","CalendarCrud","CalendarSelectors","Config","SELECTORS","ROOT","DAY","NEW_EVENT_BUTTON","DAY_CONTENT","LOADING_ICON","VIEW_DAY_LINK","CALENDAR_MONTH_WRAPPER","TODAY","DAY_NUMBER_CIRCLE","DAY_NUMBER","handleMoveEvent","e","eventId","originElement","destinationElement","originTimestamp","destinationTimestamp","attr","render","then","html","js","find","addClass","appendNodeContents","updateEventStartDay","trigger","eventMoved","always","destinationLoadingElement","removeClass","replaceNode","originLoadingElement","fail","exception","registerCalendarEventListeners","root","eventFormModalPromise","body","on","created","reloadCurrentMonth","deleted","updated","editActionEvent","url","window","location","assign","moveEvent","registerEditListeners","registerEventListeners","viewingFullCalendar","document","getElementById","fullCalendarView","dayLink","target","closest","year","data","month","day","courseId","categoryId","refreshDayContent","preventDefault","updateUrl","wwwroot","elements","courseSelector","selectElement","val","eventFormPromise","registerEventFormModal","contextId","displayingSmallBlockCalendar","parents","dateContainer","is","startTime","modal","wrapper","setCourseId","setCategoryId","setContextId","setStartTime","show","init"],"mappings":"AA0BAA,OAAM,0BAAC,CACK,QADL,CAEK,WAFL,CAGK,UAHL,CAIK,gBAJL,CAKK,mBALL,CAMK,gCANL,CAOK,mBAPL,CAQK,oBARL,CASK,gCATL,CAUK,6BAVL,CAWK,0BAXL,CAYK,sBAZL,CAaK,4BAbL,CAcK,oBAdL,CAeK,yBAfL,CAgBK,aAhBL,CAAD,CAkBE,SACIC,CADJ,CAEIC,CAFJ,CAGIC,CAHJ,CAIIC,CAJJ,CAKIC,CALJ,CAMIC,CANJ,CAOIC,CAPJ,CAQIC,CARJ,CASIC,CATJ,CAUIC,CAVJ,CAWIC,CAXJ,CAYIC,CAZJ,CAaIC,CAbJ,CAcIC,CAdJ,CAeIC,CAfJ,CAgBIC,CAhBJ,CAiBE,IAEFC,CAAAA,CAAS,CAAG,CACZC,IAAI,CAAE,0BADM,CAEZC,GAAG,CAAE,qBAFO,CAGZC,gBAAgB,CAAE,kCAHN,CAIZC,WAAW,CAAE,6BAJD,CAKZC,YAAY,CAAE,eALF,CAMZC,aAAa,CAAE,+BANH,CAOZC,sBAAsB,CAAE,kBAPZ,CAQZC,KAAK,CAAE,QARK,CASZC,iBAAiB,CAAE,oBATP,CAUZC,UAAU,CAAE,aAVA,CAFV,CA2BFC,CAAe,CAAG,SAASC,CAAT,CAAYC,CAAZ,CAAqBC,CAArB,CAAoCC,CAApC,CAAwD,IACtEC,CAAAA,CAAe,CAAG,IADoD,CAEtEC,CAAoB,CAAGF,CAAkB,CAACG,IAAnB,CAAwB,oBAAxB,CAF+C,CAI1E,GAAIJ,CAAJ,CAAmB,CACfE,CAAe,CAAGF,CAAa,CAACI,IAAd,CAAmB,oBAAnB,CACrB,CAGD,GAAI,CAACJ,CAAD,E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CAACsB,EAAP,CAAUhF,CAAS,CAACM,aAApB,CAAD,EACA,CAACoD,CAAM,CAACsB,EAAP,CAAUhF,CAAS,CAACS,iBAApB,CADD,EAC2C,CAACiD,CAAM,CAACsB,EAAP,CAAUhF,CAAS,CAACU,UAApB,CADhD,CACiF,CAC7E,GAAIuE,CAAAA,CAAS,CAAGjG,CAAC,CAAC,IAAD,CAAD,CAAQkC,IAAR,CAAa,0BAAb,CAAhB,CACAwD,CAAgB,CAACtD,IAAjB,CAAsB,SAAS8D,CAAT,CAAgB,CAClC,GAAIC,CAAAA,CAAO,CAAGzB,CAAM,CAACC,OAAP,CAAe7D,CAAiB,CAACqF,OAAjC,CAAd,CACAD,CAAK,CAACE,WAAN,CAAkBD,CAAO,CAACtB,IAAR,CAAa,UAAb,CAAlB,EAEA,GAAII,CAAAA,CAAU,CAAGkB,CAAO,CAACtB,IAAR,CAAa,YAAb,CAAjB,CACA,GAA0B,WAAtB,QAAOI,CAAAA,CAAX,CAAuC,CACnCiB,CAAK,CAACG,aAAN,CAAoBpB,CAApB,CACH,CAEDiB,CAAK,CAACI,YAAN,CAAmBH,CAAO,CAACtB,IAAR,CAAa,WAAb,CAAnB,EACAqB,CAAK,CAACK,YAAN,CAAmBN,CAAnB,EACAC,CAAK,CAACM,IAAN,EAEH,CAbD,EAaGtD,IAbH,CAaQ9C,CAAY,CAAC+C,SAbrB,EAcAvB,CAAC,CAACuD,cAAF,EACH,CACJ,CACJ,CA9BD,CA+BH,CACJ,CA1LK,CA4LN,MAAO,CACHsB,IAAI,CAAE,cAASpD,CAAT,CAAe,CACjBA,CAAI,CAAGrD,CAAC,CAACqD,CAAD,CAAR,CACAzC,CAAmB,CAAC6F,IAApB,CAAyBpD,CAAzB,EACAe,CAAsB,CAACf,CAAD,CACzB,CALE,CAOV,CAtOK,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 * @copyright 2017 Simey Lameze \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/ajax',\n 'core/str',\n 'core/templates',\n 'core/notification',\n 'core/custom_interaction_events',\n 'core/modal_events',\n 'core/modal_factory',\n 'core_calendar/modal_event_form',\n 'core_calendar/summary_modal',\n 'core_calendar/repository',\n 'core_calendar/events',\n 'core_calendar/view_manager',\n 'core_calendar/crud',\n 'core_calendar/selectors',\n 'core/config',\n ],\n function(\n $,\n Ajax,\n Str,\n Templates,\n Notification,\n CustomEvents,\n ModalEvents,\n ModalFactory,\n ModalEventForm,\n SummaryModal,\n CalendarRepository,\n CalendarEvents,\n CalendarViewManager,\n CalendarCrud,\n CalendarSelectors,\n Config,\n ) {\n\n var SELECTORS = {\n ROOT: \"[data-region='calendar']\",\n DAY: \"[data-region='day']\",\n NEW_EVENT_BUTTON: \"[data-action='new-event-button']\",\n DAY_CONTENT: \"[data-region='day-content']\",\n LOADING_ICON: '.loading-icon',\n VIEW_DAY_LINK: \"[data-action='view-day-link']\",\n CALENDAR_MONTH_WRAPPER: \".calendarwrapper\",\n TODAY: '.today',\n DAY_NUMBER_CIRCLE: '.day-number-circle',\n DAY_NUMBER: '.day-number'\n };\n\n /**\n * Handler for the drag and drop move event. Provides a loading indicator\n * while the request is sent to the server to update the event start date.\n *\n * Triggers a eventMoved calendar javascript event if the event was successfully\n * updated.\n *\n * @param {event} e The calendar move event\n * @param {int} eventId The event id being moved\n * @param {object|null} originElement The jQuery element for where the event is moving from\n * @param {object} destinationElement The jQuery element for where the event is moving to\n */\n var handleMoveEvent = function(e, eventId, originElement, destinationElement) {\n var originTimestamp = null;\n var destinationTimestamp = destinationElement.attr('data-day-timestamp');\n\n if (originElement) {\n originTimestamp = originElement.attr('data-day-timestamp');\n }\n\n // If the event has actually changed day.\n if (!originElement || originTimestamp != destinationTimestamp) {\n Templates.render('core/loading', {})\n .then(function(html, js) {\n // First we show some loading icons in each of the days being affected.\n destinationElement.find(SELECTORS.DAY_CONTENT).addClass('hidden');\n Templates.appendNodeContents(destinationElement, html, js);\n\n if (originElement) {\n originElement.find(SELECTORS.DAY_CONTENT).addClass('hidden');\n Templates.appendNodeContents(originElement, html, js);\n }\n return;\n })\n .then(function() {\n // Send a request to the server to make the change.\n return CalendarRepository.updateEventStartDay(eventId, destinationTimestamp);\n })\n .then(function() {\n // If the update was successful then broadcast an event letting the calendar\n // know that an event has been moved.\n $('body').trigger(CalendarEvents.eventMoved, [eventId, originElement, destinationElement]);\n return;\n })\n .always(function() {\n // Always remove the loading icons regardless of whether the update\n // request was successful or not.\n var destinationLoadingElement = destinationElement.find(SELECTORS.LOADING_ICON);\n destinationElement.find(SELECTORS.DAY_CONTENT).removeClass('hidden');\n Templates.replaceNode(destinationLoadingElement, '', '');\n\n if (originElement) {\n var originLoadingElement = originElement.find(SELECTORS.LOADING_ICON);\n originElement.find(SELECTORS.DAY_CONTENT).removeClass('hidden');\n Templates.replaceNode(originLoadingElement, '', '');\n }\n return;\n })\n .fail(Notification.exception);\n }\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 * @param {object} eventFormModalPromise A promise reolved with the event form modal\n */\n var registerCalendarEventListeners = function(root, eventFormModalPromise) {\n var body = $('body');\n\n body.on(CalendarEvents.created, function() {\n CalendarViewManager.reloadCurrentMonth(root);\n });\n body.on(CalendarEvents.deleted, function() {\n CalendarViewManager.reloadCurrentMonth(root);\n });\n body.on(CalendarEvents.updated, function() {\n CalendarViewManager.reloadCurrentMonth(root);\n });\n body.on(CalendarEvents.editActionEvent, function(e, url) {\n // Action events needs to be edit directly on the course module.\n window.location.assign(url);\n });\n // Handle the event fired by the drag and drop code.\n body.on(CalendarEvents.moveEvent, handleMoveEvent);\n // When an event is successfully moved we should updated the UI.\n body.on(CalendarEvents.eventMoved, function() {\n CalendarViewManager.reloadCurrentMonth(root);\n });\n\n CalendarCrud.registerEditListeners(root, eventFormModalPromise);\n };\n\n /**\n * Register event listeners for the module.\n *\n * @param {object} root The calendar root element\n */\n var registerEventListeners = function(root) {\n const viewingFullCalendar = document.getElementById(CalendarSelectors.fullCalendarView);\n // Listen the click on the day link to render the day view.\n root.on('click', SELECTORS.VIEW_DAY_LINK, function(e) {\n var dayLink = $(e.target).closest(SELECTORS.VIEW_DAY_LINK);\n var year = dayLink.data('year'),\n month = dayLink.data('month'),\n day = dayLink.data('day'),\n courseId = dayLink.data('courseid'),\n categoryId = dayLink.data('categoryid');\n const url = '?view=day&time=' + dayLink.data('timestamp');\n if (viewingFullCalendar) {\n CalendarViewManager.refreshDayContent(root, year, month, day, courseId, categoryId, root,\n 'core_calendar/calendar_day').then(function() {\n e.preventDefault();\n return CalendarViewManager.updateUrl(url);\n }).fail(Notification.exception);\n } else {\n window.location.assign(Config.wwwroot + '/calendar/view.php' + url);\n }\n });\n\n root.on('change', CalendarSelectors.elements.courseSelector, function() {\n var selectElement = $(this);\n var courseId = selectElement.val();\n CalendarViewManager.reloadCurrentMonth(root, courseId, null)\n .then(function() {\n // We need to get the selector again because the content has changed.\n return root.find(CalendarSelectors.elements.courseSelector).val(courseId);\n })\n .fail(Notification.exception);\n });\n\n var eventFormPromise = CalendarCrud.registerEventFormModal(root),\n contextId = $(SELECTORS.CALENDAR_MONTH_WRAPPER).data('context-id');\n registerCalendarEventListeners(root, eventFormPromise);\n\n if (contextId) {\n // Bind click events to calendar days.\n root.on('click', SELECTORS.DAY, function(e) {\n\n var target = $(e.target);\n const displayingSmallBlockCalendar = root.parents('aside').data('blockregion') === 'side-pre';\n\n if (!viewingFullCalendar && displayingSmallBlockCalendar) {\n const dateContainer = target.closest(SELECTORS.DAY);\n const url = '?view=day&time=' + dateContainer.data('day-timestamp');\n window.location.assign(Config.wwwroot + '/calendar/view.php' + url);\n } else {\n if (!target.is(SELECTORS.VIEW_DAY_LINK) &&\n !target.is(SELECTORS.DAY_NUMBER_CIRCLE) && !target.is(SELECTORS.DAY_NUMBER)) {\n var startTime = $(this).attr('data-new-event-timestamp');\n eventFormPromise.then(function(modal) {\n var wrapper = target.closest(CalendarSelectors.wrapper);\n modal.setCourseId(wrapper.data('courseid'));\n\n var categoryId = wrapper.data('categoryid');\n if (typeof categoryId !== 'undefined') {\n modal.setCategoryId(categoryId);\n }\n\n modal.setContextId(wrapper.data('contextId'));\n modal.setStartTime(startTime);\n modal.show();\n return;\n }).fail(Notification.exception);\n e.preventDefault();\n }\n }\n });\n }\n };\n\n return {\n init: function(root) {\n root = $(root);\n CalendarViewManager.init(root);\n registerEventListeners(root);\n }\n };\n});\n"],"file":"calendar.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/calendar.js"],"names":["define","$","Ajax","Str","Templates","Notification","CustomEvents","ModalEvents","ModalFactory","ModalEventForm","SummaryModal","CalendarRepository","CalendarEvents","CalendarViewManager","CalendarCrud","CalendarSelectors","Config","SELECTORS","ROOT","DAY","NEW_EVENT_BUTTON","DAY_CONTENT","LOADING_ICON","VIEW_DAY_LINK","CALENDAR_MONTH_WRAPPER","TODAY","DAY_NUMBER_CIRCLE","DAY_NUMBER","handleMoveEvent","e","eventId","originElement","destinationElement","originTimestamp","destinationTimestamp","attr","render","then","html","js","find","addClass","appendNodeContents","updateEventStartDay","trigger","eventMoved","always","destinationLoadingElement","removeClass","replaceNode","originLoadingElement","fail","exception","registerCalendarEventListeners","root","eventFormModalPromise","body","on","created","reloadCurrentMonth","deleted","updated","editActionEvent","url","window","location","assign","moveEvent","registerEditListeners","registerEventListeners","viewingFullCalendar","document","getElementById","fullCalendarView","dayLink","target","closest","year","data","month","day","courseId","categoryId","refreshDayContent","preventDefault","updateUrl","wwwroot","elements","courseSelector","selectElement","val","eventFormPromise","registerEventFormModal","contextId","displayingSmallBlockCalendar","parents","dateContainer","hasViewDayLink","startTime","modal","wrapper","setCourseId","setCategoryId","setContextId","setStartTime","show","init"],"mappings":"AA0BAA,OAAM,0BAAC,CACK,QADL,CAEK,WAFL,CAGK,UAHL,CAIK,gBAJL,CAKK,mBALL,CAMK,gCANL,CAOK,mBAPL,CAQK,oBARL,CASK,gCATL,CAUK,6BAVL,CAWK,0BAXL,CAYK,sBAZL,CAaK,4BAbL,CAcK,oBAdL,CAeK,yBAfL,CAgBK,aAhBL,CAAD,CAkBE,SACIC,CADJ,CAEIC,CAFJ,CAGIC,CAHJ,CAIIC,CAJJ,CAKIC,CALJ,CAMIC,CANJ,CAOIC,CAPJ,CAQIC,CARJ,CASIC,CATJ,CAUIC,CAVJ,CAWIC,CAXJ,CAYIC,CAZJ,CAaIC,CAbJ,CAcIC,CAdJ,CAeIC,CAfJ,CAgBIC,CAhBJ,CAiBE,IAEFC,CAAAA,CAAS,CAAG,CACZC,IAAI,CAAE,0BADM,CAEZC,GAAG,CAAE,qBAFO,CAGZC,gBAAgB,CAAE,kCAHN,CAIZC,WAAW,CAAE,6BAJD,CAKZC,YAAY,CAAE,eALF,CAMZC,aAAa,CAAE,+BANH,CAOZC,sBAAsB,CAAE,kBAPZ,CAQZC,KAAK,CAAE,QARK,CASZC,iBAAiB,CAAE,oBATP,CAUZC,UAAU,CAAE,aAVA,CAFV,CA2BFC,CAAe,CAAG,SAASC,CAAT,CAAYC,CAAZ,CAAqBC,CAArB,CAAoCC,CAApC,CAAwD,IACtEC,CAAAA,CAAe,CAAG,IADoD,CAEtEC,CAAoB,CAAGF,CAAkB,CAACG,IAAnB,CAAwB,oBAAxB,CAF+C,CAI1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MAAhB,CAAuBlD,CAAM,CAACsE,OAAP,CAAiB,oBAAjB,CAAwCvB,CAA/D,CACH,CAJD,IAIO,IACGkC,CAAAA,CAAc,CAAGtB,CAAM,CAACC,OAAP,CAAe3D,CAAS,CAACM,aAAzB,CADpB,CAGH,GADgC,CAAC0E,CACjC,CAA6B,CACzB,GAAIC,CAAAA,CAAS,CAAGjG,CAAC,CAAC,IAAD,CAAD,CAAQkC,IAAR,CAAa,0BAAb,CAAhB,CACAwD,CAAgB,CAACtD,IAAjB,CAAsB,SAAS8D,CAAT,CAAgB,CAClC,GAAIC,CAAAA,CAAO,CAAGzB,CAAM,CAACC,OAAP,CAAe7D,CAAiB,CAACqF,OAAjC,CAAd,CACAD,CAAK,CAACE,WAAN,CAAkBD,CAAO,CAACtB,IAAR,CAAa,UAAb,CAAlB,EAEA,GAAII,CAAAA,CAAU,CAAGkB,CAAO,CAACtB,IAAR,CAAa,YAAb,CAAjB,CACA,GAA0B,WAAtB,QAAOI,CAAAA,CAAX,CAAuC,CACnCiB,CAAK,CAACG,aAAN,CAAoBpB,CAApB,CACH,CAEDiB,CAAK,CAACI,YAAN,CAAmBH,CAAO,CAACtB,IAAR,CAAa,WAAb,CAAnB,EACAqB,CAAK,CAACK,YAAN,CAAmBN,CAAnB,EACAC,CAAK,CAACM,IAAN,EAEH,CAbD,EAaGtD,IAbH,CAaQ9C,CAAY,CAAC+C,SAbrB,CAcH,CACJ,CACDvB,CAAC,CAACuD,cAAF,EACH,CA9BD,CA+BH,CACJ,CA1LK,CA4LN,MAAO,CACHsB,IAAI,CAAE,cAASpD,CAAT,CAAe,CACjBA,CAAI,CAAGrD,CAAC,CAACqD,CAAD,CAAR,CACAzC,CAAmB,CAAC6F,IAApB,CAAyBpD,CAAzB,EACAe,CAAsB,CAACf,CAAD,CACzB,CALE,CAOV,CAtOK,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 * @copyright 2017 Simey Lameze \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/ajax',\n 'core/str',\n 'core/templates',\n 'core/notification',\n 'core/custom_interaction_events',\n 'core/modal_events',\n 'core/modal_factory',\n 'core_calendar/modal_event_form',\n 'core_calendar/summary_modal',\n 'core_calendar/repository',\n 'core_calendar/events',\n 'core_calendar/view_manager',\n 'core_calendar/crud',\n 'core_calendar/selectors',\n 'core/config',\n ],\n function(\n $,\n Ajax,\n Str,\n Templates,\n Notification,\n CustomEvents,\n ModalEvents,\n ModalFactory,\n ModalEventForm,\n SummaryModal,\n CalendarRepository,\n CalendarEvents,\n CalendarViewManager,\n CalendarCrud,\n CalendarSelectors,\n Config,\n ) {\n\n var SELECTORS = {\n ROOT: \"[data-region='calendar']\",\n DAY: \"[data-region='day']\",\n NEW_EVENT_BUTTON: \"[data-action='new-event-button']\",\n DAY_CONTENT: \"[data-region='day-content']\",\n LOADING_ICON: '.loading-icon',\n VIEW_DAY_LINK: \"[data-action='view-day-link']\",\n CALENDAR_MONTH_WRAPPER: \".calendarwrapper\",\n TODAY: '.today',\n DAY_NUMBER_CIRCLE: '.day-number-circle',\n DAY_NUMBER: '.day-number'\n };\n\n /**\n * Handler for the drag and drop move event. Provides a loading indicator\n * while the request is sent to the server to update the event start date.\n *\n * Triggers a eventMoved calendar javascript event if the event was successfully\n * updated.\n *\n * @param {event} e The calendar move event\n * @param {int} eventId The event id being moved\n * @param {object|null} originElement The jQuery element for where the event is moving from\n * @param {object} destinationElement The jQuery element for where the event is moving to\n */\n var handleMoveEvent = function(e, eventId, originElement, destinationElement) {\n var originTimestamp = null;\n var destinationTimestamp = destinationElement.attr('data-day-timestamp');\n\n if (originElement) {\n originTimestamp = originElement.attr('data-day-timestamp');\n }\n\n // If the event has actually changed day.\n if (!originElement || originTimestamp != destinationTimestamp) {\n Templates.render('core/loading', {})\n .then(function(html, js) {\n // First we show some loading icons in each of the days being affected.\n destinationElement.find(SELECTORS.DAY_CONTENT).addClass('hidden');\n Templates.appendNodeContents(destinationElement, html, js);\n\n if (originElement) {\n originElement.find(SELECTORS.DAY_CONTENT).addClass('hidden');\n Templates.appendNodeContents(originElement, html, js);\n }\n return;\n })\n .then(function() {\n // Send a request to the server to make the change.\n return CalendarRepository.updateEventStartDay(eventId, destinationTimestamp);\n })\n .then(function() {\n // If the update was successful then broadcast an event letting the calendar\n // know that an event has been moved.\n $('body').trigger(CalendarEvents.eventMoved, [eventId, originElement, destinationElement]);\n return;\n })\n .always(function() {\n // Always remove the loading icons regardless of whether the update\n // request was successful or not.\n var destinationLoadingElement = destinationElement.find(SELECTORS.LOADING_ICON);\n destinationElement.find(SELECTORS.DAY_CONTENT).removeClass('hidden');\n Templates.replaceNode(destinationLoadingElement, '', '');\n\n if (originElement) {\n var originLoadingElement = originElement.find(SELECTORS.LOADING_ICON);\n originElement.find(SELECTORS.DAY_CONTENT).removeClass('hidden');\n Templates.replaceNode(originLoadingElement, '', '');\n }\n return;\n })\n .fail(Notification.exception);\n }\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 * @param {object} eventFormModalPromise A promise reolved with the event form modal\n */\n var registerCalendarEventListeners = function(root, eventFormModalPromise) {\n var body = $('body');\n\n body.on(CalendarEvents.created, function() {\n CalendarViewManager.reloadCurrentMonth(root);\n });\n body.on(CalendarEvents.deleted, function() {\n CalendarViewManager.reloadCurrentMonth(root);\n });\n body.on(CalendarEvents.updated, function() {\n CalendarViewManager.reloadCurrentMonth(root);\n });\n body.on(CalendarEvents.editActionEvent, function(e, url) {\n // Action events needs to be edit directly on the course module.\n window.location.assign(url);\n });\n // Handle the event fired by the drag and drop code.\n body.on(CalendarEvents.moveEvent, handleMoveEvent);\n // When an event is successfully moved we should updated the UI.\n body.on(CalendarEvents.eventMoved, function() {\n CalendarViewManager.reloadCurrentMonth(root);\n });\n\n CalendarCrud.registerEditListeners(root, eventFormModalPromise);\n };\n\n /**\n * Register event listeners for the module.\n *\n * @param {object} root The calendar root element\n */\n var registerEventListeners = function(root) {\n const viewingFullCalendar = document.getElementById(CalendarSelectors.fullCalendarView);\n // Listen the click on the day link to render the day view.\n root.on('click', SELECTORS.VIEW_DAY_LINK, function(e) {\n var dayLink = $(e.target).closest(SELECTORS.VIEW_DAY_LINK);\n var year = dayLink.data('year'),\n month = dayLink.data('month'),\n day = dayLink.data('day'),\n courseId = dayLink.data('courseid'),\n categoryId = dayLink.data('categoryid');\n const url = '?view=day&time=' + dayLink.data('timestamp');\n if (viewingFullCalendar) {\n CalendarViewManager.refreshDayContent(root, year, month, day, courseId, categoryId, root,\n 'core_calendar/calendar_day').then(function() {\n e.preventDefault();\n return CalendarViewManager.updateUrl(url);\n }).fail(Notification.exception);\n } else {\n window.location.assign(Config.wwwroot + '/calendar/view.php' + url);\n }\n });\n\n root.on('change', CalendarSelectors.elements.courseSelector, function() {\n var selectElement = $(this);\n var courseId = selectElement.val();\n CalendarViewManager.reloadCurrentMonth(root, courseId, null)\n .then(function() {\n // We need to get the selector again because the content has changed.\n return root.find(CalendarSelectors.elements.courseSelector).val(courseId);\n })\n .fail(Notification.exception);\n });\n\n var eventFormPromise = CalendarCrud.registerEventFormModal(root),\n contextId = $(SELECTORS.CALENDAR_MONTH_WRAPPER).data('context-id');\n registerCalendarEventListeners(root, eventFormPromise);\n\n if (contextId) {\n // Bind click events to calendar days.\n root.on('click', SELECTORS.DAY, function(e) {\n var target = $(e.target);\n const displayingSmallBlockCalendar = root.parents('aside').data('blockregion') === 'side-pre';\n\n if (!viewingFullCalendar && displayingSmallBlockCalendar) {\n const dateContainer = target.closest(SELECTORS.DAY);\n const url = '?view=day&time=' + dateContainer.data('day-timestamp');\n window.location.assign(Config.wwwroot + '/calendar/view.php' + url);\n } else {\n const hasViewDayLink = target.closest(SELECTORS.VIEW_DAY_LINK);\n const shouldShowNewEventModal = !hasViewDayLink;\n if (shouldShowNewEventModal) {\n var startTime = $(this).attr('data-new-event-timestamp');\n eventFormPromise.then(function(modal) {\n var wrapper = target.closest(CalendarSelectors.wrapper);\n modal.setCourseId(wrapper.data('courseid'));\n\n var categoryId = wrapper.data('categoryid');\n if (typeof categoryId !== 'undefined') {\n modal.setCategoryId(categoryId);\n }\n\n modal.setContextId(wrapper.data('contextId'));\n modal.setStartTime(startTime);\n modal.show();\n return;\n }).fail(Notification.exception);\n }\n }\n e.preventDefault();\n });\n }\n };\n\n return {\n init: function(root) {\n root = $(root);\n CalendarViewManager.init(root);\n registerEventListeners(root);\n }\n };\n});\n"],"file":"calendar.min.js"} \ No newline at end of file diff --git a/calendar/amd/build/popover.min.js b/calendar/amd/build/popover.min.js index 5d2c00646ec..763a06aacdc 100644 --- a/calendar/amd/build/popover.min.js +++ b/calendar/amd/build/popover.min.js @@ -1,2 +1,2 @@ -function _typeof(a){"@babel/helpers - typeof";if("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator){_typeof=function(a){return typeof a}}else{_typeof=function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a}}return _typeof(a)}define ("core_calendar/popover",["theme_boost/popover","jquery","core_calendar/selectors"],function(a,b,c){"use strict";b=function(a){return a&&a.__esModule?a:{default:a}}(b);c=e(c);function d(){if("function"!=typeof WeakMap)return null;var a=new WeakMap;d=function(){return a};return a}function e(a){if(a&&a.__esModule){return a}if(null===a||"object"!==_typeof(a)&&"function"!=typeof a){return{default:a}}var b=d();if(b&&b.has(a)){return b.get(a)}var c={},e=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var f in a){if(Object.prototype.hasOwnProperty.call(a,f)){var g=e?Object.getOwnPropertyDescriptor(a,f):null;if(g&&(g.get||g.set)){Object.defineProperty(c,f,g)}else{c[f]=a[f]}}}c.default=a;if(b){b.set(a,c)}return c}var f=function(a){return"none"===window.getComputedStyle(a.querySelector(c.elements.dateContent)).display},g=new Map,h=function(a){if(!g.has(a)){var d=(0,b.default)(a);d.popover({trigger:"manual",placement:"top",html:!0,content:function(){var a=d.find(c.elements.dateContent),e=(0,b.default)("
");if(a.length){var f=a.find(".hidden").clone(!1);e.html(f.html())}return e.html()}});g.set(a,!0)}if(f(a)){(0,b.default)(a).popover("show");a.addEventListener("mouseleave",i)}},i=function(a){if(g.has(a.target)){(0,b.default)(a.target).popover("hide")}a.target.removeEventListener("mouseleave",i)},j=function(){document.addEventListener("mouseover",function(a){var b=a.target.closest(c.elements.dateContainer);if(!b){return}a.preventDefault();h(b)})},k=!1;if(!k){j();k=!0}}); +function _typeof(a){"@babel/helpers - typeof";if("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator){_typeof=function(a){return typeof a}}else{_typeof=function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a}}return _typeof(a)}define ("core_calendar/popover",["theme_boost/popover","jquery","core_calendar/selectors"],function(a,b,c){"use strict";b=function(a){return a&&a.__esModule?a:{default:a}}(b);c=e(c);function d(){if("function"!=typeof WeakMap)return null;var a=new WeakMap;d=function(){return a};return a}function e(a){if(a&&a.__esModule){return a}if(null===a||"object"!==_typeof(a)&&"function"!=typeof a){return{default:a}}var b=d();if(b&&b.has(a)){return b.get(a)}var c={},e=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var f in a){if(Object.prototype.hasOwnProperty.call(a,f)){var g=e?Object.getOwnPropertyDescriptor(a,f):null;if(g&&(g.get||g.set)){Object.defineProperty(c,f,g)}else{c[f]=a[f]}}}c.default=a;if(b){b.set(a,c)}return c}var f=function(a){return"none"===window.getComputedStyle(a.querySelector(c.elements.dateContent)).display},g=new Map,h=function(a){if(!g.has(a)){var d=(0,b.default)(a);d.popover({trigger:"manual",placement:"top",html:!0,content:function(){var a=d.find(c.elements.dateContent),e=(0,b.default)("
");if(a.length){var f=a.find(".hidden").clone(!1);e.html(f.html())}return e.html()}});g.set(a,!0)}if(f(a)){(0,b.default)(a).popover("show");a.addEventListener("mouseleave",i);a.addEventListener("focusout",i)}},i=function(a){var d=a.target,e=a.target.closest(c.elements.dateContainer);if(!e){return}if(g.has(e)){var f=d.contains(document.activeElement),h=d.matches(":hover");if(!f&&!h){(0,b.default)(e).popover("hide");e.removeEventListener("mouseleave",i);e.removeEventListener("focusout",i)}}},j=function(){var a=function(a){var b=a.target.closest(c.elements.dateContainer);if(!b){return}a.preventDefault();h(b)};document.addEventListener("mouseover",a);document.addEventListener("focusin",a)},k=!1;if(!k){j();k=!0}}); //# sourceMappingURL=popover.min.js.map diff --git a/calendar/amd/build/popover.min.js.map b/calendar/amd/build/popover.min.js.map index b7b95133a9e..b0926bd8490 100644 --- a/calendar/amd/build/popover.min.js.map +++ b/calendar/amd/build/popover.min.js.map @@ -1 +1 @@ -{"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","removeEventListener","registerEventListeners","document","closest","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,WAA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,CAACL,gBAAT,CAA0B,WAA1B,CAAuC,SAAAE,CAAC,CAAI,CACxC,GAAM3B,CAAAA,CAAa,CAAG2B,CAAC,CAAChB,MAAF,CAASoB,OAAT,CAAiB3B,CAAiB,CAACC,QAAlB,CAA2BL,aAA5C,CAAtB,CACA,GAAI,CAACA,CAAL,CAAoB,CAChB,MACH,CAED2B,CAAC,CAACK,cAAF,GACAtB,CAAW,CAACV,CAAD,CACd,CARD,CAUH,C,CAEGiC,CAAmB,G,CACvB,GAAI,CAACA,CAAL,CAA0B,CACtBJ,CAAsB,GACtBI,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\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,CAACC,OAAR,C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ACnC,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;