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/tree.min.js.map

{"version":3,"sources":["../src/tree.js"],"names":["define","$","SELECTORS","ITEM","GROUP","CLOSED_GROUP","FIRST_ITEM","VISIBLE_ITEM","UNLOADED_AJAX_ITEM","Tree","selector","selectCallback","treeRoot","data","keys","tab","enter","space","pageup","pagedown","end","home","left","up","right","down","asterisk","initialiseNodes","setActiveItem","find","refreshVisibleItemsCache","bindEventHandlers","prototype","registerEnterCallback","callback","enterCallback","getVisibleItems","item","currentActive","attr","isGroupItem","is","getGroupFromItem","ariaowns","plain","children","length","isGroupCollapsed","isGroupCollapsible","node","removeAllFromTabOrder","setAriaSelectedFalseOnItems","thisTree","each","unloadedNode","collapseGroup","expandGroup","expandAllGroups","groupNode","done","expandAllChildGroups","promise","Deferred","moduleName","closest","addClass","require","loader","load","finishExpandingGroup","removeClass","resolve","group","toggleGroup","handleKeyDown","e","currentIndex","index","altKey","ctrlKey","metaKey","shiftKey","keyCode","first","focus","stopPropagation","last","links","not","window","location","href","focusParent","tree","filter","has","prev","eq","next","handleClick","handleFocus","thisObj","on","click","keydown"],"mappings":"AAwBAA,OAAM,aAAC,CAAC,QAAD,CAAD,CAAa,SAASC,CAAT,CAAY,IAEvBC,CAAAA,CAAS,CAAG,CACZC,IAAI,CAAE,iBADM,CAEZC,KAAK,CAAE,yGAFK,CAGZC,YAAY,yKAHA,CAKZC,UAAU,CAAE,uBALA,CAMZC,YAAY,CAAE,yBANF,CAOZC,kBAAkB,CAAE,iFAPR,CAFW,CAkBvBC,CAAI,CAAG,SAASC,CAAT,CAAmBC,CAAnB,CAAmC,CAC1C,KAAKC,QAAL,CAAgBX,CAAC,CAACS,CAAD,CAAjB,CAEA,KAAKE,QAAL,CAAcC,IAAd,CAAmB,YAAnB,CAAiC,IAAjC,EACA,KAAKF,cAAL,CAAsBA,CAAtB,CACA,KAAKG,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iBAAf,CAAmC,UAAW,CAC1C,GAAIsE,CAAAA,CAAO,CAAG,IAAd,CAIA,KAAKzF,QAAL,CAAc0F,EAAd,CAAiB,CACbC,KAAK,CAAE,eAAS5B,CAAT,CAAY,CACjB,MAAO0B,CAAAA,CAAO,CAACF,WAAR,CAAoBlG,CAAC,CAAC,IAAD,CAArB,CAA6B0E,CAA7B,CACR,CAHY,CAIb6B,OAAO,CAAE,iBAAS7B,CAAT,CAAY,CACnB,MAAO0B,CAAAA,CAAO,CAAC3B,aAAR,CAAsBzE,CAAC,CAAC,IAAD,CAAvB,CAA+B0E,CAA/B,CACR,CANY,CAObS,KAAK,CAAE,eAAST,CAAT,CAAY,CACjB,MAAO0B,CAAAA,CAAO,CAACD,WAAR,CAAoBnG,CAAC,CAAC,IAAD,CAArB,CAA6B0E,CAA7B,CACR,CATY,CAAjB,CAUGzE,CAAS,CAACC,IAVb,CAWH,CAhBD,CAkBA,MAAyCM,CAAAA,CAC5C,CArgBK,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 * Implement an accessible aria tree widget, from a nested unordered list.\n * Based on http://oaa-accessibility.org/example/41/.\n *\n * @module     tool_lp/tree\n * @package    core\n * @copyright  2015 Damyon Wiese <damyon@moodle.com>\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery'], function($) {\n    // Private variables and functions.\n    var SELECTORS = {\n        ITEM: '[role=treeitem]',\n        GROUP: '[role=treeitem]:has([role=group]), [role=treeitem][aria-owns], [role=treeitem][data-requires-ajax=true]',\n        CLOSED_GROUP: '[role=treeitem]:has([role=group])[aria-expanded=false], [role=treeitem][aria-owns][aria-expanded=false], ' +\n                 '[role=treeitem][data-requires-ajax=true][aria-expanded=false]',\n        FIRST_ITEM: '[role=treeitem]:first',\n        VISIBLE_ITEM: '[role=treeitem]:visible',\n        UNLOADED_AJAX_ITEM: '[role=treeitem][data-requires-ajax=true][data-loaded=false][aria-expanded=true]'\n    };\n\n    /**\n     * Constructor.\n     *\n     * @param {String} selector\n     * @param {function} selectCallback Called when the active node is changed.\n     */\n    var Tree = function(selector, selectCallback) {\n        this.treeRoot = $(selector);\n\n        this.treeRoot.data('activeItem', null);\n        this.selectCallback = selectCallback;\n        this.keys = {\n            tab:      9,\n            enter:    13,\n            space:    32,\n            pageup:   33,\n            pagedown: 34,\n            end:      35,\n            home:     36,\n            left:     37,\n            up:       38,\n            right:    39,\n            down:     40,\n            asterisk: 106\n        };\n\n        // Apply the standard default initialisation for all nodes, starting with the tree root.\n        this.initialiseNodes(this.treeRoot);\n        // Make the first item the active item for the tree so that it is added to the tab order.\n        this.setActiveItem(this.treeRoot.find(SELECTORS.FIRST_ITEM));\n        // Create the cache of the visible items.\n        this.refreshVisibleItemsCache();\n        // Create the event handlers for the tree.\n        this.bindEventHandlers();\n    };\n\n    Tree.prototype.registerEnterCallback = function(callback) {\n        this.enterCallback = callback;\n    };\n\n    /**\n     * Find all visible tree items and save a cache of them on the tree object.\n     *\n     * @method refreshVisibleItemsCache\n     */\n    Tree.prototype.refreshVisibleItemsCache = function() {\n        this.treeRoot.data('visibleItems', this.treeRoot.find(SELECTORS.VISIBLE_ITEM));\n    };\n\n    /**\n     * Get all visible tree items.\n     *\n     * @method getVisibleItems\n     * @return {Object} visible items\n     */\n    Tree.prototype.getVisibleItems = function() {\n        return this.treeRoot.data('visibleItems');\n    };\n\n    /**\n     * Mark the given item as active within the tree and fire the callback for when the active item is set.\n     *\n     * @method setActiveItem\n     * @param {object} item jquery object representing an item on the tree.\n     */\n    Tree.prototype.setActiveItem = function(item) {\n        var currentActive = this.treeRoot.data('activeItem');\n        if (item === currentActive) {\n            return;\n        }\n\n        // Remove previous active from tab order.\n        if (currentActive) {\n            currentActive.attr('tabindex', '-1');\n            currentActive.attr('aria-selected', 'false');\n        }\n        item.attr('tabindex', '0');\n        item.attr('aria-selected', 'true');\n\n        // Set the new active item.\n        this.treeRoot.data('activeItem', item);\n\n        if (typeof this.selectCallback === 'function') {\n            this.selectCallback(item);\n        }\n    };\n\n    /**\n     * Determines if the given item is a group item (contains child tree items) in the tree.\n     *\n     * @method isGroupItem\n     * @param {object} item jquery object representing an item on the tree.\n     * @returns {bool}\n     */\n    Tree.prototype.isGroupItem = function(item) {\n        return item.is(SELECTORS.GROUP);\n    };\n\n    /**\n     * Determines if the given item is a group item (contains child tree items) in the tree.\n     *\n     * @method isGroupItem\n     * @param {object} item jquery object representing an item on the tree.\n     * @returns {bool}\n     */\n    Tree.prototype.getGroupFromItem = function(item) {\n        var ariaowns = this.treeRoot.find('#' + item.attr('aria-owns'));\n        var plain = item.children('[role=group]');\n        if (ariaowns.length > plain.length) {\n            return ariaowns;\n        } else {\n            return plain;\n        }\n    };\n\n    /**\n     * Determines if the given group item (contains child tree items) is collapsed.\n     *\n     * @method isGroupCollapsed\n     * @param {object} item jquery object representing a group item on the tree.\n     * @returns {bool}\n     */\n    Tree.prototype.isGroupCollapsed = function(item) {\n        return item.attr('aria-expanded') === 'false';\n    };\n\n    /**\n     * Determines if the given group item (contains child tree items) can be collapsed.\n     *\n     * @method isGroupCollapsible\n     * @param {object} item jquery object representing a group item on the tree.\n     * @returns {bool}\n     */\n    Tree.prototype.isGroupCollapsible = function(item) {\n        return item.attr('data-collapsible') !== 'false';\n    };\n\n    /**\n     * Performs the tree initialisation for all child items from the given node,\n     * such as removing everything from the tab order and setting aria selected\n     * on items.\n     *\n     * @method initialiseNodes\n     * @param {object} node jquery object representing a node.\n     */\n    Tree.prototype.initialiseNodes = function(node) {\n        this.removeAllFromTabOrder(node);\n        this.setAriaSelectedFalseOnItems(node);\n\n        // Get all ajax nodes that have been rendered as expanded but haven't loaded the child items yet.\n        var thisTree = this;\n        node.find(SELECTORS.UNLOADED_AJAX_ITEM).each(function() {\n            var unloadedNode = $(this);\n            // Collapse and then expand to trigger the ajax loading.\n            thisTree.collapseGroup(unloadedNode);\n            thisTree.expandGroup(unloadedNode);\n        });\n    };\n\n    /**\n     * Removes all child DOM elements of the given node from the tab order.\n     *\n     * @method removeAllFromTabOrder\n     * @param {object} node jquery object representing a node.\n     */\n    Tree.prototype.removeAllFromTabOrder = function(node) {\n        node.find('*').attr('tabindex', '-1');\n        this.getGroupFromItem($(node)).find('*').attr('tabindex', '-1');\n    };\n\n    /**\n     * Find all child tree items from the given node and set the aria selected attribute to false.\n     *\n     * @method setAriaSelectedFalseOnItems\n     * @param {object} node jquery object representing a node.\n     */\n    Tree.prototype.setAriaSelectedFalseOnItems = function(node) {\n        node.find(SELECTORS.ITEM).attr('aria-selected', 'false');\n    };\n\n    /**\n     * Expand all group nodes within the tree.\n     *\n     * @method expandAllGroups\n     */\n    Tree.prototype.expandAllGroups = function() {\n        var thisTree = this;\n\n        this.treeRoot.find(SELECTORS.CLOSED_GROUP).each(function() {\n            var groupNode = $(this);\n\n            thisTree.expandGroup($(this)).done(function() {\n                thisTree.expandAllChildGroups(groupNode);\n            });\n        });\n    };\n\n    /**\n     * Find all child group nodes from the given node and expand them.\n     *\n     * @method expandAllChildGroups\n     * @param {Object} item is the jquery id of the group.\n     */\n    Tree.prototype.expandAllChildGroups = function(item) {\n        var thisTree = this;\n\n        this.getGroupFromItem(item).find(SELECTORS.CLOSED_GROUP).each(function() {\n            var groupNode = $(this);\n\n            thisTree.expandGroup($(this)).done(function() {\n                thisTree.expandAllChildGroups(groupNode);\n            });\n        });\n    };\n\n    /**\n     * Expand a collapsed group.\n     *\n     * Handles expanding nodes that are ajax loaded (marked with a data-requires-ajax attribute).\n     *\n     * @method expandGroup\n     * @param {Object} item is the jquery id of the parent item of the group.\n     * @return {Object} a promise that is resolved when the group has been expanded.\n     */\n    Tree.prototype.expandGroup = function(item) {\n        var promise = $.Deferred();\n        // Ignore nodes that are explicitly maked as not expandable or are already expanded.\n        if (item.attr('data-expandable') !== 'false' && this.isGroupCollapsed(item)) {\n            // If this node requires ajax load and we haven't already loaded it.\n            if (item.attr('data-requires-ajax') === 'true' && item.attr('data-loaded') !== 'true') {\n                item.attr('data-loaded', false);\n                // Get the closes ajax loading module specificed in the tree.\n                var moduleName = item.closest('[data-ajax-loader]').attr('data-ajax-loader');\n                var thisTree = this;\n                // Flag this node as loading.\n                item.addClass('loading');\n                // Require the ajax module (must be AMD) and try to load the items.\n                require([moduleName], function(loader) {\n                    // All ajax module must implement a \"load\" method.\n                    loader.load(item).done(function() {\n                        item.attr('data-loaded', true);\n\n                        // Set defaults on the newly constructed part of the tree.\n                        thisTree.initialiseNodes(item);\n                        thisTree.finishExpandingGroup(item);\n                        // Make sure no child elements of the item we just loaded are tabbable.\n                        item.removeClass('loading');\n                        promise.resolve();\n                    });\n                });\n            } else {\n                this.finishExpandingGroup(item);\n                promise.resolve();\n            }\n        } else {\n            promise.resolve();\n        }\n        return promise;\n    };\n\n    /**\n     * Perform the necessary DOM changes to display a group item.\n     *\n     * @method finishExpandingGroup\n     * @param {Object} item is the jquery id of the parent item of the group.\n     */\n    Tree.prototype.finishExpandingGroup = function(item) {\n        // Expand the group.\n        var group = this.getGroupFromItem(item);\n        group.attr('aria-hidden', 'false');\n        item.attr('aria-expanded', 'true');\n\n        // Update the list of visible items.\n        this.refreshVisibleItemsCache();\n    };\n\n    /**\n     * Collapse an expanded group.\n     *\n     * @method collapseGroup\n     * @param {Object} item is the jquery id of the parent item of the group.\n     */\n    Tree.prototype.collapseGroup = function(item) {\n        // If the item is not collapsible or already collapsed then do nothing.\n        if (!this.isGroupCollapsible(item) || this.isGroupCollapsed(item)) {\n            return;\n        }\n\n        // Collapse the group.\n        var group = this.getGroupFromItem(item);\n        group.attr('aria-hidden', 'true');\n        item.attr('aria-expanded', 'false');\n\n        // Update the list of visible items.\n        this.refreshVisibleItemsCache();\n    };\n\n    /**\n     * Expand or collapse a group.\n     *\n     * @method toggleGroup\n     * @param {Object} item is the jquery id of the parent item of the group.\n     */\n    Tree.prototype.toggleGroup = function(item) {\n        if (item.attr('aria-expanded') === 'true') {\n            this.collapseGroup(item);\n        } else {\n            this.expandGroup(item);\n        }\n    };\n\n    /**\n     * Handle a key down event - ie navigate the tree.\n     *\n     * @method handleKeyDown\n     * @param {Object} item is the jquery id of the parent item of the group.\n     * @param {Event} e The event.\n     * @return {Boolean}\n     */\n     // This function should be simplified. In the meantime..\n     // eslint-disable-next-line complexity\n    Tree.prototype.handleKeyDown = function(item, e) {\n        var currentIndex = this.getVisibleItems().index(item);\n\n        if ((e.altKey || e.ctrlKey || e.metaKey) || (e.shiftKey && e.keyCode != this.keys.tab)) {\n            // Do nothing.\n            return true;\n        }\n\n        switch (e.keyCode) {\n            case this.keys.home: {\n                // Jump to first item in tree.\n                this.getVisibleItems().first().focus();\n\n                e.stopPropagation();\n                return false;\n            }\n            case this.keys.end: {\n                // Jump to last visible item.\n                this.getVisibleItems().last().focus();\n\n                e.stopPropagation();\n                return false;\n            }\n            case this.keys.enter: {\n                var links = item.children('a').length ? item.children('a') : item.children().not(SELECTORS.GROUP).find('a');\n                if (links.length) {\n                    // See if we have a callback.\n                    if (typeof this.enterCallback === 'function') {\n                        this.enterCallback(item);\n                    } else {\n                        window.location.href = links.first().attr('href');\n                    }\n                } else if (this.isGroupItem(item)) {\n                    this.toggleGroup(item, true);\n                }\n\n                e.stopPropagation();\n                return false;\n            }\n            case this.keys.space: {\n                if (this.isGroupItem(item)) {\n                    this.toggleGroup(item, true);\n                }\n\n                e.stopPropagation();\n                return false;\n            }\n            case this.keys.left: {\n                var focusParent = function(tree) {\n                    // Get the immediate visible parent group item that contains this element.\n                    tree.getVisibleItems().filter(function() {\n                        return tree.getGroupFromItem($(this)).has(item).length;\n                    }).focus();\n                };\n\n                // If this is a goup item then collapse it and focus the parent group\n                // in accordance with the aria spec.\n                if (this.isGroupItem(item)) {\n                    if (this.isGroupCollapsed(item)) {\n                        focusParent(this);\n                    } else {\n                        this.collapseGroup(item);\n                    }\n                } else {\n                    focusParent(this);\n                }\n\n                e.stopPropagation();\n                return false;\n            }\n            case this.keys.right: {\n                // If this is a group item then expand it and focus the first child item\n                // in accordance with the aria spec.\n                if (this.isGroupItem(item)) {\n                    if (this.isGroupCollapsed(item)) {\n                        this.expandGroup(item);\n                    } else {\n                        // Move to the first item in the child group.\n                        this.getGroupFromItem(item).find(SELECTORS.ITEM).first().focus();\n                    }\n                }\n\n                e.stopPropagation();\n                return false;\n            }\n            case this.keys.up: {\n\n                if (currentIndex > 0) {\n                    var prev = this.getVisibleItems().eq(currentIndex - 1);\n\n                    prev.focus();\n                }\n\n                e.stopPropagation();\n                return false;\n            }\n            case this.keys.down: {\n\n                if (currentIndex < this.getVisibleItems().length - 1) {\n                    var next = this.getVisibleItems().eq(currentIndex + 1);\n\n                    next.focus();\n                }\n\n                e.stopPropagation();\n                return false;\n            }\n            case this.keys.asterisk: {\n                // Expand all groups.\n                this.expandAllGroups();\n                e.stopPropagation();\n                return false;\n            }\n        }\n        return true;\n    };\n\n    /**\n     * Handle a click (select).\n     *\n     * @method handleClick\n     * @param {Object} item The jquery id of the parent item of the group.\n     * @param {Event} e The event.\n     * @return {Boolean}\n     */\n    Tree.prototype.handleClick = function(item, e) {\n\n        if (e.altKey || e.ctrlKey || e.shiftKey || e.metaKey) {\n            // Do nothing.\n            return true;\n        }\n\n        // Update the active item.\n        item.focus();\n\n        // If the item is a group node.\n        if (this.isGroupItem(item)) {\n            this.toggleGroup(item);\n        }\n\n        e.stopPropagation();\n        return true;\n    };\n\n    /**\n     * Handle a focus event.\n     *\n     * @method handleFocus\n     * @param {Object} item The jquery id of the parent item of the group.\n     * @param {Event} e The event.\n     * @return {Boolean}\n     */\n    Tree.prototype.handleFocus = function(item, e) {\n\n        this.setActiveItem(item);\n\n        e.stopPropagation();\n        return true;\n    };\n\n    /**\n     * Bind the event listeners we require.\n     *\n     * @method bindEventHandlers\n     */\n    Tree.prototype.bindEventHandlers = function() {\n        var thisObj = this;\n\n        // Bind event handlers to the tree items. Use event delegates to allow\n        // for dynamically loaded parts of the tree.\n        this.treeRoot.on({\n            click: function(e) {\n              return thisObj.handleClick($(this), e);\n            },\n            keydown: function(e) {\n              return thisObj.handleKeyDown($(this), e);\n            },\n            focus: function(e) {\n              return thisObj.handleFocus($(this), e);\n            },\n        }, SELECTORS.ITEM);\n    };\n\n    return /** @alias module:tool_lp/tree */ Tree;\n});\n"],"file":"tree.min.js"}