From 70fb7ac4b35667675cdcdf5e08f6ea37cd10fed6 Mon Sep 17 00:00:00 2001 From: Neill Magill Date: Tue, 4 Aug 2015 16:31:54 +0100 Subject: [PATCH] MDL-50971 ActionMenu: Action menus cause page to jump when closing This patch changes the behavior of open action menus when using a mouse. Before this patch when clicking on the page with an open action menu the focus would be returned to the action menu's call button. This could cause the page to jump when a mouse user did not close an action menu, scrolled and then tried to perform another action on the page. After this patch when clicking the focus will not be returned to the action menu's call button. The behavior of the script will not be changed when using the keyboard. --- .../moodle-course-toolboxes-debug.js | 4 ++-- .../moodle-course-toolboxes-min.js | 4 ++-- .../moodle-course-toolboxes.js | 4 ++-- course/yui/src/toolboxes/js/resource.js | 4 ++-- lib/upgrade.txt | 6 +++++ .../moodle-core-actionmenu-debug.js | 22 +++++++++++-------- .../moodle-core-actionmenu-min.js | 4 ++-- .../moodle-core-actionmenu.js | 22 +++++++++++-------- lib/yui/src/actionmenu/js/actionmenu.js | 22 +++++++++++-------- .../moodle-mod_quiz-toolboxes-debug.js | 4 ++-- .../moodle-mod_quiz-toolboxes-min.js | 2 +- .../moodle-mod_quiz-toolboxes.js | 4 ++-- mod/quiz/yui/src/toolboxes/js/resource.js | 4 ++-- 13 files changed, 62 insertions(+), 44 deletions(-) diff --git a/course/yui/build/moodle-course-toolboxes/moodle-course-toolboxes-debug.js b/course/yui/build/moodle-course-toolboxes/moodle-course-toolboxes-debug.js index ed1e8266009..5f25c8972ce 100644 --- a/course/yui/build/moodle-course-toolboxes/moodle-course-toolboxes-debug.js +++ b/course/yui/build/moodle-course-toolboxes/moodle-course-toolboxes-debug.js @@ -498,7 +498,7 @@ Y.extend(RESOURCETOOLBOX, TOOLBOX, { }; this.send_request(data); if (M.core.actionmenu && M.core.actionmenu.instance) { - M.core.actionmenu.instance.hideMenu(); + M.core.actionmenu.instance.hideMenu(ev); } }, this); @@ -745,7 +745,7 @@ Y.extend(RESOURCETOOLBOX, TOOLBOX, { this.send_request(data, null, function(response) { if (M.core.actionmenu && M.core.actionmenu.instance) { - M.core.actionmenu.instance.hideMenu(); + M.core.actionmenu.instance.hideMenu(ev); } // Try to retrieve the existing string from the server diff --git a/course/yui/build/moodle-course-toolboxes/moodle-course-toolboxes-min.js b/course/yui/build/moodle-course-toolboxes/moodle-course-toolboxes-min.js index b3c931726f4..d1a9942f305 100644 --- a/course/yui/build/moodle-course-toolboxes/moodle-course-toolboxes-min.js +++ b/course/yui/build/moodle-course-toolboxes/moodle-course-toolboxes-min.js @@ -1,3 +1,3 @@ -YUI.add("moodle-course-toolboxes",function(e,t){var n={ACTIVITYINSTANCE:"activityinstance",AVAILABILITYINFODIV:"div.availabilityinfo",CONTENTWITHOUTLINK:"contentwithoutlink",CONDITIONALHIDDEN:"conditionalhidden",DIMCLASS:"dimmed",DIMMEDTEXT:"dimmed_text",EDITINSTRUCTIONS:"editinstructions",EDITINGTITLE:"editor_displayed",HIDE:"hide",MODINDENTCOUNT:"mod-indent-",MODINDENTHUGE:"mod-indent-huge",MODULEIDPREFIX:"module-",SECTIONHIDDENCLASS:"hidden",SECTIONIDPREFIX:"section-",SHOW:"editing_show",TITLEEDITOR:"titleeditor"},r={ACTIONAREA:".actions",ACTIONLINKTEXT:".actionlinktext",ACTIVITYACTION:"a.cm-edit-action[data-action], a.editing_title",ACTIVITYFORM:"."+n.ACTIVITYINSTANCE+" form",ACTIVITYICON:"img.activityicon",ACTIVITYINSTANCE:"."+n.ACTIVITYINSTANCE,ACTIVITYLINK:"."+n.ACTIVITYINSTANCE+" > a",ACTIVITYLI:"li.activity",ACTIVITYTITLE:"input[name=title]",COMMANDSPAN:".commands",CONTENTAFTERLINK:"div.contentafterlink",CONTENTWITHOUTLINK:"div.contentwithoutlink",EDITTITLE:"a.editing_title",HIDE:"a.editing_hide",HIGHLIGHT:"a.editing_highlight",INSTANCENAME:"span.instancename",MODINDENTDIV:".mod-indent",MODINDENTOUTER:".mod-indent-outer",PAGECONTENT:"body",SECTIONLI:"li.section",SHOW:"a."+n.SHOW,SHOWHIDE:"a.editing_showhide"},i={MIN:0,MAX:16},s=e.one(document.body);M.course=M.course||{};var o=function(){o.superclass.constructor.apply(this,arguments)};e.extend(o,e.Base,{send_request:function(t,n,r,i){t||(t={});var s=this.get("config").pageparams,o;for(o in s)t[o]=s[o];t.sesskey=M.cfg.sesskey,t.courseId=this.get("courseid");var u=M.cfg.wwwroot+this.get("ajaxurl"),a=[],f={method:"POST",data:t,on:{success:function(t,i){try{a=e.JSON.parse(i.responseText),a.error&&new M.core.ajaxException(a)}catch(s){}r&&e.bind(r,this,a)(),n&&window.setTimeout(function(){n.hide()},400)},failure:function(e,t){n&&n.hide(),new M.core.ajaxException(t)}},context:this};if(i)for(o in i)f[o]=i[o];return n&&n.show(),e.io(u,f),this}},{NAME:"course-toolbox",ATTRS:{courseid:{value:0},format:{value:"topics"},ajaxurl:{value:null},config:{value:{}}}});var u=function(){u.superclass.constructor.apply(this,arguments)};e.extend(u,o,{GROUPS_NONE:0,GROUPS_SEPARATE:1,GROUPS_VISIBLE:2,edittitleevents:[],initializer:function(){M.course.coursebase.register_module(this),s.delegate("key",this.handle_data_action,"down:enter",r.ACTIVITYACTION,this),e.delegate("click",this.handle_data_action,s,r.ACTIVITYACTION,this)},handle_data_action:function(e){var t=e.target;t.test("a")||(t=t.ancestor(r.ACTIVITYACTION));var n=t.getData("action"),i=t.ancestor(r.ACTIVITYLI);if(!t.test("a")||!n||!i)return;switch(n){case"edittitle":this.edit_title(e,t,i,n);break;case"moveleft":case"moveright":this.change_indent(e,t,i,n);break;case"delete":this.delete_with_confirmation(e,t,i,n);break;case"duplicate":this.duplicate(e,t,i,n);break;case"hide":case"show":this.change_visibility(e,t,i,n);break;case"groupsseparate":case"groupsvisible":case"groupsnone":callback="change_groupmode",this.change_groupmode(e,t,i,n);break;case"move":case"update":case"duplicate":case"assignroles":break;default:}},add_spinner:function(t){var n=t.one(r.ACTIONAREA);return n?M.util.add_spinner(e,n):null},change_indent:function(t,s,o,u){t.preventDefault();var a=u==="moveleft"?-1:1,f=o.one(r.MODINDENTDIV),l=f.getAttribute("class").match(/mod-indent-(\d{1,})/),c=0,h;l&&(c=parseInt(l[1],10)),h=c+parseInt(a,10);if(hi.MAX)return;l&&f.removeClass(l[0]),f.addClass(n.MODINDENTCOUNT+h);var p={"class":"resource",field:"indent",value:h,id:e.Moodle.core_course.util.cm.getId(o)},d=this.add_spinner(o);this.send_request(p,d);var v;h===i.MIN?(s.addClass("hidden"),v=o.one(".editing_moveright")):h>i.MIN&&c===i.MIN&&s.ancestor(".menu").one("[data-action=moveleft]").removeClass("hidden"),h===i.MAX?(s.addClass("hidden"),v=o.one(".editing_moveleft")):h15&&!m?f.addClass(n.MODINDENTHUGE):h<=15&&m&&f.removeClass(n.MODINDENTHUGE),t.type&&t.type==="key"&&v&&v.focus()},delete_with_confirmation:function(t,n,r){t.preventDefault();var i=r,s="",o={type:M.util.get_string("pluginname",i.getAttribute("class").match(/modtype_([^\s]*)/)[1])};e.Moodle.core_course.util.cm.getName(i)!==null?(o.name=e.Moodle.core_course.util.cm.getName(i),s=M.util.get_string("deletechecktypename","moodle",o)):s=M.util.get_string("deletechecktype","moodle",o);var u=new M.core.confirm({question:s,modal:!0,visible:!1});return u.show(),u.on("complete-yes",function(){i.remove();var t={"class":"resource",action:"DELETE",id:e.Moodle.core_course.util.cm.getId(i)};this.send_request(t),M.core.actionmenu&&M.core.actionmenu.instance&&M.core.actionmenu.instance.hideMenu()},this),this},duplicate:function(t,n,r){t.preventDefault();var i=r,s=r.ancestor(M.course.format.get_section_selector(e)),o=M.util.add_lightbox(e,s).show(),u={"class":"resource",field:"duplicate",id:e.Moodle.core_course.util.cm.getId(i),sr:n.getData("sr")};return this.send_request(u,o,function(t){var n=e.Node.create(t.fullcontent);r.insert(n,"after"),e.use("moodle-course-coursebase",function(){M.course.coursebase.invoke_function("setup_for_resource",n)}),M.core.actionmenu&&M.core.actionmenu.newDOMNode&&M.core.actionmenu.newDOMNode(n)}),this},change_visibility:function(t,n,r,i){t.preventDefault();var s=r,o=this.handle_resource_dim(n,r,i),u={"class":"resource",field:"visible",value:o,id:e.Moodle.core_course.util.cm.getId(s)},a=this.add_spinner(s);return this.send_request(u,a),this},handle_resource_dim:function(t,i,s){var o=n.DIMCLASS,u=i.one([r.ACTIVITYLINK,r.CONTENTWITHOUTLINK].join(", ")),a=i.one(n.AVAILABILITYINFODIV),f=s==="hide"?"show":"hide",l=t.one("span"),c=M.util.get_string(f,"moodle"),h=t.one("img");return h.setAttrs({src:M.util.image_url("t/"+f)}),e.Lang.trim(t.getAttribute("title"))&&t.setAttribute("title",c),e.Lang.trim(h.getAttribute("alt"))&&h.setAttribute("alt",c),t.replaceClass("editing_"+s,"editing_"+f),t.setData("action",f),l&&l.set("text",c),i.one(r.CONTENTWITHOUTLINK -)&&(u=i.one(r.CONTENTWITHOUTLINK),o=n.DIMMEDTEXT),u.hasClass(n.CONDITIONALHIDDEN)||(s==="hide"?(u.addClass(o),i.all(r.CONTENTAFTERLINK).addClass(n.DIMMEDTEXT)):(u.removeClass(o),i.all(r.CONTENTAFTERLINK).removeClass(n.DIMMEDTEXT))),a&&a.toggleClass(n.HIDE),s==="hide"?0:1},change_groupmode:function(t,n,r){t.preventDefault();var i=parseInt(n.getData("nextgroupmode"),10),s="",o="",u,a,f,l=i+1,c=n.one("img");return l>2&&(l=0),i===this.GROUPS_NONE?(s="groupsnone",o=M.util.image_url("i/groupn","moodle")):i===this.GROUPS_SEPARATE?(s="groupsseparate",o=M.util.image_url("i/groups","moodle")):i===this.GROUPS_VISIBLE&&(s="groupsvisible",o=M.util.image_url("i/groupv","moodle")),u=M.util.get_string("clicktochangeinbrackets","moodle",M.util.get_string(s,"moodle")),c.setAttrs({src:o}),e.Lang.trim(n.getAttribute("title"))&&n.setAttribute("title",u).setData("action",s).setData("nextgroupmode",l),e.Lang.trim(c.getAttribute("alt"))&&c.setAttribute("alt",u),a={"class":"resource",field:"groupmode",value:i,id:e.Moodle.core_course.util.cm.getId(r)},f=this.add_spinner(r),this.send_request(a,f),this},edit_title:function(t,i,s){var o=e.Moodle.core_course.util.cm.getId(s),u=s.one(r.INSTANCENAME),a=s.one(r.ACTIVITYINSTANCE),f=u.get("firstChild"),l=f.get("data"),c=l,h,p=u.ancestor("a"),d={"class":"resource",field:"gettitle",id:o};return t.preventDefault(),this.send_request(d,null,function(t){M.core.actionmenu&&M.core.actionmenu.instance&&M.core.actionmenu.instance.hideMenu(),t.instancename&&(c=t.instancename);var i=e.Node.create('
'),o=e.Node.create('').set("innerHTML",M.util.get_string("edittitleinstructions","moodle")),u=e.Node.create('').setAttrs({value:c,autocomplete:"off","aria-describedby":"id_editinstructions",maxLength:"255"});i.appendChild(s.one(r.ACTIVITYICON).cloneNode()),i.appendChild(u),i.setData("anchor",p),a.insert(o,"before"),p.replace(i);var f="left";right_to_left()&&(f="right"),s.addClass(n.EDITINGTITLE),u.focus().select(),h=u.on("blur",this.edit_title_cancel,this,s,!1),this.edittitleevents.push(h),h=u.on("key",this.edit_title_cancel,"esc",this,s,!0),this.edittitleevents.push(h),h=i.on("submit",this.edit_title_submit,this,s,l),this.edittitleevents.push(h)}),this},edit_title_submit:function(t,n,i){t.preventDefault();var s=e.Lang.trim(n.one(r.ACTIVITYFORM+" "+r.ACTIVITYTITLE).get("value"));this.edit_title_clear(n);var o=this.add_spinner(n);if(s!==null&&s!==""&&s!==i){var u={"class":"resource",field:"updatetitle",title:s,id:e.Moodle.core_course.util.cm.getId(n)};this.send_request(u,o,function(e){e.instancename&&n.one(r.INSTANCENAME).setContent(e.instancename)})}},edit_title_cancel:function(e,t,n){n&&e.preventDefault(),this.edit_title_clear(t)},edit_title_clear:function(t){(new e.EventHandle(this.edittitleevents)).detach();var i=t.one(r.ACTIVITYFORM),s=t.one("#id_editinstructions");i&&i.replace(i.getData("anchor")),s&&s.remove(),t.removeClass(n.EDITINGTITLE),e.later(100,this,function(){t.one(r.EDITTITLE).focus()}),e.one("input[name=title]")||e.one("body").append('')},set_visibility_resource_ui:function(e){var t=e.element,n=t.one(r.HIDE),i=!0,s=!1;n||(n=t.one(r.SHOW),i=!1,s=!0),typeof e.visible!="undefined"&&(s=e.visible);if(i!==s){var o="hide";s&&(o="show"),this.handle_resource_dim(n,t,o)}}},{NAME:"course-resource-toolbox",ATTRS:{}}),M.course.resource_toolbox=null,M.course.init_resource_toolbox=function(e){return M.course.resource_toolbox=new u(e),M.course.resource_toolbox};var a=function(){a.superclass.constructor.apply(this,arguments)};e.extend(a,o,{initializer:function(){M.course.coursebase.register_module(this),e.delegate("click",this.toggle_highlight,r.PAGECONTENT,r.SECTIONLI+" "+r.HIGHLIGHT,this),e.delegate("click",this.toggle_hide_section,r.PAGECONTENT,r.SECTIONLI+" "+r.SHOWHIDE,this)},toggle_hide_section:function(t){t.preventDefault();var i=t.target.ancestor(M.course.format.get_section_selector(e)),s=t.target.ancestor("a",!0),o=s.one("img"),u,a,f;i.hasClass(n.SECTIONHIDDENCLASS)?(i.removeClass(n.SECTIONHIDDENCLASS),u=1,a="show",f="hide"):(i.addClass(n.SECTIONHIDDENCLASS),u=0,a="hide",f="show");var l=M.util.get_string(f+"fromothers","format_"+this.get("format"));o.setAttrs({alt:l,src:M.util.image_url("i/"+f)}),s.set("title",l);var c={"class":"section",field:"visible",id:e.Moodle.core_course.util.section.getId(i.ancestor(M.course.format.get_section_wrapper(e),!0)),value:u},h=M.util.add_lightbox(e,i);h.show(),this.send_request(c,h,function(t){var n=i.all(r.ACTIVITYLI);n.each(function(n){var i;n.one(r.SHOW)?i=n.one(r.SHOW):i=n.one(r.HIDE);var s=e.Moodle.core_course.util.cm.getId(n);e.Array.indexOf(t.resourcestotoggle,""+s)!==-1&&M.course.resource_toolbox.handle_resource_dim(i,n,a)},this)})},toggle_highlight:function(t){t.preventDefault();var n=t.target.ancestor(M.course.format.get_section_selector(e)),i=t.target.ancestor("a",!0),s=i.one("img"),o=n.hasClass("current"),u=0,a=M.util.get_string("markthistopic","moodle");e.one(r.PAGECONTENT).all(M.course.format.get_section_selector(e)+".current "+r.HIGHLIGHT).set("title",a),e.one(r.PAGECONTENT).all(M.course.format.get_section_selector(e)+".current "+r.HIGHLIGHT+" img").set("alt",a).set("src",M.util.image_url("i/marker")),e.one(r.PAGECONTENT).all(M.course.format.get_section_selector(e)).removeClass("current");if(!o){n.addClass("current"),u=e.Moodle.core_course.util.section.getId(n.ancestor(M.course.format.get_section_wrapper(e),!0));var f=M.util.get_string("markedthistopic","moodle");i.set("title",f),s.set("alt",f).set("src",M.util.image_url("i/marked"))}var l={"class":"course",field:"marker",value:u},c=M.util.add_lightbox(e,n);c.show(),this.send_request(l,c)}},{NAME:"course-section-toolbox",ATTRS:{}}),M.course.init_section_toolbox=function(e){return new a(e)}},"@VERSION@",{requires:["node","base","event-key","node","io","moodle-course-coursebase","moodle-course-util" +YUI.add("moodle-course-toolboxes",function(e,t){var n={ACTIVITYINSTANCE:"activityinstance",AVAILABILITYINFODIV:"div.availabilityinfo",CONTENTWITHOUTLINK:"contentwithoutlink",CONDITIONALHIDDEN:"conditionalhidden",DIMCLASS:"dimmed",DIMMEDTEXT:"dimmed_text",EDITINSTRUCTIONS:"editinstructions",EDITINGTITLE:"editor_displayed",HIDE:"hide",MODINDENTCOUNT:"mod-indent-",MODINDENTHUGE:"mod-indent-huge",MODULEIDPREFIX:"module-",SECTIONHIDDENCLASS:"hidden",SECTIONIDPREFIX:"section-",SHOW:"editing_show",TITLEEDITOR:"titleeditor"},r={ACTIONAREA:".actions",ACTIONLINKTEXT:".actionlinktext",ACTIVITYACTION:"a.cm-edit-action[data-action], a.editing_title",ACTIVITYFORM:"."+n.ACTIVITYINSTANCE+" form",ACTIVITYICON:"img.activityicon",ACTIVITYINSTANCE:"."+n.ACTIVITYINSTANCE,ACTIVITYLINK:"."+n.ACTIVITYINSTANCE+" > a",ACTIVITYLI:"li.activity",ACTIVITYTITLE:"input[name=title]",COMMANDSPAN:".commands",CONTENTAFTERLINK:"div.contentafterlink",CONTENTWITHOUTLINK:"div.contentwithoutlink",EDITTITLE:"a.editing_title",HIDE:"a.editing_hide",HIGHLIGHT:"a.editing_highlight",INSTANCENAME:"span.instancename",MODINDENTDIV:".mod-indent",MODINDENTOUTER:".mod-indent-outer",PAGECONTENT:"body",SECTIONLI:"li.section",SHOW:"a."+n.SHOW,SHOWHIDE:"a.editing_showhide"},i={MIN:0,MAX:16},s=e.one(document.body);M.course=M.course||{};var o=function(){o.superclass.constructor.apply(this,arguments)};e.extend(o,e.Base,{send_request:function(t,n,r,i){t||(t={});var s=this.get("config").pageparams,o;for(o in s)t[o]=s[o];t.sesskey=M.cfg.sesskey,t.courseId=this.get("courseid");var u=M.cfg.wwwroot+this.get("ajaxurl"),a=[],f={method:"POST",data:t,on:{success:function(t,i){try{a=e.JSON.parse(i.responseText),a.error&&new M.core.ajaxException(a)}catch(s){}r&&e.bind(r,this,a)(),n&&window.setTimeout(function(){n.hide()},400)},failure:function(e,t){n&&n.hide(),new M.core.ajaxException(t)}},context:this};if(i)for(o in i)f[o]=i[o];return n&&n.show(),e.io(u,f),this}},{NAME:"course-toolbox",ATTRS:{courseid:{value:0},format:{value:"topics"},ajaxurl:{value:null},config:{value:{}}}});var u=function(){u.superclass.constructor.apply(this,arguments)};e.extend(u,o,{GROUPS_NONE:0,GROUPS_SEPARATE:1,GROUPS_VISIBLE:2,edittitleevents:[],initializer:function(){M.course.coursebase.register_module(this),s.delegate("key",this.handle_data_action,"down:enter",r.ACTIVITYACTION,this),e.delegate("click",this.handle_data_action,s,r.ACTIVITYACTION,this)},handle_data_action:function(e){var t=e.target;t.test("a")||(t=t.ancestor(r.ACTIVITYACTION));var n=t.getData("action"),i=t.ancestor(r.ACTIVITYLI);if(!t.test("a")||!n||!i)return;switch(n){case"edittitle":this.edit_title(e,t,i,n);break;case"moveleft":case"moveright":this.change_indent(e,t,i,n);break;case"delete":this.delete_with_confirmation(e,t,i,n);break;case"duplicate":this.duplicate(e,t,i,n);break;case"hide":case"show":this.change_visibility(e,t,i,n);break;case"groupsseparate":case"groupsvisible":case"groupsnone":callback="change_groupmode",this.change_groupmode(e,t,i,n);break;case"move":case"update":case"duplicate":case"assignroles":break;default:}},add_spinner:function(t){var n=t.one(r.ACTIONAREA);return n?M.util.add_spinner(e,n):null},change_indent:function(t,s,o,u){t.preventDefault();var a=u==="moveleft"?-1:1,f=o.one(r.MODINDENTDIV),l=f.getAttribute("class").match(/mod-indent-(\d{1,})/),c=0,h;l&&(c=parseInt(l[1],10)),h=c+parseInt(a,10);if(hi.MAX)return;l&&f.removeClass(l[0]),f.addClass(n.MODINDENTCOUNT+h);var p={"class":"resource",field:"indent",value:h,id:e.Moodle.core_course.util.cm.getId(o)},d=this.add_spinner(o);this.send_request(p,d);var v;h===i.MIN?(s.addClass("hidden"),v=o.one(".editing_moveright")):h>i.MIN&&c===i.MIN&&s.ancestor(".menu").one("[data-action=moveleft]").removeClass("hidden"),h===i.MAX?(s.addClass("hidden"),v=o.one(".editing_moveleft")):h15&&!m?f.addClass(n.MODINDENTHUGE):h<=15&&m&&f.removeClass(n.MODINDENTHUGE),t.type&&t.type==="key"&&v&&v.focus()},delete_with_confirmation:function(t,n,r){t.preventDefault();var i=r,s="",o={type:M.util.get_string("pluginname",i.getAttribute("class").match(/modtype_([^\s]*)/)[1])};e.Moodle.core_course.util.cm.getName(i)!==null?(o.name=e.Moodle.core_course.util.cm.getName(i),s=M.util.get_string("deletechecktypename","moodle",o)):s=M.util.get_string("deletechecktype","moodle",o);var u=new M.core.confirm({question:s,modal:!0,visible:!1});return u.show(),u.on("complete-yes",function(){i.remove();var n={"class":"resource",action:"DELETE",id:e.Moodle.core_course.util.cm.getId(i)};this.send_request(n),M.core.actionmenu&&M.core.actionmenu.instance&&M.core.actionmenu.instance.hideMenu(t)},this),this},duplicate:function(t,n,r){t.preventDefault();var i=r,s=r.ancestor(M.course.format.get_section_selector(e)),o=M.util.add_lightbox(e,s).show(),u={"class":"resource",field:"duplicate",id:e.Moodle.core_course.util.cm.getId(i),sr:n.getData("sr")};return this.send_request(u,o,function(t){var n=e.Node.create(t.fullcontent);r.insert(n,"after"),e.use("moodle-course-coursebase",function(){M.course.coursebase.invoke_function("setup_for_resource",n)}),M.core.actionmenu&&M.core.actionmenu.newDOMNode&&M.core.actionmenu.newDOMNode(n)}),this},change_visibility:function(t,n,r,i){t.preventDefault();var s=r,o=this.handle_resource_dim(n,r,i),u={"class":"resource",field:"visible",value:o,id:e.Moodle.core_course.util.cm.getId(s)},a=this.add_spinner(s);return this.send_request(u,a),this},handle_resource_dim:function(t,i,s){var o=n.DIMCLASS,u=i.one([r.ACTIVITYLINK,r.CONTENTWITHOUTLINK].join(", ")),a=i.one(n.AVAILABILITYINFODIV),f=s==="hide"?"show":"hide",l=t.one("span"),c=M.util.get_string(f,"moodle"),h=t.one("img");return h.setAttrs({src:M.util.image_url("t/"+f)}),e.Lang.trim(t.getAttribute("title"))&&t.setAttribute("title",c),e.Lang.trim(h.getAttribute("alt"))&&h.setAttribute("alt",c),t.replaceClass("editing_"+s,"editing_"+f),t.setData("action",f),l&&l.set("text",c),i.one(r.CONTENTWITHOUTLINK +)&&(u=i.one(r.CONTENTWITHOUTLINK),o=n.DIMMEDTEXT),u.hasClass(n.CONDITIONALHIDDEN)||(s==="hide"?(u.addClass(o),i.all(r.CONTENTAFTERLINK).addClass(n.DIMMEDTEXT)):(u.removeClass(o),i.all(r.CONTENTAFTERLINK).removeClass(n.DIMMEDTEXT))),a&&a.toggleClass(n.HIDE),s==="hide"?0:1},change_groupmode:function(t,n,r){t.preventDefault();var i=parseInt(n.getData("nextgroupmode"),10),s="",o="",u,a,f,l=i+1,c=n.one("img");return l>2&&(l=0),i===this.GROUPS_NONE?(s="groupsnone",o=M.util.image_url("i/groupn","moodle")):i===this.GROUPS_SEPARATE?(s="groupsseparate",o=M.util.image_url("i/groups","moodle")):i===this.GROUPS_VISIBLE&&(s="groupsvisible",o=M.util.image_url("i/groupv","moodle")),u=M.util.get_string("clicktochangeinbrackets","moodle",M.util.get_string(s,"moodle")),c.setAttrs({src:o}),e.Lang.trim(n.getAttribute("title"))&&n.setAttribute("title",u).setData("action",s).setData("nextgroupmode",l),e.Lang.trim(c.getAttribute("alt"))&&c.setAttribute("alt",u),a={"class":"resource",field:"groupmode",value:i,id:e.Moodle.core_course.util.cm.getId(r)},f=this.add_spinner(r),this.send_request(a,f),this},edit_title:function(t,i,s){var o=e.Moodle.core_course.util.cm.getId(s),u=s.one(r.INSTANCENAME),a=s.one(r.ACTIVITYINSTANCE),f=u.get("firstChild"),l=f.get("data"),c=l,h,p=u.ancestor("a"),d={"class":"resource",field:"gettitle",id:o};return t.preventDefault(),this.send_request(d,null,function(i){M.core.actionmenu&&M.core.actionmenu.instance&&M.core.actionmenu.instance.hideMenu(t),i.instancename&&(c=i.instancename);var o=e.Node.create(''),u=e.Node.create('').set("innerHTML",M.util.get_string("edittitleinstructions","moodle")),f=e.Node.create('').setAttrs({value:c,autocomplete:"off","aria-describedby":"id_editinstructions",maxLength:"255"});o.appendChild(s.one(r.ACTIVITYICON).cloneNode()),o.appendChild(f),o.setData("anchor",p),a.insert(u,"before"),p.replace(o);var d="left";right_to_left()&&(d="right"),s.addClass(n.EDITINGTITLE),f.focus().select(),h=f.on("blur",this.edit_title_cancel,this,s,!1),this.edittitleevents.push(h),h=f.on("key",this.edit_title_cancel,"esc",this,s,!0),this.edittitleevents.push(h),h=o.on("submit",this.edit_title_submit,this,s,l),this.edittitleevents.push(h)}),this},edit_title_submit:function(t,n,i){t.preventDefault();var s=e.Lang.trim(n.one(r.ACTIVITYFORM+" "+r.ACTIVITYTITLE).get("value"));this.edit_title_clear(n);var o=this.add_spinner(n);if(s!==null&&s!==""&&s!==i){var u={"class":"resource",field:"updatetitle",title:s,id:e.Moodle.core_course.util.cm.getId(n)};this.send_request(u,o,function(e){e.instancename&&n.one(r.INSTANCENAME).setContent(e.instancename)})}},edit_title_cancel:function(e,t,n){n&&e.preventDefault(),this.edit_title_clear(t)},edit_title_clear:function(t){(new e.EventHandle(this.edittitleevents)).detach();var i=t.one(r.ACTIVITYFORM),s=t.one("#id_editinstructions");i&&i.replace(i.getData("anchor")),s&&s.remove(),t.removeClass(n.EDITINGTITLE),e.later(100,this,function(){t.one(r.EDITTITLE).focus()}),e.one("input[name=title]")||e.one("body").append('')},set_visibility_resource_ui:function(e){var t=e.element,n=t.one(r.HIDE),i=!0,s=!1;n||(n=t.one(r.SHOW),i=!1,s=!0),typeof e.visible!="undefined"&&(s=e.visible);if(i!==s){var o="hide";s&&(o="show"),this.handle_resource_dim(n,t,o)}}},{NAME:"course-resource-toolbox",ATTRS:{}}),M.course.resource_toolbox=null,M.course.init_resource_toolbox=function(e){return M.course.resource_toolbox=new u(e),M.course.resource_toolbox};var a=function(){a.superclass.constructor.apply(this,arguments)};e.extend(a,o,{initializer:function(){M.course.coursebase.register_module(this),e.delegate("click",this.toggle_highlight,r.PAGECONTENT,r.SECTIONLI+" "+r.HIGHLIGHT,this),e.delegate("click",this.toggle_hide_section,r.PAGECONTENT,r.SECTIONLI+" "+r.SHOWHIDE,this)},toggle_hide_section:function(t){t.preventDefault();var i=t.target.ancestor(M.course.format.get_section_selector(e)),s=t.target.ancestor("a",!0),o=s.one("img"),u,a,f;i.hasClass(n.SECTIONHIDDENCLASS)?(i.removeClass(n.SECTIONHIDDENCLASS),u=1,a="show",f="hide"):(i.addClass(n.SECTIONHIDDENCLASS),u=0,a="hide",f="show");var l=M.util.get_string(f+"fromothers","format_"+this.get("format"));o.setAttrs({alt:l,src:M.util.image_url("i/"+f)}),s.set("title",l);var c={"class":"section",field:"visible",id:e.Moodle.core_course.util.section.getId(i.ancestor(M.course.format.get_section_wrapper(e),!0)),value:u},h=M.util.add_lightbox(e,i);h.show(),this.send_request(c,h,function(t){var n=i.all(r.ACTIVITYLI);n.each(function(n){var i;n.one(r.SHOW)?i=n.one(r.SHOW):i=n.one(r.HIDE);var s=e.Moodle.core_course.util.cm.getId(n);e.Array.indexOf(t.resourcestotoggle,""+s)!==-1&&M.course.resource_toolbox.handle_resource_dim(i,n,a)},this)})},toggle_highlight:function(t){t.preventDefault();var n=t.target.ancestor(M.course.format.get_section_selector(e)),i=t.target.ancestor("a",!0),s=i.one("img"),o=n.hasClass("current"),u=0,a=M.util.get_string("markthistopic","moodle");e.one(r.PAGECONTENT).all(M.course.format.get_section_selector(e)+".current "+r.HIGHLIGHT).set("title",a),e.one(r.PAGECONTENT).all(M.course.format.get_section_selector(e)+".current "+r.HIGHLIGHT+" img").set("alt",a).set("src",M.util.image_url("i/marker")),e.one(r.PAGECONTENT).all(M.course.format.get_section_selector(e)).removeClass("current");if(!o){n.addClass("current"),u=e.Moodle.core_course.util.section.getId(n.ancestor(M.course.format.get_section_wrapper(e),!0));var f=M.util.get_string("markedthistopic","moodle");i.set("title",f),s.set("alt",f).set("src",M.util.image_url("i/marked"))}var l={"class":"course",field:"marker",value:u},c=M.util.add_lightbox(e,n);c.show(),this.send_request(l,c)}},{NAME:"course-section-toolbox",ATTRS:{}}),M.course.init_section_toolbox=function(e){return new a(e)}},"@VERSION@",{requires:["node","base","event-key","node","io","moodle-course-coursebase","moodle-course-util" ]}); diff --git a/course/yui/build/moodle-course-toolboxes/moodle-course-toolboxes.js b/course/yui/build/moodle-course-toolboxes/moodle-course-toolboxes.js index ed1e8266009..5f25c8972ce 100644 --- a/course/yui/build/moodle-course-toolboxes/moodle-course-toolboxes.js +++ b/course/yui/build/moodle-course-toolboxes/moodle-course-toolboxes.js @@ -498,7 +498,7 @@ Y.extend(RESOURCETOOLBOX, TOOLBOX, { }; this.send_request(data); if (M.core.actionmenu && M.core.actionmenu.instance) { - M.core.actionmenu.instance.hideMenu(); + M.core.actionmenu.instance.hideMenu(ev); } }, this); @@ -745,7 +745,7 @@ Y.extend(RESOURCETOOLBOX, TOOLBOX, { this.send_request(data, null, function(response) { if (M.core.actionmenu && M.core.actionmenu.instance) { - M.core.actionmenu.instance.hideMenu(); + M.core.actionmenu.instance.hideMenu(ev); } // Try to retrieve the existing string from the server diff --git a/course/yui/src/toolboxes/js/resource.js b/course/yui/src/toolboxes/js/resource.js index b738d401940..ac420c85fc0 100644 --- a/course/yui/src/toolboxes/js/resource.js +++ b/course/yui/src/toolboxes/js/resource.js @@ -294,7 +294,7 @@ Y.extend(RESOURCETOOLBOX, TOOLBOX, { }; this.send_request(data); if (M.core.actionmenu && M.core.actionmenu.instance) { - M.core.actionmenu.instance.hideMenu(); + M.core.actionmenu.instance.hideMenu(ev); } }, this); @@ -541,7 +541,7 @@ Y.extend(RESOURCETOOLBOX, TOOLBOX, { this.send_request(data, null, function(response) { if (M.core.actionmenu && M.core.actionmenu.instance) { - M.core.actionmenu.instance.hideMenu(); + M.core.actionmenu.instance.hideMenu(ev); } // Try to retrieve the existing string from the server diff --git a/lib/upgrade.txt b/lib/upgrade.txt index 20bbcf34914..17a086d975a 100644 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@ -1,6 +1,12 @@ This files describes API changes in core libraries and APIs, information provided here is intended especially for developers. +=== 2.8.8 === + +* The actionmenu hideMenu() function now expects an EventFacade object to be passed to it, + i.e. a call to M.core.actionmenu.instance.hideMenu() can be changed to M.core.actionmenu.instance.hideMenu(e) to ensure good + behaviour when using custom action menus. + === 2.8.7 === * New methods grade_grade::get_grade_max() and get_grade_min() must be used rather than directly the public properties rawgrademax and rawgrademin. 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 3627925630a..adacafb2282 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 @@ -246,9 +246,10 @@ ACTIONMENU.prototype = { /** * Hides the menu if it is visible. + * @param {EventFacade} e * @method hideMenu */ - hideMenu : function() { + hideMenu : function(e) { if (this.dialogue) { Y.log('Hiding an action menu', 'debug', ACTIONMENU.NAME); this.dialogue.removeClass('show'); @@ -267,7 +268,10 @@ ACTIONMENU.prototype = { } if (this.menulink) { - this.menulink.focus(); + if (!e || e.type != 'click') { + // We needed to test !e to retain backwards compatiablity if the event is not passed. + this.menulink.focus(); + } this.menulink = null; } }, @@ -294,7 +298,7 @@ ACTIONMENU.prototype = { // Prevent event propagation as it will trigger the hideIfOutside event handler in certain situations. e.halt(true); - this.hideMenu(); + this.hideMenu(e); if (menuvisible) { // The menu was visible and the user has clicked to toggle it again. return; @@ -323,7 +327,7 @@ ACTIONMENU.prototype = { this.lastMenuChild.focus(); e.preventDefault(); } else if (e.keyCode === 9 && e.shiftKey) { - this.hideMenu(); + this.hideMenu(e); e.preventDefault(); } return this; @@ -331,7 +335,7 @@ ACTIONMENU.prototype = { if (e.keyCode === 27) { // The escape key was pressed so close the menu. - this.hideMenu(); + this.hideMenu(e); e.preventDefault(); } else if (e.keyCode === 32) { @@ -342,10 +346,10 @@ ACTIONMENU.prototype = { // The tab key was pressed. Tab moves forwards, Shift + Tab moves backwards through the menu options. // We only override the Shift + Tab on the first option, and Tab on the last option to change where the focus is moved to. if (e.target === this.firstMenuChild && e.shiftKey) { - this.hideMenu(); + this.hideMenu(e); e.preventDefault(); } else if (e.target === this.lastMenuChild && !e.shiftKey) { - if (this.hideMenu()) { + if (this.hideMenu(e)) { // Determine the next selector and focus on it. next = this.menulink.next(SELECTOR.CAN_RECEIVE_FOCUS_SELECTOR); if (next) { @@ -412,7 +416,7 @@ ACTIONMENU.prototype = { */ hideIfOutside : function(e) { if (!e.target.ancestor(SELECTOR.MENUCHILD, true)) { - this.hideMenu(); + this.hideMenu(e); } }, @@ -464,7 +468,7 @@ ACTIONMENU.prototype = { if (e.currentTarget.test(SELECTOR.KEEPOPEN)) { return; } - this.hideMenu(); + this.hideMenu(e); }, SELECTOR.MENUCHILD, this)); return true; 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 38f3d5e2592..40f2b5077f4 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;if(!n)return null;r=n.all(i.MENUITEMS.join(","));if(!r)return null;var s=r.size();if(s===1)return null;var o=0,u=1,a=0;for(o=0;o=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;if(!n)return null;r=n.all(i.MENUITEMS.join(","));if(!r)return null;var s=r.size();if(s===1)return null;var o=0,u=1,a=0;for(o=0;o=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"]}); 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 ebfa02f2edb..2c1d8224c50 100644 --- a/lib/yui/build/moodle-core-actionmenu/moodle-core-actionmenu.js +++ b/lib/yui/build/moodle-core-actionmenu/moodle-core-actionmenu.js @@ -245,9 +245,10 @@ ACTIONMENU.prototype = { /** * Hides the menu if it is visible. + * @param {EventFacade} e * @method hideMenu */ - hideMenu : function() { + hideMenu : function(e) { if (this.dialogue) { this.dialogue.removeClass('show'); this.dialogue.one(SELECTOR.MENUCONTENT).set('aria-hidden', true); @@ -265,7 +266,10 @@ ACTIONMENU.prototype = { } if (this.menulink) { - this.menulink.focus(); + if (!e || e.type != 'click') { + // We needed to test !e to retain backwards compatiablity if the event is not passed. + this.menulink.focus(); + } this.menulink = null; } }, @@ -292,7 +296,7 @@ ACTIONMENU.prototype = { // Prevent event propagation as it will trigger the hideIfOutside event handler in certain situations. e.halt(true); - this.hideMenu(); + this.hideMenu(e); if (menuvisible) { // The menu was visible and the user has clicked to toggle it again. return; @@ -321,7 +325,7 @@ ACTIONMENU.prototype = { this.lastMenuChild.focus(); e.preventDefault(); } else if (e.keyCode === 9 && e.shiftKey) { - this.hideMenu(); + this.hideMenu(e); e.preventDefault(); } return this; @@ -329,7 +333,7 @@ ACTIONMENU.prototype = { if (e.keyCode === 27) { // The escape key was pressed so close the menu. - this.hideMenu(); + this.hideMenu(e); e.preventDefault(); } else if (e.keyCode === 32) { @@ -340,10 +344,10 @@ ACTIONMENU.prototype = { // The tab key was pressed. Tab moves forwards, Shift + Tab moves backwards through the menu options. // We only override the Shift + Tab on the first option, and Tab on the last option to change where the focus is moved to. if (e.target === this.firstMenuChild && e.shiftKey) { - this.hideMenu(); + this.hideMenu(e); e.preventDefault(); } else if (e.target === this.lastMenuChild && !e.shiftKey) { - if (this.hideMenu()) { + if (this.hideMenu(e)) { // Determine the next selector and focus on it. next = this.menulink.next(SELECTOR.CAN_RECEIVE_FOCUS_SELECTOR); if (next) { @@ -409,7 +413,7 @@ ACTIONMENU.prototype = { */ hideIfOutside : function(e) { if (!e.target.ancestor(SELECTOR.MENUCHILD, true)) { - this.hideMenu(); + this.hideMenu(e); } }, @@ -460,7 +464,7 @@ ACTIONMENU.prototype = { if (e.currentTarget.test(SELECTOR.KEEPOPEN)) { return; } - this.hideMenu(); + this.hideMenu(e); }, SELECTOR.MENUCHILD, this)); return true; diff --git a/lib/yui/src/actionmenu/js/actionmenu.js b/lib/yui/src/actionmenu/js/actionmenu.js index d11ee862295..ba617fa3ddf 100644 --- a/lib/yui/src/actionmenu/js/actionmenu.js +++ b/lib/yui/src/actionmenu/js/actionmenu.js @@ -244,9 +244,10 @@ ACTIONMENU.prototype = { /** * Hides the menu if it is visible. + * @param {EventFacade} e * @method hideMenu */ - hideMenu : function() { + hideMenu : function(e) { if (this.dialogue) { Y.log('Hiding an action menu', 'debug', ACTIONMENU.NAME); this.dialogue.removeClass('show'); @@ -265,7 +266,10 @@ ACTIONMENU.prototype = { } if (this.menulink) { - this.menulink.focus(); + if (!e || e.type != 'click') { + // We needed to test !e to retain backwards compatiablity if the event is not passed. + this.menulink.focus(); + } this.menulink = null; } }, @@ -292,7 +296,7 @@ ACTIONMENU.prototype = { // Prevent event propagation as it will trigger the hideIfOutside event handler in certain situations. e.halt(true); - this.hideMenu(); + this.hideMenu(e); if (menuvisible) { // The menu was visible and the user has clicked to toggle it again. return; @@ -321,7 +325,7 @@ ACTIONMENU.prototype = { this.lastMenuChild.focus(); e.preventDefault(); } else if (e.keyCode === 9 && e.shiftKey) { - this.hideMenu(); + this.hideMenu(e); e.preventDefault(); } return this; @@ -329,7 +333,7 @@ ACTIONMENU.prototype = { if (e.keyCode === 27) { // The escape key was pressed so close the menu. - this.hideMenu(); + this.hideMenu(e); e.preventDefault(); } else if (e.keyCode === 32) { @@ -340,10 +344,10 @@ ACTIONMENU.prototype = { // The tab key was pressed. Tab moves forwards, Shift + Tab moves backwards through the menu options. // We only override the Shift + Tab on the first option, and Tab on the last option to change where the focus is moved to. if (e.target === this.firstMenuChild && e.shiftKey) { - this.hideMenu(); + this.hideMenu(e); e.preventDefault(); } else if (e.target === this.lastMenuChild && !e.shiftKey) { - if (this.hideMenu()) { + if (this.hideMenu(e)) { // Determine the next selector and focus on it. next = this.menulink.next(SELECTOR.CAN_RECEIVE_FOCUS_SELECTOR); if (next) { @@ -410,7 +414,7 @@ ACTIONMENU.prototype = { */ hideIfOutside : function(e) { if (!e.target.ancestor(SELECTOR.MENUCHILD, true)) { - this.hideMenu(); + this.hideMenu(e); } }, @@ -462,7 +466,7 @@ ACTIONMENU.prototype = { if (e.currentTarget.test(SELECTOR.KEEPOPEN)) { return; } - this.hideMenu(); + this.hideMenu(e); }, SELECTOR.MENUCHILD, this)); return true; diff --git a/mod/quiz/yui/build/moodle-mod_quiz-toolboxes/moodle-mod_quiz-toolboxes-debug.js b/mod/quiz/yui/build/moodle-mod_quiz-toolboxes/moodle-mod_quiz-toolboxes-debug.js index 6d416dfdfe1..b5b10e951c3 100644 --- a/mod/quiz/yui/build/moodle-mod_quiz-toolboxes/moodle-mod_quiz-toolboxes-debug.js +++ b/mod/quiz/yui/build/moodle-mod_quiz-toolboxes/moodle-mod_quiz-toolboxes-debug.js @@ -386,7 +386,7 @@ Y.extend(RESOURCETOOLBOX, TOOLBOX, { Y.Moodle.mod_quiz.util.slot.remove(element); this.reorganise_edit_page(); if (M.core.actionmenu && M.core.actionmenu.instance) { - M.core.actionmenu.instance.hideMenu(); + M.core.actionmenu.instance.hideMenu(ev); } } else { window.location.reload(true); @@ -431,7 +431,7 @@ Y.extend(RESOURCETOOLBOX, TOOLBOX, { this.send_request(data, null, function(response) { if (M.core.actionmenu && M.core.actionmenu.instance) { - M.core.actionmenu.instance.hideMenu(); + M.core.actionmenu.instance.hideMenu(ev); } // Try to retrieve the existing string from the server. diff --git a/mod/quiz/yui/build/moodle-mod_quiz-toolboxes/moodle-mod_quiz-toolboxes-min.js b/mod/quiz/yui/build/moodle-mod_quiz-toolboxes/moodle-mod_quiz-toolboxes-min.js index c8e6785c46b..7dbcffdcb0f 100644 --- a/mod/quiz/yui/build/moodle-mod_quiz-toolboxes/moodle-mod_quiz-toolboxes-min.js +++ b/mod/quiz/yui/build/moodle-mod_quiz-toolboxes/moodle-mod_quiz-toolboxes-min.js @@ -1,2 +1,2 @@ -YUI.add("moodle-mod_quiz-toolboxes",function(e,t){var n={ACTIVITYINSTANCE:"activityinstance",AVAILABILITYINFODIV:"div.availabilityinfo",CONTENTWITHOUTLINK:"contentwithoutlink",CONDITIONALHIDDEN:"conditionalhidden",DIMCLASS:"dimmed",DIMMEDTEXT:"dimmed_text",EDITINSTRUCTIONS:"editinstructions",EDITINGMAXMARK:"editor_displayed",HIDE:"hide",JOIN:"page_join",MODINDENTCOUNT:"mod-indent-",MODINDENTHUGE:"mod-indent-huge",MODULEIDPREFIX:"slot-",PAGE:"page",SECTIONHIDDENCLASS:"hidden",SECTIONIDPREFIX:"section-",SLOT:"slot",SHOW:"editing_show",TITLEEDITOR:"titleeditor"},r={ACTIONAREA:".actions",ACTIONLINKTEXT:".actionlinktext",ACTIVITYACTION:"a.cm-edit-action[data-action], a.editing_maxmark",ACTIVITYFORM:"span.instancemaxmarkcontainer form",ACTIVITYICON:"img.activityicon",ACTIVITYINSTANCE:"."+n.ACTIVITYINSTANCE,ACTIVITYLINK:"."+n.ACTIVITYINSTANCE+" > a",ACTIVITYLI:"li.activity",ACTIVITYMAXMARK:"input[name=maxmark]",COMMANDSPAN:".commands",CONTENTAFTERLINK:"div.contentafterlink",CONTENTWITHOUTLINK:"div.contentwithoutlink",EDITMAXMARK:"a.editing_maxmark",HIDE:"a.editing_hide",HIGHLIGHT:"a.editing_highlight",INSTANCENAME:"span.instancename",INSTANCEMAXMARK:"span.instancemaxmark",MODINDENTDIV:".mod-indent",MODINDENTOUTER:".mod-indent-outer",NUMQUESTIONS:".numberofquestions",PAGECONTENT:"div#page-content",PAGELI:"li.page",SECTIONUL:"ul.section",SHOW:"a."+n.SHOW,SHOWHIDE:"a.editing_showhide",SLOTLI:"li.slot",SUMMARKS:".mod_quiz_summarks"},i=e.one(document.body);M.mod_quiz=M.mod_quiz||{};var s=function(){s.superclass.constructor.apply(this,arguments)};e.extend(s,e.Base,{send_request:function(t,n,i,s){t||(t={});var o=this.get("config").pageparams,u;for(u in o)t[u]=o[u];t.sesskey=M.cfg.sesskey,t.courseid=this.get("courseid"),t.quizid=this.get("quizid");var a=M.cfg.wwwroot+this.get("ajaxurl"),f=[],l={method:"POST",data:t,on:{success:function(t,s){try{f=e.JSON.parse(s.responseText),f.error&&new M.core.ajaxException(f)}catch(o){}f.hasOwnProperty("newsummarks")&&e.one(r.SUMMARKS).setHTML(f.newsummarks),f.hasOwnProperty("newnumquestions")&&e.one(r.NUMQUESTIONS).setHTML(M.util.get_string("numquestionsx","quiz",f.newnumquestions)),i&&e.bind(i,this,f)(),n&&window.setTimeout(function(){n.hide()},400)},failure:function(e,t){n&&n.hide(),new M.core.ajaxException(t)}},context:this};if(s)for(u in s)l[u]=s[u];return n&&n.show(),e.io(a,l),this}},{NAME:"mod_quiz-toolbox",ATTRS:{courseid:{value:0},quizid:{value:0},ajaxurl:{value:null},config:{value:{}}}});var o=function(){o.superclass.constructor.apply(this,arguments)};e.extend(o,s,{editmaxmarkevents:[],NODE_PAGE:1,NODE_SLOT:2,NODE_JOIN:3,initializer:function(){M.mod_quiz.quizbase.register_module(this),i.delegate("key",this.handle_data_action,"down:enter",r.ACTIVITYACTION,this),e.delegate("click",this.handle_data_action,i,r.ACTIVITYACTION,this)},handle_data_action:function(e){var t=e.target;t.test("a")||(t=t.ancestor(r.ACTIVITYACTION));var n=t.getData("action"),i=t.ancestor(r.ACTIVITYLI);if(!t.test("a")||!n||!i)return;switch(n){case"editmaxmark":this.edit_maxmark(e,t,i,n);break;case"delete":this.delete_with_confirmation(e,t,i,n);break;case"addpagebreak":case"removepagebreak":this.update_page_break(e,t,i,n);break;default:}},add_spinner:function(t){var n=t.one(r.ACTIONAREA);return n?M.util.add_spinner(e,n):null},delete_with_confirmation:function(t,n,r){t.preventDefault();var i=r,s="",o=M.util.get_string("pluginname","qtype_"+i.getAttribute("class").match(/qtype_([^\s]*)/)[1]);s=M.util.get_string("confirmremovequestion","quiz",o);var u=new M.core.confirm({question:s,modal:!0});return u.on("complete-yes",function(){var t=this.add_spinner(i),n={"class":"resource",action:"DELETE",id:e.Moodle.mod_quiz.util.slot.getId(i)};this.send_request(n,t,function(t){t.deleted?(e.Moodle.mod_quiz.util.slot.remove(i),this.reorganise_edit_page(),M.core.actionmenu&&M.core.actionmenu.instance&&M.core.actionmenu.instance.hideMenu()):window.location.reload(!0)})},this),this},edit_maxmark:function(t,i,s){var o=e.Moodle.mod_quiz.util.slot.getId(s),u=s.one(r.INSTANCEMAXMARK),a=s.one(r.ACTIVITYINSTANCE),f=u.get("firstChild"),l=f.get("data"),c=l,h,p=u,d={"class":"resource",field:"getmaxmark",id:o};t.preventDefault(),this.send_request(d,null,function(t){M.core.actionmenu&&M.core.actionmenu.instance&&M.core.actionmenu.instance.hideMenu(),t.instancemaxmark&&(c=t.instancemaxmark);var r=e.Node.create(''),i=e.Node.create('').set("innerHTML",M.util.get_string("edittitleinstructions","moodle")),o=e.Node.create('').setAttrs({value:c,autocomplete:"off","aria-describedby":"id_editinstructions",maxLength:"12",size:parseInt(this.get("config").questiondecimalpoints,10)+2});r.appendChild(o),r.setData("anchor",p),a.insert(i,"before"),p.replace(r);var u="left";right_to_left()&&(u="right"),s.addClass(n.EDITINGMAXMARK),o.focus().select(),h=o.on("blur",this.edit_maxmark_cancel,this,s,!1),this.editmaxmarkevents.push(h),h=o.on("key",this.edit_maxmark_cancel,"esc",this,s,!0),this.editmaxmarkevents.push(h),h=r.on("submit",this.edit_maxmark_submit,this,s,l),this.editmaxmarkevents.push(h)})},edit_maxmark_submit:function(t,n,i){t.preventDefault();var s=e.Lang.trim(n.one(r.ACTIVITYFORM+" "+r.ACTIVITYMAXMARK).get("value")),o=this.add_spinner(n);this.edit_maxmark_clear(n),n.one(r.INSTANCEMAXMARK).setContent(s);if(s!==null&&s!==""&&s!==i){var u={"class":"resource",field:"updatemaxmark",maxmark:s,id:e.Moodle.mod_quiz.util.slot.getId(n)};this.send_request(u,o,function(e){e.instancemaxmark&&n.one(r.INSTANCEMAXMARK).setContent(e.instancemaxmark)})}},edit_maxmark_cancel:function(e,t,n){n&&e.preventDefault(),this.edit_maxmark_clear(t)},edit_maxmark_clear:function(t){(new e.EventHandle(this.editmaxmarkevents)).detach();var i=t.one(r.ACTIVITYFORM),s=t.one("#id_editinstructions");i&&i.replace(i.getData("anchor")),s&&s.remove(),t.removeClass(n.EDITINGMAXMARK),e.later(100,this,function(){t.one(r.EDITMAXMARK +YUI.add("moodle-mod_quiz-toolboxes",function(e,t){var n={ACTIVITYINSTANCE:"activityinstance",AVAILABILITYINFODIV:"div.availabilityinfo",CONTENTWITHOUTLINK:"contentwithoutlink",CONDITIONALHIDDEN:"conditionalhidden",DIMCLASS:"dimmed",DIMMEDTEXT:"dimmed_text",EDITINSTRUCTIONS:"editinstructions",EDITINGMAXMARK:"editor_displayed",HIDE:"hide",JOIN:"page_join",MODINDENTCOUNT:"mod-indent-",MODINDENTHUGE:"mod-indent-huge",MODULEIDPREFIX:"slot-",PAGE:"page",SECTIONHIDDENCLASS:"hidden",SECTIONIDPREFIX:"section-",SLOT:"slot",SHOW:"editing_show",TITLEEDITOR:"titleeditor"},r={ACTIONAREA:".actions",ACTIONLINKTEXT:".actionlinktext",ACTIVITYACTION:"a.cm-edit-action[data-action], a.editing_maxmark",ACTIVITYFORM:"span.instancemaxmarkcontainer form",ACTIVITYICON:"img.activityicon",ACTIVITYINSTANCE:"."+n.ACTIVITYINSTANCE,ACTIVITYLINK:"."+n.ACTIVITYINSTANCE+" > a",ACTIVITYLI:"li.activity",ACTIVITYMAXMARK:"input[name=maxmark]",COMMANDSPAN:".commands",CONTENTAFTERLINK:"div.contentafterlink",CONTENTWITHOUTLINK:"div.contentwithoutlink",EDITMAXMARK:"a.editing_maxmark",HIDE:"a.editing_hide",HIGHLIGHT:"a.editing_highlight",INSTANCENAME:"span.instancename",INSTANCEMAXMARK:"span.instancemaxmark",MODINDENTDIV:".mod-indent",MODINDENTOUTER:".mod-indent-outer",NUMQUESTIONS:".numberofquestions",PAGECONTENT:"div#page-content",PAGELI:"li.page",SECTIONUL:"ul.section",SHOW:"a."+n.SHOW,SHOWHIDE:"a.editing_showhide",SLOTLI:"li.slot",SUMMARKS:".mod_quiz_summarks"},i=e.one(document.body);M.mod_quiz=M.mod_quiz||{};var s=function(){s.superclass.constructor.apply(this,arguments)};e.extend(s,e.Base,{send_request:function(t,n,i,s){t||(t={});var o=this.get("config").pageparams,u;for(u in o)t[u]=o[u];t.sesskey=M.cfg.sesskey,t.courseid=this.get("courseid"),t.quizid=this.get("quizid");var a=M.cfg.wwwroot+this.get("ajaxurl"),f=[],l={method:"POST",data:t,on:{success:function(t,s){try{f=e.JSON.parse(s.responseText),f.error&&new M.core.ajaxException(f)}catch(o){}f.hasOwnProperty("newsummarks")&&e.one(r.SUMMARKS).setHTML(f.newsummarks),f.hasOwnProperty("newnumquestions")&&e.one(r.NUMQUESTIONS).setHTML(M.util.get_string("numquestionsx","quiz",f.newnumquestions)),i&&e.bind(i,this,f)(),n&&window.setTimeout(function(){n.hide()},400)},failure:function(e,t){n&&n.hide(),new M.core.ajaxException(t)}},context:this};if(s)for(u in s)l[u]=s[u];return n&&n.show(),e.io(a,l),this}},{NAME:"mod_quiz-toolbox",ATTRS:{courseid:{value:0},quizid:{value:0},ajaxurl:{value:null},config:{value:{}}}});var o=function(){o.superclass.constructor.apply(this,arguments)};e.extend(o,s,{editmaxmarkevents:[],NODE_PAGE:1,NODE_SLOT:2,NODE_JOIN:3,initializer:function(){M.mod_quiz.quizbase.register_module(this),i.delegate("key",this.handle_data_action,"down:enter",r.ACTIVITYACTION,this),e.delegate("click",this.handle_data_action,i,r.ACTIVITYACTION,this)},handle_data_action:function(e){var t=e.target;t.test("a")||(t=t.ancestor(r.ACTIVITYACTION));var n=t.getData("action"),i=t.ancestor(r.ACTIVITYLI);if(!t.test("a")||!n||!i)return;switch(n){case"editmaxmark":this.edit_maxmark(e,t,i,n);break;case"delete":this.delete_with_confirmation(e,t,i,n);break;case"addpagebreak":case"removepagebreak":this.update_page_break(e,t,i,n);break;default:}},add_spinner:function(t){var n=t.one(r.ACTIONAREA);return n?M.util.add_spinner(e,n):null},delete_with_confirmation:function(t,n,r){t.preventDefault();var i=r,s="",o=M.util.get_string("pluginname","qtype_"+i.getAttribute("class").match(/qtype_([^\s]*)/)[1]);s=M.util.get_string("confirmremovequestion","quiz",o);var u=new M.core.confirm({question:s,modal:!0});return u.on("complete-yes",function(){var n=this.add_spinner(i),r={"class":"resource",action:"DELETE",id:e.Moodle.mod_quiz.util.slot.getId(i)};this.send_request(r,n,function(n){n.deleted?(e.Moodle.mod_quiz.util.slot.remove(i),this.reorganise_edit_page(),M.core.actionmenu&&M.core.actionmenu.instance&&M.core.actionmenu.instance.hideMenu(t)):window.location.reload(!0)})},this),this},edit_maxmark:function(t,i,s){var o=e.Moodle.mod_quiz.util.slot.getId(s),u=s.one(r.INSTANCEMAXMARK),a=s.one(r.ACTIVITYINSTANCE),f=u.get("firstChild"),l=f.get("data"),c=l,h,p=u,d={"class":"resource",field:"getmaxmark",id:o};t.preventDefault(),this.send_request(d,null,function(r){M.core.actionmenu&&M.core.actionmenu.instance&&M.core.actionmenu.instance.hideMenu(t),r.instancemaxmark&&(c=r.instancemaxmark);var i=e.Node.create(''),o=e.Node.create('').set("innerHTML",M.util.get_string("edittitleinstructions","moodle")),u=e.Node.create('').setAttrs({value:c,autocomplete:"off","aria-describedby":"id_editinstructions",maxLength:"12",size:parseInt(this.get("config").questiondecimalpoints,10)+2});i.appendChild(u),i.setData("anchor",p),a.insert(o,"before"),p.replace(i);var f="left";right_to_left()&&(f="right"),s.addClass(n.EDITINGMAXMARK),u.focus().select(),h=u.on("blur",this.edit_maxmark_cancel,this,s,!1),this.editmaxmarkevents.push(h),h=u.on("key",this.edit_maxmark_cancel,"esc",this,s,!0),this.editmaxmarkevents.push(h),h=i.on("submit",this.edit_maxmark_submit,this,s,l),this.editmaxmarkevents.push(h)})},edit_maxmark_submit:function(t,n,i){t.preventDefault();var s=e.Lang.trim(n.one(r.ACTIVITYFORM+" "+r.ACTIVITYMAXMARK).get("value")),o=this.add_spinner(n);this.edit_maxmark_clear(n),n.one(r.INSTANCEMAXMARK).setContent(s);if(s!==null&&s!==""&&s!==i){var u={"class":"resource",field:"updatemaxmark",maxmark:s,id:e.Moodle.mod_quiz.util.slot.getId(n)};this.send_request(u,o,function(e){e.instancemaxmark&&n.one(r.INSTANCEMAXMARK).setContent(e.instancemaxmark)})}},edit_maxmark_cancel:function(e,t,n){n&&e.preventDefault(),this.edit_maxmark_clear(t)},edit_maxmark_clear:function(t){(new e.EventHandle(this.editmaxmarkevents)).detach();var i=t.one(r.ACTIVITYFORM),s=t.one("#id_editinstructions");i&&i.replace(i.getData("anchor")),s&&s.remove(),t.removeClass(n.EDITINGMAXMARK),e.later(100,this,function(){t.one(r.EDITMAXMARK ).focus()}),e.one("input[name=maxmark")||e.one("body").append('')},update_page_break:function(t,n,r,i){t.preventDefault(),nextactivity=r.next("li.activity.slot");var s=this.add_spinner(nextactivity),o=0,u=i==="removepagebreak"?1:2,a={"class":"resource",field:"updatepagebreak",id:o,value:u};return o=e.Moodle.mod_quiz.util.slot.getId(nextactivity),o&&(a.id=Number(o)),this.send_request(a,s,function(t){if(t.slots){if(i==="addpagebreak")e.Moodle.mod_quiz.util.page.add(r);else{var n=r.next(e.Moodle.mod_quiz.util.page.SELECTORS.PAGE);e.Moodle.mod_quiz.util.page.remove(n,!0)}this.reorganise_edit_page()}else window.location.reload(!0)}),this},reorganise_edit_page:function(){e.Moodle.mod_quiz.util.slot.reorderSlots(),e.Moodle.mod_quiz.util.slot.reorderPageBreaks(),e.Moodle.mod_quiz.util.page.reorderPages()},NAME:"mod_quiz-resource-toolbox",ATTRS:{courseid:{value:0},quizid:{value:0}}}),M.mod_quiz.resource_toolbox=null,M.mod_quiz.init_resource_toolbox=function(e){return M.mod_quiz.resource_toolbox=new o(e),M.mod_quiz.resource_toolbox};var u=function(){u.superclass.constructor.apply(this,arguments)};e.extend(u,s,{initializer:function(){M.mod_quiz.quizbase.register_module(this),e.delegate("click",this.toggle_highlight,r.PAGECONTENT,r.SECTIONLI+" "+r.HIGHLIGHT,this),e.delegate("click",this.toggle_hide_section,r.PAGECONTENT,r.SECTIONLI+" "+r.SHOWHIDE,this)},toggle_hide_section:function(t){t.preventDefault();var i=t.target.ancestor(M.mod_quiz.format.get_section_selector(e)),s=t.target.ancestor("a",!0),o=s.one("img"),u,a,f;i.hasClass(n.SECTIONHIDDENCLASS)?(i.removeClass(n.SECTIONHIDDENCLASS),u=1,a="show",f="hide"):(i.addClass(n.SECTIONHIDDENCLASS),u=0,a="hide",f="show");var l=M.util.get_string(f+"fromothers","format_"+this.get("format"));o.setAttrs({alt:l,src:M.util.image_url("i/"+f)}),s.set("title",l);var c={"class":"section",field:"visible",id:e.Moodle.core_course.util.section.getId(i.ancestor(M.mod_quiz.edit.get_section_wrapper(e),!0)),value:u},h=M.util.add_lightbox(e,i);h.show(),this.send_request(c,h,function(t){var n=i.all(r.ACTIVITYLI);n.each(function(n){var i;n.one(r.SHOW)?i=n.one(r.SHOW):i=n.one(r.HIDE);var s=e.Moodle.mod_quiz.util.slot.getId(n);e.Array.indexOf(t.resourcestotoggle,""+s)!==-1&&M.mod_quiz.resource_toolbox.handle_resource_dim(i,n,a)},this)})},toggle_highlight:function(t){t.preventDefault();var n=t.target.ancestor(M.mod_quiz.edit.get_section_selector(e)),i=t.target.ancestor("a",!0),s=i.one("img"),o=n.hasClass("current"),u=0,a=M.util.get_string("markthistopic","moodle");e.one(r.PAGECONTENT).all(M.mod_quiz.edit.get_section_selector(e)+".current "+r.HIGHLIGHT).set("title",a),e.one(r.PAGECONTENT).all(M.mod_quiz.edit.get_section_selector(e)+".current "+r.HIGHLIGHT+" img").set("alt",a).set("src",M.util.image_url("i/marker")),e.one(r.PAGECONTENT).all(M.mod_quiz.edit.get_section_selector(e)).removeClass("current");if(!o){n.addClass("current"),u=e.Moodle.core_course.util.section.getId(n.ancestor(M.mod_quiz.edit.get_section_wrapper(e),!0));var f=M.util.get_string("markedthistopic","moodle");i.set("title",f),s.set("alt",f).set("src",M.util.image_url("i/marked"))}var l={"class":"course",field:"marker",value:u},c=M.util.add_lightbox(e,n);c.show(),this.send_request(l,c)}},{NAME:"mod_quiz-section-toolbox",ATTRS:{courseid:{value:0},quizid:{value:0},format:{value:"topics"}}}),M.mod_quiz.init_section_toolbox=function(e){return new u(e)}},"@VERSION@",{requires:["base","node","event","event-key","io","moodle-mod_quiz-quizbase","moodle-mod_quiz-util-slot","moodle-core-notification-ajaxexception"]}); diff --git a/mod/quiz/yui/build/moodle-mod_quiz-toolboxes/moodle-mod_quiz-toolboxes.js b/mod/quiz/yui/build/moodle-mod_quiz-toolboxes/moodle-mod_quiz-toolboxes.js index 6d416dfdfe1..b5b10e951c3 100644 --- a/mod/quiz/yui/build/moodle-mod_quiz-toolboxes/moodle-mod_quiz-toolboxes.js +++ b/mod/quiz/yui/build/moodle-mod_quiz-toolboxes/moodle-mod_quiz-toolboxes.js @@ -386,7 +386,7 @@ Y.extend(RESOURCETOOLBOX, TOOLBOX, { Y.Moodle.mod_quiz.util.slot.remove(element); this.reorganise_edit_page(); if (M.core.actionmenu && M.core.actionmenu.instance) { - M.core.actionmenu.instance.hideMenu(); + M.core.actionmenu.instance.hideMenu(ev); } } else { window.location.reload(true); @@ -431,7 +431,7 @@ Y.extend(RESOURCETOOLBOX, TOOLBOX, { this.send_request(data, null, function(response) { if (M.core.actionmenu && M.core.actionmenu.instance) { - M.core.actionmenu.instance.hideMenu(); + M.core.actionmenu.instance.hideMenu(ev); } // Try to retrieve the existing string from the server. diff --git a/mod/quiz/yui/src/toolboxes/js/resource.js b/mod/quiz/yui/src/toolboxes/js/resource.js index ad12d68865f..a011660b693 100644 --- a/mod/quiz/yui/src/toolboxes/js/resource.js +++ b/mod/quiz/yui/src/toolboxes/js/resource.js @@ -172,7 +172,7 @@ Y.extend(RESOURCETOOLBOX, TOOLBOX, { Y.Moodle.mod_quiz.util.slot.remove(element); this.reorganise_edit_page(); if (M.core.actionmenu && M.core.actionmenu.instance) { - M.core.actionmenu.instance.hideMenu(); + M.core.actionmenu.instance.hideMenu(ev); } } else { window.location.reload(true); @@ -217,7 +217,7 @@ Y.extend(RESOURCETOOLBOX, TOOLBOX, { this.send_request(data, null, function(response) { if (M.core.actionmenu && M.core.actionmenu.instance) { - M.core.actionmenu.instance.hideMenu(); + M.core.actionmenu.instance.hideMenu(ev); } // Try to retrieve the existing string from the server.