Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Multiple paginators exapmle added
  • Loading branch information
Eugene Simakin committed Jan 12, 2014
1 parent 4c89db0 commit a22ad70
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
11 changes: 11 additions & 0 deletions index.html
Expand Up @@ -168,6 +168,17 @@ <h4>Visible pages option</h4>
<ul id="visible-pages-example"></ul>
</div>

<h4>Synchronized pagination elements</h4>

<p>You can attach multiple paginators to your content and access them via class name.
The following example show this case.</p>

<div class="text-center">
<ul class="sync-pagination pagination-sm"></ul>
<div id="sync-example-page-content" class="well"></div>
<ul class="sync-pagination pagination-sm"></ul>
</div>

<h3>
<a id="license" class="anchor" href="#license"><span
class="octicon octicon-link"></span></a>License</h3>
Expand Down
16 changes: 7 additions & 9 deletions js/jquery.twbsPagination.js
Expand Up @@ -263,16 +263,14 @@
var args = Array.prototype.slice.call(arguments, 1);
var methodReturn;

var $set = this.each(function () {
var $this = $(this);
var data = $this.data('twbs-pagination');
var options = typeof option === 'object' && option;
var $this = $(this);
var data = $this.data('twbs-pagination');
var options = typeof option === 'object' && option;

if (!data) $this.data('twbs-pagination', (data = new TwbsPagination(this, options) ));
if (typeof option === 'string') methodReturn = data[ option ].apply(data, args);
});
if (!data) $this.data('twbs-pagination', (data = new TwbsPagination(this, options) ));
if (typeof option === 'string') methodReturn = data[ option ].apply(data, args);

return ( methodReturn === undefined ) ? $set : methodReturn;
return ( methodReturn === undefined ) ? $this : methodReturn;
};

$.fn.twbsPagination.defaults = {
Expand All @@ -287,7 +285,7 @@
last: 'Last',
paginationClass: 'pagination',
onPageClick: null,
version: '1.0'
version: '1.1'
};

$.fn.twbsPagination.Constructor = TwbsPagination;
Expand Down
9 changes: 7 additions & 2 deletions js/main.js
Expand Up @@ -2,7 +2,6 @@ $(document).ready(function () {
$('#pagination-demo').twbsPagination({
totalPages: 35,
visiblePages: 7,
version: '1.1',
onPageClick: function (event, page) {
$('#page-content').text('Page ' + page);
}
Expand All @@ -22,7 +21,6 @@ $(document).ready(function () {

$('#pagination-demo-v1_1').twbsPagination({
totalPages: 15,
version: '1.1',
startPage: 5
});

Expand All @@ -32,5 +30,12 @@ $(document).ready(function () {
version: '1.1'
});

$('.sync-pagination').twbsPagination({
totalPages: 20,
onPageClick: function (evt, page) {
$('#sync-example-page-content').text('Page ' + page);
}
});

});

0 comments on commit a22ad70

Please sign in to comment.