From 0cd7caee7149d8c1945664c0b165b6441885b2d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Tue, 26 Apr 2016 12:41:13 +0200 Subject: [PATCH] Share js code for username input and fix it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michal Čihař --- js/functions.js | 16 ++++++++++++++++ libraries/replication_gui.lib.php | 9 +++------ libraries/server_privileges.lib.php | 15 ++------------- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/js/functions.js b/js/functions.js index abe7a3e88f..926cd1e2b0 100644 --- a/js/functions.js +++ b/js/functions.js @@ -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') { diff --git a/libraries/replication_gui.lib.php b/libraries/replication_gui.lib.php index a6d59aa637..a0ee67afc1 100644 --- a/libraries/replication_gui.lib.php +++ b/libraries/replication_gui.lib.php @@ -797,10 +797,7 @@ function PMA_getHtmlForAddUserLoginForm($username_length) . '' . '' . ' ' . '' - . '' + . ' />' . ''; return $html; diff --git a/libraries/server_privileges.lib.php b/libraries/server_privileges.lib.php index a909de0afb..f83e46da43 100644 --- a/libraries/server_privileges.lib.php +++ b/libraries/server_privileges.lib.php @@ -1616,17 +1616,7 @@ function PMA_getHtmlForLoginInformationFields( . '' . "\n"; $html_output .= '