Do not use javascript to hide tabs content on page loading and make tabs work with javascript disabled.

git-svn-id: http://redmine.rubyforge.org/svn/trunk@1293 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2008-03-26 18:49:12 +00:00
parent 1c49bd4258
commit 805864590a
4 changed files with 53 additions and 32 deletions

View File

@ -17,6 +17,13 @@
module CustomFieldsHelper module CustomFieldsHelper
def custom_fields_tabs
tabs = [{:name => 'IssueCustomField', :label => :label_issue_plural},
{:name => 'ProjectCustomField', :label => :label_project_plural},
{:name => 'UserCustomField', :label => :label_user_plural}
]
end
# Return custom field html tag corresponding to its format # Return custom field html tag corresponding to its format
def custom_field_tag(custom_value) def custom_field_tag(custom_value)
custom_field = custom_value.custom_field custom_field = custom_value.custom_field

View File

@ -1,21 +1,26 @@
<h2><%=l(:label_custom_field_plural)%></h2> <h2><%=l(:label_custom_field_plural)%></h2>
<% selected_tab = params[:tab] ? params[:tab].to_s : custom_fields_tabs.first[:name] %>
<div class="tabs"> <div class="tabs">
<ul> <ul>
<li><%= link_to l(:label_issue_plural), {}, :id=> "tab-IssueCustomField", :onclick => "showTab('IssueCustomField'); this.blur(); return false;" %></li> <% custom_fields_tabs.each do |tab| -%>
<li><%= link_to l(:label_project_plural), {}, :id=> "tab-ProjectCustomField", :onclick => "showTab('ProjectCustomField'); this.blur(); return false;" %></li> <li><%= link_to l(tab[:label]), { :tab => tab[:name] },
<li><%= link_to l(:label_user_plural), {}, :id=> "tab-UserCustomField", :onclick => "showTab('UserCustomField'); this.blur(); return false;" %></li> :id => "tab-#{tab[:name]}",
:class => (tab[:name] != selected_tab ? nil : 'selected'),
:onclick => "showTab('#{tab[:name]}'); this.blur(); return false;" %></li>
<% end -%>
</ul> </ul>
</div> </div>
<% %w(IssueCustomField ProjectCustomField UserCustomField).each do |type| %> <% custom_fields_tabs.each do |tab| %>
<div id="tab-content-<%= type %>" class="tab-content"> <div id="tab-content-<%= tab[:name] %>" class="tab-content" style="<%= tab[:name] != selected_tab ? 'display:none' : nil %>">
<table class="list"> <table class="list">
<thead><tr> <thead><tr>
<th width="30%"><%=l(:field_name)%></th> <th width="30%"><%=l(:field_name)%></th>
<th><%=l(:field_field_format)%></th> <th><%=l(:field_field_format)%></th>
<th><%=l(:field_is_required)%></th> <th><%=l(:field_is_required)%></th>
<% if type == 'IssueCustomField' %> <% if tab[:name] == 'IssueCustomField' %>
<th><%=l(:field_is_for_all)%></th> <th><%=l(:field_is_for_all)%></th>
<th><%=l(:label_used_by)%></th> <th><%=l(:label_used_by)%></th>
<% end %> <% end %>
@ -23,12 +28,12 @@
<th width="10%"></th> <th width="10%"></th>
</tr></thead> </tr></thead>
<tbody> <tbody>
<% for custom_field in (@custom_fields_by_type[type] || []).sort %> <% (@custom_fields_by_type[tab[:name]] || []).sort.each do |custom_field| -%>
<tr class="<%= cycle("odd", "even") %>"> <tr class="<%= cycle("odd", "even") %>">
<td><%= link_to custom_field.name, :action => 'edit', :id => custom_field %></td> <td><%= link_to custom_field.name, :action => 'edit', :id => custom_field %></td>
<td align="center"><%= l(CustomField::FIELD_FORMATS[custom_field.field_format][:name]) %></td> <td align="center"><%= l(CustomField::FIELD_FORMATS[custom_field.field_format][:name]) %></td>
<td align="center"><%= image_tag 'true.png' if custom_field.is_required? %></td> <td align="center"><%= image_tag 'true.png' if custom_field.is_required? %></td>
<% if type == 'IssueCustomField' %> <% if tab[:name] == 'IssueCustomField' %>
<td align="center"><%= image_tag 'true.png' if custom_field.is_for_all? %></td> <td align="center"><%= image_tag 'true.png' if custom_field.is_for_all? %></td>
<td align="center"><%= custom_field.projects.count.to_s + ' ' + lwr(:label_project, custom_field.projects.count) if custom_field.is_a? IssueCustomField and !custom_field.is_for_all? %></td> <td align="center"><%= custom_field.projects.count.to_s + ' ' + lwr(:label_project, custom_field.projects.count) if custom_field.is_a? IssueCustomField and !custom_field.is_for_all? %></td>
<% end %> <% end %>
@ -45,11 +50,9 @@
<% end; reset_cycle %> <% end; reset_cycle %>
</tbody> </tbody>
</table> </table>
<br />
<%= link_to l(:label_custom_field_new), {:action => 'new', :type => type}, :class => 'icon icon-add' %> <p><%= link_to l(:label_custom_field_new), {:action => 'new', :type => tab[:name]}, :class => 'icon icon-add' %></p>
</div> </div>
<% end %> <% end %>
<%= javascript_tag "showTab('#{@tab}');" %>
<% html_title(l(:label_custom_field_plural)) -%> <% html_title(l(:label_custom_field_plural)) -%>

View File

@ -1,18 +1,24 @@
<h2><%=l(:label_settings)%></h2> <h2><%=l(:label_settings)%></h2>
<% tabs = project_settings_tabs %>
<% selected_tab = params[:tab] ? params[:tab].to_s : tabs.first[:name] %>
<div class="tabs"> <div class="tabs">
<ul> <ul>
<% project_settings_tabs.each do |tab| %> <% tabs.each do |tab| -%>
<li><%= link_to l(tab[:label]), {}, :id => "tab-#{tab[:name]}", :onclick => "showTab('#{tab[:name]}'); this.blur(); return false;" %></li> <li><%= link_to l(tab[:label]), { :tab => tab[:name] },
<% end %> :id => "tab-#{tab[:name]}",
:class => (tab[:name] != selected_tab ? nil : 'selected'),
:onclick => "showTab('#{tab[:name]}'); this.blur(); return false;" %></li>
<% end -%>
</ul> </ul>
</div> </div>
<% project_settings_tabs.each do |tab| %> <% tabs.each do |tab| -%>
<%= content_tag('div', render(:partial => tab[:partial]), :id => "tab-content-#{tab[:name]}", :class => 'tab-content') %> <%= content_tag('div', render(:partial => tab[:partial]),
<% end %> :id => "tab-content-#{tab[:name]}",
:style => (tab[:name] != selected_tab ? 'display:none' : nil),
<%= tab = params[:tab] ? h(params[:tab]) : project_settings_tabs.first[:name] :class => 'tab-content') %>
javascript_tag "showTab('#{tab}');" %> <% end -%>
<% html_title(l(:label_settings)) -%> <% html_title(l(:label_settings)) -%>

View File

@ -1,18 +1,23 @@
<h2><%= l(:label_settings) %></h2> <h2><%= l(:label_settings) %></h2>
<% selected_tab = params[:tab] ? params[:tab].to_s : administration_settings_tabs.first[:name] %>
<div class="tabs"> <div class="tabs">
<ul> <ul>
<% administration_settings_tabs.each do |tab| -%> <% administration_settings_tabs.each do |tab| -%>
<li><%= link_to l(tab[:label]), {}, :id => "tab-#{tab[:name]}", :onclick => "showTab('#{tab[:name]}'); this.blur(); return false;" %></li> <li><%= link_to l(tab[:label]), { :tab => tab[:name] },
<% end -%> :id => "tab-#{tab[:name]}",
</ul> :class => (tab[:name] != selected_tab ? nil : 'selected'),
:onclick => "showTab('#{tab[:name]}'); this.blur(); return false;" %></li>
<% end -%>
</ul>
</div> </div>
<% administration_settings_tabs.each do |tab| %> <% administration_settings_tabs.each do |tab| -%>
<%= content_tag('div', render(:partial => tab[:partial]), :id => "tab-content-#{tab[:name]}", :class => 'tab-content') %> <%= content_tag('div', render(:partial => tab[:partial]),
<% end %> :id => "tab-content-#{tab[:name]}",
:style => (tab[:name] != selected_tab ? 'display:none' : nil),
<%= tab = params[:tab] ? h(params[:tab]) : administration_settings_tabs.first[:name] :class => 'tab-content') %>
javascript_tag "showTab('#{tab}');" %> <% end -%>
<% html_title(l(:label_settings), l(:label_administration)) -%> <% html_title(l(:label_settings), l(:label_administration)) -%>