Skip to content

Instantly share code, notes, and snippets.

@over
Created October 29, 2010 17:04
Show Gist options
  • Save over/653906 to your computer and use it in GitHub Desktop.
Save over/653906 to your computer and use it in GitHub Desktop.
//= require <jquery>
tm.behaviors.popup = $.klass({
initialize: function(popup) {
this.popup = popup;
},
onclick: $.delegate({
'.tm-popup-close': function() {
this.popup.hide();
},
'.tm-popup-submit': function() { this.popup.submit.apply(this); }
}),
onkeydown: $.delegate({
'input,textarea': function(e, event) {
if (!this.popup.parent.multiline && event.keyCode === 13 && (typeof this.popup.submit === 'function')) {
this.popup.submit.apply(this);
} else if ( event.keyCode === 27 ) {
this.popup.hide();
}
}
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment