diff --git a/grade/report/grader/amd/build/stickycolspan.min.js b/grade/report/grader/amd/build/stickycolspan.min.js index 4a97065e470..844801ab723 100644 --- a/grade/report/grader/amd/build/stickycolspan.min.js +++ b/grade/report/grader/amd/build/stickycolspan.min.js @@ -5,6 +5,6 @@ define("gradereport_grader/stickycolspan",["exports","jquery","core/sticky-foote * @module gradereport_grader/stickycolspan * @copyright 2022 Bas Brands * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0,_jquery=(obj=_jquery)&&obj.__esModule?obj:{default:obj};const SELECTORS_GRADEPARENT=".gradeparent",SELECTORS_STUDENTHEADER="#studentheader",SELECTORS_TABLEHEADER="th.header",SELECTORS_BEHAT="body.behat-site",SELECTORS_USERDROPDOWN=".userrow th .dropdown",SELECTORS_LASTROW=".lastrow";_exports.init=()=>{if((0,_jquery.default)(SELECTORS_USERDROPDOWN).on("show.bs.dropdown hide.bs.dropdown",(e=>{e.target.closest(SELECTORS_TABLEHEADER).classList.toggle("actions-menu-active")})),defineLastRowIntersectionObserver(!0),document.addEventListener(_stickyFooter.eventTypes.stickyFooterStateChanged,(e=>{defineLastRowIntersectionObserver(e.detail.enabled)})),!document.querySelector(SELECTORS_BEHAT)){const grader=document.querySelector(SELECTORS_GRADEPARENT),tableHeaders=grader.querySelectorAll(SELECTORS_TABLEHEADER),studentHeader=grader.querySelector(SELECTORS_STUDENTHEADER),leftOffset=getComputedStyle(studentHeader).getPropertyValue("left"),rightOffset=getComputedStyle(studentHeader).getPropertyValue("right");tableHeaders.forEach((tableHeader=>{if(tableHeader.colSpan>1){const addOffset=tableHeader.offsetWidth-studentHeader.offsetWidth;window.right_to_left()?tableHeader.style.right="calc("+rightOffset+" - "+addOffset+"px )":tableHeader.style.left="calc("+leftOffset+" - "+addOffset+"px )"}}))}};const defineLastRowIntersectionObserver=stickyFooterEnabled=>{const lastRow=document.querySelector(SELECTORS_LASTROW);if(!lastRow.classList.contains("userrow")){const stickyFooterHeight=stickyFooterEnabled?document.querySelector(_stickyFooter.SELECTORS.STICKYFOOTER).offsetHeight:null;new IntersectionObserver((_ref=>{let[e]=_ref;return e.target.classList.toggle("pinned",e.intersectionRatio<1)}),{rootMargin:stickyFooterHeight?"0px 0px -".concat(stickyFooterHeight,"px 0px"):"0px",threshold:[1]}).observe(lastRow)}}})); + */Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0,_jquery=(obj=_jquery)&&obj.__esModule?obj:{default:obj};const SELECTORS_GRADEPARENT=".gradeparent",SELECTORS_STUDENTHEADER="#studentheader",SELECTORS_TABLEHEADER="th.header",SELECTORS_BEHAT="body.behat-site",SELECTORS_USERDROPDOWN=".userrow th .dropdown",SELECTORS_LASTROW=".lastrow";_exports.init=()=>{if((0,_jquery.default)(SELECTORS_USERDROPDOWN).on("show.bs.dropdown hide.bs.dropdown",(e=>{e.target.closest(SELECTORS_TABLEHEADER).classList.toggle("actions-menu-active")})),defineLastRowIntersectionObserver(!0),document.addEventListener(_stickyFooter.eventTypes.stickyFooterStateChanged,(e=>{defineLastRowIntersectionObserver(e.detail.enabled)})),!document.querySelector(SELECTORS_BEHAT)){const grader=document.querySelector(SELECTORS_GRADEPARENT),tableHeaders=grader.querySelectorAll(SELECTORS_TABLEHEADER),studentHeader=grader.querySelector(SELECTORS_STUDENTHEADER),leftOffset=getComputedStyle(studentHeader).getPropertyValue("left"),rightOffset=getComputedStyle(studentHeader).getPropertyValue("right");tableHeaders.forEach((tableHeader=>{if(tableHeader.colSpan>1){const addOffset=tableHeader.offsetWidth-studentHeader.offsetWidth;window.right_to_left()?tableHeader.style.right="calc("+rightOffset+" - "+addOffset+"px )":tableHeader.style.left="calc("+leftOffset+" - "+addOffset+"px )"}}))}};const defineLastRowIntersectionObserver=stickyFooterEnabled=>{const lastRow=document.querySelector(SELECTORS_LASTROW);if(!lastRow.classList.contains("userrow")){const stickyFooterHeight=stickyFooterEnabled?document.querySelector(_stickyFooter.SELECTORS.STICKYFOOTER).offsetHeight:null;new IntersectionObserver((_ref=>{let[e]=_ref;return lastRow.classList.toggle("pinned",e.intersectionRatio<1)}),{rootMargin:stickyFooterHeight?"0px 0px -".concat(stickyFooterHeight,"px 0px"):"0px",threshold:[1]}).observe(lastRow.querySelector("th"))}}})); //# sourceMappingURL=stickycolspan.min.js.map \ No newline at end of file diff --git a/grade/report/grader/amd/build/stickycolspan.min.js.map b/grade/report/grader/amd/build/stickycolspan.min.js.map index d7ecd6a2f9f..c5d7ea8de1e 100644 --- a/grade/report/grader/amd/build/stickycolspan.min.js.map +++ b/grade/report/grader/amd/build/stickycolspan.min.js.map @@ -1 +1 @@ -{"version":3,"file":"stickycolspan.min.js","sources":["../src/stickycolspan.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 * Javascript module for fixing the position of sticky headers with multiple colspans\n *\n * @module gradereport_grader/stickycolspan\n * @copyright 2022 Bas Brands \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport $ from 'jquery';\nimport {SELECTORS as stickyFooterSelectors, eventTypes as stickyFooterEvents} from 'core/sticky-footer';\n\nconst SELECTORS = {\n GRADEPARENT: '.gradeparent',\n STUDENTHEADER: '#studentheader',\n TABLEHEADER: 'th.header',\n BEHAT: 'body.behat-site',\n USERDROPDOWN: '.userrow th .dropdown',\n LASTROW: '.lastrow',\n};\n\n/**\n * Initialize module\n */\nexport const init = () => {\n // The sticky positioning attributed to the user column cells affects the stacking context and makes the dropdowns\n // within these cells to be cut off. To solve this problem, whenever one of these action menus (dropdowns) is opened\n // we need to manually bump up the z-index value of the parent container element and revert once closed.\n $(SELECTORS.USERDROPDOWN).on('show.bs.dropdown hide.bs.dropdown', (e) => {\n // The closest heading element has sticky positioning which affects the stacking context in this case.\n e.target.closest(SELECTORS.TABLEHEADER).classList.toggle('actions-menu-active');\n });\n\n defineLastRowIntersectionObserver(true);\n // Add an event listener to the sticky footer toggled event to re-define the average row intersection observer\n // accordingly. This is needed as on narrow screens when scrolling vertically the sticky footer is enabled and\n // disabled dynamically.\n document.addEventListener(stickyFooterEvents.stickyFooterStateChanged, (e) => {\n defineLastRowIntersectionObserver(e.detail.enabled);\n });\n\n if (!document.querySelector(SELECTORS.BEHAT)) {\n const grader = document.querySelector(SELECTORS.GRADEPARENT);\n const tableHeaders = grader.querySelectorAll(SELECTORS.TABLEHEADER);\n const studentHeader = grader.querySelector(SELECTORS.STUDENTHEADER);\n const leftOffset = getComputedStyle(studentHeader).getPropertyValue('left');\n const rightOffset = getComputedStyle(studentHeader).getPropertyValue('right');\n\n tableHeaders.forEach((tableHeader) => {\n if (tableHeader.colSpan > 1) {\n const addOffset = (tableHeader.offsetWidth - studentHeader.offsetWidth);\n if (window.right_to_left()) {\n tableHeader.style.right = 'calc(' + rightOffset + ' - ' + addOffset + 'px )';\n } else {\n tableHeader.style.left = 'calc(' + leftOffset + ' - ' + addOffset + 'px )';\n }\n }\n });\n }\n};\n\n/**\n * Define the intersection observer that will make sure that the last row is properly pinned.\n *\n * In certain scenarios, such as when both 'Overall average' and 'Range' are set not to be shown in the Grader report,\n * a user row will end up being the last row in the Grader report table. In this particular case, we want to avoid\n * pinning the last row.\n *\n * @param {boolean} stickyFooterEnabled Whether the page shows a sticky footer or not.\n */\nconst defineLastRowIntersectionObserver = (stickyFooterEnabled) => {\n const lastRow = document.querySelector(SELECTORS.LASTROW);\n // Ensure that the last row is not a user row before defining the intersection observer.\n if (!lastRow.classList.contains('userrow')) {\n const stickyFooterHeight = stickyFooterEnabled ?\n document.querySelector(stickyFooterSelectors.STICKYFOOTER).offsetHeight : null;\n // Register an observer that will bump up the z-index value of the last row when it's pinned to prevent the row\n // being cut-off by the user column cells or other components within the report table that have higher z-index\n // values. If the page has a sticky footer, we need to make sure that the bottom root margin of the observer\n // subtracts the height of the sticky footer to prevent the row being cut-off by the footer.\n const intersectionObserver = new IntersectionObserver(\n ([e]) => e.target.classList.toggle('pinned', e.intersectionRatio < 1),\n {\n rootMargin: stickyFooterHeight ? `0px 0px -${stickyFooterHeight}px 0px` : \"0px\",\n threshold: [1]\n }\n );\n intersectionObserver.observe(lastRow);\n }\n};\n"],"names":["SELECTORS","on","e","target","closest","classList","toggle","defineLastRowIntersectionObserver","document","addEventListener","stickyFooterEvents","stickyFooterStateChanged","detail","enabled","querySelector","grader","tableHeaders","querySelectorAll","studentHeader","leftOffset","getComputedStyle","getPropertyValue","rightOffset","forEach","tableHeader","colSpan","addOffset","offsetWidth","window","right_to_left","style","right","left","stickyFooterEnabled","lastRow","contains","stickyFooterHeight","stickyFooterSelectors","STICKYFOOTER","offsetHeight","IntersectionObserver","_ref","intersectionRatio","rootMargin","threshold","observe"],"mappings":";;;;;;;gJA0BMA,sBACW,eADXA,wBAEa,iBAFbA,sBAGW,YAHXA,gBAIK,kBAJLA,uBAKY,wBALZA,kBAMO,yBAMO,4BAIdA,wBAAwBC,GAAG,qCAAsCC,IAE/DA,EAAEC,OAAOC,QAAQJ,uBAAuBK,UAAUC,OAAO,0BAG7DC,mCAAkC,GAIlCC,SAASC,iBAAiBC,yBAAmBC,0BAA2BT,IACpEK,kCAAkCL,EAAEU,OAAOC,aAG1CL,SAASM,cAAcd,iBAAkB,OACpCe,OAASP,SAASM,cAAcd,uBAChCgB,aAAeD,OAAOE,iBAAiBjB,uBACvCkB,cAAgBH,OAAOD,cAAcd,yBACrCmB,WAAaC,iBAAiBF,eAAeG,iBAAiB,QAC9DC,YAAcF,iBAAiBF,eAAeG,iBAAiB,SAErEL,aAAaO,SAASC,iBACdA,YAAYC,QAAU,EAAG,OACnBC,UAAaF,YAAYG,YAAcT,cAAcS,YACvDC,OAAOC,gBACPL,YAAYM,MAAMC,MAAQ,QAAUT,YAAc,MAAQI,UAAY,OAEtEF,YAAYM,MAAME,KAAO,QAAUb,WAAa,MAAQO,UAAY,mBAgBlFnB,kCAAqC0B,4BACjCC,QAAU1B,SAASM,cAAcd,uBAElCkC,QAAQ7B,UAAU8B,SAAS,WAAY,OAClCC,mBAAqBH,oBACvBzB,SAASM,cAAcuB,wBAAsBC,cAAcC,aAAe,KAKjD,IAAIC,sBAC7BC,WAAEvC,eAAOA,EAAEC,OAAOE,UAAUC,OAAO,SAAUJ,EAAEwC,kBAAoB,KACnE,CACIC,WAAYP,sCAAiCA,6BAA6B,MAC1EQ,UAAW,CAAC,KAGCC,QAAQX"} \ No newline at end of file +{"version":3,"file":"stickycolspan.min.js","sources":["../src/stickycolspan.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 * Javascript module for fixing the position of sticky headers with multiple colspans\n *\n * @module gradereport_grader/stickycolspan\n * @copyright 2022 Bas Brands \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport $ from 'jquery';\nimport {SELECTORS as stickyFooterSelectors, eventTypes as stickyFooterEvents} from 'core/sticky-footer';\n\nconst SELECTORS = {\n GRADEPARENT: '.gradeparent',\n STUDENTHEADER: '#studentheader',\n TABLEHEADER: 'th.header',\n BEHAT: 'body.behat-site',\n USERDROPDOWN: '.userrow th .dropdown',\n LASTROW: '.lastrow',\n};\n\n/**\n * Initialize module\n */\nexport const init = () => {\n // The sticky positioning attributed to the user column cells affects the stacking context and makes the dropdowns\n // within these cells to be cut off. To solve this problem, whenever one of these action menus (dropdowns) is opened\n // we need to manually bump up the z-index value of the parent container element and revert once closed.\n $(SELECTORS.USERDROPDOWN).on('show.bs.dropdown hide.bs.dropdown', (e) => {\n // The closest heading element has sticky positioning which affects the stacking context in this case.\n e.target.closest(SELECTORS.TABLEHEADER).classList.toggle('actions-menu-active');\n });\n\n defineLastRowIntersectionObserver(true);\n // Add an event listener to the sticky footer toggled event to re-define the average row intersection observer\n // accordingly. This is needed as on narrow screens when scrolling vertically the sticky footer is enabled and\n // disabled dynamically.\n document.addEventListener(stickyFooterEvents.stickyFooterStateChanged, (e) => {\n defineLastRowIntersectionObserver(e.detail.enabled);\n });\n\n if (!document.querySelector(SELECTORS.BEHAT)) {\n const grader = document.querySelector(SELECTORS.GRADEPARENT);\n const tableHeaders = grader.querySelectorAll(SELECTORS.TABLEHEADER);\n const studentHeader = grader.querySelector(SELECTORS.STUDENTHEADER);\n const leftOffset = getComputedStyle(studentHeader).getPropertyValue('left');\n const rightOffset = getComputedStyle(studentHeader).getPropertyValue('right');\n\n tableHeaders.forEach((tableHeader) => {\n if (tableHeader.colSpan > 1) {\n const addOffset = (tableHeader.offsetWidth - studentHeader.offsetWidth);\n if (window.right_to_left()) {\n tableHeader.style.right = 'calc(' + rightOffset + ' - ' + addOffset + 'px )';\n } else {\n tableHeader.style.left = 'calc(' + leftOffset + ' - ' + addOffset + 'px )';\n }\n }\n });\n }\n};\n\n/**\n * Define the intersection observer that will make sure that the last row is properly pinned.\n *\n * In certain scenarios, such as when both 'Overall average' and 'Range' are set not to be shown in the Grader report,\n * a user row will end up being the last row in the Grader report table. In this particular case, we want to avoid\n * pinning the last row.\n *\n * @param {boolean} stickyFooterEnabled Whether the page shows a sticky footer or not.\n */\nconst defineLastRowIntersectionObserver = (stickyFooterEnabled) => {\n const lastRow = document.querySelector(SELECTORS.LASTROW);\n // Ensure that the last row is not a user row before defining the intersection observer.\n if (!lastRow.classList.contains('userrow')) {\n const stickyFooterHeight = stickyFooterEnabled ?\n document.querySelector(stickyFooterSelectors.STICKYFOOTER).offsetHeight : null;\n // Register an observer that will bump up the z-index value of the last row when it's pinned to prevent the row\n // being cut-off by the user column cells or other components within the report table that have higher z-index\n // values. If the page has a sticky footer, we need to make sure that the bottom root margin of the observer\n // subtracts the height of the sticky footer to prevent the row being cut-off by the footer.\n const intersectionObserver = new IntersectionObserver(\n ([e]) => lastRow.classList.toggle('pinned', e.intersectionRatio < 1),\n {\n rootMargin: stickyFooterHeight ? `0px 0px -${stickyFooterHeight}px 0px` : \"0px\",\n threshold: [1]\n }\n );\n intersectionObserver.observe(lastRow.querySelector('th'));\n }\n};\n"],"names":["SELECTORS","on","e","target","closest","classList","toggle","defineLastRowIntersectionObserver","document","addEventListener","stickyFooterEvents","stickyFooterStateChanged","detail","enabled","querySelector","grader","tableHeaders","querySelectorAll","studentHeader","leftOffset","getComputedStyle","getPropertyValue","rightOffset","forEach","tableHeader","colSpan","addOffset","offsetWidth","window","right_to_left","style","right","left","stickyFooterEnabled","lastRow","contains","stickyFooterHeight","stickyFooterSelectors","STICKYFOOTER","offsetHeight","IntersectionObserver","_ref","intersectionRatio","rootMargin","threshold","observe"],"mappings":";;;;;;;gJA0BMA,sBACW,eADXA,wBAEa,iBAFbA,sBAGW,YAHXA,gBAIK,kBAJLA,uBAKY,wBALZA,kBAMO,yBAMO,4BAIdA,wBAAwBC,GAAG,qCAAsCC,IAE/DA,EAAEC,OAAOC,QAAQJ,uBAAuBK,UAAUC,OAAO,0BAG7DC,mCAAkC,GAIlCC,SAASC,iBAAiBC,yBAAmBC,0BAA2BT,IACpEK,kCAAkCL,EAAEU,OAAOC,aAG1CL,SAASM,cAAcd,iBAAkB,OACpCe,OAASP,SAASM,cAAcd,uBAChCgB,aAAeD,OAAOE,iBAAiBjB,uBACvCkB,cAAgBH,OAAOD,cAAcd,yBACrCmB,WAAaC,iBAAiBF,eAAeG,iBAAiB,QAC9DC,YAAcF,iBAAiBF,eAAeG,iBAAiB,SAErEL,aAAaO,SAASC,iBACdA,YAAYC,QAAU,EAAG,OACnBC,UAAaF,YAAYG,YAAcT,cAAcS,YACvDC,OAAOC,gBACPL,YAAYM,MAAMC,MAAQ,QAAUT,YAAc,MAAQI,UAAY,OAEtEF,YAAYM,MAAME,KAAO,QAAUb,WAAa,MAAQO,UAAY,mBAgBlFnB,kCAAqC0B,4BACjCC,QAAU1B,SAASM,cAAcd,uBAElCkC,QAAQ7B,UAAU8B,SAAS,WAAY,OAClCC,mBAAqBH,oBACvBzB,SAASM,cAAcuB,wBAAsBC,cAAcC,aAAe,KAKjD,IAAIC,sBAC7BC,WAAEvC,eAAOgC,QAAQ7B,UAAUC,OAAO,SAAUJ,EAAEwC,kBAAoB,KAClE,CACIC,WAAYP,sCAAiCA,6BAA6B,MAC1EQ,UAAW,CAAC,KAGCC,QAAQX,QAAQpB,cAAc"} \ No newline at end of file diff --git a/grade/report/grader/amd/src/stickycolspan.js b/grade/report/grader/amd/src/stickycolspan.js index ef83dd1c860..ebeac852da0 100644 --- a/grade/report/grader/amd/src/stickycolspan.js +++ b/grade/report/grader/amd/src/stickycolspan.js @@ -93,12 +93,12 @@ const defineLastRowIntersectionObserver = (stickyFooterEnabled) => { // values. If the page has a sticky footer, we need to make sure that the bottom root margin of the observer // subtracts the height of the sticky footer to prevent the row being cut-off by the footer. const intersectionObserver = new IntersectionObserver( - ([e]) => e.target.classList.toggle('pinned', e.intersectionRatio < 1), + ([e]) => lastRow.classList.toggle('pinned', e.intersectionRatio < 1), { rootMargin: stickyFooterHeight ? `0px 0px -${stickyFooterHeight}px 0px` : "0px", threshold: [1] } ); - intersectionObserver.observe(lastRow); + intersectionObserver.observe(lastRow.querySelector('th')); } };