diff --git a/lib/yui/build/moodle-core-actionmenu/moodle-core-actionmenu-debug.js b/lib/yui/build/moodle-core-actionmenu/moodle-core-actionmenu-debug.js index bb305198e530c..343219441bc68 100644 --- a/lib/yui/build/moodle-core-actionmenu/moodle-core-actionmenu-debug.js +++ b/lib/yui/build/moodle-core-actionmenu/moodle-core-actionmenu-debug.js @@ -318,18 +318,22 @@ ACTIONMENU.prototype = { */ handleKeyboardEvent: function(e) { var next; + var markEventHandled = function(e) { + e.preventDefault(); + e.stopPropagation(); + }; // Handle when the menu is still selected. if (e.currentTarget.ancestor(SELECTOR.TOGGLE, true)) { if ((e.keyCode === 40 || (e.keyCode === 9 && !e.shiftKey)) && this.firstMenuChild) { this.firstMenuChild.focus(); - e.preventDefault(); + markEventHandled(e); } else if (e.keyCode === 38 && this.lastMenuChild) { this.lastMenuChild.focus(); - e.preventDefault(); + markEventHandled(e); } else if (e.keyCode === 9 && e.shiftKey) { this.hideMenu(e); - e.preventDefault(); + markEventHandled(e); } return this; } @@ -337,11 +341,11 @@ ACTIONMENU.prototype = { if (e.keyCode === 27) { // The escape key was pressed so close the menu. this.hideMenu(e); - e.preventDefault(); + markEventHandled(e); } else if (e.keyCode === 32) { // The space bar was pressed. Trigger a click. - e.preventDefault(); + markEventHandled(e); e.currentTarget.simulate('click'); } else if (e.keyCode === 9) { // The tab key was pressed. Tab moves forwards, Shift + Tab moves backwards through the menu options. @@ -349,13 +353,14 @@ ACTIONMENU.prototype = { // focus is moved to. if (e.target === this.firstMenuChild && e.shiftKey) { this.hideMenu(e); - e.preventDefault(); + markEventHandled(e); } else if (e.target === this.lastMenuChild && !e.shiftKey) { if (this.hideMenu(e)) { // Determine the next selector and focus on it. next = this.menulink.next(SELECTOR.CAN_RECEIVE_FOCUS_SELECTOR); if (next) { next.focus(); + markEventHandled(e); } } } @@ -404,7 +409,7 @@ ACTIONMENU.prototype = { if (next) { next.focus(); - e.preventDefault(); + markEventHandled(e); } } }, diff --git a/lib/yui/build/moodle-core-actionmenu/moodle-core-actionmenu-min.js b/lib/yui/build/moodle-core-actionmenu/moodle-core-actionmenu-min.js index c28277fbe4014..dc737a34cabe2 100644 --- a/lib/yui/build/moodle-core-actionmenu/moodle-core-actionmenu-min.js +++ b/lib/yui/build/moodle-core-actionmenu/moodle-core-actionmenu-min.js @@ -1,2 +1,2 @@ -YUI.add("moodle-core-actionmenu",function(e,t){var n=e.one(e.config.doc.body),r={MENUSHOWN:"action-menu-shown"},i={CAN_RECEIVE_FOCUS_SELECTOR:'input:not([type="hidden"]), a[href], button, textarea, select, [tabindex]',MENU:".moodle-actionmenu[data-enhance=moodle-core-actionmenu]",MENUBAR:'[role="menubar"]',MENUITEM:'[role="menuitem"]',MENUCONTENT:".menu[data-rel=menu-content]",MENUCONTENTCHILD:"li a",MENUCHILD:".menu li a",TOGGLE:".toggle-display",KEEPOPEN:'[data-keepopen="1"]',MENUBARITEMS:['[role="menubar"] > [role="menuitem"]','[role="menubar"] > [role="presentation"] > [role="menuitem"]'],MENUITEMS:['> [role="menuitem"]','> [role="presentation"] > [role="menuitem"]']},s,o={TL:"tl",TR:"tr",BL:"bl",BR:"br"};s=function(){s.superclass.constructor.apply(this,arguments)},s.prototype={dialogue:null,events:[],owner:null,menulink:null,menuChildren:null,firstMenuChild:null,lastMenuChild:null,initializer:function(){e.all(i.MENU).each(this.enhance,this),n.delegate("key",this.moveMenuItem,"down:37,39",i.MENUBARITEMS.join(","),this),n.delegate("click",this.toggleMenu,i.MENU+" "+i.TOGGLE,this),n.delegate("key",this.showIfHidden,"down:enter,38,40",i.MENU+" "+i.TOGGLE,this),n.delegate("key",function(e){e.currentTarget.simulate("click"),e.preventDefault()},"down:32",i.MENUBARITEMS.join(","))},enhance:function(e){var t=e.one(i.MENUCONTENT),n;if(!t)return!1;n=t.getData("align")||this.get("align").join("-"),e.one(i.TOGGLE).set("aria-haspopup",!0),t.set("aria-hidden",!0),t.hasClass("align-"+n)||t.addClass("align-"+n),t.hasChildNodes()&&e.setAttribute("data-enhanced","1")},moveMenuItem:function(e){var t,n=e.target.ancestor(i.MENUITEM,!0);return e.keyCode===37?t=this.getMenuItem(n,!0):e.keyCode===39&&(t=this.getMenuItem(n)),t&&t.focus(),this},getMenuItem:function(e,t){var n=e.ancestor(i.MENUBAR),r,s;if(!n)return null;r=n.all(i.MENUITEMS.join(","));if(!r)return null;var o=r.size();if(o===1)return null;var u=0,a=1,f=0;for(u=0;u=this.menuChildren.size()&&(r=0),t=this.menuChildren.item(r),o++;while(oa?(c=i=a,p=n=o):n=o+a&&(p=o+a-i),s>f&&l.toLowerCase()==="hidden"&&(h=s=f,e.setStyle("overflow","auto"));if(r>=u&&r+s>u+f){d=u+f-s;try{v=e.getStyle("boxShadow").replace(/.*? (\d+)px \d+px$/,"$1"),(new RegExp(/^\d+$/)).test(v)&&d-u>v&&(d-=v)}catch(m){}}p!==null&&e.setX(p),d!==null&&e.setY(d),c!==null&&e.setStyle("width",c.toString()+"px"),h!==null&&e.setStyle("height",h.toString()+"px")}},e.extend(s,e.Base,s.prototype,{NAME:"moodle-core-actionmenu",ATTRS:{align:{value:[o.TR,o.BR]}}}),M.core=M.core||{},M.core.actionmenu=M.core.actionmenu||{},M.core.actionmenu.instance=null,M.core.actionmenu.init=M.core.actionmenu.init||function(e){M.core.actionmenu.instance=M.core.actionmenu.instance||new s(e)},M.core.actionmenu.newDOMNode=function(e){if(M.core.actionmenu -.instance===null)return!0;e.all(i.MENU).each(M.core.actionmenu.instance.enhance,M.core.actionmenu.instance)}},"@VERSION@",{requires:["base","event","node-event-simulate"]}); +YUI.add("moodle-core-actionmenu",function(e,t){var n=e.one(e.config.doc.body),r={MENUSHOWN:"action-menu-shown"},i={CAN_RECEIVE_FOCUS_SELECTOR:'input:not([type="hidden"]), a[href], button, textarea, select, [tabindex]',MENU:".moodle-actionmenu[data-enhance=moodle-core-actionmenu]",MENUBAR:'[role="menubar"]',MENUITEM:'[role="menuitem"]',MENUCONTENT:".menu[data-rel=menu-content]",MENUCONTENTCHILD:"li a",MENUCHILD:".menu li a",TOGGLE:".toggle-display",KEEPOPEN:'[data-keepopen="1"]',MENUBARITEMS:['[role="menubar"] > [role="menuitem"]','[role="menubar"] > [role="presentation"] > [role="menuitem"]'],MENUITEMS:['> [role="menuitem"]','> [role="presentation"] > [role="menuitem"]']},s,o={TL:"tl",TR:"tr",BL:"bl",BR:"br"};s=function(){s.superclass.constructor.apply(this,arguments)},s.prototype={dialogue:null,events:[],owner:null,menulink:null,menuChildren:null,firstMenuChild:null,lastMenuChild:null,initializer:function(){e.all(i.MENU).each(this.enhance,this),n.delegate("key",this.moveMenuItem,"down:37,39",i.MENUBARITEMS.join(","),this),n.delegate("click",this.toggleMenu,i.MENU+" "+i.TOGGLE,this),n.delegate("key",this.showIfHidden,"down:enter,38,40",i.MENU+" "+i.TOGGLE,this),n.delegate("key",function(e){e.currentTarget.simulate("click"),e.preventDefault()},"down:32",i.MENUBARITEMS.join(","))},enhance:function(e){var t=e.one(i.MENUCONTENT),n;if(!t)return!1;n=t.getData("align")||this.get("align").join("-"),e.one(i.TOGGLE).set("aria-haspopup",!0),t.set("aria-hidden",!0),t.hasClass("align-"+n)||t.addClass("align-"+n),t.hasChildNodes()&&e.setAttribute("data-enhanced","1")},moveMenuItem:function(e){var t,n=e.target.ancestor(i.MENUITEM,!0);return e.keyCode===37?t=this.getMenuItem(n,!0):e.keyCode===39&&(t=this.getMenuItem(n)),t&&t.focus(),this},getMenuItem:function(e,t){var n=e.ancestor(i.MENUBAR),r,s;if(!n)return null;r=n.all(i.MENUITEMS.join(","));if(!r)return null;var o=r.size();if(o===1)return null;var u=0,a=1,f=0;for(u=0;u=this.menuChildren.size()&&(s=0),t=this.menuChildren.item(s),u++;while(ua?(c=i=a,p=n=o):n=o+a&&(p=o+a-i),s>f&&l.toLowerCase()==="hidden"&&(h=s=f,e.setStyle("overflow","auto"));if(r>=u&&r+s>u+f){d=u+f-s;try{v=e.getStyle("boxShadow").replace(/.*? (\d+)px \d+px$/,"$1"),(new RegExp(/^\d+$/)).test(v)&&d-u>v&&(d-=v)}catch(m){}}p!==null&&e.setX(p),d!==null&&e.setY(d),c!==null&&e.setStyle("width",c.toString()+"px"),h!==null&&e.setStyle("height",h.toString()+"px")}},e.extend(s,e.Base,s.prototype,{NAME:"moodle-core-actionmenu",ATTRS:{align:{value:[o.TR,o.BR]}}}),M.core=M.core||{},M.core.actionmenu=M.core.actionmenu||{},M.core.actionmenu.instance=null,M.core.actionmenu.init=M.core.actionmenu.init||function(e){M.core.actionmenu.instance=M.core.actionmenu.instance||new s(e)},M.core.actionmenu.newDOMNode=function(e){if(M.core.actionmenu.instance===null)return!0;e.all +(i.MENU).each(M.core.actionmenu.instance.enhance,M.core.actionmenu.instance)}},"@VERSION@",{requires:["base","event","node-event-simulate"]}); diff --git a/lib/yui/build/moodle-core-actionmenu/moodle-core-actionmenu.js b/lib/yui/build/moodle-core-actionmenu/moodle-core-actionmenu.js index 79adfdcb6c3af..c5812541a02ae 100644 --- a/lib/yui/build/moodle-core-actionmenu/moodle-core-actionmenu.js +++ b/lib/yui/build/moodle-core-actionmenu/moodle-core-actionmenu.js @@ -316,18 +316,22 @@ ACTIONMENU.prototype = { */ handleKeyboardEvent: function(e) { var next; + var markEventHandled = function(e) { + e.preventDefault(); + e.stopPropagation(); + }; // Handle when the menu is still selected. if (e.currentTarget.ancestor(SELECTOR.TOGGLE, true)) { if ((e.keyCode === 40 || (e.keyCode === 9 && !e.shiftKey)) && this.firstMenuChild) { this.firstMenuChild.focus(); - e.preventDefault(); + markEventHandled(e); } else if (e.keyCode === 38 && this.lastMenuChild) { this.lastMenuChild.focus(); - e.preventDefault(); + markEventHandled(e); } else if (e.keyCode === 9 && e.shiftKey) { this.hideMenu(e); - e.preventDefault(); + markEventHandled(e); } return this; } @@ -335,11 +339,11 @@ ACTIONMENU.prototype = { if (e.keyCode === 27) { // The escape key was pressed so close the menu. this.hideMenu(e); - e.preventDefault(); + markEventHandled(e); } else if (e.keyCode === 32) { // The space bar was pressed. Trigger a click. - e.preventDefault(); + markEventHandled(e); e.currentTarget.simulate('click'); } else if (e.keyCode === 9) { // The tab key was pressed. Tab moves forwards, Shift + Tab moves backwards through the menu options. @@ -347,13 +351,14 @@ ACTIONMENU.prototype = { // focus is moved to. if (e.target === this.firstMenuChild && e.shiftKey) { this.hideMenu(e); - e.preventDefault(); + markEventHandled(e); } else if (e.target === this.lastMenuChild && !e.shiftKey) { if (this.hideMenu(e)) { // Determine the next selector and focus on it. next = this.menulink.next(SELECTOR.CAN_RECEIVE_FOCUS_SELECTOR); if (next) { next.focus(); + markEventHandled(e); } } } @@ -401,7 +406,7 @@ ACTIONMENU.prototype = { if (next) { next.focus(); - e.preventDefault(); + markEventHandled(e); } } }, diff --git a/lib/yui/src/actionmenu/js/actionmenu.js b/lib/yui/src/actionmenu/js/actionmenu.js index 720294458447c..ca4b94660680b 100644 --- a/lib/yui/src/actionmenu/js/actionmenu.js +++ b/lib/yui/src/actionmenu/js/actionmenu.js @@ -316,18 +316,22 @@ ACTIONMENU.prototype = { */ handleKeyboardEvent: function(e) { var next; + var markEventHandled = function(e) { + e.preventDefault(); + e.stopPropagation(); + }; // Handle when the menu is still selected. if (e.currentTarget.ancestor(SELECTOR.TOGGLE, true)) { if ((e.keyCode === 40 || (e.keyCode === 9 && !e.shiftKey)) && this.firstMenuChild) { this.firstMenuChild.focus(); - e.preventDefault(); + markEventHandled(e); } else if (e.keyCode === 38 && this.lastMenuChild) { this.lastMenuChild.focus(); - e.preventDefault(); + markEventHandled(e); } else if (e.keyCode === 9 && e.shiftKey) { this.hideMenu(e); - e.preventDefault(); + markEventHandled(e); } return this; } @@ -335,11 +339,11 @@ ACTIONMENU.prototype = { if (e.keyCode === 27) { // The escape key was pressed so close the menu. this.hideMenu(e); - e.preventDefault(); + markEventHandled(e); } else if (e.keyCode === 32) { // The space bar was pressed. Trigger a click. - e.preventDefault(); + markEventHandled(e); e.currentTarget.simulate('click'); } else if (e.keyCode === 9) { // The tab key was pressed. Tab moves forwards, Shift + Tab moves backwards through the menu options. @@ -347,13 +351,14 @@ ACTIONMENU.prototype = { // focus is moved to. if (e.target === this.firstMenuChild && e.shiftKey) { this.hideMenu(e); - e.preventDefault(); + markEventHandled(e); } else if (e.target === this.lastMenuChild && !e.shiftKey) { if (this.hideMenu(e)) { // Determine the next selector and focus on it. next = this.menulink.next(SELECTOR.CAN_RECEIVE_FOCUS_SELECTOR); if (next) { next.focus(); + markEventHandled(e); } } } @@ -402,7 +407,7 @@ ACTIONMENU.prototype = { if (next) { next.focus(); - e.preventDefault(); + markEventHandled(e); } } },