Module: Redmine::Pagination::Helper
Instance Method Summary collapse
-
#pagination_links_each(paginator, count = nil, options = {}, &block) ⇒ Object
Yields the given block with the text and parameters for each pagination link and returns a string that represents the links.
-
#pagination_links_full(*args) ⇒ Object
Renders the pagination links for the given paginator.
-
#per_page_links(paginator, &block) ⇒ Object
Renders the “Per page” links.
- #per_page_options(selected = nil, item_count = nil) ⇒ Object
Methods included from I18n
#current_language, #day_letter, #day_name, #find_language, #format_date, #format_hours, #format_time, included, #l, #l_hours, #l_hours_short, #l_or_humanize, #languages_options, #ll, #lu, #month_name, #set_language_if_valid, #valid_languages
Instance Method Details
#pagination_links_each(paginator, count = nil, options = {}, &block) ⇒ Object
Yields the given block with the text and parameters for each pagination link and returns a string that represents the links
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
# File 'lib/redmine/pagination.rb', line 155 def pagination_links_each(paginator, count=nil, ={}, &block) .assert_valid_keys :per_page_links per_page_links = .delete(:per_page_links) per_page_links = false if count.nil? page_param = paginator.page_param html = +'<ul class="pages">' if paginator.multiple_pages? # \xc2\xab(utf-8) = « text = "\xc2\xab " + l(:label_previous) if paginator.previous_page html << content_tag('li', yield(text, {page_param => paginator.previous_page}, :accesskey => accesskey(:previous)), :class => 'previous page') else html << content_tag('li', content_tag('span', text), :class => 'previous') end end previous = nil paginator.linked_pages.each do |page| if previous && previous != page - 1 html << content_tag('li', content_tag('span', '…'.html_safe), :class => 'spacer') end if page == paginator.page html << content_tag('li', content_tag('span', page.to_s), :class => 'current') else html << content_tag('li', yield(page.to_s, {page_param => page}), :class => 'page') end previous = page end if paginator.multiple_pages? # \xc2\xbb(utf-8) = » text = l(:label_next) + " \xc2\xbb" if paginator.next_page html << content_tag('li', yield(text, {page_param => paginator.next_page}, :accesskey => accesskey(:next)), :class => 'next page') else html << content_tag('li', content_tag('span', text), :class => 'next') end end html << '</ul>' info = ''.html_safe info << content_tag('span', "(#{paginator.first_item}-#{paginator.last_item}/#{paginator.item_count})", :class => 'items') + ' ' if per_page_links != false && links = per_page_links(paginator, &block) info << content_tag('span', links.to_s, :class => 'per-page') end html << content_tag('span', info) html.html_safe end |
#pagination_links_full(*args) ⇒ Object
Renders the pagination links for the given paginator.
Options:
:per_page_links if set to false, the "Per page" links are not rendered
143 144 145 146 147 148 149 150 151 |
# File 'lib/redmine/pagination.rb', line 143 def pagination_links_full(*args) pagination_links_each(*args) do |text, parameters, | if block_given? yield text, parameters, else link_to text, {:params => request.query_parameters.merge(parameters)}, end end end |
#per_page_links(paginator, &block) ⇒ Object
Renders the “Per page” links.
217 218 219 220 221 222 223 224 225 226 227 228 229 |
# File 'lib/redmine/pagination.rb', line 217 def per_page_links(paginator, &block) values = (paginator.per_page, paginator.item_count) if values.any? links = values.collect do |n| if n == paginator.per_page content_tag('span', n.to_s, :class => 'selected') else yield(n, :per_page => n, paginator.page_param => nil) end end l(:label_display_per_page, links.join(', ')).html_safe end end |
#per_page_options(selected = nil, item_count = nil) ⇒ Object
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
# File 'lib/redmine/pagination.rb', line 231 def (selected=nil, item_count=nil) = Setting. if item_count && .any? if item_count > .first max = .detect {|value| value >= item_count} || item_count else max = item_count end = .select {|value| value <= max || value == selected} end if .empty? || (.size == 1 && .first == selected) [] else end end |