Created
December 14, 2012 15:41
-
-
Save bogdanRada/4286332 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module PaginationHelper | |
class LinkRenderer < WillPaginate::ActionView::LinkRenderer | |
def link(text, target, attributes = {}) | |
attributes["data-remote"] = true if @options[:remote] | |
super | |
end | |
def pagination | |
items = @options[:page_links] ? windowed_page_numbers : [] | |
items.unshift :first_page, :previous_page | |
items.push :next_page, :last_page | |
end | |
# The container_attributes method must be overridden to prevent custom options being output as HTML attributes for the pagination container. | |
def container_attributes | |
super.except(:first_label, :last_label) | |
end | |
# A first_page method that handles the generation of HTML for the first page link. | |
def first_page | |
previous_or_next_page(current_page == 1 ? nil : 1, @options[:first_label], "first_page") | |
end | |
# A last_page method that handles the generation of HTML for the last page link. | |
def last_page | |
previous_or_next_page(current_page == total_pages ? nil : total_pages, @options[:last_label], "last_page") | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment