Skip to content

Commit 70906c9

Browse files
committed
render nothing if there is only one page
1 parent f8ad60a commit 70906c9

File tree

6 files changed

+26
-4
lines changed

6 files changed

+26
-4
lines changed

Gemfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ gemspec
77
gem "guard-coffeescript"
88
gem "guard-jasmine-headless-webkit"
99
gem "jasmine"
10-
gem "jasmine-headless-webkit"
10+
gem "jasmine-headless-webkit"
11+
gem 'rb-fsevent'

Gemfile.lock

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
jquery-bootstrap-pagination (0.0.1)
4+
jquery-bootstrap-pagination (1.0.0)
55

66
GEM
77
remote: https://rubygems.org/
@@ -55,6 +55,7 @@ GEM
5555
slop (~> 3.3.1)
5656
rack (1.4.1)
5757
rainbow (1.1.4)
58+
rb-fsevent (0.9.2)
5859
rspec (2.12.0)
5960
rspec-core (~> 2.12.0)
6061
rspec-expectations (~> 2.12.0)
@@ -88,3 +89,4 @@ DEPENDENCIES
8889
jasmine
8990
jasmine-headless-webkit
9091
jquery-bootstrap-pagination!
92+
rb-fsevent
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Jquery
22
module Bootstrap
33
module Pagination
4-
VERSION = "1.0.0"
4+
VERSION = "1.0.1"
55
end
66
end
77
end

spec/javascripts/jquery-bootstrap-pagination_spec.coffee

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ describe "pagination", ->
9393
</div>
9494
""")
9595

96+
it "renders nothing if there is only 1 page", ->
97+
@view.settings.total_pages = 1
98+
@view.settings.current_page = 1
99+
@view.render()
100+
expect(@page.html()).toEqual("")
101+
96102
it "adds 'active' to the current page", ->
97103
@view.settings.current_page = 2
98104
@view.render()

src/jquery-bootstrap-pagination.coffee

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
last: false
4141
# how many links before truncation happens:
4242
display_max: 8
43+
# render nothing if there is only 1 page:
44+
ignore_single_page: true
4345

4446
# merge defaults with passed in options:
4547
@settings = $.extend(defaults, options)
@@ -130,6 +132,12 @@
130132
# renders the pagination links to the element. the
131133
# element is cleared of all of it's HTML in this process.
132134
render: =>
135+
# if there is only 1 page and the 'ignore_single_page' flag
136+
# is 'true' then render nothing.
137+
if @settings.total_pages is 1 and @settings.ignore_single_page
138+
@el.html("")
139+
return
140+
# render all of the pages:
133141
html = ["<div class='jquery-bootstrap-pagination'>"]
134142
html.push "<ul>"
135143
for link in @buildLinks()

vendor/assets/javascripts/jquery-bootstrap-pagination.js

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)