Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'MDL-43267-master-3' of git://github.com/andrewnicols/mo…

…odle
  • Loading branch information...
commit 52b7e8aa58d9a794c64a3c8aa2dddf3e773bf5b8 2 parents 1c8c3a6 + 8659df9
@samhemelryk samhemelryk authored
View
8 course/lib.php
@@ -3238,11 +3238,15 @@ function include_course_ajax($course, $usedmodules = array(), $enabledmodules =
'clicktochangeinbrackets',
'markthistopic',
'markedthistopic',
- 'move',
'movesection',
+ 'movecoursemodule',
+ 'movecoursesection',
'movecontent',
'tocontent',
- 'emptydragdropregion'
+ 'emptydragdropregion',
+ 'afterresource',
+ 'aftersection',
+ 'totopofsection',
), 'moodle');
// Include section-specific strings for formats which support sections.
View
11 course/yui/build/moodle-course-dragdrop/moodle-course-dragdrop-debug.js
@@ -303,7 +303,16 @@ Y.extend(DRAGRESOURCE, M.core.dragdrop, {
this.groups = ['resource'];
this.samenodeclass = CSS.ACTIVITY;
this.parentnodeclass = CSS.SECTION;
- this.resourcedraghandle = this.get_drag_handle(M.str.moodle.move, CSS.EDITINGMOVE, CSS.ICONCLASS, true);
+ this.resourcedraghandle = this.get_drag_handle(M.util.get_string('movecoursemodule', 'moodle'), CSS.EDITINGMOVE, CSS.ICONCLASS, true);
+
+ this.samenodelabel = {
+ identifier: 'afterresource',
+ component: 'moodle'
+ };
+ this.parentnodelabel = {
+ identifier: 'totopofsection',
+ component: 'moodle'
+ };
// Go through all sections
var sectionlistselector = M.course.format.get_section_selector(Y);
View
4 course/yui/build/moodle-course-dragdrop/moodle-course-dragdrop-min.js
@@ -1,2 +1,2 @@
-YUI.add("moodle-course-dragdrop",function(e,t){var n={ACTIONAREA:".actions",ACTIVITY:"activity",ACTIVITYINSTANCE:"activityinstance",CONTENT:"content",COURSECONTENT:"course-content",EDITINGMOVE:"editing_move",ICONCLASS:"iconsmall",JUMPMENU:"jumpmenu",LEFT:"left",LIGHTBOX:"lightbox",MOVEDOWN:"movedown",MOVEUP:"moveup",PAGECONTENT:"page-content",RIGHT:"right",SECTION:"section",SECTIONADDMENUS:"section_add_menus",SECTIONHANDLE:"section-handle",SUMMARY:"summary",SECTIONDRAGGABLE:"sectiondraggable"};M.course=M.course||{};var r=function(){r.superclass.constructor.apply(this,arguments)};e.extend(r,M.core.dragdrop,{sectionlistselector:null,initializer:function(){this.groups=[n.SECTIONDRAGGABLE],this.samenodeclass=M.course.format.get_sectionwrapperclass(),this.parentnodeclass=M.course.format.get_containerclass();if(e.Node.one("."+n.JUMPMENU))return!1;this.sectionlistselector=M.course.format.get_section_wrapper(e);if(this.sectionlistselector){this.sectionlistselector="."+n.COURSECONTENT+" "+this.sectionlistselector,this.setup_for_section(this.sectionlistselector);var t=new e.DD.Delegate({container:"."+n.COURSECONTENT,nodes:"."+n.SECTIONDRAGGABLE,target:!0,handles:["."+n.LEFT],dragConfig:{groups:this.groups}});t.dd.plug(e.Plugin.DDProxy,{moveOnEnd:!1}),t.dd.plug(e.Plugin.DDConstrained,{constrain:"#"+n.PAGECONTENT,stickY:!0}),t.dd.plug(e.Plugin.DDWinScroll)}},setup_for_section:function(t){e.Node.all(t).each(function(t){var r=e.Moodle.core_course.util.section.getId(t);if(r>0){var i=t.one("."+n.RIGHT+" a."+n.MOVEDOWN),s=t.one("."+n.RIGHT+" a."+n.MOVEUP),o=M.util.get_string("movesection","moodle",r),u=t.one("."+n.LEFT);(i||s)&&u&&(u.setStyle("cursor","move"),u.appendChild(this.get_drag_handle(o,n.SECTIONHANDLE,"icon",!0)),s&&s.remove(),i&&i.remove(),t.addClass(n.SECTIONDRAGGABLE))}},this)},drag_start:function(t){var r=t.target,i=e.Node.create("<"+M.course.format.get_containernode()+"></"+M.course.format.get_containernode()+">");i.addClass(M.course.format.get_containerclass());var s=e.Node.create("<"+M.course.format.get_sectionwrappernode()+"></"+M.course.format.get_sectionwrappernode()+">");s.addClass(M.course.format.get_sectionwrapperclass()),s.setStyle("margin",0),s.setContent(r.get("node").get("innerHTML")),i.appendChild(s),r.get("dragNode").setContent(i),r.get("dragNode").addClass(n.COURSECONTENT)},drag_dropmiss:function(e){this.drop_hit(e)},get_section_index:function(t){var r="."+n.COURSECONTENT+" "+M.course.format.get_section_selector(e),i=e.all(r),s=i.indexOf(t),o=i.indexOf(e.one("#section-0"));return s-o},drop_hit:function(t){var r=t.drag,i=r.get("node"),s=e.Moodle.core_course.util.section.getId(i),o=s,u=this.get_section_index(i),a=u;if(s===u)return;o>a&&(o=u,a=s),r.get("dragNode").removeClass(n.COURSECONTENT);var f=e.Node.all(this.sectionlistselector),l=M.util.add_lightbox(e,i),c={},h=this.get("config").pageparams,p;for(p in h){if(!h.hasOwnProperty(p))continue;c[p]=h[p]}c.sesskey=M.cfg.sesskey,c.courseId=this.get("courseid"),c["class"]="section",c.field="move",c.id=s,c.value=u;var d=M.cfg.wwwroot+this.get("ajaxurl");e.io(d,{method:"POST",data:c,on:{start:function(){l.show()},success:function(t,n){try{var r=e.JSON.parse(n.responseText);r.error&&new M.core.ajaxException(r),M.course.format.process_sections(e,f,r,o,a)}catch(i){}var s,u=!1;do{u=!1;for(s=o;s<=a;s++)if(e.Moodle.core_course.util.section.getId(f.item(s-1))>e.Moodle.core_course.util.section.getId(f.item(s))){var c=f.item(s-1).get("id");f.item(s-1).set("id",f.item(s).get("id")),f.item(s).set("id",c),M.course.format.swap_sections(e,s-1,s),u=!0}a-=1}while(u);window.setTimeout(function(){l.hide()},250)},failure:function(e,t){this.ajax_failure(t),l.hide()}},context:this})}},{NAME:"course-dragdrop-section",ATTRS:{courseid:{value:null},ajaxurl:{value:0},config:{value:0}}}),M.course=M.course||{},M.course.init_section_dragdrop=function(e){new r(e)};var i=function(){i.superclass.constructor.apply(this,arguments)};e.extend(i,M.core.dragdrop,{initializer:function(){this.groups=["resource"],this.samenodeclass=n.ACTIVITY,this.parentnodeclass=n.SECTION,this.resourcedraghandle=this.get_drag_handle(M.str.moodle.move,n.EDITINGMOVE,n.ICONCLASS,!0);var t=M.course.format.get_section_selector(e);if(t){t="."+n.COURSECONTENT+" "+t,this.setup_for_section(t);var r=t.slice(n.COURSECONTENT.length+2)+" li."+n.ACTIVITY,i=new e.DD.Delegate({container:"."+n.COURSECONTENT,nodes:r,target:!0,handles:["."+n.EDITINGMOVE],dragConfig:{groups:this.groups}});i.dd.plug(e.Plugin.DDProxy,{moveOnEnd:!1,cloneNode:!0}),i.dd.plug(e.Plugin.DDConstrained,{constrain:"#"+n.PAGECONTENT}),i.dd.plug(e.Plugin.DDWinScroll),M.course.coursebase.register_module(this),M.course.dragres=this}},setup_for_section:function(t){e.Node.all(t).each(function(t){var r=t.one("."+n.CONTENT+" ul."+n.SECTION);r||(r=e.Node.create("<ul></ul>"),r.addClass(n.SECTION),t.one("."+n.CONTENT+" div."+n.SUMMARY).insert(r,"after")),r.setAttribute("data-draggroups",this.groups.join(" ")),new e.DD.Drop({node:r,groups:this.groups,padding:"20 0 20 0"}),this.setup_for_resource("#"+t.get("id")+" li."+n.ACTIVITY)},this)},setup_for_resource:function(t){e.Node.all(t).each(function(e){var t=e.one("a."+n.EDITINGMOVE);t&&t.replace(this.resourcedraghandle.cloneNode(!0))},this)},drag_start:function(e){var t=e.target;t.get("dragNode").setContent(t.get("node").get("innerHTML")),t.get("dragNode").all("img.iconsmall").setStyle("vertical-align","baseline")},drag_dropmiss:function(e){this.drop_hit(e)},drop_hit:function(t){var r=t.drag,i=r.get("node"),s=t.drop.get("node"),o=i.one(n.ACTIONAREA),u=M.util.add_spinner(e,o),a={},f=this.get("config").pageparams,l;for(l in f)a[l]=f[l];a.sesskey=M.cfg.sesskey,a.courseId=this.get("courseid"),a["class"]="resource",a.field="move",a.id=Number(e.Moodle.core_course.util.cm.getId(i)),a.sectionId=e.Moodle.core_course.util.section.getId(s.ancestor(M.course.format.get_section_wrapper(e),!0)),i.next()&&(a.beforeId=Number(e.Moodle.core_course.util.cm.getId(i.next())));var c=M.cfg.wwwroot+this.get("ajaxurl");e.io(c,
-{method:"POST",data:a,on:{start:function(){this.lock_drag_handle(r,n.EDITINGMOVE),u.show()},success:function(t,s){var o=e.JSON.parse(s.responseText),a={element:i,visible:o.visible};M.course.coursebase.invoke_function("set_visibility_resource_ui",a),this.unlock_drag_handle(r,n.EDITINGMOVE),window.setTimeout(function(){u.hide()},250)},failure:function(e,t){this.ajax_failure(t),this.unlock_drag_handle(r,n.SECTIONHANDLE),u.hide()}},context:this})}},{NAME:"course-dragdrop-resource",ATTRS:{courseid:{value:null},ajaxurl:{value:0},config:{value:0}}}),M.course=M.course||{},M.course.init_resource_dragdrop=function(e){new i(e)}},"@VERSION@",{requires:["base","node","io","dom","dd","dd-scroll","moodle-core-dragdrop","moodle-core-notification","moodle-course-coursebase","moodle-course-util"]});
+YUI.add("moodle-course-dragdrop",function(e,t){var n={ACTIONAREA:".actions",ACTIVITY:"activity",ACTIVITYINSTANCE:"activityinstance",CONTENT:"content",COURSECONTENT:"course-content",EDITINGMOVE:"editing_move",ICONCLASS:"iconsmall",JUMPMENU:"jumpmenu",LEFT:"left",LIGHTBOX:"lightbox",MOVEDOWN:"movedown",MOVEUP:"moveup",PAGECONTENT:"page-content",RIGHT:"right",SECTION:"section",SECTIONADDMENUS:"section_add_menus",SECTIONHANDLE:"section-handle",SUMMARY:"summary",SECTIONDRAGGABLE:"sectiondraggable"};M.course=M.course||{};var r=function(){r.superclass.constructor.apply(this,arguments)};e.extend(r,M.core.dragdrop,{sectionlistselector:null,initializer:function(){this.groups=[n.SECTIONDRAGGABLE],this.samenodeclass=M.course.format.get_sectionwrapperclass(),this.parentnodeclass=M.course.format.get_containerclass();if(e.Node.one("."+n.JUMPMENU))return!1;this.sectionlistselector=M.course.format.get_section_wrapper(e);if(this.sectionlistselector){this.sectionlistselector="."+n.COURSECONTENT+" "+this.sectionlistselector,this.setup_for_section(this.sectionlistselector);var t=new e.DD.Delegate({container:"."+n.COURSECONTENT,nodes:"."+n.SECTIONDRAGGABLE,target:!0,handles:["."+n.LEFT],dragConfig:{groups:this.groups}});t.dd.plug(e.Plugin.DDProxy,{moveOnEnd:!1}),t.dd.plug(e.Plugin.DDConstrained,{constrain:"#"+n.PAGECONTENT,stickY:!0}),t.dd.plug(e.Plugin.DDWinScroll)}},setup_for_section:function(t){e.Node.all(t).each(function(t){var r=e.Moodle.core_course.util.section.getId(t);if(r>0){var i=t.one("."+n.RIGHT+" a."+n.MOVEDOWN),s=t.one("."+n.RIGHT+" a."+n.MOVEUP),o=M.util.get_string("movesection","moodle",r),u=t.one("."+n.LEFT);(i||s)&&u&&(u.setStyle("cursor","move"),u.appendChild(this.get_drag_handle(o,n.SECTIONHANDLE,"icon",!0)),s&&s.remove(),i&&i.remove(),t.addClass(n.SECTIONDRAGGABLE))}},this)},drag_start:function(t){var r=t.target,i=e.Node.create("<"+M.course.format.get_containernode()+"></"+M.course.format.get_containernode()+">");i.addClass(M.course.format.get_containerclass());var s=e.Node.create("<"+M.course.format.get_sectionwrappernode()+"></"+M.course.format.get_sectionwrappernode()+">");s.addClass(M.course.format.get_sectionwrapperclass()),s.setStyle("margin",0),s.setContent(r.get("node").get("innerHTML")),i.appendChild(s),r.get("dragNode").setContent(i),r.get("dragNode").addClass(n.COURSECONTENT)},drag_dropmiss:function(e){this.drop_hit(e)},get_section_index:function(t){var r="."+n.COURSECONTENT+" "+M.course.format.get_section_selector(e),i=e.all(r),s=i.indexOf(t),o=i.indexOf(e.one("#section-0"));return s-o},drop_hit:function(t){var r=t.drag,i=r.get("node"),s=e.Moodle.core_course.util.section.getId(i),o=s,u=this.get_section_index(i),a=u;if(s===u)return;o>a&&(o=u,a=s),r.get("dragNode").removeClass(n.COURSECONTENT);var f=e.Node.all(this.sectionlistselector),l=M.util.add_lightbox(e,i),c={},h=this.get("config").pageparams,p;for(p in h){if(!h.hasOwnProperty(p))continue;c[p]=h[p]}c.sesskey=M.cfg.sesskey,c.courseId=this.get("courseid"),c["class"]="section",c.field="move",c.id=s,c.value=u;var d=M.cfg.wwwroot+this.get("ajaxurl");e.io(d,{method:"POST",data:c,on:{start:function(){l.show()},success:function(t,n){try{var r=e.JSON.parse(n.responseText);r.error&&new M.core.ajaxException(r),M.course.format.process_sections(e,f,r,o,a)}catch(i){}var s,u=!1;do{u=!1;for(s=o;s<=a;s++)if(e.Moodle.core_course.util.section.getId(f.item(s-1))>e.Moodle.core_course.util.section.getId(f.item(s))){var c=f.item(s-1).get("id");f.item(s-1).set("id",f.item(s).get("id")),f.item(s).set("id",c),M.course.format.swap_sections(e,s-1,s),u=!0}a-=1}while(u);window.setTimeout(function(){l.hide()},250)},failure:function(e,t){this.ajax_failure(t),l.hide()}},context:this})}},{NAME:"course-dragdrop-section",ATTRS:{courseid:{value:null},ajaxurl:{value:0},config:{value:0}}}),M.course=M.course||{},M.course.init_section_dragdrop=function(e){new r(e)};var i=function(){i.superclass.constructor.apply(this,arguments)};e.extend(i,M.core.dragdrop,{initializer:function(){this.groups=["resource"],this.samenodeclass=n.ACTIVITY,this.parentnodeclass=n.SECTION,this.resourcedraghandle=this.get_drag_handle(M.util.get_string("movecoursemodule","moodle"),n.EDITINGMOVE,n.ICONCLASS,!0),this.samenodelabel={identifier:"afterresource",component:"moodle"},this.parentnodelabel={identifier:"totopofsection",component:"moodle"};var t=M.course.format.get_section_selector(e);if(t){t="."+n.COURSECONTENT+" "+t,this.setup_for_section(t);var r=t.slice(n.COURSECONTENT.length+2)+" li."+n.ACTIVITY,i=new e.DD.Delegate({container:"."+n.COURSECONTENT,nodes:r,target:!0,handles:["."+n.EDITINGMOVE],dragConfig:{groups:this.groups}});i.dd.plug(e.Plugin.DDProxy,{moveOnEnd:!1,cloneNode:!0}),i.dd.plug(e.Plugin.DDConstrained,{constrain:"#"+n.PAGECONTENT}),i.dd.plug(e.Plugin.DDWinScroll),M.course.coursebase.register_module(this),M.course.dragres=this}},setup_for_section:function(t){e.Node.all(t).each(function(t){var r=t.one("."+n.CONTENT+" ul."+n.SECTION);r||(r=e.Node.create("<ul></ul>"),r.addClass(n.SECTION),t.one("."+n.CONTENT+" div."+n.SUMMARY).insert(r,"after")),r.setAttribute("data-draggroups",this.groups.join(" ")),new e.DD.Drop({node:r,groups:this.groups,padding:"20 0 20 0"}),this.setup_for_resource("#"+t.get("id")+" li."+n.ACTIVITY)},this)},setup_for_resource:function(t){e.Node.all(t).each(function(e){var t=e.one("a."+n.EDITINGMOVE);t&&t.replace(this.resourcedraghandle.cloneNode(!0))},this)},drag_start:function(e){var t=e.target;t.get("dragNode").setContent(t.get("node").get("innerHTML")),t.get("dragNode").all("img.iconsmall").setStyle("vertical-align","baseline")},drag_dropmiss:function(e){this.drop_hit(e)},drop_hit:function(t){var r=t.drag,i=r.get("node"),s=t.drop.get("node"),o=i.one(n.ACTIONAREA),u=M.util.add_spinner(e,o),a={},f=this.get("config").pageparams,l;for(l in f)a[l]=f[l];a.sesskey=M.cfg.sesskey,a.courseId=this.get("courseid"),a["class"]="resource",a.field="move",a.id=Number(e.Moodle.core_course.util.cm.getId(i)),a.sectionId=e.Moodle.core_course.util.section.getId(s.ancestor(M
+.course.format.get_section_wrapper(e),!0)),i.next()&&(a.beforeId=Number(e.Moodle.core_course.util.cm.getId(i.next())));var c=M.cfg.wwwroot+this.get("ajaxurl");e.io(c,{method:"POST",data:a,on:{start:function(){this.lock_drag_handle(r,n.EDITINGMOVE),u.show()},success:function(t,s){var o=e.JSON.parse(s.responseText),a={element:i,visible:o.visible};M.course.coursebase.invoke_function("set_visibility_resource_ui",a),this.unlock_drag_handle(r,n.EDITINGMOVE),window.setTimeout(function(){u.hide()},250)},failure:function(e,t){this.ajax_failure(t),this.unlock_drag_handle(r,n.SECTIONHANDLE),u.hide()}},context:this})}},{NAME:"course-dragdrop-resource",ATTRS:{courseid:{value:null},ajaxurl:{value:0},config:{value:0}}}),M.course=M.course||{},M.course.init_resource_dragdrop=function(e){new i(e)}},"@VERSION@",{requires:["base","node","io","dom","dd","dd-scroll","moodle-core-dragdrop","moodle-core-notification","moodle-course-coursebase","moodle-course-util"]});
View
11 course/yui/build/moodle-course-dragdrop/moodle-course-dragdrop.js
@@ -299,7 +299,16 @@ Y.extend(DRAGRESOURCE, M.core.dragdrop, {
this.groups = ['resource'];
this.samenodeclass = CSS.ACTIVITY;
this.parentnodeclass = CSS.SECTION;
- this.resourcedraghandle = this.get_drag_handle(M.str.moodle.move, CSS.EDITINGMOVE, CSS.ICONCLASS, true);
+ this.resourcedraghandle = this.get_drag_handle(M.util.get_string('movecoursemodule', 'moodle'), CSS.EDITINGMOVE, CSS.ICONCLASS, true);
+
+ this.samenodelabel = {
+ identifier: 'afterresource',
+ component: 'moodle'
+ };
+ this.parentnodelabel = {
+ identifier: 'totopofsection',
+ component: 'moodle'
+ };
// Go through all sections
var sectionlistselector = M.course.format.get_section_selector(Y);
View
11 course/yui/src/dragdrop/js/resource.js
@@ -14,7 +14,16 @@ Y.extend(DRAGRESOURCE, M.core.dragdrop, {
this.groups = ['resource'];
this.samenodeclass = CSS.ACTIVITY;
this.parentnodeclass = CSS.SECTION;
- this.resourcedraghandle = this.get_drag_handle(M.str.moodle.move, CSS.EDITINGMOVE, CSS.ICONCLASS, true);
+ this.resourcedraghandle = this.get_drag_handle(M.util.get_string('movecoursemodule', 'moodle'), CSS.EDITINGMOVE, CSS.ICONCLASS, true);
+
+ this.samenodelabel = {
+ identifier: 'afterresource',
+ component: 'moodle'
+ };
+ this.parentnodelabel = {
+ identifier: 'totopofsection',
+ component: 'moodle'
+ };
// Go through all sections
var sectionlistselector = M.course.format.get_section_selector(Y);
View
5 lang/en/moodle.php
@@ -115,6 +115,8 @@
$string['advanced'] = 'Advanced';
$string['advancedfilter'] = 'Advanced search';
$string['advancedsettings'] = 'Advanced settings';
+$string['afterresource'] = 'After resource "{$a}"';
+$string['aftersection'] = 'After section "{$a}"';
$string['again'] = 'again';
$string['aimid'] = 'AIM ID';
$string['ajaxuse'] = 'AJAX and Javascript';
@@ -1165,6 +1167,8 @@
$string['moreprofileinfoneeded'] = 'Please tell us more about yourself';
$string['mostrecently'] = 'most recently';
$string['move'] = 'Move';
+$string['movecoursemodule'] = 'Move resource';
+$string['movecoursesection'] = 'Move section';
$string['movecontent'] = 'Move {$a}';
$string['movecategorycontentto'] = 'Move into';
$string['movecategorysuccess'] = 'Successfully moved category \'{$a->moved}\' into category \'{$a->to}\'';
@@ -1820,6 +1824,7 @@
$string['topicshow'] = 'Show this topic to {$a}';
$string['topichide'] = 'Hide this topic from {$a}';
$string['total'] = 'Total';
+$string['totopofsection'] = 'To the top of section "{$a}"';
$string['trackforums'] = 'Forum tracking';
$string['trackforumsno'] = 'No: don\'t keep track of posts I have seen';
$string['trackforumsyes'] = 'Yes: highlight new posts for me';
View
52 lib/yui/build/moodle-core-dragdrop/moodle-core-dragdrop-debug.js
@@ -65,6 +65,24 @@ Y.extend(DRAGDROP, Y.Base, {
parentnodeclass: null,
/**
+ * The label to use with keyboard drag/drop to describe items of the same Node.
+ *
+ * @property samenodelabel
+ * @type Object
+ * @default null
+ */
+ samenodelabel : null,
+
+ /**
+ * The label to use with keyboard drag/drop to describe items of the parent Node.
+ *
+ * @property samenodelabel
+ * @type Object
+ * @default null
+ */
+ parentnodelabel : null,
+
+ /**
* The groups for this instance.
*
* @property groups
@@ -148,8 +166,7 @@ Y.extend(DRAGDROP, Y.Base, {
.setAttribute('title', title)
.setAttribute('tabIndex', 0)
.setAttribute('data-draggroups', this.groups)
- .setAttribute('role', 'button')
- .setAttribute('aria-grabbed', 'false');
+ .setAttribute('role', 'button');
dragelement.appendChild(dragicon);
dragelement.addClass(MOVEICON.cssclass);
@@ -162,6 +179,7 @@ Y.extend(DRAGDROP, Y.Base, {
unlock_drag_handle: function(drag, classname) {
drag.addHandle('.'+classname);
+ drag.get('activeHandle').focus();
},
ajax_failure: function(response) {
@@ -352,8 +370,6 @@ Y.extend(DRAGDROP, Y.Base, {
M.core.dragdrop.keydragcontainer = dragcontainer;
M.core.dragdrop.keydraghandle = draghandle;
- // Indicate to a screenreader the node that is selected for drag and drop.
- dragcontainer.setAttribute('aria-grabbed', 'true');
// Get the name of the thing to move.
var nodetitle = this.find_element_text(dragcontainer);
var dialogtitle = M.util.get_string('movecontent', 'moodle', nodetitle);
@@ -397,13 +413,17 @@ Y.extend(DRAGDROP, Y.Base, {
listlink = Y.Node.create('<a></a>');
nodetitle = this.find_element_text(labelroot);
- listitemtext = M.util.get_string('tocontent', 'moodle', nodetitle);
+ if (this.samenodelabel && node.hasClass(this.samenodeclass)) {
+ listitemtext = M.util.get_string(this.samenodelabel.identifier, this.samenodelabel.component, nodetitle);
+ } else if (this.parentnodelabel && node.hasClass(this.parentnodeclass)) {
+ listitemtext = M.util.get_string(this.parentnodelabel.identifier, this.parentnodelabel.component, nodetitle);
+ } else {
+ listitemtext = M.util.get_string('tocontent', 'moodle', nodetitle);
+ }
listlink.setContent(listitemtext);
// Add a data attribute so we can get the real drop target.
listlink.setAttribute('data-drop-target', node.get('id'));
- // Notify the screen reader this is a valid drop target.
- listlink.setAttribute('aria-dropeffect', 'move');
// Allow tabbing to the link.
listlink.setAttribute('tabindex', '0');
@@ -423,9 +443,18 @@ Y.extend(DRAGDROP, Y.Base, {
bodyContent: droplist,
draggable: true,
visible: true,
- centered: true
+ center: true,
+ modal: true
});
+ M.core.dragdrop.dropui.after('visibleChange', function(e) {
+ // After the dialogue has been closed, we call the cancel function. This will
+ // ensure that tidying up happens (e.g. focusing on the start Node).
+ if (e.prevVal && !e.newVal) {
+ this.global_cancel_keyboard_drag();
+ }
+ }, this);
+
// Focus the first drop target.
if (droplist.one('a')) {
droplist.one('a').focus();
@@ -465,6 +494,9 @@ Y.extend(DRAGDROP, Y.Base, {
if (param === 'node' || param === 'dragNode' || param === 'dropNode') {
return this.node;
}
+ if (param === 'activeHandle') {
+ return this.node.one('.editing_move');
+ }
return null;
};
@@ -493,7 +525,6 @@ Y.extend(DRAGDROP, Y.Base, {
global_keyboard_drop: function(e) {
// The drag node was saved.
var dragcontainer = M.core.dragdrop.keydragcontainer;
- dragcontainer.setAttribute('aria-grabbed', 'false');
// The real drop node is stored in an attribute of the proxy.
var droptarget = Y.one('#' + e.target.getAttribute('data-drop-target'));
@@ -508,7 +539,6 @@ Y.extend(DRAGDROP, Y.Base, {
this.drag_start(dragevent);
this.global_drop_over(dropevent);
this.global_drop_hit(dropevent);
- M.core.dragdrop.keydraghandle.focus();
},
/**
@@ -518,7 +548,7 @@ Y.extend(DRAGDROP, Y.Base, {
*/
global_cancel_keyboard_drag: function() {
if (M.core.dragdrop.keydragcontainer) {
- M.core.dragdrop.keydragcontainer.setAttribute('aria-grabbed', 'false');
+ // Focus on the node which was being dragged.
M.core.dragdrop.keydraghandle.focus();
M.core.dragdrop.keydragcontainer = null;
}
View
4 lib/yui/build/moodle-core-dragdrop/moodle-core-dragdrop-min.js
@@ -1,2 +1,2 @@
-YUI.add("moodle-core-dragdrop",function(e,t){var n={pix:"i/move_2d",largepix:"i/dragdrop",component:"moodle",cssclass:"moodle-core-dragdrop-draghandle"},r=function(){r.superclass.constructor.apply(this,arguments)};e.extend(r,e.Base,{goingup:null,absgoingup:null,samenodeclass:null,parentnodeclass:null,groups:[],lastdroptarget:null,initializer:function(){e.DD.DDM.on("drag:start",this.global_drag_start,this),e.DD.DDM.on("drag:end",this.global_drag_end,this),e.DD.DDM.on("drag:drag",this.global_drag_drag,this),e.DD.DDM.on("drop:over",this.global_drop_over,this),e.DD.DDM.on("drop:hit",this.global_drop_hit,this),e.DD.DDM.on("drag:dropmiss",this.global_drag_dropmiss,this),e.one(e.config.doc.body).delegate("key",this.global_keydown,"down:32, enter, esc","."+n.cssclass,this),e.one(e.config.doc.body).delegate("click",this.global_keydown,"."+n.cssclass,this)},get_drag_handle:function(t,r,i,s){var o=n.pix;s&&(o=n.largepix);var u=e.Node.create("<img />").setStyle("cursor","move").setAttrs({src:M.util.image_url(o,n.component),alt:t});i&&u.addClass(i);var a=e.Node.create("<span></span>").addClass(r).setAttribute("title",t).setAttribute("tabIndex",0).setAttribute("data-draggroups",this.groups).setAttribute("role","button").setAttribute("aria-grabbed","false");return a.appendChild(u),a.addClass(n.cssclass),a},lock_drag_handle:function(e,t){e.removeHandle("."+t)},unlock_drag_handle:function(e,t){e.addHandle("."+t)},ajax_failure:function(e){var t={name:e.status+" "+e.statusText,message:e.responseText};return new M.core.exception(t)},in_group:function(t){var n=!1;return e.each(this.groups,function(e){t._groups[e]&&(n=!0)},this),n},global_drag_start:function(e){var t=e.target;if(!this.in_group(t))return;t.get("node").setStyle("opacity",".25"),t.get("dragNode").setStyles({opacity:".75",borderColor:t.get("node").getStyle("borderColor"),backgroundColor:t.get("node").getStyle("backgroundColor")}),t.get("dragNode").empty(),this.drag_start(e)},global_drag_end:function(e){var t=e.target;if(!this.in_group(t))return;t.get("node").setStyles({visibility:"",opacity:"1"}),this.drag_end(e)},global_drag_drag:function(e){var t=e.target,n=e.info;if(!this.in_group(t))return;n.start[1]<n.xy[1]?this.absgoingup=!0:n.start[1]>n.xy[1]&&(this.absgoingup=!1),n.delta[1]<0?this.goingup=!0:n.delta[1]>0&&(this.goingup=!1),this.drag_drag(e)},global_drop_over:function(e){if(!e.drop||!e.drop.inGroup(this.groups))return;var t=e.drag.get("node"),n=e.drop.get("node");this.lastdroptarget=e.drop;if(n.hasClass(this.samenodeclass)){var r;this.goingup?r="before":r="after",n.insert(t,r)}else(n.hasClass(this.parentnodeclass)||n.test('[data-droptarget="1"]'))&&!n.contains(t)&&(this.goingup?n.append(t):n.prepend(t));this.drop_over(e)},global_drag_dropmiss:function(e){e.drag=e.target,e.drop=this.lastdroptarget;if(!this.in_group(e.drag))return;if(!e.drop||!e.drop.inGroup(this.groups))return;this.drag_dropmiss(e)},global_drop_hit:function(e){if(!e.drop||!e.drop.inGroup(this.groups))return;this.drop_hit(e)},find_element_text:function(t){var n=t.all("h2, h3, h4, h5, span, p, div.no-overflow, div.dimmed_text"),r="";return n.each(function(){r===""&&e.Lang.trim(this.get("text"))!==""&&(r=this.get("text"))}),r!==""?r:M.util.get_string("emptydragdropregion","moodle")},global_start_keyboard_drag:function(t,n,r){M.core.dragdrop.keydragcontainer=r,M.core.dragdrop.keydraghandle=n,r.setAttribute("aria-grabbed","true");var i=this.find_element_text(r),s=M.util.get_string("movecontent","moodle",i),o=e.Node.create("<ul></ul>");o.addClass("dragdrop-keyboard-drag");var u,a,f=e.all("."+this.samenodeclass+", ."+this.parentnodeclass);f.each(function(t){var n=!1,s=t;if(t.drop&&t.drop.inGroup(this.groups)&&t.drop.get("node")!==r)n=!0;else{var f=t.getAttribute("data-draggroups").split(" "),l,c;for(l=0;l<f.length;l++){for(c=0;c<this.groups.length;c++)if(f[l]===this.groups[c]){n=!0,s=t.get("parentNode");break}if(n)break}}n&&(u=e.Node.create("<li></li>"),listlink=e.Node.create("<a></a>"),i=this.find_element_text(s),a=M.util.get_string("tocontent","moodle",i),listlink.setContent(a),listlink.setAttribute("data-drop-target",t.get("id")),listlink.setAttribute("aria-dropeffect","move"),listlink.setAttribute("tabindex","0"),listlink.on("click",this.global_keyboard_drop,this),listlink.on("key",this.global_keyboard_drop,"down:enter,32",this),u.append(listlink),o.append(u))},this),M.core.dragdrop.dropui=new M.core.dialogue({headerContent:s,bodyContent:o,draggable:!0,visible:!0,centered:!0}),o.one("a")&&o.one("a").focus()},simulated_drag_drop_event:function(e,t){var n=function(e){this.node=e};n.prototype.get=function(e){return e==="node"||e==="dragNode"||e==="dropNode"?this.node:null},n.prototype.inGroup=function(){return!0},n.prototype.addHandle=function(){},n.prototype.removeHandle=function(){},this.drop=new n(t),this.drag=new n(e),this.target=this.drop},global_keyboard_drop:function(t){var n=M.core.dragdrop.keydragcontainer;n.setAttribute("aria-grabbed","false");var r=e.one("#"+t.target.getAttribute("data-drop-target"));M.core.dragdrop.dropui.hide(),t.preventDefault();var i=new this.simulated_drag_drop_event(n,n),s=new this.simulated_drag_drop_event(n,r);this.drag_start(i),this.global_drop_over(s),this.global_drop_hit(s),M.core.dragdrop.keydraghandle.focus()},global_cancel_keyboard_drag:function(){M.core.dragdrop.keydragcontainer&&(M.core.dragdrop.keydragcontainer.setAttribute("aria-grabbed","false"),M.core.dragdrop.keydraghandle.focus(),M.core.dragdrop.keydragcontainer=null)},global_keydown:function(e){var t=e.target.ancestor("."+n.cssclass,!0),r,i;if(t===null)return;if(e.keyCode===27){this.global_cancel_keyboard_drag(),e.preventDefault();return}if(!t.hasClass(n.cssclass))return;if(e.keyCode!==13&&e.keyCode!==32&&e.type!=="click")return;i=t.getAttribute("data-draggroups").split(" ");var s,o,u=!1;for(s=0;s<i.length;s++){for(o=0;o<this.groups.length;o++)if(i[s]===this.groups[o]){u=!0;break}if(u)break}if(!u)return;r=t.ancestor(".yui3-dd-drop"),this.global_start_keyboard_drag(e,t,r),e.preventDefault
-()},drag_start:function(){},drag_end:function(){},drag_drag:function(){},drag_dropmiss:function(){},drop_over:function(){},drop_hit:function(){}},{NAME:"dragdrop",ATTRS:{}}),M.core=M.core||{},M.core.dragdrop=r},"@VERSION@",{requires:["base","node","io","dom","dd","event-key","event-focus","moodle-core-notification"]});
+YUI.add("moodle-core-dragdrop",function(e,t){var n={pix:"i/move_2d",largepix:"i/dragdrop",component:"moodle",cssclass:"moodle-core-dragdrop-draghandle"},r=function(){r.superclass.constructor.apply(this,arguments)};e.extend(r,e.Base,{goingup:null,absgoingup:null,samenodeclass:null,parentnodeclass:null,samenodelabel:null,parentnodelabel:null,groups:[],lastdroptarget:null,initializer:function(){e.DD.DDM.on("drag:start",this.global_drag_start,this),e.DD.DDM.on("drag:end",this.global_drag_end,this),e.DD.DDM.on("drag:drag",this.global_drag_drag,this),e.DD.DDM.on("drop:over",this.global_drop_over,this),e.DD.DDM.on("drop:hit",this.global_drop_hit,this),e.DD.DDM.on("drag:dropmiss",this.global_drag_dropmiss,this),e.one(e.config.doc.body).delegate("key",this.global_keydown,"down:32, enter, esc","."+n.cssclass,this),e.one(e.config.doc.body).delegate("click",this.global_keydown,"."+n.cssclass,this)},get_drag_handle:function(t,r,i,s){var o=n.pix;s&&(o=n.largepix);var u=e.Node.create("<img />").setStyle("cursor","move").setAttrs({src:M.util.image_url(o,n.component),alt:t});i&&u.addClass(i);var a=e.Node.create("<span></span>").addClass(r).setAttribute("title",t).setAttribute("tabIndex",0).setAttribute("data-draggroups",this.groups).setAttribute("role","button");return a.appendChild(u),a.addClass(n.cssclass),a},lock_drag_handle:function(e,t){e.removeHandle("."+t)},unlock_drag_handle:function(e,t){e.addHandle("."+t),e.get("activeHandle").focus()},ajax_failure:function(e){var t={name:e.status+" "+e.statusText,message:e.responseText};return new M.core.exception(t)},in_group:function(t){var n=!1;return e.each(this.groups,function(e){t._groups[e]&&(n=!0)},this),n},global_drag_start:function(e){var t=e.target;if(!this.in_group(t))return;t.get("node").setStyle("opacity",".25"),t.get("dragNode").setStyles({opacity:".75",borderColor:t.get("node").getStyle("borderColor"),backgroundColor:t.get("node").getStyle("backgroundColor")}),t.get("dragNode").empty(),this.drag_start(e)},global_drag_end:function(e){var t=e.target;if(!this.in_group(t))return;t.get("node").setStyles({visibility:"",opacity:"1"}),this.drag_end(e)},global_drag_drag:function(e){var t=e.target,n=e.info;if(!this.in_group(t))return;n.start[1]<n.xy[1]?this.absgoingup=!0:n.start[1]>n.xy[1]&&(this.absgoingup=!1),n.delta[1]<0?this.goingup=!0:n.delta[1]>0&&(this.goingup=!1),this.drag_drag(e)},global_drop_over:function(e){if(!e.drop||!e.drop.inGroup(this.groups))return;var t=e.drag.get("node"),n=e.drop.get("node");this.lastdroptarget=e.drop;if(n.hasClass(this.samenodeclass)){var r;this.goingup?r="before":r="after",n.insert(t,r)}else(n.hasClass(this.parentnodeclass)||n.test('[data-droptarget="1"]'))&&!n.contains(t)&&(this.goingup?n.append(t):n.prepend(t));this.drop_over(e)},global_drag_dropmiss:function(e){e.drag=e.target,e.drop=this.lastdroptarget;if(!this.in_group(e.drag))return;if(!e.drop||!e.drop.inGroup(this.groups))return;this.drag_dropmiss(e)},global_drop_hit:function(e){if(!e.drop||!e.drop.inGroup(this.groups))return;this.drop_hit(e)},find_element_text:function(t){var n=t.all("h2, h3, h4, h5, span, p, div.no-overflow, div.dimmed_text"),r="";return n.each(function(){r===""&&e.Lang.trim(this.get("text"))!==""&&(r=this.get("text"))}),r!==""?r:M.util.get_string("emptydragdropregion","moodle")},global_start_keyboard_drag:function(t,n,r){M.core.dragdrop.keydragcontainer=r,M.core.dragdrop.keydraghandle=n;var i=this.find_element_text(r),s=M.util.get_string("movecontent","moodle",i),o=e.Node.create("<ul></ul>");o.addClass("dragdrop-keyboard-drag");var u,a,f=e.all("."+this.samenodeclass+", ."+this.parentnodeclass);f.each(function(t){var n=!1,s=t;if(t.drop&&t.drop.inGroup(this.groups)&&t.drop.get("node")!==r)n=!0;else{var f=t.getAttribute("data-draggroups").split(" "),l,c;for(l=0;l<f.length;l++){for(c=0;c<this.groups.length;c++)if(f[l]===this.groups[c]){n=!0,s=t.get("parentNode");break}if(n)break}}n&&(u=e.Node.create("<li></li>"),listlink=e.Node.create("<a></a>"),i=this.find_element_text(s),this.samenodelabel&&t.hasClass(this.samenodeclass)?a=M.util.get_string(this.samenodelabel.identifier,this.samenodelabel.component,i):this.parentnodelabel&&t.hasClass(this.parentnodeclass)?a=M.util.get_string(this.parentnodelabel.identifier,this.parentnodelabel.component,i):a=M.util.get_string("tocontent","moodle",i),listlink.setContent(a),listlink.setAttribute("data-drop-target",t.get("id")),listlink.setAttribute("tabindex","0"),listlink.on("click",this.global_keyboard_drop,this),listlink.on("key",this.global_keyboard_drop,"down:enter,32",this),u.append(listlink),o.append(u))},this),M.core.dragdrop.dropui=new M.core.dialogue({headerContent:s,bodyContent:o,draggable:!0,visible:!0,center:!0,modal:!0}),M.core.dragdrop.dropui.after("visibleChange",function(e){e.prevVal&&!e.newVal&&this.global_cancel_keyboard_drag()},this),o.one("a")&&o.one("a").focus()},simulated_drag_drop_event:function(e,t){var n=function(e){this.node=e};n.prototype.get=function(e){return e==="node"||e==="dragNode"||e==="dropNode"?this.node:e==="activeHandle"?this.node.one(".editing_move"):null},n.prototype.inGroup=function(){return!0},n.prototype.addHandle=function(){},n.prototype.removeHandle=function(){},this.drop=new n(t),this.drag=new n(e),this.target=this.drop},global_keyboard_drop:function(t){var n=M.core.dragdrop.keydragcontainer,r=e.one("#"+t.target.getAttribute("data-drop-target"));M.core.dragdrop.dropui.hide(),t.preventDefault();var i=new this.simulated_drag_drop_event(n,n),s=new this.simulated_drag_drop_event(n,r);this.drag_start(i),this.global_drop_over(s),this.global_drop_hit(s)},global_cancel_keyboard_drag:function(){M.core.dragdrop.keydragcontainer&&(M.core.dragdrop.keydraghandle.focus(),M.core.dragdrop.keydragcontainer=null)},global_keydown:function(e){var t=e.target.ancestor("."+n.cssclass,!0),r,i;if(t===null)return;if(e.keyCode===27){this.global_cancel_keyboard_drag(),e.preventDefault();return}if(!t.hasClass(n.cssclass))return;if(e.keyCode!==13&&e.keyCode!==32&&e.type!=="click")return;i=t.getAttribute
+("data-draggroups").split(" ");var s,o,u=!1;for(s=0;s<i.length;s++){for(o=0;o<this.groups.length;o++)if(i[s]===this.groups[o]){u=!0;break}if(u)break}if(!u)return;r=t.ancestor(".yui3-dd-drop"),this.global_start_keyboard_drag(e,t,r),e.preventDefault()},drag_start:function(){},drag_end:function(){},drag_drag:function(){},drag_dropmiss:function(){},drop_over:function(){},drop_hit:function(){}},{NAME:"dragdrop",ATTRS:{}}),M.core=M.core||{},M.core.dragdrop=r},"@VERSION@",{requires:["base","node","io","dom","dd","event-key","event-focus","moodle-core-notification"]});
View
52 lib/yui/build/moodle-core-dragdrop/moodle-core-dragdrop.js
@@ -65,6 +65,24 @@ Y.extend(DRAGDROP, Y.Base, {
parentnodeclass: null,
/**
+ * The label to use with keyboard drag/drop to describe items of the same Node.
+ *
+ * @property samenodelabel
+ * @type Object
+ * @default null
+ */
+ samenodelabel : null,
+
+ /**
+ * The label to use with keyboard drag/drop to describe items of the parent Node.
+ *
+ * @property samenodelabel
+ * @type Object
+ * @default null
+ */
+ parentnodelabel : null,
+
+ /**
* The groups for this instance.
*
* @property groups
@@ -148,8 +166,7 @@ Y.extend(DRAGDROP, Y.Base, {
.setAttribute('title', title)
.setAttribute('tabIndex', 0)
.setAttribute('data-draggroups', this.groups)
- .setAttribute('role', 'button')
- .setAttribute('aria-grabbed', 'false');
+ .setAttribute('role', 'button');
dragelement.appendChild(dragicon);
dragelement.addClass(MOVEICON.cssclass);
@@ -162,6 +179,7 @@ Y.extend(DRAGDROP, Y.Base, {
unlock_drag_handle: function(drag, classname) {
drag.addHandle('.'+classname);
+ drag.get('activeHandle').focus();
},
ajax_failure: function(response) {
@@ -352,8 +370,6 @@ Y.extend(DRAGDROP, Y.Base, {
M.core.dragdrop.keydragcontainer = dragcontainer;
M.core.dragdrop.keydraghandle = draghandle;
- // Indicate to a screenreader the node that is selected for drag and drop.
- dragcontainer.setAttribute('aria-grabbed', 'true');
// Get the name of the thing to move.
var nodetitle = this.find_element_text(dragcontainer);
var dialogtitle = M.util.get_string('movecontent', 'moodle', nodetitle);
@@ -397,13 +413,17 @@ Y.extend(DRAGDROP, Y.Base, {
listlink = Y.Node.create('<a></a>');
nodetitle = this.find_element_text(labelroot);
- listitemtext = M.util.get_string('tocontent', 'moodle', nodetitle);
+ if (this.samenodelabel && node.hasClass(this.samenodeclass)) {
+ listitemtext = M.util.get_string(this.samenodelabel.identifier, this.samenodelabel.component, nodetitle);
+ } else if (this.parentnodelabel && node.hasClass(this.parentnodeclass)) {
+ listitemtext = M.util.get_string(this.parentnodelabel.identifier, this.parentnodelabel.component, nodetitle);
+ } else {
+ listitemtext = M.util.get_string('tocontent', 'moodle', nodetitle);
+ }
listlink.setContent(listitemtext);
// Add a data attribute so we can get the real drop target.
listlink.setAttribute('data-drop-target', node.get('id'));
- // Notify the screen reader this is a valid drop target.
- listlink.setAttribute('aria-dropeffect', 'move');
// Allow tabbing to the link.
listlink.setAttribute('tabindex', '0');
@@ -423,9 +443,18 @@ Y.extend(DRAGDROP, Y.Base, {
bodyContent: droplist,
draggable: true,
visible: true,
- centered: true
+ center: true,
+ modal: true
});
+ M.core.dragdrop.dropui.after('visibleChange', function(e) {
+ // After the dialogue has been closed, we call the cancel function. This will
+ // ensure that tidying up happens (e.g. focusing on the start Node).
+ if (e.prevVal && !e.newVal) {
+ this.global_cancel_keyboard_drag();
+ }
+ }, this);
+
// Focus the first drop target.
if (droplist.one('a')) {
droplist.one('a').focus();
@@ -465,6 +494,9 @@ Y.extend(DRAGDROP, Y.Base, {
if (param === 'node' || param === 'dragNode' || param === 'dropNode') {
return this.node;
}
+ if (param === 'activeHandle') {
+ return this.node.one('.editing_move');
+ }
return null;
};
@@ -493,7 +525,6 @@ Y.extend(DRAGDROP, Y.Base, {
global_keyboard_drop: function(e) {
// The drag node was saved.
var dragcontainer = M.core.dragdrop.keydragcontainer;
- dragcontainer.setAttribute('aria-grabbed', 'false');
// The real drop node is stored in an attribute of the proxy.
var droptarget = Y.one('#' + e.target.getAttribute('data-drop-target'));
@@ -508,7 +539,6 @@ Y.extend(DRAGDROP, Y.Base, {
this.drag_start(dragevent);
this.global_drop_over(dropevent);
this.global_drop_hit(dropevent);
- M.core.dragdrop.keydraghandle.focus();
},
/**
@@ -518,7 +548,7 @@ Y.extend(DRAGDROP, Y.Base, {
*/
global_cancel_keyboard_drag: function() {
if (M.core.dragdrop.keydragcontainer) {
- M.core.dragdrop.keydragcontainer.setAttribute('aria-grabbed', 'false');
+ // Focus on the node which was being dragged.
M.core.dragdrop.keydraghandle.focus();
M.core.dragdrop.keydragcontainer = null;
}
View
52 lib/yui/src/dragdrop/js/dragdrop.js
@@ -63,6 +63,24 @@ Y.extend(DRAGDROP, Y.Base, {
parentnodeclass: null,
/**
+ * The label to use with keyboard drag/drop to describe items of the same Node.
+ *
+ * @property samenodelabel
+ * @type Object
+ * @default null
+ */
+ samenodelabel : null,
+
+ /**
+ * The label to use with keyboard drag/drop to describe items of the parent Node.
+ *
+ * @property samenodelabel
+ * @type Object
+ * @default null
+ */
+ parentnodelabel : null,
+
+ /**
* The groups for this instance.
*
* @property groups
@@ -146,8 +164,7 @@ Y.extend(DRAGDROP, Y.Base, {
.setAttribute('title', title)
.setAttribute('tabIndex', 0)
.setAttribute('data-draggroups', this.groups)
- .setAttribute('role', 'button')
- .setAttribute('aria-grabbed', 'false');
+ .setAttribute('role', 'button');
dragelement.appendChild(dragicon);
dragelement.addClass(MOVEICON.cssclass);
@@ -160,6 +177,7 @@ Y.extend(DRAGDROP, Y.Base, {
unlock_drag_handle: function(drag, classname) {
drag.addHandle('.'+classname);
+ drag.get('activeHandle').focus();
},
ajax_failure: function(response) {
@@ -350,8 +368,6 @@ Y.extend(DRAGDROP, Y.Base, {
M.core.dragdrop.keydragcontainer = dragcontainer;
M.core.dragdrop.keydraghandle = draghandle;
- // Indicate to a screenreader the node that is selected for drag and drop.
- dragcontainer.setAttribute('aria-grabbed', 'true');
// Get the name of the thing to move.
var nodetitle = this.find_element_text(dragcontainer);
var dialogtitle = M.util.get_string('movecontent', 'moodle', nodetitle);
@@ -395,13 +411,17 @@ Y.extend(DRAGDROP, Y.Base, {
listlink = Y.Node.create('<a></a>');
nodetitle = this.find_element_text(labelroot);
- listitemtext = M.util.get_string('tocontent', 'moodle', nodetitle);
+ if (this.samenodelabel && node.hasClass(this.samenodeclass)) {
+ listitemtext = M.util.get_string(this.samenodelabel.identifier, this.samenodelabel.component, nodetitle);
+ } else if (this.parentnodelabel && node.hasClass(this.parentnodeclass)) {
+ listitemtext = M.util.get_string(this.parentnodelabel.identifier, this.parentnodelabel.component, nodetitle);
+ } else {
+ listitemtext = M.util.get_string('tocontent', 'moodle', nodetitle);
+ }
listlink.setContent(listitemtext);
// Add a data attribute so we can get the real drop target.
listlink.setAttribute('data-drop-target', node.get('id'));
- // Notify the screen reader this is a valid drop target.
- listlink.setAttribute('aria-dropeffect', 'move');
// Allow tabbing to the link.
listlink.setAttribute('tabindex', '0');
@@ -421,9 +441,18 @@ Y.extend(DRAGDROP, Y.Base, {
bodyContent: droplist,
draggable: true,
visible: true,
- centered: true
+ center: true,
+ modal: true
});
+ M.core.dragdrop.dropui.after('visibleChange', function(e) {
+ // After the dialogue has been closed, we call the cancel function. This will
+ // ensure that tidying up happens (e.g. focusing on the start Node).
+ if (e.prevVal && !e.newVal) {
+ this.global_cancel_keyboard_drag();
+ }
+ }, this);
+
// Focus the first drop target.
if (droplist.one('a')) {
droplist.one('a').focus();
@@ -463,6 +492,9 @@ Y.extend(DRAGDROP, Y.Base, {
if (param === 'node' || param === 'dragNode' || param === 'dropNode') {
return this.node;
}
+ if (param === 'activeHandle') {
+ return this.node.one('.editing_move');
+ }
return null;
};
@@ -491,7 +523,6 @@ Y.extend(DRAGDROP, Y.Base, {
global_keyboard_drop: function(e) {
// The drag node was saved.
var dragcontainer = M.core.dragdrop.keydragcontainer;
- dragcontainer.setAttribute('aria-grabbed', 'false');
// The real drop node is stored in an attribute of the proxy.
var droptarget = Y.one('#' + e.target.getAttribute('data-drop-target'));
@@ -506,7 +537,6 @@ Y.extend(DRAGDROP, Y.Base, {
this.drag_start(dragevent);
this.global_drop_over(dropevent);
this.global_drop_hit(dropevent);
- M.core.dragdrop.keydraghandle.focus();
},
/**
@@ -516,7 +546,7 @@ Y.extend(DRAGDROP, Y.Base, {
*/
global_cancel_keyboard_drag: function() {
if (M.core.dragdrop.keydragcontainer) {
- M.core.dragdrop.keydragcontainer.setAttribute('aria-grabbed', 'false');
+ // Focus on the node which was being dragged.
M.core.dragdrop.keydraghandle.focus();
M.core.dragdrop.keydragcontainer = null;
}
Please sign in to comment.
Something went wrong with that request. Please try again.