From a1bee10fd1d49aa46022eb4445a6613a8cfcb307 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Fri, 24 Nov 2017 19:22:11 +0100 Subject: [PATCH] generic way for initial focus --- lam/templates/config/conflogin.php | 13 +----------- lam/templates/config/conftypes.php | 1 - lam/templates/config/mainlogin.php | 10 +--------- lam/templates/lib/500_lam.js | 8 ++++++++ lam/templates/login.php | 32 +++++++++++------------------- 5 files changed, 22 insertions(+), 42 deletions(-) diff --git a/lam/templates/config/conflogin.php b/lam/templates/config/conflogin.php index 6140b6eb..4363a9ea 100644 --- a/lam/templates/config/conflogin.php +++ b/lam/templates/config/conflogin.php @@ -80,19 +80,7 @@ $tabindex = 1; -
@@ -131,6 +119,7 @@ $tabindex = 1; $box->add(new htmlResponsiveSelect('filename', $profiles, $selectedProfile, _('Profile name')), 12); $passwordInput = new htmlResponsiveInputField(_('Password'), 'passwd', '', '200'); $passwordInput->setIsPassword(true); + $passwordInput->setCSSClasses(array('lam-initial-focus')); $box->add($passwordInput, 12); $box->addVerticalSpacer('1rem'); $button = new htmlButton('submit', _("Ok")); diff --git a/lam/templates/config/conftypes.php b/lam/templates/config/conftypes.php index 75a6d950..0830f75e 100644 --- a/lam/templates/config/conftypes.php +++ b/lam/templates/config/conftypes.php @@ -9,7 +9,6 @@ use \htmlButton; use \htmlGroup; use \htmlResponsiveInputCheckbox; use \LAMConfig; -use \htmlTableExtendedInputCheckbox; use \htmlResponsiveRow; use \htmlResponsiveInputField; /* diff --git a/lam/templates/config/mainlogin.php b/lam/templates/config/mainlogin.php index 5f1f3860..d3a43899 100644 --- a/lam/templates/config/mainlogin.php +++ b/lam/templates/config/mainlogin.php @@ -72,15 +72,6 @@ printHeaderContents(_("Login"), '../..'); \n"; - echo "\n"; - echo "\n"; // include all JavaScript files $jsDirName = dirname(__FILE__) . '/../lib'; $jsDir = dir($jsDirName); @@ -142,6 +133,7 @@ printHeaderContents(_("Login"), '../..'); $passwordField = new htmlInputField('passwd'); $passwordField->setFieldSize(15); $passwordField->setIsPassword(true); + $passwordField->setCSSClasses(array('lam-initial-focus')); $passwordGroup->addElement($passwordField); $passwordGroup->addElement(new htmlHelpLink('236')); $passwordDiv = new htmlDiv(null, $passwordGroup); diff --git a/lam/templates/lib/500_lam.js b/lam/templates/lib/500_lam.js index 197124d2..68ac75a0 100644 --- a/lam/templates/lib/500_lam.js +++ b/lam/templates/lib/500_lam.js @@ -866,10 +866,18 @@ window.lam.tools.activateTab = function() { jQuery('.lam-active-tab').addClass('ui-tabs-active ui-state-active user-bright'); }; +/** + * Sets the focus on the initial field. + */ +window.lam.tools.setInitialFocus = function() { + jQuery('.lam-initial-focus').focus(); +}; + jQuery(document).ready(function() { window.lam.gui.equalHeight(); window.lam.form.autoTrim(); window.lam.account.addDefaultProfileListener(); window.lam.tools.addSavedSelectListener(); window.lam.tools.activateTab(); + window.lam.tools.setInitialFocus(); }); diff --git a/lam/templates/login.php b/lam/templates/login.php index 99a14cda..5a12114f 100644 --- a/lam/templates/login.php +++ b/lam/templates/login.php @@ -194,7 +194,7 @@ function display_LoginPage(LAMConfig $config_object, LAMCfgMain $cfgMain, $licen printHeaderContents('LDAP Account Manager', '..'); ?> - + isEvaluationLicense()) { StatusMessage('INFO', _('Evaluation Licence')); } - - // set focus on password field - if (!empty($config_object)) { - echo "\n"; - } ?> @@ -351,6 +333,9 @@ function display_LoginPage(LAMConfig $config_object, LAMCfgMain $cfgMain, $licen $userSelect = new htmlSelect('username', $adminList, $selectedAdmin); $userSelect->setHasDescriptiveElements(true); $userSelect->setTransformSingleSelect(false); + if (empty($_COOKIE['lam_login_name'])) { + $userSelect->setCSSClasses(array('lam-initial-focus')); + } $row->addField(new htmlDiv(null, $userSelect)); } else { @@ -364,7 +349,11 @@ function display_LoginPage(LAMConfig $config_object, LAMCfgMain $cfgMain, $licen if (isset($_COOKIE["lam_login_name"])) { $user = $_COOKIE["lam_login_name"]; } - $userInput = new htmlDiv(null, new htmlInputField('username', $user)); + $userNameInput = new htmlInputField('username', $user); + if (empty($_COOKIE['lam_login_name'])) { + $userNameInput->setCSSClasses(array('lam-initial-focus')); + } + $userInput = new htmlDiv(null, $userNameInput); $row->addField($userInput); } } @@ -378,6 +367,9 @@ function display_LoginPage(LAMConfig $config_object, LAMCfgMain $cfgMain, $licen else { $passwordInput = new htmlInputField('passwd'); $passwordInput->setIsPassword(true); + if (($config_object->getLoginMethod() == LAMConfig::LOGIN_SEARCH) && !empty($_COOKIE['lam_login_name'])) { + $passwordInput->setCSSClasses(array('lam-initial-focus')); + } $row->addField($passwordInput); } // language