mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
simplify the js code a bit and also detect up arrow key for auto completion
git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10255 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
f0ef35ce6e
commit
91721d67fa
1 changed files with 21 additions and 24 deletions
|
@ -321,16 +321,12 @@ var in_autocomplete = false;
|
||||||
var last_key_entered = '';
|
var last_key_entered = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Usually used for onkeypress event, to submit a form on enter
|
* Check event key
|
||||||
*/
|
*/
|
||||||
function submit_default_button(event, selector, class_name)
|
function phpbb_check_key(event)
|
||||||
{
|
{
|
||||||
// Add which for key events
|
// Keycode is array down or up?
|
||||||
if (!event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode))
|
if (event.keyCode && (event.keyCode == 40 || event.keyCode == 38))
|
||||||
event.which = event.charCode || event.keyCode;
|
|
||||||
|
|
||||||
// Keycode is array down?
|
|
||||||
if (event.keyCode && event.keyCode == 40)
|
|
||||||
in_autocomplete = true;
|
in_autocomplete = true;
|
||||||
|
|
||||||
// Make sure we are not within an "autocompletion" field
|
// Make sure we are not within an "autocompletion" field
|
||||||
|
@ -351,6 +347,21 @@ function submit_default_button(event, selector, class_name)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Usually used for onkeypress event, to submit a form on enter
|
||||||
|
*/
|
||||||
|
function submit_default_button(event, selector, class_name)
|
||||||
|
{
|
||||||
|
// Add which for key events
|
||||||
|
if (!event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode))
|
||||||
|
event.which = event.charCode || event.keyCode;
|
||||||
|
|
||||||
|
if (phpbb_set_autocomplete(event))
|
||||||
|
return true;
|
||||||
|
|
||||||
var current = selector['parentNode'];
|
var current = selector['parentNode'];
|
||||||
|
|
||||||
// Search parent form element
|
// Search parent form element
|
||||||
|
@ -394,20 +405,8 @@ function apply_onkeypress_event()
|
||||||
if (!default_button || default_button.length <= 0)
|
if (!default_button || default_button.length <= 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Keycode is array down?
|
if (phpbb_check_key(e))
|
||||||
if (e.keyCode && e.keyCode == 40)
|
return true;
|
||||||
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))
|
if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13))
|
||||||
{
|
{
|
||||||
|
@ -415,8 +414,6 @@ function apply_onkeypress_event()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
last_key_entered = e.which;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue