Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for bootstrap 4 #18

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{<img src="https://badge.fury.io/rb/bootstrap-kaminari-views.svg" alt="Gem Version" />}[http://badge.fury.io/rb/bootstrap-kaminari-views]

Basic Gem for quick default inclusion of {Kaminari}[https://github.com/amatsuda/kaminari] theme compatible with {Twitter Bootstrap 2.0}[http://getbootstrap.com/2.3.2/] and {Twitter Bootstrap 3.0}[http://getbootstrap.com]
Basic Gem for quick default inclusion of {Kaminari}[https://github.com/amatsuda/kaminari] theme compatible with {Twitter Bootstrap 2.0}[http://getbootstrap.com/2.3.2/], {Twitter Bootstrap 3.0}[http://getbootstrap.com] and {Twitter Bootstrap 4.0}[https://v4-alpha.getbootstrap.com]

= Usage

Expand All @@ -17,6 +17,8 @@ Render Pagination with a theme

= paginate @posts, :theme => 'twitter-bootstrap-3'

= paginate @posts, :theme => 'twitter-bootstrap-4'

Render with specific pagination classes

= paginate @posts, :theme => 'twitter-bootstrap-3',
Expand All @@ -33,13 +35,13 @@ If you want to use one or more options as the default across your app, you can o


module ApplicationHelper

def paginate objects, options = {}
options.reverse_merge!( theme: 'twitter-bootstrap' )

super( objects, options )
end

end


Expand Down
Binary file added app/views/kaminari/.DS_Store
Binary file not shown.
13 changes: 13 additions & 0 deletions app/views/kaminari/twitter-bootstrap-4/_first_page.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<%# Link to the "First" page
- available local variables
url: url to the first page
current_page: a page object for the currently displayed page
num_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<% unless current_page.first? %>
<li class="page-item first">
<%= link_to_unless current_page.first?, raw(t 'views.pagination.first'), url, :remote => remote, class: 'page-link' %>
</li>
<% end %>
10 changes: 10 additions & 0 deletions app/views/kaminari/twitter-bootstrap-4/_gap.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<%# Non-link tag that stands for skipped pages...
- available local variables
current_page: a page object for the currently displayed page
num_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<li class="page-item page gap disabled">
<a class="page-link" href="#" onclick="return false;"><%= raw(t 'views.pagination.truncate') %></a>
</li>
13 changes: 13 additions & 0 deletions app/views/kaminari/twitter-bootstrap-4/_last_page.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<%# Link to the "Last" page
- available local variables
url: url to the last page
current_page: a page object for the currently displayed page
num_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<% unless current_page.last? %>
<li class="page-item last next"><%# "next" class present for border styling in twitter bootstrap %>
<%= link_to_unless current_page.last?, raw(t 'views.pagination.last'), url, {class: 'page-link', :remote => remote} %>
</li>
<% end %>
13 changes: 13 additions & 0 deletions app/views/kaminari/twitter-bootstrap-4/_next_page.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<%# Link to the "Next" page
- available local variables
url: url to the next page
current_page: a page object for the currently displayed page
num_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<% unless current_page.last? %>
<li class="page-item next_page">
<%= link_to_unless current_page.last?, raw(t 'views.pagination.next'), url, class: 'page-link', :rel => 'next', :remote => remote %>
</li>
<% end %>
12 changes: 12 additions & 0 deletions app/views/kaminari/twitter-bootstrap-4/_page.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<%# Link showing page number
- available local variables
page: a page object for "this" page
url: url to this page
current_page: a page object for the currently displayed page
num_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<li class="page-item page-item<%= ' active' if page.current? %>">
<%= link_to page, url, opts = {class: 'page-link', :remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil} %>
</li>
26 changes: 26 additions & 0 deletions app/views/kaminari/twitter-bootstrap-4/_paginator.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<%# The container tag
- available local variables
current_page: a page object for the currently displayed page
num_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
paginator: the paginator that renders the pagination tags inside
-%>
<%- pagination_class ||= '' %>
<%= paginator.render do -%>
<nav>
<ul class="pagination <%= pagination_class %>">
<%= first_page_tag unless current_page.first? %>
<%= prev_page_tag unless current_page.first? %>
<% each_page do |page| -%>
<% if page.left_outer? || page.right_outer? || page.inside_window? -%>
<%= page_tag page %>
<% elsif !page.was_truncated? -%>
<%= gap_tag %>
<% end -%>
<% end -%>
<%= next_page_tag unless current_page.last? %>
<%= last_page_tag unless current_page.last? %>
</ul>
</nav>
<% end -%>
13 changes: 13 additions & 0 deletions app/views/kaminari/twitter-bootstrap-4/_prev_page.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<%# Link to the "Previous" page
- available local variables
url: url to the previous page
current_page: a page object for the currently displayed page
num_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<% unless current_page.first? %>
<li class="page-item prev">
<%= link_to_unless current_page.first?, raw(t 'views.pagination.previous'), url, class: 'page-link', :rel => 'prev', :remote => remote %>
</li>
<% end %>