Your IP : 192.168.165.1


Current Path : C:/Users/Mahmood/Desktop/moodle/lib/amd/build/
Upload File :
Current File : C:/Users/Mahmood/Desktop/moodle/lib/amd/build/checkbox-toggleall.min.js.map

{"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","slaves","checkedSlaves","setMasterStates","prop","trigger","publish","anyChecked","toggleMastersFromSlaves","toggleGroups","split","toggleGroupLevels","toggleGroupLevel","forEach","push","trim","length","setActionElementStates","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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C,CAAxB,CACtB,CAsJM,CAQV,CAjRK,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 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        var checkedSlaves = slaves.filter(':checked');\n\n        setMasterStates(root, toggleGroupName, targetState, false);\n\n        // Set the slave checkboxes from the masters.\n        slaves.prop('checked', targetState);\n        // Trigger 'change' event to toggle other master checkboxes (e.g. parent master checkboxes) and action elements.\n        slaves.trigger('change');\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\n        var toggleGroups = target.data('togglegroup').split(' ');\n        var toggleGroupLevels = [];\n        var toggleGroupLevel = '';\n        toggleGroups.forEach(function(toggleGroupName) {\n            toggleGroupLevel += ' ' + toggleGroupName;\n            toggleGroupLevels.push(toggleGroupLevel.trim());\n        });\n\n        toggleGroupLevels.forEach(function(toggleGroupName) {\n            var slaves = getAllSlaveCheckboxes(root, toggleGroupName);\n            var checkedSlaves = slaves.filter(':checked');\n            var targetState = (slaves.length === checkedSlaves.length);\n\n            // Make sure to toggle the exact master checkbox.\n            setMasterStates(root, toggleGroupName, targetState, true);\n\n            // Enable action elements when there's at least one checkbox checked. Disable otherwise.\n            setActionElementStates(root, toggleGroupName, !checkedSlaves.length);\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    /**\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('change', '[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"}