Sindbad~EG File Manager
{"version":3,"file":"hide_settings.min.js","sources":["../src/hide_settings.js"],"sourcesContent":["/**\n * 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 <http://www.gnu.org/licenses/>.\n *\n * @package\n * @copyright Copyright (c) 2023 Open LMS (https://www.openlms.net)\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n/**\n * A javascript module to hide/show settings\n */\nimport $ from 'jquery';\n\nexport const hideDependingOnChecked = (name, dependencies, dependants = []) => {\n\n const formItemSelector = $(`#admin-${name}`);\n const checkboxSelector = $(`#admin-${name} input[type=\"checkbox\"]`);\n const inputs = $('#adminsettings input[type=\"checkbox\"]').filter((i, input) => {\n return dependencies.some(suffix => input.id.endsWith(suffix));\n });\n const depends = $('#adminsettings .form-item').filter((i, item) => {\n return dependants.some(suffix => item.id.endsWith(suffix));\n });\n\n const hide = () => {\n formItemSelector.hide();\n hideDependants();\n };\n\n const show = () => {\n formItemSelector.show();\n showDependants();\n };\n\n const hideDependants = () => {\n if (dependants.length > 0) {\n depends.hide();\n }\n };\n\n const showDependants = () => {\n if (dependants.length > 0 && checkboxSelector.is(':checked')) {\n depends.show();\n }\n };\n\n const update = () => {\n const anyChecked = inputs.is(':checked');\n if (anyChecked) {\n show();\n } else {\n hide();\n }\n };\n\n hideDependants();\n update();\n\n inputs.on('change', () => {\n update();\n });\n\n checkboxSelector.on('change', () => {\n if (checkboxSelector.is(':checked')) {\n showDependants();\n } else {\n hideDependants();\n }\n });\n};"],"names":["name","dependencies","dependants","formItemSelector","checkboxSelector","inputs","filter","i","input","some","suffix","id","endsWith","depends","item","hide","hideDependants","show","showDependants","length","is","update","on"],"mappings":";;;;;;;;;;;;;;;;;;;;4LA0BsC,SAACA,KAAMC,kBAAcC,kEAAa,SAE9DC,kBAAmB,oCAAYH,OAC/BI,kBAAmB,oCAAYJ,iCAC/BK,QAAS,mBAAE,yCAAyCC,QAAO,CAACC,EAAGC,QAC1DP,aAAaQ,MAAKC,QAAUF,MAAMG,GAAGC,SAASF,YAEnDG,SAAU,mBAAE,6BAA6BP,QAAO,CAACC,EAAGO,OAC/CZ,WAAWO,MAAKC,QAAUI,KAAKH,GAAGC,SAASF,YAGhDK,KAAO,KACTZ,iBAAiBY,OACjBC,kBAGEC,KAAO,KACTd,iBAAiBc,OACjBC,kBAGEF,eAAiB,KACfd,WAAWiB,OAAS,GACpBN,QAAQE,QAIVG,eAAiB,KACfhB,WAAWiB,OAAS,GAAKf,iBAAiBgB,GAAG,aAC7CP,QAAQI,QAIVI,OAAS,KACQhB,OAAOe,GAAG,YAEzBH,OAEAF,QAIRC,iBACAK,SAEAhB,OAAOiB,GAAG,UAAU,KAChBD,YAGJjB,iBAAiBkB,GAAG,UAAU,KACtBlB,iBAAiBgB,GAAG,YACpBF,iBAEAF"}
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists