4 lines
4.6 KiB
JavaScript
4 lines
4.6 KiB
JavaScript
|
/*! DSFR v1.11.2 | SPDX-License-Identifier: MIT | License-Filename: LICENSE.md | restricted use (see terms and conditions) */
|
||
|
!function(){"use strict";var t=window.dsfr,e=t.internals.ns.selector("nav__item"),i=t.internals.ns.selector("collapse"),n={NAVIGATION:t.internals.ns.selector("nav"),COLLAPSE:e+" > "+i+", "+e+" > *:not("+e+"):not("+i+") > "+i+", "+e+" > *:not("+e+"):not("+i+") > *:not("+e+"):not("+i+") > "+i,COLLAPSE_LEGACY:e+" "+i,ITEM:e,ITEM_RIGHT:e+"--align-right",MENU:t.internals.ns.selector("menu"),BUTTON:t.internals.ns.selector("nav__btn"),TRANSLATE_BUTTON:t.internals.ns.selector("translate__btn")},s=function(e){function i(){e.call(this),this._isRightAligned=!1}e&&(i.__proto__=e),i.prototype=Object.create(e&&e.prototype),i.prototype.constructor=i;var s={isRightAligned:{configurable:!0},collapsePrimary:{configurable:!0}},o={instanceClassName:{configurable:!0}};return o.instanceClassName.get=function(){return"NavigationItem"},i.prototype.init=function(){this.addAscent(t.core.DisclosureEmission.ADDED,this.calculate.bind(this)),this.addAscent(t.core.DisclosureEmission.REMOVED,this.calculate.bind(this)),this.isResizing=!0,this.calculate()},i.prototype.resize=function(){this.calculate()},i.prototype.calculate=function(){var e=this.element.getDescendantInstances(t.core.Collapse.instanceClassName,null,!0)[0];if(e&&this.isBreakpoint(t.core.Breakpoints.LG)&&e.element.node.matches(n.MENU)){var i=this.element.node.parentElement.getBoundingClientRect().right,s=e.element.node.getBoundingClientRect().width,o=this.element.node.getBoundingClientRect().left;this.isRightAligned=o+s>i}else this.isRightAligned=!1},s.isRightAligned.get=function(){return this._isRightAligned},s.isRightAligned.set=function(e){this._isRightAligned!==e&&(this._isRightAligned=e,e?t.internals.dom.addClass(this.element.node,n.ITEM_RIGHT):t.internals.dom.removeClass(this.element.node,n.ITEM_RIGHT))},s.collapsePrimary.get=function(){return this.element.children.map((function(t){return t.getInstance("CollapseButton")})).filter((function(t){return null!==t&&(t.hasClass(n.BUTTON)||t.hasClass(n.TRANSLATE_BUTTON))}))[0]},Object.defineProperties(i.prototype,s),Object.defineProperties(i,o),i}(t.core.Instance),o={NONE:-1,INSIDE:0,OUTSIDE:1},r=function(e){function i(){e.apply(this,arguments)}e&&(i.__proto__=e),i.prototype=Object.create(e&&e.prototype),i.prototype.constructor=i;var s={index:{configurable:!0},canUngroup:{configurable:!0}},r={instanceClassName:{configurable:!0}};return r.instanceClassName.get=function(){return"Navigation"},i.prototype.init=function(){e.prototype.init.call(this),this.clicked=!1,this.out=!1,this.addEmission(t.core.RootEmission.CLICK,this._handleRootClick.bind(this)),this.listen("mousedown",this.handleMouseDown.bind(this)),this.listenClick({capture:!0}),this.isResizing=!0},i.prototype.validate=function(i){return e.prototype.validate.call(this,i)&&i.element.node.matches(t.internals.legacy.isLegacy?n.COLLAPSE_LEGACY:n.COLLAPSE)},i.prototype.handleMouseDown=function(e){this.isBreakpoint(t.core.Breakpoints.LG)&&-1!==this.index&&this.current&&(this.position=this.current.node.contains(e.target)?o.INSIDE:o.OUTSIDE,this.requestPosition())},i.prototype.handleClick=function(e){!e.target.matches("a, button")||e.target.matches("[aria-controls]")||e.target.matches(t.core.DisclosureSelector.PREVENT_CONCEAL)||(this.index=-1)},i.prototype._handleRootClick=function(e){this.isBreakpoint(t.core.Breakpoints.LG)&&(this.node.contains(e)||(this.out=!0,this.requestPosition()))},i.prototype.requestPosition=function(){this.isRequesting||(this.isRequesting=!0,this.request(this.getPosition.bind(this)))},i.prototype.getPosition=function(){if(this.out)switch(this.position){case o.OUTSIDE:this.index=-1;break;case o.INSIDE:this.current&&!this.current.node.contains(document.activeElement)&&this.current.focus();break;default:this.index>-1&&!this.current.hasFocus&&(this.index=-1)}this.request(this.requested.bind(this))},i.prototype.requested=function(){this.position=o.NONE,this.out=!1,this.isRequesting=!1},s.index.get=function(){return e.prototype.index},s.index.set=function(t){-1===t&&this.current&&this.current.hasFocus&&this.current.focus(),e.prototype.index=t},s.canUngroup.get=function(){ret
|
||
|
//# sourceMappingURL=navigation.nomodule.min.js.map
|