Escape key closes share dialog

This commit is contained in:
Neil Lalonde 2013-03-27 16:28:53 -04:00
parent 36269cfbaa
commit 55884e4b77

View File

@ -36,7 +36,7 @@ Discourse.ShareView = Discourse.View.extend({
_this.get('controller').close(); _this.get('controller').close();
return true; return true;
}); });
return $('html').on('click.discoure-share-link', '[data-share-url]', function(e) { $('html').on('click.discoure-share-link', '[data-share-url]', function(e) {
var $currentTarget, url; var $currentTarget, url;
e.preventDefault(); e.preventDefault();
$currentTarget = $(e.currentTarget); $currentTarget = $(e.currentTarget);
@ -50,11 +50,17 @@ Discourse.ShareView = Discourse.View.extend({
_this.get('controller').shareLink(e, url); _this.get('controller').shareLink(e, url);
return false; return false;
}); });
$('html').on('keydown.shareView', function(e){
if (e.keyCode === 27) {
_this.get('controller').close();
}
});
}, },
willDestroyElement: function() { willDestroyElement: function() {
$('html').off('click.discoure-share-link'); $('html').off('click.discoure-share-link');
$('html').off('click.outside-share-link'); $('html').off('click.outside-share-link');
$('html').off('keydown.shareView');
} }
}); });