Project

General

Profile

Feature #3058 » 01_allow-tabs-to-have-a-custom-action_v2_fixed.patch

Andrey Lobanov (RedSoft), 2017-07-07 13:42

View differences:

app/views/common/_tabs.html.erb (revision )
1
<% default_action = false %>
2

  
1 3
<div class="tabs">
2 4
  <ul>
3 5
  <% tabs.each do |tab| -%>
6
    <% action = tab[:onclick] ? tab[:onclick] : (tab[:partial] ? "showTab('#{tab[:name]}', this.href)" : nil) %>
4 7
    <li><%= link_to l(tab[:label]), (tab[:url] || { :tab => tab[:name] }),
5 8
                                    :id => "tab-#{tab[:name]}",
6 9
                                    :class => (tab[:name] != selected_tab ? nil : 'selected'),
7
                                    :onclick => tab[:partial] ? "showTab('#{tab[:name]}', this.href); this.blur(); return false;" : nil %></li>
10
                                    :onclick => action ? "#{action}; this.blur(); return false;" : nil %></li>
11
    <% default_action = action if tab[:name] == selected_tab %>
8 12
  <% end -%>
9 13
  </ul>
10 14
  <div class="tabs-buttons" style="display:none;">
......
19 23
                       :style => (tab[:name] != selected_tab ? 'display:none' : nil),
20 24
                       :class => 'tab-content') if tab[:partial] %>
21 25
<% end -%>
26

  
27
<%= javascript_tag default_action if default_action %>
(12-12/28)