1
0
mirror of https://github.com/phpmyadmin/phpmyadmin.git synced 2026-10-29 21:24:44 +03:00

Share js code for username input and fix it

Signed-off-by: Michal Čihař <michal@cihar.com>
This commit is contained in:
Michal Čihař
2016-04-26 12:41:13 +02:00
parent 6fdb046f9b
commit 0cd7caee71
3 changed files with 21 additions and 19 deletions

View File

@@ -3039,6 +3039,22 @@ AJAX.registerTeardown('functions.js', function () {
*/
AJAX.registerOnload('functions.js', function () {
/* Handler for username type */
$(document).on('change', '#select_pred_username', function () {
if (this.value == 'any') {
$('#pma_username').val('').prop('required', false);
$('#user_exists_warning').css('display', 'none');
} else if (this.value == 'userdefined') {
$('#pma_username').focus().select().prop('required', true);
}
});
/* Handler for editing username */
$(document).on('change', '#pma_username', function () {
$('#select_pred_username').val('userdefined');
$('#pma_username').prop('required', true);
});
/* Handler for password type */
$(document).on('change', '#select_pred_password', function () {
if (this.value == 'none') {

View File

@@ -797,10 +797,7 @@ function PMA_getHtmlForAddUserLoginForm($username_length)
. '</label>'
. '<span class="options">'
. ' <select name="pred_username" id="select_pred_username" '
. 'title="' . __('User name') . '"'
. ' onchange="if (this.value == \'any\') { username.value = \'\'; } '
. 'else if (this.value == \'userdefined\') { '
. ' username.focus(); username.select(); }">'
. 'title="' . __('User name') . '">'
. ' <option value="any"'
. ((isset($GLOBALS['pred_username'])
&& $GLOBALS['pred_username'] == 'any') ? ' selected="selected"' : '')
@@ -812,13 +809,13 @@ function PMA_getHtmlForAddUserLoginForm($username_length)
. '>' . __('Use text field:') . '</option>'
. ' </select>'
. '</span>'
. '<input type="text" name="username" maxlength="'
. '<input type="text" name="username" id="pma_username" maxlength="'
. $username_length . '" title="' . __('User name') . '"'
. (empty($_REQUEST['username']) ? '' : ' value="'
. (isset($GLOBALS['new_username'])
? $GLOBALS['new_username']
: $_REQUEST['username']) . '"')
. ' onchange="pred_username.value = \'userdefined\';" />'
. ' />'
. '</div>';
return $html;

View File

@@ -1616,17 +1616,7 @@ function PMA_getHtmlForLoginInformationFields(
. '<span class="options">' . "\n";
$html_output .= '<select name="pred_username" id="select_pred_username" '
. 'title="' . __('User name') . '"' . "\n";
$html_output .= ' onchange="'
. 'if (this.value == \'any\') {'
. ' username.value = \'\'; '
. ' user_exists_warning.style.display = \'none\'; '
. ' username.required = false; '
. '} else if (this.value == \'userdefined\') {'
. ' username.focus(); username.select(); '
. ' username.required = true; '
. '}">' . "\n";
. 'title="' . __('User name') . '">' . "\n";
$html_output .= '<option value="any"'
. ((isset($GLOBALS['pred_username']) && $GLOBALS['pred_username'] == 'any')
@@ -1647,7 +1637,7 @@ function PMA_getHtmlForLoginInformationFields(
$html_output .= '</select>' . "\n"
. '</span>' . "\n";
$html_output .= '<input type="text" name="username" class="autofocus"'
$html_output .= '<input type="text" name="username" id="pma_username" class="autofocus"'
. ' maxlength="' . $username_length . '" title="' . __('User name') . '"'
. (empty($GLOBALS['username'])
? ''
@@ -1657,7 +1647,6 @@ function PMA_getHtmlForLoginInformationFields(
: $GLOBALS['username']
) . '"'
)
. ' onchange="pred_username.value = \'userdefined\'; this.required = true;" '
. ((! isset($GLOBALS['pred_username'])
|| $GLOBALS['pred_username'] == 'userdefined'
)