Skip to content

Commit

Permalink
MDL-35981 comments: Make delete comment keyboard accessible.
Browse files Browse the repository at this point in the history
  • Loading branch information
Damyon Wiese committed Aug 2, 2013
1 parent a31e811 commit ba29e21
Showing 1 changed file with 11 additions and 32 deletions.
43 changes: 11 additions & 32 deletions comment/comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ M.core_comment = {
}, this);
}
scope.toggle_textarea(false);
CommentHelper.confirmoverlay = new Y.Overlay({
bodyContent: '<div class="comment-delete-confirm"><a href="#" id="confirmdelete-'+this.client_id+'">'+M.str.moodle.yes+'</a> <a href="#" id="canceldelete-'+this.client_id+'">'+M.str.moodle.no+'</a></div>',
visible: false
});
CommentHelper.confirmoverlay.render(document.body);
},
post: function() {
var ta = Y.one('#dlg-content-'+this.client_id);
Expand Down Expand Up @@ -238,7 +233,6 @@ bodyContent: '<div class="comment-delete-confirm"><a href="#" id="confirmdelete-
dodelete: function(id) { // note: delete is a reserved word in javascript, chrome and safary do not like it at all here!
var scope = this;
var params = {'commentid': id};
scope.cancel_delete();
function remove_dom(type, anim, cmt) {
cmt.remove();
}
Expand Down Expand Up @@ -294,37 +288,22 @@ bodyContent: '<div class="comment-delete-confirm"><a href="#" id="confirmdelete-
if (commentid[1]) {
Y.Event.purgeElement('#'+theid, false, 'click');
}
node.on('click', function(e, node) {
node.on('click', function(e) {
e.preventDefault();
var width = CommentHelper.confirmoverlay.bodyNode.getStyle('width');
var re = new RegExp("(\\d+).*", "i");
var result = width.match(re);
if (result[1]) {
width = Number(result[1]);
} else {
width = 0;
if (commentid[1]) {
scope.dodelete(commentid[1]);
}
//CommentHelper.confirmoverlay.set('xy', [e.pageX-(width/2), e.pageY]);
CommentHelper.confirmoverlay.set('xy', [e.pageX-width-5, e.pageY]);
CommentHelper.confirmoverlay.set('visible', true);
Y.one('#canceldelete-'+scope.client_id).on('click', function(e) {
e.preventDefault();
scope.cancel_delete();
});
Y.Event.purgeElement('#confirmdelete-'+scope.client_id, false, 'click');
Y.one('#confirmdelete-'+scope.client_id).on('click', function(e) {
e.preventDefault();
if (commentid[1]) {
scope.dodelete(commentid[1]);
}
});
}, scope, node);
});
// Also handle space/enter key.
node.on('key', function(e) {
e.preventDefault();
if (commentid[1]) {
scope.dodelete(commentid[1]);
}
}, '13,32');
}
);
},
cancel_delete: function() {
CommentHelper.confirmoverlay.set('visible', false);
},
register_pagination: function() {
var scope = this;
// page buttons
Expand Down

0 comments on commit ba29e21

Please sign in to comment.