mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
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
This commit is contained in:
parent
9c7109d59e
commit
f0ef35ce6e
1 changed files with 38 additions and 0 deletions
|
@ -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;
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue