diff --git a/app/views/issues/new.html.erb b/app/views/issues/new.html.erb index feb9e792f..40dae18b2 100644 --- a/app/views/issues/new.html.erb +++ b/app/views/issues/new.html.erb @@ -44,8 +44,6 @@ <%= submit_tag l(:button_create) %> <%= submit_tag l(:button_create_and_continue), :name => 'continue' %> <%= preview_link preview_new_issue_path(:project_id => @project), 'issue-form' %> - - <%= javascript_tag "$('#issue_subject').focus();" %> <% end %>
diff --git a/app/views/my/password.html.erb b/app/views/my/password.html.erb index 5dbf24cb0..c3f86b99f 100644 --- a/app/views/my/password.html.erb +++ b/app/views/my/password.html.erb @@ -22,5 +22,3 @@ <%= render :partial => 'sidebar' %> <% end %> <% end %> - -<%= javascript_tag "$('#password').focus();" %> diff --git a/app/views/projects/new.html.erb b/app/views/projects/new.html.erb index a14a9cf3e..bd474bb79 100644 --- a/app/views/projects/new.html.erb +++ b/app/views/projects/new.html.erb @@ -4,5 +4,4 @@ <%= render :partial => 'form', :locals => { :f => f } %> <%= submit_tag l(:button_create) %> <%= submit_tag l(:button_create_and_continue), :name => 'continue' %> -<%= javascript_tag "$('#project_name').focus();" %> <% end %> diff --git a/app/views/search/index.html.erb b/app/views/search/index.html.erb index 32e067e6f..ffa0b483f 100644 --- a/app/views/search/index.html.erb +++ b/app/views/search/index.html.erb @@ -4,7 +4,6 @@ <%= form_tag({}, :method => :get, :id => 'search-form') do %> <%= label_tag "search-input", l(:description_search), :class => "hidden-for-sighted" %><%= text_field_tag 'q', @question, :size => 60, :id => 'search-input' %> -<%= javascript_tag "$('#search-input').focus()" %> <%= project_select_tag %> <%= hidden_field_tag 'all_words', '', :id => nil %> diff --git a/public/javascripts/application.js b/public/javascripts/application.js index a6d15f2f0..f31cb353a 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -583,6 +583,12 @@ function addFormObserversForDoubleSubmit() { }); } +function defaultFocus(){ + if ($('#content :focus').length == 0) { + $('#content input[type=text], #content textarea').first().focus(); + } +} + function blockEventPropagation(event) { event.stopPropagation(); event.preventDefault(); @@ -604,4 +610,5 @@ $(document).ready(function(){ $(document).ready(setupAjaxIndicator); $(document).ready(hideOnLoad); $(document).ready(addFormObserversForDoubleSubmit); +$(document).ready(defaultFocus);