Better expanding of extra nutrients
This commit is contained in:
parent
fcec8364bc
commit
526a4b1fe6
@ -25,11 +25,12 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @primary_nutrients.each do |i, values| %>
|
||||
|
||||
<% row_class = "ingredient#{' hidden' if i.hidden} #{cycle('odd', 'even')}" %>
|
||||
<tr id="ingredient-<%= i.id %>" class="primary <%= row_class %>">
|
||||
<td class="name">
|
||||
<%= link_to '', '#', {
|
||||
onclick: "$(this).closest('tr').nextUntil('tr.primary', 'tr').toggle(); $(this).toggleClass('icon-bullet-closed'); $(this).toggleClass('icon-bullet-open'); return false;",
|
||||
onclick: "$(this).closest('tr').toggle(); $(this).closest('tr').nextUntil('tr.primary', 'tr').toggle(); return false;",
|
||||
class: "icon icon-bullet-closed"
|
||||
} %>
|
||||
<%= i.name %>
|
||||
@ -40,6 +41,29 @@
|
||||
</td>
|
||||
<% end %>
|
||||
</tr>
|
||||
|
||||
<tr class="<%= row_class %>" style="display:none">
|
||||
<td class="name" rowspan="2">
|
||||
<%= link_to '', '#', {
|
||||
onclick: "$(this).closest('tr').prev('tr.primary').toggle(); $(this).closest('tr').prev('tr.primary').nextUntil('tr.primary', 'tr').toggle(); return false;",
|
||||
class: "icon icon-bullet-open"
|
||||
} %>
|
||||
<%= i.name %>
|
||||
</td>
|
||||
<% @primary_quantities.each do |q| %>
|
||||
<td class="primary quantity">
|
||||
<%= q.name %>
|
||||
</td>
|
||||
<% end %>
|
||||
</tr>
|
||||
<tr class="<%= row_class %>" style="display:none">
|
||||
<% @primary_quantities.each do |q| %>
|
||||
<td class="primary value">
|
||||
<%= values[q.id] || '-' %>
|
||||
</td>
|
||||
<% end %>
|
||||
</tr>
|
||||
|
||||
<% extras = @extra_nutrients[i].keys %>
|
||||
<% extras.each_slice(@primary_quantities.length).with_index do |names, index| %>
|
||||
<tr class="extra <%= row_class %>" style="display:none">
|
||||
@ -59,13 +83,13 @@
|
||||
</tr>
|
||||
<tr class="extra <%= row_class %>" style="display:none">
|
||||
<% names.each do |name| %>
|
||||
<% title = %>
|
||||
<td class="extra value">
|
||||
<%= @extra_nutrients[i][name] %>
|
||||
</td>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
@ -1,8 +1,8 @@
|
||||
table.list tr.quantity.primary td.name {font-weight: bold;}
|
||||
table.nutrients.list td.name,
|
||||
table.list td.quantity.extra {text-align: left; border-bottom: none;}
|
||||
table.nutrients.list td.quantity {text-align: left; border-bottom: none;}
|
||||
table.nutrients.list td.space,
|
||||
table.list td.value.extra {border-top: none;}
|
||||
table.nutrients.list td.value {border-top: none;}
|
||||
table.list tr.ingredient.hidden {opacity: 0.4}
|
||||
table.list td.action,
|
||||
table.list td.value {text-align: right;}
|
||||
|
Reference in New Issue
Block a user