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

{"version":3,"sources":["../src/popover_region_controller.js"],"names":["define","$","str","customEvents","SELECTORS","CONTENT","CONTENT_CONTAINER","MENU_CONTAINER","MENU_TOGGLE","CAN_RECEIVE_FOCUS","PopoverRegionController","element","root","content","find","contentContainer","menuContainer","menuToggle","isLoading","promises","closeHandlers","Deferred","navigationHandlers","registerBaseEventListeners","prototype","events","menuOpened","menuClosed","startLoading","stopLoading","getContentContainer","getContent","isMenuOpen","hasClass","toggleMenu","closeMenu","openMenu","addClass","attr","updateButtonAriaLabel","trigger","removeClass","resolve","get_string","done","string","bind","focusMenuToggle","focus","contentItemHasFocus","getContentItemWithFocus","length","currentFocus","document","activeElement","items","children","currentItem","filter","has","focusContentItem","item","is","first","focusFirstContentItem","focusLastContentItem","last","focusNextContentItem","next","focusPreviousContentItem","prev","activate","escape","on","click","e","target","scrollBottom","registerListNavigationEventListeners","down","data","originalEvent","preventDefault","up","home","end"],"mappings":"AA2BAA,OAAM,kCAAC,CAAC,QAAD,CAAW,UAAX,CAAuB,gCAAvB,CAAD,CACE,SAASC,CAAT,CAAYC,CAAZ,CAAiBC,CAAjB,CAA+B,IAE/BC,CAAAA,CAAS,CAAG,CACZC,OAAO,CAAE,yBADG,CAEZC,iBAAiB,CAAE,mCAFP,CAGZC,cAAc,CAAE,2BAHJ,CAIZC,WAAW,CAAE,wBAJD,CAKZC,iBAAiB,CAAE,6EALP,CAFmB,CAe/BC,CAAuB,CAAG,SAASC,CAAT,CAAkB,CAC5C,KAAKC,IAAL,CAAYX,CAAC,CAACU,CAAD,CAAb,CACA,KAAKE,OAAL,CAAe,KAAKD,IAAL,CAAUE,IAAV,CAAeV,CAAS,CAACC,OAAzB,CAAf,CACA,KAAKU,gBAAL,CAAwB,KAAKH,IAAL,CAAUE,IAAV,CAAeV,CAAS,CA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IAHoC,CAG/B,IAH+B,CAAtC,CAIH,CAxBqC,CAwBpCA,IAxBoC,CAwB/B,IAxB+B,CAAtC,CAyBH,CAhDD,CAkDA,MAAOpC,CAAAA,CACV,CAlXK,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 * Controls the popover region element.\n *\n * See template: core/popover_region\n *\n * @module     core/popover_region_controller\n * @class      popover_region_controller\n * @package    core\n * @copyright  2015 Ryan Wyllie <ryan@moodle.com>\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since      3.2\n */\ndefine(['jquery', 'core/str', 'core/custom_interaction_events'],\n        function($, str, customEvents) {\n\n    var SELECTORS = {\n        CONTENT: '.popover-region-content',\n        CONTENT_CONTAINER: '.popover-region-content-container',\n        MENU_CONTAINER: '.popover-region-container',\n        MENU_TOGGLE: '.popover-region-toggle',\n        CAN_RECEIVE_FOCUS: 'input:not([type=\"hidden\"]), a[href], button, textarea, select, [tabindex]',\n    };\n\n    /**\n     * Constructor for the PopoverRegionController.\n     *\n     * @param {jQuery} element object root element of the popover\n     */\n    var PopoverRegionController = function(element) {\n        this.root = $(element);\n        this.content = this.root.find(SELECTORS.CONTENT);\n        this.contentContainer = this.root.find(SELECTORS.CONTENT_CONTAINER);\n        this.menuContainer = this.root.find(SELECTORS.MENU_CONTAINER);\n        this.menuToggle = this.root.find(SELECTORS.MENU_TOGGLE);\n        this.isLoading = false;\n        this.promises = {\n            closeHandlers: $.Deferred(),\n            navigationHandlers: $.Deferred(),\n        };\n\n        // Core event listeners to open and close.\n        this.registerBaseEventListeners();\n    };\n\n    /**\n     * The collection of events triggered by this controller.\n     *\n     * @returns {object}\n     */\n    PopoverRegionController.prototype.events = function() {\n        return {\n            menuOpened: 'popoverregion:menuopened',\n            menuClosed: 'popoverregion:menuclosed',\n            startLoading: 'popoverregion:startLoading',\n            stopLoading: 'popoverregion:stopLoading',\n        };\n    };\n\n    /**\n     * Return the container element for the content element.\n     *\n     * @method getContentContainer\n     * @return {jQuery} object\n     */\n    PopoverRegionController.prototype.getContentContainer = function() {\n        return this.contentContainer;\n    };\n\n    /**\n     * Return the content element.\n     *\n     * @method getContent\n     * @return {jQuery} object\n     */\n    PopoverRegionController.prototype.getContent = function() {\n        return this.content;\n    };\n\n    /**\n     * Checks if the popover is displayed.\n     *\n     * @method isMenuOpen\n     * @return {bool}\n     */\n    PopoverRegionController.prototype.isMenuOpen = function() {\n        return !this.root.hasClass('collapsed');\n    };\n\n    /**\n     * Toggle the visibility of the popover.\n     *\n     * @method toggleMenu\n     */\n    PopoverRegionController.prototype.toggleMenu = function() {\n        if (this.isMenuOpen()) {\n            this.closeMenu();\n        } else {\n            this.openMenu();\n        }\n    };\n\n    /**\n     * Hide the popover.\n     *\n     * Note: This triggers the menuClosed event.\n     *\n     * @method closeMenu\n     */\n    PopoverRegionController.prototype.closeMenu = function() {\n        // We're already closed.\n        if (!this.isMenuOpen()) {\n            return;\n        }\n\n        this.root.addClass('collapsed');\n        this.menuContainer.attr('aria-expanded', 'false');\n        this.menuContainer.attr('aria-hidden', 'true');\n        this.updateButtonAriaLabel();\n        this.root.trigger(this.events().menuClosed);\n    };\n\n    /**\n     * Show the popover.\n     *\n     * Note: This triggers the menuOpened event.\n     *\n     * @method openMenu\n     */\n    PopoverRegionController.prototype.openMenu = function() {\n        // We're already open.\n        if (this.isMenuOpen()) {\n            return;\n        }\n\n        this.root.removeClass('collapsed');\n        this.menuContainer.attr('aria-expanded', 'true');\n        this.menuContainer.attr('aria-hidden', 'false');\n        this.updateButtonAriaLabel();\n        // Resolve the promises to allow the handlers to be added\n        // to the DOM, if they have been requested.\n        this.promises.closeHandlers.resolve();\n        this.promises.navigationHandlers.resolve();\n        this.root.trigger(this.events().menuOpened);\n    };\n\n    /**\n     * Set the appropriate aria label on the popover toggle.\n     *\n     * @method updateButtonAriaLabel\n     */\n    PopoverRegionController.prototype.updateButtonAriaLabel = function() {\n        if (this.isMenuOpen()) {\n            str.get_string('hidepopoverwindow').done(function(string) {\n                this.menuToggle.attr('aria-label', string);\n            }.bind(this));\n        } else {\n            str.get_string('showpopoverwindow').done(function(string) {\n                this.menuToggle.attr('aria-label', string);\n            }.bind(this));\n        }\n    };\n\n    /**\n     * Set the loading state on this popover.\n     *\n     * Note: This triggers the startLoading event.\n     *\n     * @method startLoading\n     */\n    PopoverRegionController.prototype.startLoading = function() {\n        this.isLoading = true;\n        this.getContentContainer().addClass('loading');\n        this.getContentContainer().attr('aria-busy', 'true');\n        this.root.trigger(this.events().startLoading);\n    };\n\n    /**\n     * Undo the loading state on this popover.\n     *\n     * Note: This triggers the stopLoading event.\n     *\n     * @method stopLoading\n     */\n    PopoverRegionController.prototype.stopLoading = function() {\n        this.isLoading = false;\n        this.getContentContainer().removeClass('loading');\n        this.getContentContainer().attr('aria-busy', 'false');\n        this.root.trigger(this.events().stopLoading);\n    };\n\n    /**\n     * Sets the focus on the menu toggle.\n     *\n     * @method focusMenuToggle\n     */\n    PopoverRegionController.prototype.focusMenuToggle = function() {\n        this.menuToggle.focus();\n    };\n\n    /**\n     * Check if a content item has focus.\n     *\n     * @method contentItemHasFocus\n     * @return {bool}\n     */\n    PopoverRegionController.prototype.contentItemHasFocus = function() {\n        return this.getContentItemWithFocus().length > 0;\n    };\n\n    /**\n     * Return the currently focused content item.\n     *\n     * @method getContentItemWithFocus\n     * @return {jQuery} object\n     */\n    PopoverRegionController.prototype.getContentItemWithFocus = function() {\n        var currentFocus = $(document.activeElement);\n        var items = this.getContent().children();\n        var currentItem = items.filter(currentFocus);\n\n        if (!currentItem.length) {\n            currentItem = items.has(currentFocus);\n        }\n\n        return currentItem;\n    };\n\n    /**\n     * Focus the given content item or the first focusable element within\n     * the content item.\n     *\n     * @method focusContentItem\n     * @param {object} item The content item jQuery element\n     */\n    PopoverRegionController.prototype.focusContentItem = function(item) {\n        if (item.is(SELECTORS.CAN_RECEIVE_FOCUS)) {\n            item.focus();\n        } else {\n            item.find(SELECTORS.CAN_RECEIVE_FOCUS).first().focus();\n        }\n    };\n\n    /**\n     * Set focus on the first content item in the list.\n     *\n     * @method focusFirstContentItem\n     */\n    PopoverRegionController.prototype.focusFirstContentItem = function() {\n        this.focusContentItem(this.getContent().children().first());\n    };\n\n    /**\n     * Set focus on the last content item in the list.\n     *\n     * @method focusLastContentItem\n     */\n    PopoverRegionController.prototype.focusLastContentItem = function() {\n        this.focusContentItem(this.getContent().children().last());\n    };\n\n    /**\n     * Set focus on the content item after the item that currently has focus\n     * in the list.\n     *\n     * @method focusNextContentItem\n     */\n    PopoverRegionController.prototype.focusNextContentItem = function() {\n        var currentItem = this.getContentItemWithFocus();\n\n        if (currentItem.length && currentItem.next()) {\n            this.focusContentItem(currentItem.next());\n        }\n    };\n\n    /**\n     * Set focus on the content item preceding the item that currently has focus\n     * in the list.\n     *\n     * @method focusPreviousContentItem\n     */\n    PopoverRegionController.prototype.focusPreviousContentItem = function() {\n        var currentItem = this.getContentItemWithFocus();\n\n        if (currentItem.length && currentItem.prev()) {\n            this.focusContentItem(currentItem.prev());\n        }\n    };\n\n    /**\n     * Register the minimal amount of listeners for the popover to function.\n     *\n     * @method registerBaseEventListeners\n     */\n    PopoverRegionController.prototype.registerBaseEventListeners = function() {\n        customEvents.define(this.root, [\n            customEvents.events.activate,\n            customEvents.events.escape,\n        ]);\n\n        // Toggle the popover visibility on activation (click/enter/space) of the toggle button.\n        this.root.on(customEvents.events.activate, SELECTORS.MENU_TOGGLE, function() {\n            this.toggleMenu();\n        }.bind(this));\n\n        // Delay the binding of these handlers until the region has been opened.\n        this.promises.closeHandlers.done(function() {\n            // Close the popover if escape is pressed.\n            this.root.on(customEvents.events.escape, function() {\n                this.closeMenu();\n                this.focusMenuToggle();\n            }.bind(this));\n\n            // Close the popover if any other part of the page is clicked.\n            $('html').click(function(e) {\n                var target = $(e.target);\n                if (!this.root.is(target) && !this.root.has(target).length) {\n                    this.closeMenu();\n                }\n            }.bind(this));\n\n            customEvents.define(this.getContentContainer(), [\n                customEvents.events.scrollBottom\n            ]);\n        }.bind(this));\n    };\n\n    /**\n     * Set up the event listeners for keyboard navigating a list of content items.\n     *\n     * @method registerListNavigationEventListeners\n     */\n    PopoverRegionController.prototype.registerListNavigationEventListeners = function() {\n        customEvents.define(this.root, [\n            customEvents.events.down\n        ]);\n\n        // If the down arrow is pressed then open the menu and focus the first content\n        // item or focus the next content item if the menu is open.\n        this.root.on(customEvents.events.down, function(e, data) {\n            if (!this.isMenuOpen()) {\n                this.openMenu();\n                this.focusFirstContentItem();\n            } else {\n                if (this.contentItemHasFocus()) {\n                    this.focusNextContentItem();\n                } else {\n                    this.focusFirstContentItem();\n                }\n            }\n\n            data.originalEvent.preventDefault();\n        }.bind(this));\n\n        // Delay the binding of these handlers until the region has been opened.\n        this.promises.navigationHandlers.done(function() {\n            customEvents.define(this.root, [\n                customEvents.events.up,\n                customEvents.events.home,\n                customEvents.events.end,\n            ]);\n\n            // Shift focus to the previous content item if the up key is pressed.\n            this.root.on(customEvents.events.up, function(e, data) {\n                this.focusPreviousContentItem();\n                data.originalEvent.preventDefault();\n            }.bind(this));\n\n            // Jump focus to the first content item if the home key is pressed.\n            this.root.on(customEvents.events.home, function(e, data) {\n                this.focusFirstContentItem();\n                data.originalEvent.preventDefault();\n            }.bind(this));\n\n            // Jump focus to the last content item if the end key is pressed.\n            this.root.on(customEvents.events.end, function(e, data) {\n                this.focusLastContentItem();\n                data.originalEvent.preventDefault();\n            }.bind(this));\n        }.bind(this));\n    };\n\n    return PopoverRegionController;\n});\n"],"file":"popover_region_controller.min.js"}