aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMeik Sievertsen <acydburn@phpbb.com>2009-11-05 14:58:25 +0000
committerMeik Sievertsen <acydburn@phpbb.com>2009-11-05 14:58:25 +0000
commitf0ef35ce6ed4b6e2d17a299a5ee250c32f41ad56 (patch)
treef0c12250d51173c735af432910c2eae96286df12
parent9c7109d59e8d603208da0fcae3060d731f09ea42 (diff)
downloadforums-f0ef35ce6ed4b6e2d17a299a5ee250c32f41ad56.tar
forums-f0ef35ce6ed4b6e2d17a299a5ee250c32f41ad56.tar.gz
forums-f0ef35ce6ed4b6e2d17a299a5ee250c32f41ad56.tar.bz2
forums-f0ef35ce6ed4b6e2d17a299a5ee250c32f41ad56.tar.xz
forums-f0ef35ce6ed4b6e2d17a299a5ee250c32f41ad56.zip
update to r10069 (try to detect auto completion on input fields and do not submit form if user uses enter key for auto completion instead of right arrow key)
git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10254 89ea8834-ac86-4346-8a33-228a782c2dd0
-rw-r--r--phpBB/styles/prosilver/template/forum_fn.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js
index 11e4315e2a..153f0c2ae5 100644
--- a/phpBB/styles/prosilver/template/forum_fn.js
+++ b/phpBB/styles/prosilver/template/forum_fn.js
@@ -317,6 +317,9 @@ function find_in_tree(node, tag, type, class_name)
}
}
+var in_autocomplete = false;
+var last_key_entered = '';
+
/**
* Usually used for onkeypress event, to submit a form on enter
*/
@@ -326,9 +329,27 @@ function submit_default_button(event, selector, class_name)
if (!event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode))
event.which = event.charCode || event.keyCode;
+ // Keycode is array down?
+ if (event.keyCode && event.keyCode == 40)
+ in_autocomplete = true;
+
+ // Make sure we are not within an "autocompletion" field
+ if (in_autocomplete)
+ {
+ // If return pressed and key changed we reset the autocompletion
+ if (!last_key_entered || last_key_entered == event.which)
+ {
+ in_autocompletion = false;
+ return true;
+ }
+ }
+
// Keycode is not return, then return. ;)
if (event.which != 13)
+ {
+ last_key_entered = event.which;
return true;
+ }
var current = selector['parentNode'];
@@ -373,12 +394,29 @@ function apply_onkeypress_event()
if (!default_button || default_button.length <= 0)
return true;
+ // Keycode is array down?
+ if (e.keyCode && e.keyCode == 40)
+ in_autocomplete = true;
+
+ // Make sure we are not within an "autocompletion" field
+ if (in_autocomplete)
+ {
+ // If return pressed and key changed we reset the autocompletion
+ if (!last_key_entered || last_key_entered == e.which)
+ {
+ in_autocompletion = false;
+ return true;
+ }
+ }
+
if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13))
{
default_button.click();
return false;
}
+ last_key_entered = e.which;
+
return true;
});