From 0fadf679247264ae598e8375c676338823fd0a89 Mon Sep 17 00:00:00 2001 From: Johannes Wollert Date: Fri, 20 Jun 2014 13:46:38 +0200 Subject: [PATCH] adds unobtrusive scrollTo on cost_object update --- app/assets/javascripts/costs/cost_objects.js | 15 +++++++++++++++ app/views/cost_objects/show.html.erb | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/costs/cost_objects.js b/app/assets/javascripts/costs/cost_objects.js index a3fb8ee09c..1a1fbb8d50 100644 --- a/app/assets/javascripts/costs/cost_objects.js +++ b/app/assets/javascripts/costs/cost_objects.js @@ -31,3 +31,18 @@ function confirmChangeType(text, select, originalValue) { if (!ret) select.setValue(originalValue); return ret; } + +jQuery(function($) { + $(window).load(function () { + $('.action_menu_specific > .icon-edit').click(function () { + var scrollToId = "#update", + focusId = "#cost_object_description"; + $(scrollToId).show(); + $('html, body').animate({ + scrollTop: $(scrollToId).offset().top + }, 500); + $(focusId).focus(); + return false; + }); + }); +}); diff --git a/app/views/cost_objects/show.html.erb b/app/views/cost_objects/show.html.erb index d9688b0c72..1a7b89601c 100644 --- a/app/views/cost_objects/show.html.erb +++ b/app/views/cost_objects/show.html.erb @@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. <%= render :partial => 'shared/costs_header' %> <% content_for :action_menu_specific do %> - <%= link_to_if_authorized l(:button_update), {:controller => 'cost_objects', :action => 'edit', :id => @cost_object}, :onclick => 'showAndScrollTo("update", "cost_object_description"); return false;', :class => 'icon icon-edit', :accesskey => accesskey(:edit) %> + <%= link_to_if_authorized l(:button_update), {:controller => 'cost_objects', :action => 'edit', :id => @cost_object}, :class => 'icon icon-edit', :accesskey => accesskey(:edit) %> <%= link_to_if_authorized l(:button_copy), {:controller => 'cost_objects', :action => 'copy', :id => @cost_object }, :class => 'icon icon-copy' %> <%= link_to_if_authorized l(:button_delete), {:controller => 'cost_objects', :action => 'destroy', :id => @cost_object}, :confirm => l(:text_are_you_sure), :method => :delete, :class => 'icon icon-delete' %> <% end %>