Pressing escape closes the lightbox

// FREEBIE
This commit is contained in:
lilia 2016-06-30 00:55:44 -07:00
parent a069939f65
commit f670061669

View file

@ -131,6 +131,12 @@
Whisper.LightboxView = Whisper.View.extend({
templateName: 'lightbox',
className: 'modal lightbox',
initialize: function() {
this.window = extension.windows.getWindow();
this.$document = $(this.window.document);
this.listener = this.onkeyup.bind(this);
this.$document.on('keyup', this.listener);
},
events: {
'click .save': 'save',
'click .close': 'remove',
@ -147,6 +153,12 @@
return false;
}
},
onkeyup: function(e) {
if (e.keyCode === 27) {
this.remove();
this.$document.off('keyup', this.listener);
}
},
render_attributes: function() {
return { url: this.model.objectUrl };
}