diff --git a/amd/build/showmore.min.js b/amd/build/showmore.min.js index 7e0950da..4eac89e1 100644 --- a/amd/build/showmore.min.js +++ b/amd/build/showmore.min.js @@ -1,3 +1,3 @@ -define("qtype_questionpy/showmore",["exports"],(function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0;const isOverflowing=element=>element.scrollHeight>element.clientHeight;_exports.init=id=>{const element=document.getElementById(id),container=element.querySelector(".qpy-show-more-container"),button=element.querySelector(".qpy-show-more-button");window.addEventListener("resize",(()=>{button.classList.toggle("d-none",!isOverflowing(container))})),button.classList.toggle("d-none",!isOverflowing(container))}})); +define("qtype_questionpy/showmore",["exports"],(function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0;const isOverflowing=element=>element.scrollHeight>element.clientHeight;_exports.init=id=>{const element=document.getElementById(id),container=element.querySelector(".qpy-show-more-container"),button=element.querySelector(".qpy-show-more-button");window.addEventListener("resize",(()=>{button.classList.contains("collapsed")&&button.classList.toggle("d-none",!isOverflowing(container))})),button.classList.toggle("d-none",!isOverflowing(container))}})); //# sourceMappingURL=showmore.min.js.map \ No newline at end of file diff --git a/amd/build/showmore.min.js.map b/amd/build/showmore.min.js.map index 71e55733..378de919 100644 --- a/amd/build/showmore.min.js.map +++ b/amd/build/showmore.min.js.map @@ -1 +1 @@ -{"version":3,"file":"showmore.min.js","sources":["../src/showmore.js"],"sourcesContent":["/*\n * This file is part of the QuestionPy Moodle plugin - https://questionpy.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/**\n * @module qtype_questionpy/showmore\n */\n\n\n/**\n * Return `true` if the element is overflowing.\n *\n * @param {HTMLElement} element\n * @returns {boolean}\n */\nconst isOverflowing = (element) => {\n return element.scrollHeight > element.clientHeight;\n};\n\n\n/**\n * Initializes the dynamic description box.\n *\n * @param {string} id\n */\nexport const init = (id) => {\n const element = document.getElementById(id);\n\n const container = element.querySelector(\".qpy-show-more-container\");\n const button = element.querySelector(\".qpy-show-more-button\");\n\n window.addEventListener(\"resize\", () => {\n button.classList.toggle(\"d-none\", !isOverflowing(container));\n });\n\n button.classList.toggle(\"d-none\", !isOverflowing(container));\n};\n"],"names":["isOverflowing","element","scrollHeight","clientHeight","id","document","getElementById","container","querySelector","button","window","addEventListener","classList","toggle"],"mappings":"sJA4BMA,cAAiBC,SACZA,QAAQC,aAAeD,QAAQE,2BASrBC,WACXH,QAAUI,SAASC,eAAeF,IAElCG,UAAYN,QAAQO,cAAc,4BAClCC,OAASR,QAAQO,cAAc,yBAErCE,OAAOC,iBAAiB,UAAU,KAC9BF,OAAOG,UAAUC,OAAO,UAAWb,cAAcO,eAGrDE,OAAOG,UAAUC,OAAO,UAAWb,cAAcO"} \ No newline at end of file +{"version":3,"file":"showmore.min.js","sources":["../src/showmore.js"],"sourcesContent":["/*\n * This file is part of the QuestionPy Moodle plugin - https://questionpy.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/**\n * @module qtype_questionpy/showmore\n */\n\n\n/**\n * Return `true` if the element is overflowing.\n *\n * @param {HTMLElement} element\n * @returns {boolean}\n */\nconst isOverflowing = (element) => {\n return element.scrollHeight > element.clientHeight;\n};\n\n\n/**\n * Initializes the dynamic description box.\n *\n * @param {string} id\n */\nexport const init = (id) => {\n const element = document.getElementById(id);\n\n const container = element.querySelector(\".qpy-show-more-container\");\n const button = element.querySelector(\".qpy-show-more-button\");\n\n window.addEventListener(\"resize\", () => {\n if (button.classList.contains(\"collapsed\")) {\n button.classList.toggle(\"d-none\", !isOverflowing(container));\n }\n });\n\n button.classList.toggle(\"d-none\", !isOverflowing(container));\n};\n"],"names":["isOverflowing","element","scrollHeight","clientHeight","id","document","getElementById","container","querySelector","button","window","addEventListener","classList","contains","toggle"],"mappings":"sJA4BMA,cAAiBC,SACZA,QAAQC,aAAeD,QAAQE,2BASrBC,WACXH,QAAUI,SAASC,eAAeF,IAElCG,UAAYN,QAAQO,cAAc,4BAClCC,OAASR,QAAQO,cAAc,yBAErCE,OAAOC,iBAAiB,UAAU,KAC1BF,OAAOG,UAAUC,SAAS,cAC1BJ,OAAOG,UAAUE,OAAO,UAAWd,cAAcO,eAIzDE,OAAOG,UAAUE,OAAO,UAAWd,cAAcO"} \ No newline at end of file diff --git a/amd/src/showmore.js b/amd/src/showmore.js index ca5e7744..2f4d4a5c 100644 --- a/amd/src/showmore.js +++ b/amd/src/showmore.js @@ -43,7 +43,9 @@ export const init = (id) => { const button = element.querySelector(".qpy-show-more-button"); window.addEventListener("resize", () => { - button.classList.toggle("d-none", !isOverflowing(container)); + if (button.classList.contains("collapsed")) { + button.classList.toggle("d-none", !isOverflowing(container)); + } }); button.classList.toggle("d-none", !isOverflowing(container));