Created
May 23, 2013 05:53
-
-
Save firedev/5632994 to your computer and use it in GitHub Desktop.
Fix for Kaminari strange window implementation. Works with Kaminari 0.13
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
# Fixes https://github.com/amatsuda/kaminari/issues/133 | |
# put into /initializers/kaminari.rb | |
module Kaminari | |
module Helpers | |
class Paginator < Tag | |
class PageProxy | |
def inside_window? | |
if @options[:current_page] <= @options[:window] | |
@page <= (@options[:window] * 2) + 1 | |
elsif (@options[:num_pages] - @options[:current_page].number) < @options[:window] | |
@page >= (@options[:num_pages] - (@options[:window] * 2)) | |
else | |
(@options[:current_page] - @page).abs <= @options[:window] | |
end | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment