template.js.base.menu.min.js Maven / Gradle / Ivy
'use strict';(function(d){"function"===typeof define&&define.amd?define("jquery ../keycode ../position ../safe-active-element ../unique-id ../version ../widget".split(" "),d):d(jQuery)})(function(d){return d.widget("ui.menu",{version:"1.12.1",defaultElement:"\x3cul\x3e",delay:300,options:{icons:{submenu:"ui-icon-caret-1-e"},items:"\x3e *",menus:"ul",position:{my:"left top",at:"right top"},role:"menu",blur:null,focus:null,select:null},_create:function(){this.activeMenu=this.element;this.mouseHandled=
!1;this.element.uniqueId().attr({role:this.options.role,tabIndex:0});this._addClass("ui-menu","ui-widget ui-widget-content");this._on({"mousedown .ui-menu-item":function(a){a.preventDefault()},"click .ui-menu-item":function(a){var b=d(a.target),c=d(d.ui.safeActiveElement(this.document[0]));!this.mouseHandled&&b.not(".ui-state-disabled").length&&(this.select(a),a.isPropagationStopped()||(this.mouseHandled=!0),b.has(".ui-menu").length?this.expand(a):!this.element.is(":focus")&&c.closest(".ui-menu").length&&
(this.element.trigger("focus",[!0]),this.active&&1===this.active.parents(".ui-menu").length&&clearTimeout(this.timer)))},"mouseenter .ui-menu-item":function(a){if(!this.previousFilter){var b=d(a.target).closest(".ui-menu-item"),c=d(a.currentTarget);b[0]===c[0]&&(this._removeClass(c.siblings().children(".ui-state-active"),null,"ui-state-active"),this.focus(a,c))}},mouseleave:"collapseAll","mouseleave .ui-menu":"collapseAll",focus:function(a,b){var c=this.active||this.element.find(this.options.items).eq(0);
b||this.focus(a,c)},blur:function(a){this._delay(function(){d.contains(this.element[0],d.ui.safeActiveElement(this.document[0]))||this.collapseAll(a)})},keydown:"_keydown"});this.refresh();this._on(this.document,{click:function(a){this._closeOnDocumentClick(a)&&this.collapseAll(a);this.mouseHandled=!1}})},_destroy:function(){var a=this.element.find(".ui-menu-item").removeAttr("role aria-disabled").children(".ui-menu-item-wrapper").removeUniqueId().removeAttr("tabIndex role aria-haspopup");this.element.removeAttr("aria-activedescendant").find(".ui-menu").addBack().removeAttr("role aria-labelledby aria-expanded aria-hidden aria-disabled tabIndex").removeUniqueId().show();
a.children().each(function(){var a=d(this);a.data("ui-menu-submenu-caret")&&a.remove()})},_keydown:function(a){var b,c,e,f=!0;switch(a.keyCode){case d.ui.keyCode.PAGE_UP:this.previousPage(a);break;case d.ui.keyCode.PAGE_DOWN:this.nextPage(a);break;case d.ui.keyCode.HOME:this._move("first","first",a);break;case d.ui.keyCode.END:this._move("last","last",a);break;case d.ui.keyCode.UP:this.previous(a);break;case d.ui.keyCode.DOWN:this.next(a);break;case d.ui.keyCode.LEFT:this.collapse(a);break;case d.ui.keyCode.RIGHT:this.active&&
!this.active.is(".ui-state-disabled")&&this.expand(a);break;case d.ui.keyCode.ENTER:case d.ui.keyCode.SPACE:this._activate(a);break;case d.ui.keyCode.ESCAPE:this.collapse(a);break;default:f=!1,b=this.previousFilter||"",e=!1,c=96<=a.keyCode&&105>=a.keyCode?(a.keyCode-96).toString():String.fromCharCode(a.keyCode),clearTimeout(this.filterTimer),c===b?e=!0:c=b+c,b=this._filterMenuItems(c),b=e&&-1!==b.index(this.active.next())?this.active.nextAll(".ui-menu-item"):b,b.length||(c=String.fromCharCode(a.keyCode),
b=this._filterMenuItems(c)),b.length?(this.focus(a,b),this.previousFilter=c,this.filterTimer=this._delay(function(){delete this.previousFilter},1E3)):delete this.previousFilter}f&&a.preventDefault()},_activate:function(a){this.active&&!this.active.is(".ui-state-disabled")&&(this.active.children("[aria-haspopup\x3d'true']").length?this.expand(a):this.select(a))},refresh:function(){var a,b,c,e=this,f=this.options.icons.submenu;b=this.element.find(this.options.menus);this._toggleClass("ui-menu-icons",
null,!!this.element.find(".ui-icon").length);a=b.filter(":not(.ui-menu)").hide().attr({role:this.options.role,"aria-hidden":"true","aria-expanded":"false"}).each(function(){var a=d(this),b=a.prev(),c=d("\x3cspan\x3e").data("ui-menu-submenu-caret",!0);e._addClass(c,"ui-menu-icon","ui-icon "+f);b.attr("aria-haspopup","true").prepend(c);a.attr("aria-labelledby",b.attr("id"))});this._addClass(a,"ui-menu","ui-widget ui-widget-content ui-front");a=b.add(this.element).find(this.options.items);a.not(".ui-menu-item").each(function(){var a=
d(this);e._isDivider(a)&&e._addClass(a,"ui-menu-divider","ui-widget-content")});b=a.not(".ui-menu-item, .ui-menu-divider");c=b.children().not(".ui-menu").uniqueId().attr({tabIndex:-1,role:this._itemRole()});this._addClass(b,"ui-menu-item")._addClass(c,"ui-menu-item-wrapper");a.filter(".ui-state-disabled").attr("aria-disabled","true");this.active&&!d.contains(this.element[0],this.active[0])&&this.blur()},_itemRole:function(){return{menu:"menuitem",listbox:"option"}[this.options.role]},_setOption:function(a,
b){if("icons"===a){var c=this.element.find(".ui-menu-icon");this._removeClass(c,null,this.options.icons.submenu)._addClass(c,null,b.submenu)}this._super(a,b)},_setOptionDisabled:function(a){this._super(a);this.element.attr("aria-disabled",String(a));this._toggleClass(null,"ui-state-disabled",!!a)},focus:function(a,b){var c;this.blur(a,a&&"focus"===a.type);this._scrollIntoView(b);this.active=b.first();c=this.active.children(".ui-menu-item-wrapper");this._addClass(c,null,"ui-state-active");this.options.role&&
this.element.attr("aria-activedescendant",c.attr("id"));c=this.active.parent().closest(".ui-menu-item").children(".ui-menu-item-wrapper");this._addClass(c,null,"ui-state-active");a&&"keydown"===a.type?this._close():this.timer=this._delay(function(){this._close()},this.delay);c=b.children(".ui-menu");c.length&&a&&/^mouse/.test(a.type)&&this._startOpening(c);this.activeMenu=b.parent();this._trigger("focus",a,{item:b})},_scrollIntoView:function(a){var b,c,e;this._hasScroll()&&(b=parseFloat(d.css(this.activeMenu[0],
"borderTopWidth"))||0,c=parseFloat(d.css(this.activeMenu[0],"paddingTop"))||0,b=a.offset().top-this.activeMenu.offset().top-b-c,c=this.activeMenu.scrollTop(),e=this.activeMenu.height(),a=a.outerHeight(),0>b?this.activeMenu.scrollTop(c+b):b+a>e&&this.activeMenu.scrollTop(c+b-e+a))},blur:function(a,b){b||clearTimeout(this.timer);this.active&&(this._removeClass(this.active.children(".ui-menu-item-wrapper"),null,"ui-state-active"),this._trigger("blur",a,{item:this.active}),this.active=null)},_startOpening:function(a){clearTimeout(this.timer);
"true"===a.attr("aria-hidden")&&(this.timer=this._delay(function(){this._close();this._open(a)},this.delay))},_open:function(a){var b=d.extend({of:this.active},this.options.position);clearTimeout(this.timer);this.element.find(".ui-menu").not(a.parents(".ui-menu")).hide().attr("aria-hidden","true");a.show().removeAttr("aria-hidden").attr("aria-expanded","true").position(b)},collapseAll:function(a,b){clearTimeout(this.timer);this.timer=this._delay(function(){var c=b?this.element:d(a&&a.target).closest(this.element.find(".ui-menu"));
c.length||(c=this.element);this._close(c);this.blur(a);this._removeClass(c.find(".ui-state-active"),null,"ui-state-active");this.activeMenu=c},this.delay)},_close:function(a){a||(a=this.active?this.active.parent():this.element);a.find(".ui-menu").hide().attr("aria-hidden","true").attr("aria-expanded","false")},_closeOnDocumentClick:function(a){return!d(a.target).closest(".ui-menu").length},_isDivider:function(a){return!/[^\-\u2014\u2013\s]/.test(a.text())},collapse:function(a){var b=this.active&&
this.active.parent().closest(".ui-menu-item",this.element);b&&b.length&&(this._close(),this.focus(a,b))},expand:function(a){var b=this.active&&this.active.children(".ui-menu ").find(this.options.items).first();b&&b.length&&(this._open(b.parent()),this._delay(function(){this.focus(a,b)}))},next:function(a){this._move("next","first",a)},previous:function(a){this._move("prev","last",a)},isFirstItem:function(){return this.active&&!this.active.prevAll(".ui-menu-item").length},isLastItem:function(){return this.active&&
!this.active.nextAll(".ui-menu-item").length},_move:function(a,b,c){var d;this.active&&(d="first"===a||"last"===a?this.active["first"===a?"prevAll":"nextAll"](".ui-menu-item").eq(-1):this.active[a+"All"](".ui-menu-item").eq(0));d&&d.length&&this.active||(d=this.activeMenu.find(this.options.items)[b]());this.focus(c,d)},nextPage:function(a){var b,c,e;this.active?this.isLastItem()||(this._hasScroll()?(c=this.active.offset().top,e=this.element.height(),this.active.nextAll(".ui-menu-item").each(function(){b=
d(this);return 0>b.offset().top-c-e}),this.focus(a,b)):this.focus(a,this.activeMenu.find(this.options.items)[this.active?"last":"first"]())):this.next(a)},previousPage:function(a){var b,c,e;this.active?this.isFirstItem()||(this._hasScroll()?(c=this.active.offset().top,e=this.element.height(),this.active.prevAll(".ui-menu-item").each(function(){b=d(this);return 0
© 2015 - 2024 Weber Informatics LLC | Privacy Policy