Current Path : C:/Users/Mahmood/Desktop/moodle/lib/amd/build/ |
Current File : C:/Users/Mahmood/Desktop/moodle/lib/amd/build/popover_region_controller.min.js |
define ("core/popover_region_controller",["jquery","core/str","core/custom_interaction_events"],function(a,b,c){var d={CONTENT:".popover-region-content",CONTENT_CONTAINER:".popover-region-content-container",MENU_CONTAINER:".popover-region-container",MENU_TOGGLE:".popover-region-toggle",CAN_RECEIVE_FOCUS:"input:not([type=\"hidden\"]), a[href], button, textarea, select, [tabindex]"},e=function(b){this.root=a(b);this.content=this.root.find(d.CONTENT);this.contentContainer=this.root.find(d.CONTENT_CONTAINER);this.menuContainer=this.root.find(d.MENU_CONTAINER);this.menuToggle=this.root.find(d.MENU_TOGGLE);this.isLoading=!1;this.promises={closeHandlers:a.Deferred(),navigationHandlers:a.Deferred()};this.registerBaseEventListeners()};e.prototype.events=function(){return{menuOpened:"popoverregion:menuopened",menuClosed:"popoverregion:menuclosed",startLoading:"popoverregion:startLoading",stopLoading:"popoverregion:stopLoading"}};e.prototype.getContentContainer=function(){return this.contentContainer};e.prototype.getContent=function(){return this.content};e.prototype.isMenuOpen=function(){return!this.root.hasClass("collapsed")};e.prototype.toggleMenu=function(){if(this.isMenuOpen()){this.closeMenu()}else{this.openMenu()}};e.prototype.closeMenu=function(){if(!this.isMenuOpen()){return}this.root.addClass("collapsed");this.menuContainer.attr("aria-expanded","false");this.menuContainer.attr("aria-hidden","true");this.updateButtonAriaLabel();this.root.trigger(this.events().menuClosed)};e.prototype.openMenu=function(){if(this.isMenuOpen()){return}this.root.removeClass("collapsed");this.menuContainer.attr("aria-expanded","true");this.menuContainer.attr("aria-hidden","false");this.updateButtonAriaLabel();this.promises.closeHandlers.resolve();this.promises.navigationHandlers.resolve();this.root.trigger(this.events().menuOpened)};e.prototype.updateButtonAriaLabel=function(){if(this.isMenuOpen()){b.get_string("hidepopoverwindow").done(function(a){this.menuToggle.attr("aria-label",a)}.bind(this))}else{b.get_string("showpopoverwindow").done(function(a){this.menuToggle.attr("aria-label",a)}.bind(this))}};e.prototype.startLoading=function(){this.isLoading=!0;this.getContentContainer().addClass("loading");this.getContentContainer().attr("aria-busy","true");this.root.trigger(this.events().startLoading)};e.prototype.stopLoading=function(){this.isLoading=!1;this.getContentContainer().removeClass("loading");this.getContentContainer().attr("aria-busy","false");this.root.trigger(this.events().stopLoading)};e.prototype.focusMenuToggle=function(){this.menuToggle.focus()};e.prototype.contentItemHasFocus=function(){return 0<this.getContentItemWithFocus().length};e.prototype.getContentItemWithFocus=function(){var b=a(document.activeElement),c=this.getContent().children(),d=c.filter(b);if(!d.length){d=c.has(b)}return d};e.prototype.focusContentItem=function(a){if(a.is(d.CAN_RECEIVE_FOCUS)){a.focus()}else{a.find(d.CAN_RECEIVE_FOCUS).first().focus()}};e.prototype.focusFirstContentItem=function(){this.focusContentItem(this.getContent().children().first())};e.prototype.focusLastContentItem=function(){this.focusContentItem(this.getContent().children().last())};e.prototype.focusNextContentItem=function(){var a=this.getContentItemWithFocus();if(a.length&&a.next()){this.focusContentItem(a.next())}};e.prototype.focusPreviousContentItem=function(){var a=this.getContentItemWithFocus();if(a.length&&a.prev()){this.focusContentItem(a.prev())}};e.prototype.registerBaseEventListeners=function(){c.define(this.root,[c.events.activate,c.events.escape]);this.root.on(c.events.activate,d.MENU_TOGGLE,function(){this.toggleMenu()}.bind(this));this.promises.closeHandlers.done(function(){this.root.on(c.events.escape,function(){this.closeMenu();this.focusMenuToggle()}.bind(this));a("html").click(function(b){var c=a(b.target);if(!this.root.is(c)&&!this.root.has(c).length){this.closeMenu()}}.bind(this));c.define(this.getContentContainer(),[c.events.scrollBottom])}.bind(this))};e.prototype.registerListNavigationEventListeners=function(){c.define(this.root,[c.events.down]);this.root.on(c.events.down,function(a,b){if(!this.isMenuOpen()){this.openMenu();this.focusFirstContentItem()}else{if(this.contentItemHasFocus()){this.focusNextContentItem()}else{this.focusFirstContentItem()}}b.originalEvent.preventDefault()}.bind(this));this.promises.navigationHandlers.done(function(){c.define(this.root,[c.events.up,c.events.home,c.events.end]);this.root.on(c.events.up,function(a,b){this.focusPreviousContentItem();b.originalEvent.preventDefault()}.bind(this));this.root.on(c.events.home,function(a,b){this.focusFirstContentItem();b.originalEvent.preventDefault()}.bind(this));this.root.on(c.events.end,function(a,b){this.focusLastContentItem();b.originalEvent.preventDefault()}.bind(this))}.bind(this))};return e}); //# sourceMappingURL=popover_region_controller.min.js.map