This cuts down on the complexity of having to use the `cycle` function
and makes the templates easier to read. CSS-based striping has been
around for many years.
The CSS is in order to keep our custom colour for striped tables.
-/* Rules for doing distinct colour of alternate table rows */
+/* Customise the background colour of striped tables */
-.table0,
-.item0 {
- background: $offwhite;
-}
-
-.table1,
-.item1 {
- background: #fff;
+.table-striped > tbody > tr:nth-child(2n+1) > td,
+.table-striped > tbody > tr:nth-child(2n+1) > th {
+ background-color: $offwhite;
}
/* Rules for OpenID logo */
}
/* Rules for OpenID logo */
<h1><%= t(".has_commented_on", :display_name => @user.display_name) %></h1>
<% end %>
<h1><%= t(".has_commented_on", :display_name => @user.display_name) %></h1>
<% end %>
-<table class="messages" width="100%">
+<table class="table table-striped" width="100%">
<thead>
<tr>
<th width="25%"><%= t ".post" %></th>
<thead>
<tr>
<th width="25%"><%= t ".post" %></th>
</tr>
</thead>
<% @comments.each do |comment| -%>
</tr>
</thead>
<% @comments.each do |comment| -%>
- <% cl = cycle("table0", "table1") %>
- <tr class="<%= cl %><%= " deemphasize" unless comment.visible? %>">
+ <tr class="<%= "deemphasize" unless comment.visible? %>">
<td width="25%"><%= link_to comment.diary_entry.title, diary_entry_path(comment.diary_entry.user, comment.diary_entry) %></td>
<td width="25%"><span title="<%= l comment.created_at, :format => :friendly %>"><%= time_ago_in_words(comment.created_at, :scope => :'datetime.distance_in_words_ago') %></span></td>
<td width="50%" class="richtext"><%= comment.body.to_html %></td>
<td width="25%"><%= link_to comment.diary_entry.title, diary_entry_path(comment.diary_entry.user, comment.diary_entry) %></td>
<td width="25%"><span title="<%= l comment.created_at, :format => :friendly %>"><%= time_ago_in_words(comment.created_at, :scope => :'datetime.distance_in_words_ago') %></span></td>
<td width="50%" class="richtext"><%= comment.body.to_html %></td>
- <% cl = cycle("table0", "table1") %>
- <td class="<%= cl %>">
<% if Settings.status != "gpx_offline" %>
<% if trace.inserted %>
<a href="<%= url_for :controller => "traces", :action => "show", :id => trace.id, :display_name => trace.user.display_name %>"><img src="<%= url_for :controller => "traces", :action => "icon", :id => trace.id, :display_name => trace.user.display_name %>" border="0" alt="" /></a>
<% if Settings.status != "gpx_offline" %>
<% if trace.inserted %>
<a href="<%= url_for :controller => "traces", :action => "show", :id => trace.id, :display_name => trace.user.display_name %>"><img src="<%= url_for :controller => "traces", :action => "icon", :id => trace.id, :display_name => trace.user.display_name %>" border="0" alt="" /></a>
<% end %>
<% end %>
</td>
<% end %>
<% end %>
</td>
- <td class="<%= cl %>"><%= link_to trace.name, :controller => "traces", :action => "show", :display_name => trace.user.display_name, :id => trace.id %>
+ <td><%= link_to trace.name, :controller => "traces", :action => "show", :display_name => trace.user.display_name, :id => trace.id %>
<span class="trace_summary" title="<%= trace.timestamp %>"> ...
<% if trace.inserted %>
(<%= t ".count_points", :count => trace.size %>)
<span class="trace_summary" title="<%= trace.timestamp %>"> ...
<% if trace.inserted %>
(<%= t ".count_points", :count => trace.size %>)
<% if @traces.size > 0 %>
<%= render :partial => "trace_paging_nav" %>
<% if @traces.size > 0 %>
<%= render :partial => "trace_paging_nav" %>
- <table id="trace_list" cellpadding="3">
+ <table id="trace_list" class="table table-borderless table-striped">
- <% c1 = cycle("table0", "table1") %>
-
- <td class="<%= c1 %>"><%= link_to h(block.user.display_name), user_path(block.user) %></td>
+ <td><%= link_to h(block.user.display_name), user_path(block.user) %></td>
<% end %>
<% if show_creator_name %>
<% end %>
<% if show_creator_name %>
- <td class="<%= c1 %>"><%= link_to h(block.creator.display_name), user_path(block.creator) %></td>
+ <td><%= link_to h(block.creator.display_name), user_path(block.creator) %></td>
- <td class="<%= c1 %>"><%= h truncate(block.reason) %></td>
- <td class="<%= c1 %>"><%= h block_status(block) %></td>
- <td class="<%= c1 %>">
+ <td><%= h truncate(block.reason) %></td>
+ <td><%= h block_status(block) %></td>
+ <td>
<% if block.revoker_id.nil? %>
<%= t(".not_revoked") %>
<% else %>
<%= link_to h(block.revoker.display_name), user_path(block.revoker) %>
<% end %>
</td>
<% if block.revoker_id.nil? %>
<%= t(".not_revoked") %>
<% else %>
<%= link_to h(block.revoker.display_name), user_path(block.revoker) %>
<% end %>
</td>
- <td class="<%= c1 %>"><%= link_to t(".show"), block %></td>
- <td class="<%= c1 %>"><% if current_user and current_user.id == block.creator_id and block.active? %><%= link_to t(".edit"), edit_user_block_path(block) %><% end %></td>
+ <td><%= link_to t(".show"), block %></td>
+ <td><% if current_user and current_user.id == block.creator_id and block.active? %><%= link_to t(".edit"), edit_user_block_path(block) %><% end %></td>
<% if show_revoke_link %>
<% if show_revoke_link %>
- <td class="<%= c1 %>"><% if block.active? %><%= link_to t(".revoke"), :controller => "user_blocks", :action => "revoke", :id => block.id %><% end %></td>
+ <td><% if block.active? %><%= link_to t(".revoke"), :controller => "user_blocks", :action => "revoke", :id => block.id %><% end %></td>
-<table id="block_list" cellpadding="3">
+<table id="block_list" class="table table-borderless table-striped table-sm">
<thead>
<tr>
<% if show_user_name %>
<thead>
<tr>
<% if show_user_name %>
-<% cl = cycle("table0", "table1") %>
-
-<tr class="<%= cl %>">
<td>
<%= user_thumbnail(user) %>
</td>
<td>
<%= user_thumbnail(user) %>
</td>
<%= hidden_field_tag :status, params[:status] if params[:status] %>
<%= hidden_field_tag :ip, params[:ip] if params[:ip] %>
<%= hidden_field_tag :page, params[:page] if params[:page] %>
<%= hidden_field_tag :status, params[:status] if params[:status] %>
<%= hidden_field_tag :ip, params[:ip] if params[:ip] %>
<%= hidden_field_tag :page, params[:page] if params[:page] %>
+ <table id="user_list" class="table table-borderless table-striped">
<thead>
<tr>
<td colspan="2">
<thead>
<tr>
<td colspan="2">
get :comments, :params => { :display_name => user.display_name }
assert_response :success
assert_template :comments
get :comments, :params => { :display_name => user.display_name }
assert_response :success
assert_template :comments
- assert_select "table.messages" do
+ assert_select "table.table-striped" do
assert_select "tr", :count => 1 # header, no comments
end
assert_select "tr", :count => 1 # header, no comments
end
get :comments, :params => { :display_name => other_user.display_name }
assert_response :success
assert_template :comments
get :comments, :params => { :display_name => other_user.display_name }
assert_response :success
assert_template :comments
- assert_select "table.messages" do
+ assert_select "table.table-striped" do
assert_select "tr", :count => 2 # header and one comment
end
assert_select "tr", :count => 2 # header and one comment
end