moodle/lib/amd/build/checkbox-toggleall.min.js.map

1 line
20 KiB
Plaintext

{"version":3,"sources":["../src/checkbox-toggleall.js"],"names":["define","$","PubSub","registered","events","checkboxToggled","getToggleGroupElements","root","toggleGroup","exactMatch","find","getAllSlaveCheckboxes","filter","getControlCheckboxes","getActionElements","toggleSlavesFromMasters","e","data","target","toggleGroupName","targetState","is","toggleSlavesToState","toggleMastersAndActionElements","toggleGroupSlaves","length","toggleGroupCheckedSlaves","setMasterStates","setActionElementStates","getToggleGroupLevels","toggleGroups","split","toggleGroupLevels","toggleGroupLevel","forEach","push","trim","slaves","prop","trigger","checkedSlaves","publish","anyChecked","toggleMastersFromSlaves","disableActionElements","masters","each","i","masterElement","targetString","masterLabel","attr","html","text","registerListeners","document","body","on","init","setGroupState","updateSlavesFromMasterState"],"mappings":"AAsBAA,OAAM,2BAAC,CAAC,QAAD,CAAW,aAAX,CAAD,CAA4B,SAASC,CAAT,CAAYC,CAAZ,CAAoB,IAQ9CC,CAAAA,CAAU,GARoC,CAgB9CC,CAAM,CAAG,CACTC,eAAe,CAAE,yCADR,CAhBqC,CA8B9CC,CAAsB,CAAG,SAASC,CAAT,CAAeC,CAAf,CAA4BC,CAA5B,CAAwC,CACjE,GAAIA,CAAJ,CAAgB,CACZ,MAAOF,CAAAA,CAAI,CAACG,IAAL,CAAU,+CAA8CF,CAA9C,CAA4D,KAAtE,CACV,CAFD,IAEO,CACH,MAAOD,CAAAA,CAAI,CAACG,IAAL,CAAU,gDAA+CF,CAA/C,CAA6D,KAAvE,CACV,CACJ,CApCiD,CA8C9CG,CAAqB,CAAG,SAASJ,CAAT,CAAeC,CAAf,CAA4B,CACpD,MAAOF,CAAAA,CAAsB,CAACC,CAAD,CAAOC,CAAP,IAAtB,CAAiDI,MAAjD,CAAwD,yBAAxD,CACV,CAhDiD,CA2D9CC,CAAoB,CAAG,SAASN,CAAT,CAAeC,CAAf,CAA4BC,CAA5B,CAAwC,CAC/D,MAAOH,CAAAA,CAAsB,CAAC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TlD,MAAO,CACHe,IAAI,CAAE,eAAW,CACbJ,CAAiB,EACpB,CAHE,CAIHlD,MAAM,CAAEA,CAJL,CAKHuD,aAAa,CA9GG,QAAhBA,CAAAA,aAAgB,CAASpD,CAAT,CAAeY,CAAf,CAAgCC,CAAhC,CAA6C,CAE7Db,CAAI,CAAGN,CAAC,CAACM,CAAD,CAAR,CAGAoB,CAAe,CAACpB,CAAD,CAAOY,CAAP,CAAwBC,CAAxB,IAAf,CACAE,CAAmB,CAACf,CAAD,CAAOY,CAAP,CAAwBC,CAAxB,CACtB,CAkGM,CAMHwC,2BAA2B,CAnNG,QAA9BA,CAAAA,2BAA8B,CAASrD,CAAT,CAAeY,CAAf,CAAgC,CAE9DZ,CAAI,CAAGN,CAAC,CAACM,CAAD,CAAR,CAF8D,GAI1DW,CAAAA,CAAM,CAAGL,CAAoB,CAACN,CAAD,CAAOY,CAAP,IAJ6B,CAK1DC,CAL0D,CAM9D,GAAIF,CAAM,CAACG,EAAP,CAAU,WAAV,CAAJ,CAA4B,CACxBD,CAAW,CAAGF,CAAM,CAACG,EAAP,CAAU,UAAV,CACjB,CAFD,IAEO,CACHD,CAAW,CAA+B,CAA5B,GAAAF,CAAM,CAACD,IAAP,CAAY,UAAZ,CACjB,CAEDK,CAAmB,CAACf,CAAD,CAAOY,CAAP,CAAwBC,CAAxB,CACtB,CAgMM,CAQV,CA3TK,CAAN","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 <http://www.gnu.org/licenses/>.\n\n/**\n * A module to help with toggle select/deselect all.\n *\n * @module core/checkbox-toggleall\n * @copyright 2019 Andrew Nicols <andrew@nicols.co.uk>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/pubsub'], function($, PubSub) {\n\n /**\n * Whether event listeners have already been registered.\n *\n * @private\n * @type {boolean}\n */\n var registered = false;\n\n /**\n * List of custom events that this module publishes.\n *\n * @private\n * @type {{checkboxToggled: string}}\n */\n var events = {\n checkboxToggled: 'core/checkbox-toggleall:checkboxToggled',\n };\n\n /**\n * Fetches elements that are member of a given toggle group.\n *\n * @private\n * @param {jQuery} root The root jQuery element.\n * @param {string} toggleGroup The toggle group name that we're searching form.\n * @param {boolean} exactMatch Whether we want an exact match we just want to match toggle groups that start with the given\n * toggle group name.\n * @returns {jQuery} The elements matching the given toggle group.\n */\n var getToggleGroupElements = function(root, toggleGroup, exactMatch) {\n if (exactMatch) {\n return root.find('[data-action=\"toggle\"][data-togglegroup=\"' + toggleGroup + '\"]');\n } else {\n return root.find('[data-action=\"toggle\"][data-togglegroup^=\"' + toggleGroup + '\"]');\n }\n };\n\n /**\n * Fetches the slave checkboxes for a given toggle group.\n *\n * @private\n * @param {jQuery} root The root jQuery element.\n * @param {string} toggleGroup The toggle group name.\n * @returns {jQuery} The slave checkboxes belonging to the toggle group.\n */\n var getAllSlaveCheckboxes = function(root, toggleGroup) {\n return getToggleGroupElements(root, toggleGroup, false).filter('[data-toggle=\"slave\"]');\n };\n\n /**\n * Fetches the master elements (checkboxes or buttons) that control the slave checkboxes in a given toggle group.\n *\n * @private\n * @param {jQuery} root The root jQuery element.\n * @param {string} toggleGroup The toggle group name.\n * @param {boolean} exactMatch\n * @returns {jQuery} The control elements belonging to the toggle group.\n */\n var getControlCheckboxes = function(root, toggleGroup, exactMatch) {\n return getToggleGroupElements(root, toggleGroup, exactMatch).filter('[data-toggle=\"master\"]');\n };\n\n /**\n * Fetches the action elements that perform actions on the selected checkboxes in a given toggle group.\n *\n * @private\n * @param {jQuery} root The root jQuery element.\n * @param {string} toggleGroup The toggle group name.\n * @returns {jQuery} The action elements belonging to the toggle group.\n */\n var getActionElements = function(root, toggleGroup) {\n return getToggleGroupElements(root, toggleGroup, true).filter('[data-toggle=\"action\"]');\n };\n\n /**\n * Toggles the slave checkboxes in a given toggle group when a master element in that toggle group is toggled.\n *\n * @private\n * @param {Object} e The event object.\n */\n var toggleSlavesFromMasters = function(e) {\n var root = e.data.root;\n var target = $(e.target);\n\n var toggleGroupName = target.data('togglegroup');\n var targetState;\n if (target.is(':checkbox')) {\n targetState = target.is(':checked');\n } else {\n targetState = target.data('checkall') === 1;\n }\n\n toggleSlavesToState(root, toggleGroupName, targetState);\n };\n\n /**\n * Toggles the slave checkboxes from the masters.\n *\n * @param {HTMLElement} root\n * @param {String} toggleGroupName\n */\n var updateSlavesFromMasterState = function(root, toggleGroupName) {\n // Normalise to jQuery Object.\n root = $(root);\n\n var target = getControlCheckboxes(root, toggleGroupName, false);\n var targetState;\n if (target.is(':checkbox')) {\n targetState = target.is(':checked');\n } else {\n targetState = target.data('checkall') === 1;\n }\n\n toggleSlavesToState(root, toggleGroupName, targetState);\n };\n\n /**\n * Toggles the master checkboxes and action elements in a given toggle group.\n *\n * @param {jQuery} root The root jQuery element.\n * @param {String} toggleGroupName The name of the toggle group\n */\n var toggleMastersAndActionElements = function(root, toggleGroupName) {\n var toggleGroupSlaves = getAllSlaveCheckboxes(root, toggleGroupName);\n if (toggleGroupSlaves.length > 0) {\n var toggleGroupCheckedSlaves = toggleGroupSlaves.filter(':checked');\n var targetState = toggleGroupSlaves.length === toggleGroupCheckedSlaves.length;\n\n // Make sure to toggle the exact master checkbox in the given toggle group.\n setMasterStates(root, toggleGroupName, targetState, true);\n // Enable the action elements if there's at least one checkbox checked in the given toggle group.\n // Disable otherwise.\n setActionElementStates(root, toggleGroupName, !toggleGroupCheckedSlaves.length);\n }\n };\n\n /**\n * Returns an array containing every toggle group level of a given toggle group.\n *\n * @param {String} toggleGroupName The name of the toggle group\n * @return {Array} toggleGroupLevels Array that contains every toggle group level of a given toggle group\n */\n var getToggleGroupLevels = function(toggleGroupName) {\n var toggleGroups = toggleGroupName.split(' ');\n var toggleGroupLevels = [];\n var toggleGroupLevel = '';\n\n toggleGroups.forEach(function(toggleGroupName) {\n toggleGroupLevel += ' ' + toggleGroupName;\n toggleGroupLevels.push(toggleGroupLevel.trim());\n });\n\n return toggleGroupLevels;\n };\n\n /**\n * Toggles the slave checkboxes to a specific state.\n *\n * @param {HTMLElement} root\n * @param {String} toggleGroupName\n * @param {Bool} targetState\n */\n var toggleSlavesToState = function(root, toggleGroupName, targetState) {\n var slaves = getAllSlaveCheckboxes(root, toggleGroupName);\n // Set the slave checkboxes from the masters and manually trigger the native 'change' event.\n slaves.prop('checked', targetState).trigger('change');\n // Get all checked slaves after the change of state.\n var checkedSlaves = slaves.filter(':checked');\n\n // Toggle the master checkbox in the given toggle group.\n setMasterStates(root, toggleGroupName, targetState, false);\n // Enable the action elements if there's at least one checkbox checked in the given toggle group. Disable otherwise.\n setActionElementStates(root, toggleGroupName, !checkedSlaves.length);\n\n // Get all toggle group levels and toggle accordingly all parent master checkboxes and action elements from each\n // level. Exclude the given toggle group (toggleGroupName) as the master checkboxes and action elements from this\n // level have been already toggled.\n var toggleGroupLevels = getToggleGroupLevels(toggleGroupName)\n .filter(toggleGroupLevel => toggleGroupLevel !== toggleGroupName);\n\n toggleGroupLevels.forEach(function(toggleGroupLevel) {\n // Toggle the master checkboxes action elements in the given toggle group level.\n toggleMastersAndActionElements(root, toggleGroupLevel);\n });\n\n PubSub.publish(events.checkboxToggled, {\n root: root,\n toggleGroupName: toggleGroupName,\n slaves: slaves,\n checkedSlaves: checkedSlaves,\n anyChecked: targetState,\n });\n };\n\n /**\n * Set the state for an entire group of checkboxes.\n *\n * @param {HTMLElement} root\n * @param {String} toggleGroupName\n * @param {Bool} targetState\n */\n var setGroupState = function(root, toggleGroupName, targetState) {\n // Normalise to jQuery Object.\n root = $(root);\n\n // Set the master and slaves.\n setMasterStates(root, toggleGroupName, targetState, true);\n toggleSlavesToState(root, toggleGroupName, targetState);\n };\n\n /**\n * Toggles the master checkboxes in a given toggle group when all or none of the slave checkboxes in the same toggle group\n * have been selected.\n *\n * @private\n * @param {Object} e The event object.\n */\n var toggleMastersFromSlaves = function(e) {\n var root = e.data.root;\n var target = $(e.target);\n var toggleGroupName = target.data('togglegroup');\n var slaves = getAllSlaveCheckboxes(root, toggleGroupName);\n var checkedSlaves = slaves.filter(':checked');\n\n // Get all toggle group levels for the given toggle group and toggle accordingly all master checkboxes\n // and action elements from each level.\n var toggleGroupLevels = getToggleGroupLevels(toggleGroupName);\n toggleGroupLevels.forEach(function(toggleGroupLevel) {\n // Toggle the master checkboxes action elements in the given toggle group level.\n toggleMastersAndActionElements(root, toggleGroupLevel);\n });\n\n PubSub.publish(events.checkboxToggled, {\n root: root,\n toggleGroupName: toggleGroupName,\n slaves: slaves,\n checkedSlaves: checkedSlaves,\n anyChecked: !!checkedSlaves.length,\n });\n };\n\n /**\n * Enables or disables the action elements.\n *\n * @private\n * @param {jQuery} root The root jQuery element.\n * @param {string} toggleGroupName The toggle group name of the action element(s).\n * @param {boolean} disableActionElements Whether to disable or to enable the action elements.\n */\n var setActionElementStates = function(root, toggleGroupName, disableActionElements) {\n getActionElements(root, toggleGroupName).prop('disabled', disableActionElements);\n };\n\n /**\n * Selects or deselects the master elements.\n *\n * @private\n * @param {jQuery} root The root jQuery element.\n * @param {string} toggleGroupName The toggle group name of the master element(s).\n * @param {boolean} targetState Whether to select (true) or deselect (false).\n * @param {boolean} exactMatch Whether to do an exact match for the toggle group name or not.\n */\n var setMasterStates = function(root, toggleGroupName, targetState, exactMatch) {\n // Set the master checkboxes value and ARIA labels..\n var masters = getControlCheckboxes(root, toggleGroupName, exactMatch);\n masters.prop('checked', targetState);\n masters.each(function(i, masterElement) {\n masterElement = $(masterElement);\n\n var targetString;\n if (targetState) {\n targetString = masterElement.data('toggle-deselectall');\n } else {\n targetString = masterElement.data('toggle-selectall');\n }\n\n if (masterElement.is(':checkbox')) {\n var masterLabel = root.find('[for=\"' + masterElement.attr('id') + '\"]');\n if (masterLabel.length) {\n if (masterLabel.html() !== targetString) {\n masterLabel.html(targetString);\n }\n }\n } else {\n masterElement.text(targetString);\n // Set the checkall data attribute.\n masterElement.data('checkall', targetState ? 0 : 1);\n }\n });\n };\n\n /**\n * Registers the event listeners.\n *\n * @private\n */\n var registerListeners = function() {\n if (!registered) {\n registered = true;\n\n var root = $(document.body);\n root.on('click', '[data-action=\"toggle\"][data-toggle=\"master\"]', {root: root}, toggleSlavesFromMasters);\n root.on('click', '[data-action=\"toggle\"][data-toggle=\"slave\"]', {root: root}, toggleMastersFromSlaves);\n }\n };\n\n return {\n init: function() {\n registerListeners();\n },\n events: events,\n setGroupState: setGroupState,\n updateSlavesFromMasterState: updateSlavesFromMasterState,\n };\n});\n"],"file":"checkbox-toggleall.min.js"}