4 lines
17 KiB
JavaScript
4 lines
17 KiB
JavaScript
|
/*! jQuery UI - v1.10.2 - 2013-03-14
|
||
|
* http://jqueryui.com
|
||
|
* Copyright 2013 jQuery Foundation and other contributors; Licensed MIT */
|
||
|
(function(e){e.widget("ui.menu",{version:"1.10.2",defaultElement:"<ul>",delay:300,options:{icons:{submenu:"ui-icon-carat-1-e"},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().addClass("ui-menu ui-widget ui-widget-content ui-corner-all").toggleClass("ui-menu-icons",!!this.element.find(".ui-icon").length).attr({role:this.options.role,tabIndex:0}).bind("click"+this.eventNamespace,e.proxy(function(e){this.options.disabled&&e.preventDefault()},this)),this.options.disabled&&this.element.addClass("ui-state-disabled").attr("aria-disabled","true"),this._on({"mousedown .ui-menu-item > a":function(e){e.preventDefault()},"click .ui-state-disabled > a":function(e){e.preventDefault()},"click .ui-menu-item:has(a)":function(n){var r=e(n.target).closest(".ui-menu-item");!this.mouseHandled&&r.not(".ui-state-disabled").length&&(this.mouseHandled=!0,this.select(n),r.has(".ui-menu").length?this.expand(n):this.element.is(":focus")||(this.element.trigger("focus",[!0]),this.active&&1===this.active.parents(".ui-menu").length&&clearTimeout(this.timer)))},"mouseenter .ui-menu-item":function(n){var r=e(n.currentTarget);r.siblings().children(".ui-state-active").removeClass("ui-state-active"),this.focus(n,r)},mouseleave:"collapseAll","mouseleave .ui-menu":"collapseAll",focus:function(e,t){var n=this.active||this.element.children(".ui-menu-item").eq(0);t||this.focus(e,n)},blur:function(n){this._delay(function(){e.contains(this.element[0],this.document[0].activeElement)||this.collapseAll(n)})},keydown:"_keydown"}),this.refresh(),this._on(this.document,{click:function(n){e(n.target).closest(".ui-menu").length||this.collapseAll(n),this.mouseHandled=!1}})},_destroy:function(){this.element.removeAttr("aria-activedescendant").find(".ui-menu").addBack().removeClass("ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons").removeAttr("role").removeAttr("tabIndex").removeAttr("aria-labelledby").removeAttr("aria-expanded").removeAttr("aria-hidden").removeAttr("aria-disabled").removeUniqueId().show(),this.element.find(".ui-menu-item").removeClass("ui-menu-item").removeAttr("role").removeAttr("aria-disabled").children("a").removeUniqueId().removeClass("ui-corner-all ui-state-hover").removeAttr("tabIndex").removeAttr("role").removeAttr("aria-haspopup").children().each(function(){var n=e(this);n.data("ui-menu-submenu-carat")&&n.remove()}),this.element.find(".ui-menu-divider").removeClass("ui-menu-divider ui-widget-content")},_keydown:function(n){function r(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}var i,s,o,u,a,f=!0;switch(n.keyCode){case e.ui.keyCode.PAGE_UP:this.previousPage(n);break;case e.ui.keyCode.PAGE_DOWN:this.nextPage(n);break;case e.ui.keyCode.HOME:this._move("first","first",n);break;case e.ui.keyCode.END:this._move("last","last",n);break;case e.ui.keyCode.UP:this.previous(n);break;case e.ui.keyCode.DOWN:this.next(n);break;case e.ui.keyCode.LEFT:this.collapse(n);break;case e.ui.keyCode.RIGHT:this.active&&!this.active.is(".ui-state-disabled")&&this.expand(n);break;case e.ui.keyCode.ENTER:case e.ui.keyCode.SPACE:this._activate(n);break;case e.ui.keyCode.ESCAPE:this.collapse(n);break;default:f=!1,s=this.previousFilter||"",o=String.fromCharCode(n.keyCode),u=!1,clearTimeout(this.filterTimer),o===s?u=!0:o=s+o,a=RegExp("^"+r(o),"i"),i=this.activeMenu.children(".ui-menu-item").filter(function(){return a.test(e(this).children("a").text())}),i=u&&-1!==i.index(this.active.next())?this.active.nextAll(".ui-menu-item"):i,i.length||(o=String.fromCharCode(n.keyCode),a=RegExp("^"+r(o),"i"),i=this.activeMenu.children(".ui-menu-item").filter(function(){return a.test(e(this).children("a").text())})),i.length?(this.focus(n,i),i.length>1?(this.previousFilter=o,this.filterTimer=this._delay(function(){delete this.previousFilter},1e3)):delete this.previousFilter):delete this.previousFilter}f&&n.preventDefault()},_activate:function(e){this.active.is(".ui-state-disabled")||(this.active.children("a[aria-haspopup='true
|