|
1 |
| -# Jquery::Bootstrap::Pagination |
| 1 | +# jQuery Bootstrap Pagination |
2 | 2 |
|
3 |
| -TODO: Write a gem description |
| 3 | +A simple, full-featured, pagination system for [jQuery](http://jquery.com/) that outputs [Twitter Bootstrap](http://twitter.github.com/bootstrap/) marked up pagination links. Of course, there's no reason you need to use this with Bootstrap, the HTML output is very clean. |
4 | 4 |
|
5 | 5 | ## Installation
|
6 | 6 |
|
| 7 | +The library can be used in CoffeeScript, JavaScript, and Rails applications very easily. |
| 8 | + |
| 9 | +### Standalone |
| 10 | + |
| 11 | +#### CoffeeScript |
| 12 | + |
| 13 | +Use the `src/jquery-bootstrap-pagination.coffee` file. |
| 14 | + |
| 15 | +#### JavaScript |
| 16 | + |
| 17 | +Use the `vendor/assets/javascripts/jquery-bootstrap-pagination.js` file. This file is auto generated from the CoffeeScript file. |
| 18 | + |
| 19 | +### Rails 3.x |
| 20 | + |
7 | 21 | Add this line to your application's Gemfile:
|
8 | 22 |
|
9 |
| - gem 'jquery-bootstrap-pagination' |
| 23 | +``` ruby |
| 24 | +gem 'jquery-bootstrap-pagination' |
| 25 | +``` |
10 | 26 |
|
11 | 27 | And then execute:
|
12 | 28 |
|
13 |
| - $ bundle |
| 29 | +``` |
| 30 | +$ bundle |
| 31 | +``` |
14 | 32 |
|
15 |
| -Or install it yourself as: |
| 33 | +Add it to your `application.js` file: |
16 | 34 |
|
17 |
| - $ gem install jquery-bootstrap-pagination |
| 35 | +``` javascript |
| 36 | +//= require jquery-bootstrap-pagination |
| 37 | +``` |
18 | 38 |
|
19 | 39 | ## Usage
|
20 | 40 |
|
21 |
| -TODO: Write usage instructions here |
| 41 | +### CoffeeScript |
| 42 | +``` coffeescript |
| 43 | +# Basic usage: |
| 44 | +$("#my-pagination-section").pagination() |
| 45 | + |
| 46 | +# With options: |
| 47 | +$("#my-pagination-section").pagination |
| 48 | + total_pages: 10 |
| 49 | + current_page: 2 |
| 50 | + callback: (event, page) -> |
| 51 | + alert("Page #{page} was clicked!") |
| 52 | + |
| 53 | +# Retrieve the underlying PaginationView: |
| 54 | +$("#my-pagination-section").data("paginationView") |
| 55 | +``` |
| 56 | + |
| 57 | +### JavaScript: |
| 58 | +``` javascript |
| 59 | +// Basic usage: |
| 60 | +$("#my-pagination-section").pagination(); |
| 61 | + |
| 62 | +// With options: |
| 63 | +$("#my-pagination-section").pagination({ |
| 64 | + total_pages: 10, |
| 65 | + current_page: 2, |
| 66 | + callback: function(event, page) { |
| 67 | + return alert("Page " + page + " was clicked!"); |
| 68 | + } |
| 69 | +}); |
| 70 | + |
| 71 | +// Retrieve the underlying PaginationView: |
| 72 | +$("#my-pagination-section").data("paginationView"); |
| 73 | +``` |
| 74 | + |
| 75 | +### Options and Defaults: |
| 76 | +``` coffeescript |
| 77 | +# what is the current page: |
| 78 | +current_page: 1 |
| 79 | +# how many pages are there total: |
| 80 | +total_pages: 1 |
| 81 | +# change text of the 'next' link, |
| 82 | +# set to false for no next link: |
| 83 | +next: ">" |
| 84 | +# change text of the 'previous' link, |
| 85 | +# set to false for no previous link: |
| 86 | +prev: "<" |
| 87 | +# change text of the 'first' link, |
| 88 | +# set to false for no first link: |
| 89 | +first: false |
| 90 | +# change text of the 'last' link, |
| 91 | +# set to false for no last link: |
| 92 | +last: false |
| 93 | +# how many links before truncation happens: |
| 94 | +display_max: 8 |
| 95 | +``` |
22 | 96 |
|
23 | 97 | ## Contributing
|
24 | 98 |
|
25 | 99 | 1. Fork it
|
26 | 100 | 2. Create your feature branch (`git checkout -b my-new-feature`)
|
27 |
| -3. Commit your changes (`git commit -am 'Add some feature'`) |
28 |
| -4. Push to the branch (`git push origin my-new-feature`) |
29 |
| -5. Create new Pull Request |
| 101 | +3. Write/Run tests (`bundle exec rake`) |
| 102 | +4. Commit your changes (`git commit -am 'Add some feature'`) |
| 103 | +5. Push to the branch (`git push origin my-new-feature`) |
| 104 | +6. Create new Pull Request |
0 commit comments