From b7f9e7c5169b410e53a54b24d8dc7de76faf64d0 Mon Sep 17 00:00:00 2001
From: Gareth Barnard <1058419+gjb2048@users.noreply.github.com>
Date: Fri, 29 Sep 2023 19:12:17 +0100
Subject: [PATCH] Work in progress.
---
amd/build/thegrid.min.js | 2 +-
amd/build/thegrid.min.js.map | 2 +-
amd/src/thegrid.js | 130 +++++++++++++++++------------------
3 files changed, 66 insertions(+), 68 deletions(-)
diff --git a/amd/build/thegrid.min.js b/amd/build/thegrid.min.js
index 8d3d7a6d..1153d67f 100644
--- a/amd/build/thegrid.min.js
+++ b/amd/build/thegrid.min.js
@@ -6,6 +6,6 @@ define("format_grid/thegrid",["exports","core_course/events","jquery","core/log"
* @copyright © 2023-onwards G J Barnard.
* @author G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */(CourseEvents),_jquery=_interopRequireDefault(_jquery),_log=_interopRequireDefault(_log);let registered=!1,mctFired=!1;_exports.init=(sectionnumbers,popup,showcompletion)=>{if(_log.default.debug("Grid thegrid JS init"),registered)_log.default.debug("Grid thegrid JS init already registered");else{_log.default.debug("Grid thegrid sectionnumbers "+sectionnumbers),document.addEventListener(CourseEvents.manualCompletionToggled,(()=>{mctFired=!0})),registered=!0;var currentmodalsection=null,modalshown=!1,currentsection=null,currentsectionshown=!1,endsection=sectionnumbers.length-1,sectionchange=function(direction){null===currentsection&&(currentsection=direction<0?endsection:0),null!==currentsection&&((0,_jquery.default)("#section-"+sectionnumbers[currentsection]).removeClass("grid-current-section"),(currentsection+=direction)<0?currentsection=endsection:currentsection>endsection&&(currentsection=0),(0,_jquery.default)("#section-"+sectionnumbers[currentsection]).addClass("grid-current-section"))};if(popup){var updatecurrentsection=function(){currentsectionshown&&(0,_jquery.default)("#section-"+sectionnumbers[currentsection]).removeClass("grid-current-section"),currentsection=currentmodalsection-1,currentsectionshown&&(0,_jquery.default)("#section-"+sectionnumbers[currentsection]).addClass("grid-current-section")};(0,_jquery.default)("#gridPopup").on("show.bs.modal",(function(event){if(modalshown=!0,null===currentmodalsection){var trigger=(0,_jquery.default)(event.relatedTarget);currentmodalsection=trigger.data("section")}updatecurrentsection();var gml=(0,_jquery.default)("#gridPopupLabel"),triggersectionname=(0,_jquery.default)("#gridpopupsection-"+currentmodalsection).data("sectiontitle");gml.text(triggersectionname),(0,_jquery.default)(this).find("#gridpopupsection-"+currentmodalsection).addClass("active"),(0,_jquery.default)("#gridPopupCarousel").on("slid.bs.carousel",(function(event){var item=(0,_jquery.default)(".gridcarousel-item.active"),st=item.data("sectiontitle");gml.text(st),_log.default.debug("Carousel direction: "+event.direction),currentmodalsection=item.data("section"),updatecurrentsection()}))})),(0,_jquery.default)("#gridPopup").on("hidden.bs.modal",(function(){updatecurrentsection(),null!==currentmodalsection&&(currentmodalsection=null),(0,_jquery.default)(".gridcarousel-item").removeClass("active"),showcompletion&&mctFired&&(mctFired=!1,window.location.reload()),modalshown=!1})),(0,_jquery.default)(".grid-section .grid-modal").on("keydown",(function(event){if(13==event.which||27==event.which){event.preventDefault();var trigger=(0,_jquery.default)(event.currentTarget);currentmodalsection=trigger.data("section"),(0,_jquery.default)("#gridPopup").modal("show")}}))}(0,_jquery.default)(document).on("keydown",(function(event){37==event.which?(event.preventDefault(),currentsectionshown=!0,sectionchange(-1),_log.default.debug("Left: "+sectionnumbers[currentsection]),modalshown&&(0,_jquery.default)("#gridPopupCarouselLeft").trigger("click")):39==event.which?(event.preventDefault(),currentsectionshown=!0,sectionchange(1),_log.default.debug("Right: "+sectionnumbers[currentsection]),modalshown&&(0,_jquery.default)("#gridPopupCarouselRight").trigger("click")):13!=event.which&&27!=event.which||popup&&!modalshown&¤tsectionshown&&(null===currentmodalsection&&(currentmodalsection=sectionnumbers[currentsection]),(0,_jquery.default)("#gridPopup").modal("show"))}))}}}));
+ */(CourseEvents),_jquery=_interopRequireDefault(_jquery),_log=_interopRequireDefault(_log);let registered=!1,mctFired=!1;_exports.init=(sectionnumbers,popup,showcompletion)=>{if(_log.default.debug("Grid thegrid JS init"),registered)_log.default.debug("Grid thegrid JS init already registered");else if(popup){_log.default.debug("Grid thegrid sectionnumbers "+sectionnumbers),document.addEventListener(CourseEvents.manualCompletionToggled,(()=>{mctFired=!0})),registered=!0;var currentmodalsection=null,modalshown=!1,currentsection=null,currentsectionshown=!1,endsection=sectionnumbers.length-1,sectionchange=function(direction){null===currentsection&&(currentsection=direction<0?endsection:0),null!==currentsection&&((0,_jquery.default)("#section-"+sectionnumbers[currentsection]).removeClass("grid-current-section"),(currentsection+=direction)<0?currentsection=endsection:currentsection>endsection&&(currentsection=0),(0,_jquery.default)("#section-"+sectionnumbers[currentsection]).addClass("grid-current-section"))},updatecurrentsection=function(){currentsectionshown&&(0,_jquery.default)("#section-"+sectionnumbers[currentsection]).removeClass("grid-current-section"),currentsection=currentmodalsection-1,currentsectionshown&&(0,_jquery.default)("#section-"+sectionnumbers[currentsection]).addClass("grid-current-section")};(0,_jquery.default)("#gridPopup").on("show.bs.modal",(function(event){if(modalshown=!0,null===currentmodalsection){var trigger=(0,_jquery.default)(event.relatedTarget);currentmodalsection=trigger.data("section")}updatecurrentsection();var gml=(0,_jquery.default)("#gridPopupLabel"),triggersectionname=(0,_jquery.default)("#gridpopupsection-"+currentmodalsection).data("sectiontitle");gml.text(triggersectionname),(0,_jquery.default)(this).find("#gridpopupsection-"+currentmodalsection).addClass("active"),(0,_jquery.default)("#gridPopupCarousel").on("slid.bs.carousel",(function(event){var item=(0,_jquery.default)(".gridcarousel-item.active"),st=item.data("sectiontitle");gml.text(st),_log.default.debug("Carousel direction: "+event.direction),currentmodalsection=item.data("section"),updatecurrentsection()}))})),(0,_jquery.default)("#gridPopup").on("hidden.bs.modal",(function(){updatecurrentsection(),null!==currentmodalsection&&(currentmodalsection=null),(0,_jquery.default)(".gridcarousel-item").removeClass("active"),showcompletion&&mctFired&&(mctFired=!1,window.location.reload()),modalshown=!1})),(0,_jquery.default)(".grid-section .grid-modal").on("keydown",(function(event){if(13==event.which||27==event.which){event.preventDefault();var trigger=(0,_jquery.default)(event.currentTarget);currentmodalsection=trigger.data("section"),(0,_jquery.default)("#gridPopup").modal("show")}})),(0,_jquery.default)(document).on("keydown",(function(event){37==event.which?(event.preventDefault(),currentsectionshown=!0,sectionchange(-1),_log.default.debug("Left: "+sectionnumbers[currentsection]),modalshown&&(0,_jquery.default)("#gridPopupCarouselLeft").trigger("click")):39==event.which?(event.preventDefault(),currentsectionshown=!0,sectionchange(1),_log.default.debug("Right: "+sectionnumbers[currentsection]),modalshown&&(0,_jquery.default)("#gridPopupCarouselRight").trigger("click")):13!=event.which&&27!=event.which||!modalshown&¤tsectionshown&&(null===currentmodalsection&&(currentmodalsection=sectionnumbers[currentsection]),(0,_jquery.default)("#gridPopup").modal("show"))}))}}}));
//# sourceMappingURL=thegrid.min.js.map
\ No newline at end of file
diff --git a/amd/build/thegrid.min.js.map b/amd/build/thegrid.min.js.map
index 63245c4b..557dd6b8 100644
--- a/amd/build/thegrid.min.js.map
+++ b/amd/build/thegrid.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"thegrid.min.js","sources":["../src/thegrid.js"],"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 * JS module for the grid.\n *\n * @module format_grid/thegrid\n * @copyright © 2023-onwards G J Barnard.\n * @author G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195}\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport * as CourseEvents from 'core_course/events';\nimport jQuery from 'jquery';\nimport log from 'core/log';\n\n/**\n * Whether the event listener has already been registered for this module.\n *\n * @type {boolean}\n */\nlet registered = false;\n\n/**\n * If the manualCompletionToggled event has fired.\n *\n * @type {boolean}\n */\nlet mctFired = false;\n\n/**\n * Function to intialise and register event listeners for this module.\n *\n * @param {array} sectionnumbers Show completion is on.\n * @param {boolean} popup Popup is used.\n * @param {boolean} showcompletion Show completion is on.\n */\nexport const init = (sectionnumbers, popup, showcompletion) => {\n log.debug('Grid thegrid JS init');\n if (registered) {\n log.debug('Grid thegrid JS init already registered');\n return;\n } else {\n log.debug('Grid thegrid sectionnumbers ' + sectionnumbers);\n }\n // Listen for toggled manual completion states of activities.\n document.addEventListener(CourseEvents.manualCompletionToggled, () => {\n mctFired = true;\n });\n registered = true;\n\n // Modal.\n var currentmodalsection = null;\n var modalshown = false;\n\n // Grid current section.\n var currentsection = null;\n var currentsectionshown = false;\n var endsection = sectionnumbers.length - 1;\n\n /**\n * Change the current selected section, arrow keys only.\n * If the modal is shown then will also move the carousel.\n * @param {int} direction -1 = left and 1 = right.\n */\n var sectionchange = function (direction) {\n if (currentsection === null) {\n if (direction < 0) {\n currentsection = endsection;\n } else {\n currentsection = 0;\n }\n }\n if (currentsection !== null) {\n jQuery('#section-' + sectionnumbers[currentsection]).removeClass('grid-current-section');\n currentsection = currentsection + direction;\n if (currentsection < 0) {\n currentsection = endsection;\n } else if (currentsection > endsection) {\n currentsection = 0;\n }\n jQuery('#section-' + sectionnumbers[currentsection]).addClass('grid-current-section');\n }\n };\n\n if (popup) {\n var updatecurrentsection = function () {\n if (currentsectionshown) {\n jQuery('#section-' + sectionnumbers[currentsection]).removeClass('grid-current-section');\n }\n currentsection = currentmodalsection - 1;\n if (currentsectionshown) {\n jQuery('#section-' + sectionnumbers[currentsection]).addClass('grid-current-section');\n }\n };\n\n jQuery('#gridPopup').on('show.bs.modal', function (event) {\n modalshown = true;\n if (currentmodalsection === null) {\n var trigger = jQuery(event.relatedTarget);\n currentmodalsection = trigger.data('section');\n }\n\n updatecurrentsection();\n\n var gml = jQuery('#gridPopupLabel');\n var triggersectionname = jQuery('#gridpopupsection-' + currentmodalsection).data('sectiontitle');\n gml.text(triggersectionname);\n\n var modal = jQuery(this);\n modal.find('#gridpopupsection-' + currentmodalsection).addClass('active');\n\n jQuery('#gridPopupCarousel').on('slid.bs.carousel', function (event) {\n var item = jQuery('.gridcarousel-item.active');\n var st = item.data('sectiontitle');\n gml.text(st);\n log.debug(\"Carousel direction: \" + event.direction);\n currentmodalsection = item.data('section');\n updatecurrentsection();\n });\n });\n\n jQuery('#gridPopup').on('hidden.bs.modal', function () {\n updatecurrentsection();\n\n if (currentmodalsection !== null) {\n currentmodalsection = null;\n }\n jQuery('.gridcarousel-item').removeClass('active');\n if (showcompletion && mctFired) {\n mctFired = false;\n window.location.reload();\n }\n modalshown = false;\n });\n\n jQuery(\".grid-section .grid-modal\").on('keydown', function (event) {\n // Clicked within the modal\n if ((event.which == 13) || (event.which == 27)) {\n event.preventDefault();\n var trigger = jQuery(event.currentTarget);\n currentmodalsection = trigger.data('section');\n jQuery('#gridPopup').modal('show');\n }\n });\n }\n\n jQuery(document).on('keydown', function (event) {\n if (event.which == 37) {\n // Left.\n event.preventDefault();\n currentsectionshown = true;\n sectionchange(-1);\n log.debug(\"Left: \" + sectionnumbers[currentsection]);\n if (modalshown) {\n jQuery('#gridPopupCarouselLeft').trigger('click');\n }\n } else if (event.which == 39) {\n // Right.\n event.preventDefault();\n currentsectionshown = true;\n sectionchange(1);\n log.debug(\"Right: \" + sectionnumbers[currentsection]);\n if (modalshown) {\n jQuery('#gridPopupCarouselRight').trigger('click');\n }\n } else if ((event.which == 13) || (event.which == 27)) {\n // Enter (13) and ESC keys (27).\n if ((popup) && (!modalshown)) {\n if (currentsectionshown) {\n if (currentmodalsection === null) {\n currentmodalsection = sectionnumbers[currentsection];\n }\n jQuery('#gridPopup').modal('show');\n }\n }\n }\n });\n};\n"],"names":["registered","mctFired","sectionnumbers","popup","showcompletion","debug","document","addEventListener","CourseEvents","manualCompletionToggled","currentmodalsection","modalshown","currentsection","currentsectionshown","endsection","length","sectionchange","direction","removeClass","addClass","updatecurrentsection","on","event","trigger","relatedTarget","data","gml","triggersectionname","text","this","find","item","st","window","location","reload","which","preventDefault","currentTarget","modal"],"mappings":";;;;;;;;kGAiCIA,YAAa,EAObC,UAAW,gBASK,CAACC,eAAgBC,MAAOC,kCACpCC,MAAM,wBACNL,wBACIK,MAAM,6DAGNA,MAAM,+BAAiCH,gBAG/CI,SAASC,iBAAiBC,aAAaC,yBAAyB,KAC5DR,UAAW,KAEfD,YAAa,MAGTU,oBAAsB,KACtBC,YAAa,EAGbC,eAAiB,KACjBC,qBAAsB,EACtBC,WAAaZ,eAAea,OAAS,EAOrCC,cAAgB,SAAUC,WACH,OAAnBL,iBAEIA,eADAK,UAAY,EACKH,WAEA,GAGF,OAAnBF,qCACO,YAAcV,eAAeU,iBAAiBM,YAAY,yBACjEN,gBAAkCK,WACb,EACjBL,eAAiBE,WACVF,eAAiBE,aACxBF,eAAiB,uBAEd,YAAcV,eAAeU,iBAAiBO,SAAS,6BAIlEhB,MAAO,KACHiB,qBAAuB,WACnBP,yCACO,YAAcX,eAAeU,iBAAiBM,YAAY,wBAErEN,eAAiBF,oBAAsB,EACnCG,yCACO,YAAcX,eAAeU,iBAAiBO,SAAS,6CAI/D,cAAcE,GAAG,iBAAiB,SAAUC,UAC/CX,YAAa,EACe,OAAxBD,oBAA8B,KAC1Ba,SAAU,mBAAOD,MAAME,eAC3Bd,oBAAsBa,QAAQE,KAAK,WAGvCL,2BAEIM,KAAM,mBAAO,mBACbC,oBAAqB,mBAAO,qBAAuBjB,qBAAqBe,KAAK,gBACjFC,IAAIE,KAAKD,qBAEG,mBAAOE,MACbC,KAAK,qBAAuBpB,qBAAqBS,SAAS,8BAEzD,sBAAsBE,GAAG,oBAAoB,SAAUC,WACtDS,MAAO,mBAAO,6BACdC,GAAKD,KAAKN,KAAK,gBACnBC,IAAIE,KAAKI,iBACL3B,MAAM,uBAAyBiB,MAAML,WACzCP,oBAAsBqB,KAAKN,KAAK,WAChCL,iDAID,cAAcC,GAAG,mBAAmB,WACvCD,uBAE4B,OAAxBV,sBACAA,oBAAsB,0BAEnB,sBAAsBQ,YAAY,UACrCd,gBAAkBH,WAClBA,UAAW,EACXgC,OAAOC,SAASC,UAEpBxB,YAAa,yBAGV,6BAA6BU,GAAG,WAAW,SAAUC,UAEpC,IAAfA,MAAMc,OAAgC,IAAfd,MAAMc,MAAc,CAC5Cd,MAAMe,qBACFd,SAAU,mBAAOD,MAAMgB,eAC3B5B,oBAAsBa,QAAQE,KAAK,+BAC5B,cAAcc,MAAM,gCAKhCjC,UAAUe,GAAG,WAAW,SAAUC,OAClB,IAAfA,MAAMc,OAENd,MAAMe,iBACNxB,qBAAsB,EACtBG,eAAe,gBACXX,MAAM,SAAWH,eAAeU,iBAChCD,gCACO,0BAA0BY,QAAQ,UAEvB,IAAfD,MAAMc,OAEbd,MAAMe,iBACNxB,qBAAsB,EACtBG,cAAc,gBACVX,MAAM,UAAYH,eAAeU,iBACjCD,gCACO,2BAA2BY,QAAQ,UAEvB,IAAfD,MAAMc,OAAgC,IAAfd,MAAMc,OAEhCjC,QAAYQ,YACTE,sBAC4B,OAAxBH,sBACAA,oBAAsBR,eAAeU,qCAElC,cAAc2B,MAAM"}
\ No newline at end of file
+{"version":3,"file":"thegrid.min.js","sources":["../src/thegrid.js"],"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 * JS module for the grid.\n *\n * @module format_grid/thegrid\n * @copyright © 2023-onwards G J Barnard.\n * @author G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195}\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport * as CourseEvents from 'core_course/events';\nimport jQuery from 'jquery';\nimport log from 'core/log';\n\n/**\n * Whether the event listener has already been registered for this module.\n *\n * @type {boolean}\n */\nlet registered = false;\n\n/**\n * If the manualCompletionToggled event has fired.\n *\n * @type {boolean}\n */\nlet mctFired = false;\n\n/**\n * Function to intialise and register event listeners for this module.\n *\n * @param {array} sectionnumbers Show completion is on.\n * @param {boolean} popup Popup is used.\n * @param {boolean} showcompletion Show completion is on.\n */\nexport const init = (sectionnumbers, popup, showcompletion) => {\n log.debug('Grid thegrid JS init');\n if (registered) {\n log.debug('Grid thegrid JS init already registered');\n return;\n }\n if (popup) {\n log.debug('Grid thegrid sectionnumbers ' + sectionnumbers);\n\n // Listen for toggled manual completion states of activities.\n document.addEventListener(CourseEvents.manualCompletionToggled, () => {\n mctFired = true;\n });\n registered = true;\n\n // Modal.\n var currentmodalsection = null;\n var modalshown = false;\n\n // Grid current section.\n var currentsection = null;\n var currentsectionshown = false;\n var endsection = sectionnumbers.length - 1;\n\n /**\n * Change the current selected section, arrow keys only.\n * If the modal is shown then will also move the carousel.\n * @param {int} direction -1 = left and 1 = right.\n */\n var sectionchange = function (direction) {\n if (currentsection === null) {\n if (direction < 0) {\n currentsection = endsection;\n } else {\n currentsection = 0;\n }\n }\n if (currentsection !== null) {\n jQuery('#section-' + sectionnumbers[currentsection]).removeClass('grid-current-section');\n currentsection = currentsection + direction;\n if (currentsection < 0) {\n currentsection = endsection;\n } else if (currentsection > endsection) {\n currentsection = 0;\n }\n jQuery('#section-' + sectionnumbers[currentsection]).addClass('grid-current-section');\n }\n };\n\n var updatecurrentsection = function () {\n if (currentsectionshown) {\n jQuery('#section-' + sectionnumbers[currentsection]).removeClass('grid-current-section');\n }\n currentsection = currentmodalsection - 1;\n if (currentsectionshown) {\n jQuery('#section-' + sectionnumbers[currentsection]).addClass('grid-current-section');\n }\n };\n\n jQuery('#gridPopup').on('show.bs.modal', function (event) {\n modalshown = true;\n if (currentmodalsection === null) {\n var trigger = jQuery(event.relatedTarget);\n currentmodalsection = trigger.data('section');\n }\n\n updatecurrentsection();\n\n var gml = jQuery('#gridPopupLabel');\n var triggersectionname = jQuery('#gridpopupsection-' + currentmodalsection).data('sectiontitle');\n gml.text(triggersectionname);\n\n var modal = jQuery(this);\n modal.find('#gridpopupsection-' + currentmodalsection).addClass('active');\n\n jQuery('#gridPopupCarousel').on('slid.bs.carousel', function (event) {\n var item = jQuery('.gridcarousel-item.active');\n var st = item.data('sectiontitle');\n gml.text(st);\n log.debug(\"Carousel direction: \" + event.direction);\n currentmodalsection = item.data('section');\n updatecurrentsection();\n });\n });\n\n jQuery('#gridPopup').on('hidden.bs.modal', function () {\n updatecurrentsection();\n\n if (currentmodalsection !== null) {\n currentmodalsection = null;\n }\n jQuery('.gridcarousel-item').removeClass('active');\n if (showcompletion && mctFired) {\n mctFired = false;\n window.location.reload();\n }\n modalshown = false;\n });\n\n jQuery(\".grid-section .grid-modal\").on('keydown', function (event) {\n // Clicked within the modal\n if ((event.which == 13) || (event.which == 27)) {\n event.preventDefault();\n var trigger = jQuery(event.currentTarget);\n currentmodalsection = trigger.data('section');\n jQuery('#gridPopup').modal('show');\n }\n });\n\n jQuery(document).on('keydown', function (event) {\n if (event.which == 37) {\n // Left.\n event.preventDefault();\n currentsectionshown = true;\n sectionchange(-1);\n log.debug(\"Left: \" + sectionnumbers[currentsection]);\n if (modalshown) {\n jQuery('#gridPopupCarouselLeft').trigger('click');\n }\n } else if (event.which == 39) {\n // Right.\n event.preventDefault();\n currentsectionshown = true;\n sectionchange(1);\n log.debug(\"Right: \" + sectionnumbers[currentsection]);\n if (modalshown) {\n jQuery('#gridPopupCarouselRight').trigger('click');\n }\n } else if ((event.which == 13) || (event.which == 27)) {\n // Enter (13) and ESC keys (27).\n if ((!modalshown) && (currentsectionshown)) {\n if (currentmodalsection === null) {\n currentmodalsection = sectionnumbers[currentsection];\n }\n jQuery('#gridPopup').modal('show');\n }\n }\n });\n }\n};\n"],"names":["registered","mctFired","sectionnumbers","popup","showcompletion","debug","document","addEventListener","CourseEvents","manualCompletionToggled","currentmodalsection","modalshown","currentsection","currentsectionshown","endsection","length","sectionchange","direction","removeClass","addClass","updatecurrentsection","on","event","trigger","relatedTarget","data","gml","triggersectionname","text","this","find","item","st","window","location","reload","which","preventDefault","currentTarget","modal"],"mappings":";;;;;;;;kGAiCIA,YAAa,EAObC,UAAW,gBASK,CAACC,eAAgBC,MAAOC,kCACpCC,MAAM,wBACNL,wBACIK,MAAM,mDAGVF,MAAO,cACHE,MAAM,+BAAiCH,gBAG3CI,SAASC,iBAAiBC,aAAaC,yBAAyB,KAC5DR,UAAW,KAEfD,YAAa,MAGTU,oBAAsB,KACtBC,YAAa,EAGbC,eAAiB,KACjBC,qBAAsB,EACtBC,WAAaZ,eAAea,OAAS,EAOrCC,cAAgB,SAAUC,WACH,OAAnBL,iBAEIA,eADAK,UAAY,EACKH,WAEA,GAGF,OAAnBF,qCACO,YAAcV,eAAeU,iBAAiBM,YAAY,yBACjEN,gBAAkCK,WACb,EACjBL,eAAiBE,WACVF,eAAiBE,aACxBF,eAAiB,uBAEd,YAAcV,eAAeU,iBAAiBO,SAAS,0BAIlEC,qBAAuB,WACnBP,yCACO,YAAcX,eAAeU,iBAAiBM,YAAY,wBAErEN,eAAiBF,oBAAsB,EACnCG,yCACO,YAAcX,eAAeU,iBAAiBO,SAAS,6CAI/D,cAAcE,GAAG,iBAAiB,SAAUC,UAC/CX,YAAa,EACe,OAAxBD,oBAA8B,KAC1Ba,SAAU,mBAAOD,MAAME,eAC3Bd,oBAAsBa,QAAQE,KAAK,WAGvCL,2BAEIM,KAAM,mBAAO,mBACbC,oBAAqB,mBAAO,qBAAuBjB,qBAAqBe,KAAK,gBACjFC,IAAIE,KAAKD,qBAEG,mBAAOE,MACbC,KAAK,qBAAuBpB,qBAAqBS,SAAS,8BAEzD,sBAAsBE,GAAG,oBAAoB,SAAUC,WACtDS,MAAO,mBAAO,6BACdC,GAAKD,KAAKN,KAAK,gBACnBC,IAAIE,KAAKI,iBACL3B,MAAM,uBAAyBiB,MAAML,WACzCP,oBAAsBqB,KAAKN,KAAK,WAChCL,iDAID,cAAcC,GAAG,mBAAmB,WACvCD,uBAE4B,OAAxBV,sBACAA,oBAAsB,0BAEnB,sBAAsBQ,YAAY,UACrCd,gBAAkBH,WAClBA,UAAW,EACXgC,OAAOC,SAASC,UAEpBxB,YAAa,yBAGV,6BAA6BU,GAAG,WAAW,SAAUC,UAEpC,IAAfA,MAAMc,OAAgC,IAAfd,MAAMc,MAAc,CAC5Cd,MAAMe,qBACFd,SAAU,mBAAOD,MAAMgB,eAC3B5B,oBAAsBa,QAAQE,KAAK,+BAC5B,cAAcc,MAAM,gCAI5BjC,UAAUe,GAAG,WAAW,SAAUC,OAClB,IAAfA,MAAMc,OAENd,MAAMe,iBACNxB,qBAAsB,EACtBG,eAAe,gBACXX,MAAM,SAAWH,eAAeU,iBAChCD,gCACO,0BAA0BY,QAAQ,UAEvB,IAAfD,MAAMc,OAEbd,MAAMe,iBACNxB,qBAAsB,EACtBG,cAAc,gBACVX,MAAM,UAAYH,eAAeU,iBACjCD,gCACO,2BAA2BY,QAAQ,UAEvB,IAAfD,MAAMc,OAAgC,IAAfd,MAAMc,QAE/BzB,YAAgBE,sBACU,OAAxBH,sBACAA,oBAAsBR,eAAeU,qCAElC,cAAc2B,MAAM"}
\ No newline at end of file
diff --git a/amd/src/thegrid.js b/amd/src/thegrid.js
index 08df8fd9..363b5d62 100644
--- a/amd/src/thegrid.js
+++ b/amd/src/thegrid.js
@@ -52,50 +52,50 @@ export const init = (sectionnumbers, popup, showcompletion) => {
if (registered) {
log.debug('Grid thegrid JS init already registered');
return;
- } else {
- log.debug('Grid thegrid sectionnumbers ' + sectionnumbers);
}
- // Listen for toggled manual completion states of activities.
- document.addEventListener(CourseEvents.manualCompletionToggled, () => {
- mctFired = true;
- });
- registered = true;
-
- // Modal.
- var currentmodalsection = null;
- var modalshown = false;
-
- // Grid current section.
- var currentsection = null;
- var currentsectionshown = false;
- var endsection = sectionnumbers.length - 1;
-
- /**
- * Change the current selected section, arrow keys only.
- * If the modal is shown then will also move the carousel.
- * @param {int} direction -1 = left and 1 = right.
- */
- var sectionchange = function (direction) {
- if (currentsection === null) {
- if (direction < 0) {
- currentsection = endsection;
- } else {
- currentsection = 0;
+ if (popup) {
+ log.debug('Grid thegrid sectionnumbers ' + sectionnumbers);
+
+ // Listen for toggled manual completion states of activities.
+ document.addEventListener(CourseEvents.manualCompletionToggled, () => {
+ mctFired = true;
+ });
+ registered = true;
+
+ // Modal.
+ var currentmodalsection = null;
+ var modalshown = false;
+
+ // Grid current section.
+ var currentsection = null;
+ var currentsectionshown = false;
+ var endsection = sectionnumbers.length - 1;
+
+ /**
+ * Change the current selected section, arrow keys only.
+ * If the modal is shown then will also move the carousel.
+ * @param {int} direction -1 = left and 1 = right.
+ */
+ var sectionchange = function (direction) {
+ if (currentsection === null) {
+ if (direction < 0) {
+ currentsection = endsection;
+ } else {
+ currentsection = 0;
+ }
}
- }
- if (currentsection !== null) {
- jQuery('#section-' + sectionnumbers[currentsection]).removeClass('grid-current-section');
- currentsection = currentsection + direction;
- if (currentsection < 0) {
- currentsection = endsection;
- } else if (currentsection > endsection) {
- currentsection = 0;
+ if (currentsection !== null) {
+ jQuery('#section-' + sectionnumbers[currentsection]).removeClass('grid-current-section');
+ currentsection = currentsection + direction;
+ if (currentsection < 0) {
+ currentsection = endsection;
+ } else if (currentsection > endsection) {
+ currentsection = 0;
+ }
+ jQuery('#section-' + sectionnumbers[currentsection]).addClass('grid-current-section');
}
- jQuery('#section-' + sectionnumbers[currentsection]).addClass('grid-current-section');
- }
- };
+ };
- if (popup) {
var updatecurrentsection = function () {
if (currentsectionshown) {
jQuery('#section-' + sectionnumbers[currentsection]).removeClass('grid-current-section');
@@ -155,37 +155,35 @@ export const init = (sectionnumbers, popup, showcompletion) => {
jQuery('#gridPopup').modal('show');
}
});
- }
- jQuery(document).on('keydown', function (event) {
- if (event.which == 37) {
- // Left.
- event.preventDefault();
- currentsectionshown = true;
- sectionchange(-1);
- log.debug("Left: " + sectionnumbers[currentsection]);
- if (modalshown) {
- jQuery('#gridPopupCarouselLeft').trigger('click');
- }
- } else if (event.which == 39) {
- // Right.
- event.preventDefault();
- currentsectionshown = true;
- sectionchange(1);
- log.debug("Right: " + sectionnumbers[currentsection]);
- if (modalshown) {
- jQuery('#gridPopupCarouselRight').trigger('click');
- }
- } else if ((event.which == 13) || (event.which == 27)) {
- // Enter (13) and ESC keys (27).
- if ((popup) && (!modalshown)) {
- if (currentsectionshown) {
+ jQuery(document).on('keydown', function (event) {
+ if (event.which == 37) {
+ // Left.
+ event.preventDefault();
+ currentsectionshown = true;
+ sectionchange(-1);
+ log.debug("Left: " + sectionnumbers[currentsection]);
+ if (modalshown) {
+ jQuery('#gridPopupCarouselLeft').trigger('click');
+ }
+ } else if (event.which == 39) {
+ // Right.
+ event.preventDefault();
+ currentsectionshown = true;
+ sectionchange(1);
+ log.debug("Right: " + sectionnumbers[currentsection]);
+ if (modalshown) {
+ jQuery('#gridPopupCarouselRight').trigger('click');
+ }
+ } else if ((event.which == 13) || (event.which == 27)) {
+ // Enter (13) and ESC keys (27).
+ if ((!modalshown) && (currentsectionshown)) {
if (currentmodalsection === null) {
currentmodalsection = sectionnumbers[currentsection];
}
jQuery('#gridPopup').modal('show');
}
}
- }
- });
+ });
+ }
};