Permalink
Browse files

Use array for `autocomplete` and `autofocus` attributes

This partially reverts commit 9e8ce96.
  • Loading branch information...
philwareham committed Oct 11, 2018
1 parent e431c92 commit eb852360126fc21945acb85246a2a05da96ec173
Showing with 34 additions and 11 deletions.
  1. +10 −2 textpattern/include/txp_admin.php
  2. +23 −4 textpattern/include/txp_auth.php
  3. +1 −5 textpattern/lib/txplib_forms.php
@@ -213,12 +213,20 @@ function new_pass_form($message = '')
hed(gTxt('change_password'), 2).
inputLabel(
'current_pass',
fInput('password', 'current_pass', '', '', '', '', INPUT_REGULAR, '', 'current_pass', false, true, '', 'current-password'),
fInput('password',
array(
'name' => 'current_pass',
'autocomplete' => 'current-password',
), '', '', '', '', INPUT_REGULAR, '', 'current_pass', false, true),
'current_password', '', array('class' => 'txp-form-field edit-admin-current-password')
).
inputLabel(
'new_pass',
fInput('password', 'new_pass', '', 'txp-maskable', '', '', INPUT_REGULAR, '', 'new_pass', false, true, '', 'new-password').
fInput('password',
array(
'name' => 'new_pass',
'autocomplete' => 'new-password',
), '', 'txp-maskable', '', '', INPUT_REGULAR, '', 'new_pass', false, true).
n.tag(
checkbox('unmask', 1, false, 0, 'show_password').
n.tag(gTxt('show_password'), 'label', array('for' => 'show_password')),
@@ -103,7 +103,12 @@ function doLoginForm($message)
$out[] = hed(gTxt('password_reset'), 1, array('id' => 'txp-login-heading')).
inputLabel(
'login_name',
fInput('text', 'p_userid', $name, '', '', '', INPUT_REGULAR, '', 'login_name', false, true, '', 'username', true),
fInput('text',
array(
'name' => 'p_userid',
'autocomplete' => 'username',
'autofocus' => true,
), $name, '', '', '', INPUT_REGULAR, '', 'login_name', false, true),
'name', '', array('class' => 'txp-form-field login-name')
).
graf(
@@ -120,7 +125,12 @@ function doLoginForm($message)
$out[] = hed($pageTitle, 1, array('id' => 'txp-'.$class.'-heading')).
inputLabel(
$label,
fInput('password', 'p_password', '', 'txp-maskable', '', '', INPUT_REGULAR, '', $label, false, true, '', 'new-password').
fInput('password',
array(
'name' => 'p_password',
'autocomplete' => 'new-password',
'autofocus' => true,
), '', 'txp-maskable', '', '', INPUT_REGULAR, '', $label, false, true).
n.tag(
checkbox('unmask', 1, false, 0, 'show_password').
n.tag(gTxt('show_password'), 'label', array('for' => 'show_password')),
@@ -140,12 +150,21 @@ function doLoginForm($message)
$out[] = hed(gTxt('login_to_textpattern'), 1, array('id' => 'txp-login-heading')).
inputLabel(
'login_name',
fInput('text', 'p_userid', $name, '', '', '', INPUT_REGULAR, '', 'login_name', false, true, '', 'username', true),
fInput('text',
array(
'name' => 'p_userid',
'autocomplete' => 'username',
'autofocus' => true,
), $name, '', '', '', INPUT_REGULAR, '', 'login_name', false, true),
'name', '', array('class' => 'txp-form-field login-name')
).
inputLabel(
'login_password',
fInput('password', 'p_password', '', '', '', '', INPUT_REGULAR, '', 'login_password', false, true, '', 'current-password'),
fInput('password',
array(
'name' => 'p_password',
'autocomplete' => 'current-password',
), '', '', '', '', INPUT_REGULAR, '', 'login_password', false, true),
'password', '', array('class' => 'txp-form-field login-password')
).
graf(
@@ -310,14 +310,12 @@ function timezoneSelectInput($name = '', $value = '', $blank_first = '', $onchan
* @param bool $disabled If TRUE renders the input disabled
* @param bool $required If TRUE the field is marked as required
* @param string $placeholder The placeholder value displayed when the field is empty
* @param string $autocomplete The autocomplete attribute value
* @param bool $autofocus If TRUE the field is auto-focused
* @return string HTML input
* @example
* echo fInput('text', 'myInput', 'My example value');
*/
function fInput($type, $name, $value, $class = '', $title = '', $onClick = '', $size = 0, $tab = 0, $id = '', $disabled = false, $required = false, $placeholder = '', $autocomplete = '', $autofocus = false)
function fInput($type, $name, $value, $class = '', $title = '', $onClick = '', $size = 0, $tab = 0, $id = '', $disabled = false, $required = false, $placeholder = '')
{
$atts = join_atts((is_array($name) ? $name : array('name' => $name)) + array(
'class' => $class,
@@ -330,8 +328,6 @@ function fInput($type, $name, $value, $class = '', $title = '', $onClick = '', $
'disabled' => (bool) $disabled,
'required' => (bool) $required,
'placeholder' => $placeholder,
'autocomplete' => $autocomplete,
'autofocus' => (bool) $autofocus,
), TEXTPATTERN_STRIP_EMPTY);
if ($type != 'file' && $type != 'image') {

0 comments on commit eb85236

Please sign in to comment.