2961: Now loads tab panes (past the first one) in the background.
[arvados.git] / apps / workbench / app / views / application / _content.html.erb
1 <% content_for :tab_panes do %>
2
3 <% comparable = controller.respond_to? :compare %>
4
5 <ul class="nav nav-tabs">
6   <% pane_list.each_with_index do |pane, i| %>
7     <li class="<%= 'active' if i==0 %>"><a href="#<%= pane %>" data-toggle="tab" id="<%= pane %>-tab"> <%= pane.gsub('_', ' ') %></a></li>
8   <% end %>
9 </ul>
10 <div class="tab-content">
11 <% pane_list.each_with_index do |pane, i| %>
12   <div id="<%= pane %>"
13        class="tab-pane fade <%= 'in active' if i==0 %> arv-log-event-listener"
14        data-object-uuid="<%= @object.uuid if @object %>">
15
16 <% content_for :js do %>
17   $(document).on('<%= 'ready' if i != 0 %> arv-log-event', function() {
18   $.ajax('<%= url_for @object %>?tab_pane=<%= pane %>', {dataType: 'html', type: 'GET'}).
19   done(function(data, status, jqxhr) {
20     $('#<%= pane %> > div > div').html(data);
21   }).
22   fail(function(jqxhr, status, error) {
23   });
24   });
25 <% end %>
26
27     <div class="smart-scroll" style="margin-top:0.5em;">
28       <div class="pane-content">
29         <% if i == 0 %>
30           <%= render(partial: 'show_' + pane.downcase,
31                      locals: { comparable: comparable, objects: @objects }) %>
32           <% else %>
33             <%= image_tag 'ajax-loader.gif' %>
34         <% end %>
35       </div>
36     </div>
37   </div>
38 <% end %>
39 </div>
40
41 <% end %>
42
43 <% content_for :js do %>
44     $(window).on('load', smart_scroll_fixup);
45     $(document).on('shown.bs.tab', 'ul.nav-tabs > li > a', smart_scroll_fixup);
46 <% end %>