uses ajaxAppend for loading the issue#edit form

This means that it is no longer necessary to render the edit form on
every show request which will significantely increase the load speed
of the page. We will have to see if it is ok for the user to have to
wait for the form to load once he actually wishes to edit the issue.
pull/29/head
Jens Ulferts 12 years ago committed by Christian Ratz
parent a0a81ee546
commit 857dd7c4d2
  1. 1
      app/controllers/issues_controller.rb
  2. 8
      app/views/issues/_action_menu.rhtml
  3. 3
      app/views/issues/show.rhtml
  4. 34
      public/javascripts/application.js

@ -178,6 +178,7 @@ class IssuesController < ApplicationController
@journal = @issue.current_journal
respond_to do |format|
format.js { render :partial => 'edit' }
format.html { }
format.xml { }
end

@ -1,5 +1,9 @@
<% content_for :action_menu_main do %>
<%= li_unless_nil(link_to_if_authorized(l(:button_update), {:controller => 'issues', :action => 'edit', :id => @issue }, :onclick => 'showAndScrollTo("update", "notes"); return false;', :class => 'icon icon-edit', :accesskey => accesskey(:edit))) %>
<%= li_unless_nil(link_to_if_authorized(l(:button_update), { :controller => 'issues',
:action => 'edit',
:id => @issue },
:class => 'edit icon icon-edit',
:accesskey => accesskey(:edit))) %>
<%= li_unless_nil(watcher_link(@issue,
User.current,
{ :class => 'watcher_link',
@ -11,4 +15,4 @@
<%= li_unless_nil(link_to_if_authorized l(:button_copy), {:controller => 'issue_moves', :action => 'new', :id => @issue, :copy_options => {:copy => 't'}}, :class => 'icon icon-copy') %>
<%= li_unless_nil(link_to_if_authorized l(:button_move), {:controller => 'issue_moves', :action => 'new', :id => @issue}, :class => 'icon icon-move') %>
<%= li_unless_nil(link_to_if_authorized l(:button_delete), {:controller => 'issues', :action => 'destroy', :id => @issue}, :confirm => (@issue.leaf? ? l(:text_are_you_sure) : l(:text_are_you_sure_with_children)), :method => :post, :class => 'icon icon-del') %>
<% end %>
<% end %>

@ -113,8 +113,7 @@
<div style="clear: both;"></div>
<% if authorize_for('issues', 'edit') %>
<div id="update" style="display:none;">
<%= render :partial => 'edit' %>
<div id="update">
</div>
<% end %>

@ -1458,3 +1458,37 @@ var SubmitConfirm = (function($) {
init: init
};
})(jQuery);
var Issue = Issue || {};
Issue.Show = (function($) {
var init;
init = function () {
$.ajaxAppend({
trigger: '.action_menu_main .edit',
indicator_class: 'ajax-indicator',
load_target: '#update',
loading_text: I18n.t("js.ajax.loading"),
loading_class: 'box loading',
loading: function(update) {
$('html, body').animate({
scrollTop: $(update).offset().top
}, 200);
},
loaded: function(update) {
$('html, body').animate({
scrollTop: $(update).offset().top
}, 200);
$("#notes").focus();
}
});
};
$('document').ready(function () {
if ($('body.controller-issues.action-show').size() > 0) {
init();
};
});
})(jQuery);

Loading…
Cancel
Save