Merge pull request #95 from finnlabs/feature/unobtrusive_scroll_to

adds unobtrusive scrollTo on cost_object update
pull/6827/head
Alex Coles 11 years ago
commit fa372c96a7
  1. 15
      app/assets/javascripts/costs/cost_objects.js
  2. 2
      app/views/cost_objects/show.html.erb

@ -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;
});
});
});

@ -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 %>

Loading…
Cancel
Save