diff --git a/app/views/account/login.html.erb b/app/views/account/login.html.erb index 38991ae60..27878bc7e 100644 --- a/app/views/account/login.html.erb +++ b/app/views/account/login.html.erb @@ -5,13 +5,13 @@ <%= back_url_hidden_field_tag %> - <%= text_field_tag 'username', params[:username], :tabindex => '1' %> + <%= text_field_tag 'username', params[:username], :tabindex => '1', :autofocus => params[:username].blank? %> - <%= password_field_tag 'password', nil, :tabindex => '2' %> + <%= password_field_tag 'password', nil, :tabindex => '2', :autofocus => params[:username].present? %> <% if Setting.autologin? %> @@ -22,9 +22,3 @@ <%= call_hook :view_account_login_bottom %> - -<% if params[:username].present? %> -<%= javascript_tag "$('#password').focus();" %> -<% else %> -<%= javascript_tag "$('#username').focus();" %> -<% end %> diff --git a/app/views/sudo_mode/new.html.erb b/app/views/sudo_mode/new.html.erb index 6532dc4a9..cd25ea1d6 100644 --- a/app/views/sudo_mode/new.html.erb +++ b/app/views/sudo_mode/new.html.erb @@ -8,10 +8,9 @@

- <%= password_field_tag :sudo_password, nil, size: 25 %> + <%= password_field_tag :sudo_password, nil, size: 25, autofocus: true %>
<%= link_to l(:label_password_lost), lost_password_path, :class => "lost_password" if Setting.lost_password? %>

<%= submit_tag l(:button_submit) %> <% end %> -<%= javascript_tag "$('#sudo_password').focus();" %>