8784: Fix test for latest firefox.
[arvados.git] / apps / workbench / app / views / application / _paging.html.erb
1 <% content_for :css do %>
2 .index-paging {
3 text-align: center;
4 padding-left: 1em;
5 padding-right: 1em;
6 background-color: whitesmoke;
7 }
8 .paging-number {
9 display: inline-block;
10 min-width: 1.2em;
11 }
12 <% end %>
13
14 <% results.fetch_multiple_pages(false) %>
15
16 <% if results.respond_to? :result_offset and
17        results.respond_to? :result_limit and
18        results.respond_to? :items_available and
19        results.result_offset != nil and
20        results.result_limit != nil and
21        results.items_available != nil
22 %>
23 <div class="index-paging">
24   Displaying <%= results.result_offset+1 %> &ndash;
25   <%= if results.result_offset + results.result_limit > results.items_available
26         results.items_available
27       else
28         results.result_offset + results.result_limit
29       end %>
30  out of <%= results.items_available %>
31 </div>
32
33 <% if not (results.result_offset == 0 and results.items_available <= results.result_limit) %>
34
35 <div class="index-paging">
36
37 <% if results.result_offset > 0 %>
38   <% if results.result_offset > results.result_limit %>
39     <% prev_offset = results.result_offset - results.result_limit %>
40   <% else %>
41     <% prev_offset = 0 %>
42   <% end %>
43 <% else %>
44   <% prev_offset = nil %>
45 <% end %>
46
47 <% this_offset = results.result_offset %>
48
49 <% if (results.result_offset + results.result_limit) < results.items_available %>
50   <% next_offset = results.result_offset + results.result_limit %>
51 <% else %>
52   <% next_offset = nil %>
53 <% end %>
54
55 <span class="pull-left">
56 <% if results.result_offset > 0 %>
57   <%= link_to raw("<span class='glyphicon glyphicon-fast-backward'></span>"), {:id => object, :offset => 0, :limit => results.result_limit}  %>
58 <% else %>
59   <span class='glyphicon glyphicon-fast-backward text-muted'></span>
60 <% end %>
61
62 <% if prev_offset %>
63   <%= link_to raw("<span class='glyphicon glyphicon-step-backward'></span>"), {:id => object, :offset => prev_offset, :limit => results.result_limit}  %>
64 <% else %>
65 <span class='glyphicon glyphicon-step-backward text-muted'></span>
66 <% end %>
67 </span>
68
69 <% first = this_offset - (10 * results.result_limit) %>
70 <% last = this_offset + (11 * results.result_limit) %>
71
72 <% lastpage_offset = (results.items_available / results.result_limit) * results.result_limit %>
73
74 <% if last > results.items_available %>
75   <% first -= (last - lastpage_offset) %>
76   <% last -= (last - results.items_available) %>
77 <% end %>
78
79 <% if first < 0 %>
80   <% d = -first %>
81   <% first += d %>
82   <% last += d %>
83 <% end %>
84
85 <% last = results.items_available if last > results.items_available %>
86
87 <% i = first %>
88 <% n = first / results.result_limit %>
89
90 <% if first > 0 %>
91 &hellip;
92 <% end %>
93
94 <% while i < last %>
95 <% if i != this_offset %>
96   <%= link_to "#{n+1}", {:id => @object, :offset => i, :limit => results.result_limit}, class: 'paging-number' %>
97 <% else %>
98   <span class="paging-number" style="font-weight: bold;"><%= n+1 %></span>
99 <% end %>
100 <% i += results.result_limit %>
101 <% n += 1 %>
102 <% end %>
103
104 <% if last < results.items_available %>
105 &hellip;
106 <% end %>
107
108 <span class="pull-right">
109 <% if next_offset %>
110   <%= link_to raw("<span class='glyphicon glyphicon-step-forward'></span>"), {:id => @object, :offset => next_offset, :limit => results.result_limit}  %>
111 <% else %>
112 <span class='glyphicon glyphicon-forward text-muted'></span>
113 <% end %>
114
115 <% if (results.items_available - results.result_offset) >= results.result_limit %>
116   <%= link_to raw("<span class='glyphicon glyphicon-fast-forward'></span>"), {:id => @object, :offset => results.items_available - (results.items_available % results.result_limit),
117         :limit => results.result_limit}  %>
118 <% else %>
119   <span class='glyphicon glyphicon-fast-forward text-muted'></span>
120 <% end %>
121
122 </span>
123
124 </div>
125
126 <% end %>
127
128 <% end %>