diff --git a/grade/report/grader/amd/build/stickycolspan.min.js b/grade/report/grader/amd/build/stickycolspan.min.js index 33ea4088e4d76..4fd44f1955f04 100644 --- a/grade/report/grader/amd/build/stickycolspan.min.js +++ b/grade/report/grader/amd/build/stickycolspan.min.js @@ -6,6 +6,6 @@ define("gradereport_grader/stickycolspan",["exports"],(function(_exports){Object * @copyright 2022 Bas Brands * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -const SELECTORS_GRADEPARENT=".gradeparent",SELECTORS_STUDENTHEADER="#studentheader",SELECTORS_TABLEHEADER="th.header",SELECTORS_BEHAT="body.behat-site",SELECTORS_TABLEHEADING="tr.heading";_exports.init=()=>{if(document.querySelector(SELECTORS_BEHAT))return;const grader=document.querySelector(SELECTORS_GRADEPARENT),studentHeader=grader.querySelector(SELECTORS_STUDENTHEADER),leftOffset=getComputedStyle(studentHeader).getPropertyValue("left"),rightOffset=getComputedStyle(studentHeader).getPropertyValue("right"),tableHeaders=grader.querySelectorAll(SELECTORS_TABLEHEADER);let i=0;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 )"}else tableHeader.style.zIndex=tableHeaders.length-i;i++})),grader.querySelector(SELECTORS_TABLEHEADING).style.zIndex=tableHeaders.length+1}})); +const SELECTORS_GRADEPARENT=".gradeparent",SELECTORS_STUDENTHEADER="#studentheader",SELECTORS_TABLEHEADER="th.header",SELECTORS_BEHAT="body.behat-site",SELECTORS_TABLEHEADING="tr.heading";_exports.init=()=>{const grader=document.querySelector(SELECTORS_GRADEPARENT),tableHeaders=grader.querySelectorAll(SELECTORS_TABLEHEADER);let i=0;tableHeaders.forEach((tableHeader=>{tableHeader.colSpan<=1&&(tableHeader.style.zIndex=tableHeaders.length-i),i++}));if(grader.querySelector(SELECTORS_TABLEHEADING).style.zIndex=tableHeaders.length+1,!document.querySelector(SELECTORS_BEHAT)){const 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 )"}}))}}})); //# 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 969395aba3373..2521aba63cc53 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\nconst SELECTORS = {\n GRADEPARENT: '.gradeparent',\n STUDENTHEADER: '#studentheader',\n TABLEHEADER: 'th.header',\n BEHAT: 'body.behat-site',\n AVERAGEROW: 'tr.lastrow',\n TABLEHEADING: 'tr.heading',\n};\n\n/**\n * Initialize module\n */\nexport const init = () => {\n if (document.querySelector(SELECTORS.BEHAT)) {\n return;\n }\n const grader = document.querySelector(SELECTORS.GRADEPARENT);\n const studentHeader = grader.querySelector(SELECTORS.STUDENTHEADER);\n const leftOffset = getComputedStyle(studentHeader).getPropertyValue('left');\n const rightOffset = getComputedStyle(studentHeader).getPropertyValue('right');\n\n const tableHeaders = grader.querySelectorAll(SELECTORS.TABLEHEADER);\n let i = 0;\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 } else {\n tableHeader.style.zIndex = tableHeaders.length - i;\n }\n i++;\n });\n\n let tableHeader = grader.querySelector(SELECTORS.TABLEHEADING);\n tableHeader.style.zIndex = tableHeaders.length + 1;\n\n\n};\n"],"names":["SELECTORS","document","querySelector","grader","studentHeader","leftOffset","getComputedStyle","getPropertyValue","rightOffset","tableHeaders","querySelectorAll","i","forEach","tableHeader","colSpan","addOffset","offsetWidth","window","right_to_left","style","right","left","zIndex","length"],"mappings":";;;;;;;;MAuBMA,sBACW,eADXA,wBAEa,iBAFbA,sBAGW,YAHXA,gBAIK,kBAJLA,uBAMY,2BAME,QACZC,SAASC,cAAcF,8BAGrBG,OAASF,SAASC,cAAcF,uBAChCI,cAAgBD,OAAOD,cAAcF,yBACrCK,WAAaC,iBAAiBF,eAAeG,iBAAiB,QAC9DC,YAAcF,iBAAiBF,eAAeG,iBAAiB,SAE/DE,aAAeN,OAAOO,iBAAiBV,2BACzCW,EAAI,EACRF,aAAaG,SAASC,iBACdA,YAAYC,QAAU,EAAG,OACnBC,UAAaF,YAAYG,YAAcZ,cAAcY,YACvDC,OAAOC,gBACPL,YAAYM,MAAMC,MAAQ,QAAUZ,YAAc,MAAQO,UAAY,OAEtEF,YAAYM,MAAME,KAAO,QAAUhB,WAAa,MAAQU,UAAY,YAGxEF,YAAYM,MAAMG,OAASb,aAAac,OAASZ,EAErDA,OAGcR,OAAOD,cAAcF,wBAC3BmB,MAAMG,OAASb,aAAac,OAAS"} \ 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\nconst SELECTORS = {\n GRADEPARENT: '.gradeparent',\n STUDENTHEADER: '#studentheader',\n TABLEHEADER: 'th.header',\n BEHAT: 'body.behat-site',\n AVERAGEROW: 'tr.lastrow',\n TABLEHEADING: 'tr.heading',\n};\n\n/**\n * Initialize module\n */\nexport const init = () => {\n const grader = document.querySelector(SELECTORS.GRADEPARENT);\n const tableHeaders = grader.querySelectorAll(SELECTORS.TABLEHEADER);\n\n let i = 0;\n tableHeaders.forEach((tableHeader) => {\n if (tableHeader.colSpan <= 1) {\n tableHeader.style.zIndex = tableHeaders.length - i;\n }\n i++;\n });\n\n const tableHeader = grader.querySelector(SELECTORS.TABLEHEADING);\n tableHeader.style.zIndex = tableHeaders.length + 1;\n\n if (!document.querySelector(SELECTORS.BEHAT)) {\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"],"names":["SELECTORS","grader","document","querySelector","tableHeaders","querySelectorAll","i","forEach","tableHeader","colSpan","style","zIndex","length","studentHeader","leftOffset","getComputedStyle","getPropertyValue","rightOffset","addOffset","offsetWidth","window","right_to_left","right","left"],"mappings":";;;;;;;;MAuBMA,sBACW,eADXA,wBAEa,iBAFbA,sBAGW,YAHXA,gBAIK,kBAJLA,uBAMY,2BAME,WACVC,OAASC,SAASC,cAAcH,uBAChCI,aAAeH,OAAOI,iBAAiBL,2BAEzCM,EAAI,EACRF,aAAaG,SAASC,cACdA,YAAYC,SAAW,IACvBD,YAAYE,MAAMC,OAASP,aAAaQ,OAASN,GAErDA,UAGgBL,OAAOE,cAAcH,wBAC7BU,MAAMC,OAASP,aAAaQ,OAAS,GAE5CV,SAASC,cAAcH,iBAAkB,OACpCa,cAAgBZ,OAAOE,cAAcH,yBACrCc,WAAaC,iBAAiBF,eAAeG,iBAAiB,QAC9DC,YAAcF,iBAAiBF,eAAeG,iBAAiB,SAErEZ,aAAaG,SAASC,iBACdA,YAAYC,QAAU,EAAG,OACnBS,UAAaV,YAAYW,YAAcN,cAAcM,YACvDC,OAAOC,gBACPb,YAAYE,MAAMY,MAAQ,QAAUL,YAAc,MAAQC,UAAY,OAEtEV,YAAYE,MAAMa,KAAO,QAAUT,WAAa,MAAQI,UAAY"} \ 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 0cbdce47ea672..edb85529f3b4a 100644 --- a/grade/report/grader/amd/src/stickycolspan.js +++ b/grade/report/grader/amd/src/stickycolspan.js @@ -34,32 +34,34 @@ const SELECTORS = { * Initialize module */ export const init = () => { - if (document.querySelector(SELECTORS.BEHAT)) { - return; - } const grader = document.querySelector(SELECTORS.GRADEPARENT); - const studentHeader = grader.querySelector(SELECTORS.STUDENTHEADER); - const leftOffset = getComputedStyle(studentHeader).getPropertyValue('left'); - const rightOffset = getComputedStyle(studentHeader).getPropertyValue('right'); - const tableHeaders = grader.querySelectorAll(SELECTORS.TABLEHEADER); + let i = 0; tableHeaders.forEach((tableHeader) => { - if (tableHeader.colSpan > 1) { - const addOffset = (tableHeader.offsetWidth - studentHeader.offsetWidth); - if (window.right_to_left()) { - tableHeader.style.right = 'calc(' + rightOffset + ' - ' + addOffset + 'px )'; - } else { - tableHeader.style.left = 'calc(' + leftOffset + ' - ' + addOffset + 'px )'; - } - } else { + if (tableHeader.colSpan <= 1) { tableHeader.style.zIndex = tableHeaders.length - i; } i++; }); - let tableHeader = grader.querySelector(SELECTORS.TABLEHEADING); + const tableHeader = grader.querySelector(SELECTORS.TABLEHEADING); tableHeader.style.zIndex = tableHeaders.length + 1; + if (!document.querySelector(SELECTORS.BEHAT)) { + const studentHeader = grader.querySelector(SELECTORS.STUDENTHEADER); + const leftOffset = getComputedStyle(studentHeader).getPropertyValue('left'); + const rightOffset = getComputedStyle(studentHeader).getPropertyValue('right'); + tableHeaders.forEach((tableHeader) => { + if (tableHeader.colSpan > 1) { + const addOffset = (tableHeader.offsetWidth - studentHeader.offsetWidth); + if (window.right_to_left()) { + tableHeader.style.right = 'calc(' + rightOffset + ' - ' + addOffset + 'px )'; + } else { + tableHeader.style.left = 'calc(' + leftOffset + ' - ' + addOffset + 'px )'; + } + } + }); + } };