Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added page_links_act_like_will_paginate config option

  • Loading branch information...
commit 8cab49d17dfebac490603e2064f56191871f6b41 1 parent 44c4c73
@binarylogic authored
View
6 CHANGELOG.rdoc
@@ -1,3 +1,9 @@
+== 1.5.5 released 2008-11-17
+
+* Cleaned up class_name configuration for helpers, so that setting them to nil disables the class name
+* Added page_links_div_wrapper and page_links_div_wrapper_class_name configuration option to add an wrapping div around page_links
+* Added page_links_act_like_will_paginate configuration option to help with the transition from will_paginate
+
== 1.5.4 released 2008-11-16
* Removed subclass requirement for adding conditions in Conditions::Base
View
105 lib/searchlogic/config/helpers.rb
@@ -31,18 +31,20 @@ def javascript_library
# The class name for used in the order_as_link helper
#
# * <tt>Default:</tt> "order_as"
- # * <tt>Accepts:</tt> String
+ # * <tt>Accepts:</tt> String, set to nil to disable
def order_as_link_class_name
- @order_as_link_class_name ||= "order_as"
+ return @order_as_link_class_name if defined?(@order_as_link_class_name)
+ @order_as_link_class_name = "order_as"
end
attr_writer :order_as_link_class_name
# The class name for used in the order_as_select helper
#
# * <tt>Default:</tt> "order_as"
- # * <tt>Accepts:</tt> String
+ # * <tt>Accepts:</tt> String, set to nil to disable
def order_as_select_class_name
- @order_as_select_class_name ||= "order_as"
+ return @order_as_select_class_name if defined?(@order_as_select_class_name)
+ @order_as_select_class_name = "order_as"
end
attr_writer :order_as_select_class_name
@@ -63,9 +65,10 @@ def order_by_link_asc_indicator
# The class name for used in the order_by_link helper
#
# * <tt>Default:</tt> "order_by"
- # * <tt>Accepts:</tt> String
+ # * <tt>Accepts:</tt> String, set to nil to disable
def order_by_link_class_name
- @order_by_link_class_name ||= "order_by"
+ return @order_by_link_class_name if defined?(@order_by_link_class_name)
+ @order_by_link_class_name = "order_by"
end
attr_writer :order_by_link_class_name
@@ -80,9 +83,10 @@ def order_by_link_desc_indicator
# * <tt>Default:</tt> "# The class name for used in the page_link helper
#
# * <tt>Default:</tt> "page"
- # * <tt>Accepts:</tt> String
+ # * <tt>Accepts:</tt> String, set to nil to disable
def order_by_links_ordering_by_class_name
- @order_by_links_ordering_by_class_name ||= "ordering_by"
+ return @order_by_links_ordering_by_class_name if defined?(@order_by_links_ordering_by_class_name)
+ @order_by_links_ordering_by_class_name = "ordering_by"
end
attr_writer :order_by_links_ordering_by_class_name
@@ -95,12 +99,27 @@ def order_by_select_class_name
end
attr_writer :order_by_select_class_name
+ # Makes page_links look just like the output of will_paginate.
+ #
+ # * <tt>Default:</tt> false
+ # * <tt>Accepts:</tt> Boolean
+ def page_links_act_like_will_paginate
+ @page_links_act_like_will_paginate ||= false
+ end
+ attr_writer :page_links_act_like_will_paginate
+
+ # Convenience methods for determining if page_links_act_like_will_paginate is set to true
+ def page_links_act_like_will_paginate?
+ page_links_act_like_will_paginate == true
+ end
+
# The class name for used in the page_link helper
#
# * <tt>Default:</tt> "page"
- # * <tt>Accepts:</tt> String
+ # * <tt>Accepts:</tt> String, set to nil to disable
def page_link_class_name
- @page_link_class_name ||= "page"
+ return @page_link_class_name if defined?(@page_link_class_name)
+ @page_link_class_name = "page"
end
attr_writer :page_link_class_name
@@ -115,7 +134,8 @@ def per_page_links_choices
# * <tt>Default:</tt> "current_page"
# * <tt>Accepts:</tt> String, set to nil to disable
def page_links_current_page_class_name
- @page_links_current_page_class_name ||= "current_page"
+ return @page_links_current_page_class_name if defined?(@page_links_current_page_class_name)
+ @page_links_current_page_class_name = page_links_act_like_will_paginate? ? "current" : "current_page"
end
attr_writer :page_links_current_page_class_name
@@ -124,10 +144,31 @@ def page_links_current_page_class_name
# * <tt>Default:</tt> "disabled_page"
# * <tt>Accepts:</tt> String, set to nil to disable
def page_links_disabled_class_name
- @page_links_disabled_class_name ||= "disabled_page"
+ return @page_links_disabled_class_name if defined?(@page_links_disabled_class_name)
+ @page_links_disabled_class_name = page_links_act_like_will_paginate? ? "disabled" : "disabled_page"
end
attr_writer :page_links_disabled_class_name
+ # Wraps page links in a div
+ #
+ # * <tt>Default:</tt> false
+ # * <tt>Accepts:</tt> Boolean
+ def page_links_div_wrapper
+ return @page_links_div_wrapper if defined?(@page_links_div_wrapper)
+ @page_links_div_wrapper = page_links_act_like_will_paginate?
+ end
+ attr_writer :page_links_div_wrapper
+
+ # If page_links_div_wrapper is true you can specify a class name here.
+ #
+ # * <tt>Default:</tt> "pagination"
+ # * <tt>Accepts:</tt> String, set to nil to disable
+ def page_links_div_wrapper_class_name
+ return @page_links_div_wrapper_class_name if defined?(@page_links_div_wrapper_class_name)
+ @page_links_div_wrapper_class_name = "pagination"
+ end
+ attr_writer :page_links_div_wrapper_class_name
+
# The default for the :first option for the page_links helper.
#
# * <tt>Default:</tt> nil
@@ -149,9 +190,10 @@ def page_links_inner_spread
# The class for the first page link
#
# * <tt>Default:</tt> "first_page"
- # * <tt>Accepts:</tt> String, nil to disable
+ # * <tt>Accepts:</tt> String, set to nil to disable
def page_links_first_page_class_name
- @page_links_first_page_class_name ||= "first_page"
+ return @page_links_first_page_class_name if defined?(@page_links_first_page_class_name)
+ @page_links_first_page_class_name = "first_page"
end
attr_writer :page_links_first_page_class_name
@@ -167,9 +209,10 @@ def page_links_last
# The class for the last page link
#
# * <tt>Default:</tt> "last_page"
- # * <tt>Accepts:</tt> String, nil to disable
+ # * <tt>Accepts:</tt> String, set to nil to disable
def page_links_last_page_class_name
- @page_links_last_page_class_name ||= "last_page"
+ return @page_links_last_page_class_name if defined?(@page_links_last_page_class_name)
+ @page_links_last_page_class_name = "last_page"
end
attr_writer :page_links_last_page_class_name
@@ -185,9 +228,10 @@ def page_links_next
# The class for the next page link
#
# * <tt>Default:</tt> "next_page"
- # * <tt>Accepts:</tt> String, nil to disable
+ # * <tt>Accepts:</tt> String, set to nil to disable
def page_links_next_page_class_name
- @page_links_next_page_class_name ||= "next_page"
+ return @page_links_next_page_class_name if defined?(@page_links_next_page_class_name)
+ @page_links_next_page_class_name = "next_page"
end
attr_writer :page_links_next_page_class_name
@@ -203,9 +247,10 @@ def page_links_outer_spread
# The class for the previous page link
#
# * <tt>Default:</tt> "prev_page"
- # * <tt>Accepts:</tt> String, nil to disable
+ # * <tt>Accepts:</tt> String, set to nil to disable
def page_links_prev_page_class_name
- @page_links_prev_page_class_name ||= "prev_page"
+ return @page_links_prev_page_class_name if defined?(@page_links_prev_page_class_name)
+ @page_links_prev_page_class_name = "prev_page"
end
attr_writer :page_links_prev_page_class_name
@@ -221,18 +266,20 @@ def page_links_prev
# The class name for used in the page_seect helper
#
# * <tt>Default:</tt> "page"
- # * <tt>Accepts:</tt> String
+ # * <tt>Accepts:</tt> String, set to nil to disable
def page_select_class_name
- @page_select_class_name ||= "page"
+ return @page_select_class_name if defined?(@page_select_class_name)
+ @page_select_class_name = "page"
end
attr_writer :page_select_class_name
# The class name for used in the per_page_link helper
#
# * <tt>Default:</tt> "per_page"
- # * <tt>Accepts:</tt> String
+ # * <tt>Accepts:</tt> String, set to nil to disable
def per_page_link_class_name
- @per_page_link_class_name ||= "per_page"
+ return @per_page_link_class_name if defined?(@per_page_link_class_name)
+ @per_page_link_class_name = "per_page"
end
attr_writer :per_page_link_class_name
@@ -251,9 +298,10 @@ def per_page_select_choices
# The class name for used in the per_page_select helper
#
# * <tt>Default:</tt> "per_page"
- # * <tt>Accepts:</tt> String
+ # * <tt>Accepts:</tt> String, set to nil to disable
def per_page_select_class_name
- @per_page_select_class_name ||= "per_page"
+ return @per_page_select_class_name if defined?(@per_page_select_class_name)
+ @per_page_select_class_name = "per_page"
end
attr_writer :per_page_select_class_name
@@ -269,9 +317,10 @@ def priority_order_by_link_activate_text
# The class name for used in the priority_order_by_link helper
#
# * <tt>Default:</tt> "priority_order_by"
- # * <tt>Accepts:</tt> String
+ # * <tt>Accepts:</tt> String, set to nil to disable
def priority_order_by_link_class_name
- @priority_order_by_link_class_name ||= "priority_order_by"
+ return @priority_order_by_link_class_name if defined?(@priority_order_by_link_class_name)
+ @priority_order_by_link_class_name = "priority_order_by"
end
attr_writer :priority_order_by_link_class_name
View
1  lib/searchlogic/helpers/control_types/links.rb
@@ -159,6 +159,7 @@ def page_links(options = {})
html += span_or_page_link(:next, options.deep_dup, options[:current_page] == options[:last_page]) if options[:next]
html += span_or_page_link(:last, options.deep_dup, options[:current_page] == options[:last_page]) if options[:last]
+ html = content_tag(:div, html, :class => Config.helpers.page_links_div_wrapper_class_name) if Config.helpers.page_links_div_wrapper
html
end
View
2  lib/searchlogic/version.rb
@@ -67,7 +67,7 @@ def to_a
MAJOR = 1
MINOR = 5
- TINY = 4
+ TINY = 5
# The current version as a Version instance
CURRENT = new(MAJOR, MINOR, TINY)
Please sign in to comment.
Something went wrong with that request. Please try again.