MDL-43267 Javascript: Improve focus before and after drag/drop

This commit is contained in:
Andrew Nicols
2014-02-07 15:12:18 +08:00
parent 472b07b8e7
commit 4974d22b8d
+13 -1
View File
@@ -75,6 +75,7 @@ YUI.add('moodle-core-dragdrop', function(Y) {
unlock_drag_handle: function(drag, classname) {
drag.addHandle('.'+classname);
drag.get('activeHandle').focus();
},
ajax_failure: function(response) {
@@ -341,6 +342,14 @@ YUI.add('moodle-core-dragdrop', function(Y) {
centered : 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();
@@ -380,6 +389,9 @@ YUI.add('moodle-core-dragdrop', function(Y) {
if (param == 'node' || param == 'dragNode' || param == 'dropNode') {
return this.node;
}
if (param === 'activeHandle') {
return this.node.one('.editing_move');
}
return null;
};
@@ -422,7 +434,6 @@ YUI.add('moodle-core-dragdrop', function(Y) {
this.drag_start(dragevent);
this.global_drop_over(dropevent);
this.global_drop_hit(dropevent);
M.core.dragdrop.keydraghandle.focus();
},
/**
@@ -432,6 +443,7 @@ YUI.add('moodle-core-dragdrop', function(Y) {
*/
global_cancel_keyboard_drag : function() {
if (M.core.dragdrop.keydragcontainer) {
// Focus on the node which was being dragged.
M.core.dragdrop.keydraghandle.focus();
M.core.dragdrop.keydragcontainer = null;
}