MDL-79041 core: Fix typo for MoodleNet resource URL
[moodle.git] / lib / amd / build / usermenu.min.js
blob09855bbddf0c51a2e1dc794cf0a64bcf8d90a452
1 define("core/usermenu",["exports","jquery","core/key_codes"],(function(_exports,_jquery,_key_codes){var obj;
2 /**
3    * Initializes and handles events in the user menu.
4    *
5    * @module     core/usermenu
6    * @copyright  2021 Moodle
7    * @author     Mihail Geshoski <mihail@moodle.com>
8    * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
9    */Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_jquery=(obj=_jquery)&&obj.__esModule?obj:{default:obj};const selectors_userMenu=".usermenu",selectors_userMenuCarousel=".usermenu #usermenu-carousel",selectors_userMenuCarouselItem=".usermenu #usermenu-carousel .carousel-item",selectors_userMenuCarouselItemActive=".usermenu #usermenu-carousel .carousel-item.active",selectors_userMenuCarouselNavigationLink=".usermenu #usermenu-carousel .carousel-navigation-link";var _default={init:()=>{(()=>{const userMenu=document.querySelector(selectors_userMenu);(0,_jquery.default)(selectors_userMenu).on("shown.bs.dropdown",(()=>{const activeCarouselItem=document.querySelector(selectors_userMenuCarouselItemActive);activeCarouselItem.focus(),userMenu.querySelectorAll(selectors_userMenuCarouselItem).forEach((element=>{element.classList.contains("active")||(element.style.width=activeCarouselItem.offsetWidth+"px",element.style.height=activeCarouselItem.offsetHeight+"px")}))})),userMenu.addEventListener("click",(e=>{e.target.matches(selectors_userMenuCarouselNavigationLink)&&carouselManagement(e)})),userMenu.addEventListener("keydown",(e=>{e.keyCode!==_key_codes.space&&e.keyCode!==_key_codes.enter||!e.target.matches(selectors_userMenuCarouselNavigationLink)||(e.preventDefault(),carouselManagement(e))}));const carouselManagement=e=>{e.stopPropagation();const targetedCarouselItemId=e.target.dataset.carouselTargetId,targetedCarouselItem=userMenu.querySelector("#"+targetedCarouselItemId),index=Array.from(targetedCarouselItem.parentNode.children).indexOf(targetedCarouselItem);(0,_jquery.default)(selectors_userMenuCarousel).carousel(index)};(0,_jquery.default)(selectors_userMenu).on("hide.bs.dropdown",(()=>{(0,_jquery.default)(selectors_userMenuCarousel).carousel(0)})),(0,_jquery.default)(selectors_userMenuCarousel).on("slid.bs.carousel",(()=>{userMenu.querySelector(selectors_userMenuCarouselItemActive).focus()}))})()}};return _exports.default=_default,_exports.default}));
11 //# sourceMappingURL=usermenu.min.js.map