Feature #3058 » 0001-allow-tabs-to-have-a-custom-action.patch
| app/helpers/application_helper.rb | ||
|---|---|---|
| 407 | 407 |
end |
| 408 | 408 |
end |
| 409 | 409 | |
| 410 |
# Returns the tab action depending on the tab properties |
|
| 411 |
def get_tab_action(tab) |
|
| 412 |
if tab[:onclick] |
|
| 413 |
return tab[:onclick] |
|
| 414 |
elsif tab[:partial] |
|
| 415 |
return "showTab('#{tab[:name]}', this.href)"
|
|
| 416 |
else |
|
| 417 |
return nil |
|
| 418 |
end |
|
| 419 |
end |
|
| 420 | ||
| 410 | 421 |
# Returns the default scope for the quick search form |
| 411 | 422 |
# Could be 'all', 'my_projects', 'subprojects' or nil (current project) |
| 412 | 423 |
def default_search_project_scope |
| app/views/common/_tabs.html.erb | ||
|---|---|---|
| 1 |
<% default_action = false %> |
|
| 2 | ||
| 1 | 3 |
<div class="tabs"> |
| 2 | 4 |
<ul> |
| 3 | 5 |
<% tabs.each do |tab| -%> |
| 6 |
<% action = get_tab_action(tab) %> |
|
| 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.nil? ? nil : "#{ action }; return false;") %></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 %> |
|