2
YUI 3.13.0 (build 508226d)
3
Copyright 2013 Yahoo! Inc. All rights reserved.
4
Licensed under the BSD License.
5
http://yuilibrary.com/license/
8
YUI.add('paginator', function (Y, NAME) {
11
The Paginator utility allows you to display an item or a group of items
12
depending on the number of items you wish to display at one time.
14
Paginator's primary functionality is contained in `paginator-core` and is mixed
15
into `paginator` to allow `paginator` to have extra functionality added to it
16
while leaving the core functionality untouched. This allows `paginator-core` to
17
remain available for use later on or used in isolation if it is the only piece
20
Due to the vast number of interfaces a paginator could possibly consist of,
21
`Paginator` does not contain any ready to use UIs. However, `Paginator` is
22
ready to be used in any Based-based, module such as a Widget, by extending your
23
desired class and mixing in `Paginator`. This is displayed in the following
27
YUI().use('paginator-url', 'widget', function (Y){
28
var MyPaginator = Y.Base.create('my-paginator', Y.Widget, [Y.Paginator], {
30
renderUI: function () {
32
i, numberOfPages = this.get('totalPages');
34
for (i = 1; i <= numberOfPages; i++) {
35
// use paginator-url's formatUrl method
36
numbers += '<a href="' + this.formatUrl(i) + '">' + i + '</a>';
39
this.get('boundingBox').append(numbers);
43
this.get('boundingBox').delegate('click', function (e) {
44
// let's not go to the page, just update internally
46
this.set('page', parseInt(e.currentTarget.getContent(), 10));
49
this.after('pageChange', function (e) {
50
// mark the link selected when it's the page being displayed
51
var bb = this.get('boundingBox'),
52
activeClass = 'selected';
54
bb.all('a').removeClass(activeClass).item(e.newVal).addClass(activeClass);
60
var myPg = new MyPaginator({
77
Y.Base.create('paginator', Y.Base, [Y.Paginator.Core]),
82
}, '3.13.0', {"requires": ["paginator-core"]});