From: Michael M Slusarz Date: Mon, 21 Dec 2009 20:34:49 +0000 (-0700) Subject: Optimize return trapping code X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=10627abff221427012b952347cc65b3a679b6145;p=horde.git Optimize return trapping code --- diff --git a/imp/js/compose.js b/imp/js/compose.js index 312c25e67..dc23acc56 100644 --- a/imp/js/compose.js +++ b/imp/js/compose.js @@ -360,19 +360,23 @@ var ImpCompose = { } }, + keyDownHandler: function(e) + { + if (e.keyCode == 10 || e.keyCode == Event.KEY_RETURN) { + e.stop(); + } + }, + onDomLoad: function() { + var handler = this.keyDownHandler.bindAsEventListener(this); + /* Prevent Return from sending messages - it should bring us out of * autocomplete, not submit the whole form. */ - $$('INPUT').each(function(i) { + $('compose').select('INPUT').each(function(i) { /* Attach to everything but button and submit elements. */ if (i.type != 'submit' && i.type != 'button') { - i.observe('keydown', function(e) { - if (e.keyCode == 10 || e.keyCode == Event.KEY_RETURN) { - e.stop(); - return false; - } - }); + i.observe('keydown', handler); } });