From d803fc7c69beb6715ce4b5cacfbf1c6385de32ba Mon Sep 17 00:00:00 2001 From: Yorhel Date: Wed, 26 Nov 2008 14:59:25 +0100 Subject: Added a hack for opera to not submit the form on the return key --- lib/ChangeLog | 2 ++ static/f/forms.js | 23 ++++++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/ChangeLog b/lib/ChangeLog index ce2268e5..8181e961 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -31,6 +31,8 @@ TODO: - Boardmods can edit threads without updating the last edited field - No more RSS feeds for changes (will be replaced with a notification system in the future) + - Improved formsub interface + - Improved VN relation editor interface 1.23 - 2008-10-22 (r117) - Removed redirects for old revision URLs (the code wasn't very secure...) diff --git a/static/f/forms.js b/static/f/forms.js index 8c09e1e2..02f570ad 100644 --- a/static/f/forms.js +++ b/static/f/forms.js @@ -117,16 +117,25 @@ function dsKeyDown(ev) { // do some processing when the enter key has been pressed if(c == 13) { - if(obj.selectedId != 0) { + if(obj.selectedId != 0) obj.value = obj.serFunc(x('ds_box_'+obj.selectedId).itemData); - x('ds_box').style.top = '-500px'; - obj.selectedId = 0; - return false; - } else if(obj.returnFunc) { + else if(obj.returnFunc) obj.returnFunc(); - return false; + else + return true; + x('ds_box').style.top = '-500px'; + obj.selectedId = 0; + + // opera hack: make sure to not send the form on the return key + while(obj && obj.nodeName.toLowerCase() != 'form') + obj = obj.parentNode; + if(obj) { + var oldsubmit = obj.onsubmit; + obj.onsubmit = function() { return false }; + setTimeout(function() { obj.onsubmit = oldsubmit }, 100); } - return true; + + return false; } // process up/down keys -- cgit v1.2.3