Advertisement
Guest User

Untitled

a guest
Nov 26th, 2015
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. module PaginateHelper
  2. class PaginateJSLinkRenderer < WillPaginate::ActionView::LinkRenderer
  3. def prepare(collection, options, template)
  4. options[:params] ||= {}
  5. options[:params]['_'] = nil
  6. super(collection, options, template)
  7. end
  8.  
  9. protected
  10. def html_container(html)
  11. tag(:nav, tag(:ul, html, class: "pagination"))
  12. end
  13.  
  14. def previous_or_next_page(page, text, classname)
  15. if page
  16. link(text, page, :class => classname)
  17. else
  18. tag(:li, tag(:a, text, class: classname), class: "disabled")
  19. end
  20. end
  21.  
  22. def page_number(page)
  23. unless page == current_page
  24. tag(:li, link(page, page, :rel => rel_value(page)))
  25. else
  26. tag(:li, tag(:a, page), class: "active")
  27. end
  28. end
  29.  
  30. def link(text, target, attributes = {})
  31. if target.is_a? Fixnum
  32. attributes[:rel] = rel_value(target)
  33. target = url(target)
  34. end
  35.  
  36. tag(:li, @template.link_to(text.to_s.html_safe, target, attributes.merge(remote: true)))
  37. end
  38.  
  39. def gap
  40. tag(:li, tag(:a, '...'))
  41. end
  42.  
  43. end##end of class
  44.  
  45. def js_will_paginate(collection, options = {})
  46. will_paginate(collection, options.merge(:renderer => PaginateHelper::PaginateJSLinkRenderer))
  47. end
  48. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement