~ubuntu-branches/ubuntu/utopic/moodle/utopic

« back to all changes in this revision

Viewing changes to lib/yuilib/3.13.0/paginator/paginator-debug.js

  • Committer: Package Import Robot
  • Author(s): Thijs Kinkhorst
  • Date: 2014-05-12 16:10:38 UTC
  • mfrom: (36.1.3 sid)
  • Revision ID: package-import@ubuntu.com-20140512161038-puyqf65k4e0s8ytz
Tags: 2.6.3-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
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/
 
6
*/
 
7
 
 
8
YUI.add('paginator', function (Y, NAME) {
 
9
 
 
10
/**
 
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.
 
13
 
 
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
 
18
 you need.
 
19
 
 
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
 
24
 example:
 
25
 
 
26
 <pre><code>
 
27
 YUI().use('paginator-url', 'widget', function (Y){
 
28
     var MyPaginator = Y.Base.create('my-paginator', Y.Widget, [Y.Paginator], {
 
29
 
 
30
        renderUI: function () {
 
31
            var numbers = '',
 
32
                i, numberOfPages = this.get('totalPages');
 
33
 
 
34
            for (i = 1; i <= numberOfPages; i++) {
 
35
                // use paginator-url's formatUrl method
 
36
                numbers += '&lt;a href="' + this.formatUrl(i) + '">' + i + '&lt;/a>';
 
37
            }
 
38
 
 
39
            this.get('boundingBox').append(numbers);
 
40
        },
 
41
 
 
42
        bindUI: function () {
 
43
            this.get('boundingBox').delegate('click', function (e) {
 
44
                // let's not go to the page, just update internally
 
45
                e.preventDefault();
 
46
                this.set('page', parseInt(e.currentTarget.getContent(), 10));
 
47
            }, 'a', this);
 
48
 
 
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';
 
53
 
 
54
                bb.all('a').removeClass(activeClass).item(e.newVal).addClass(activeClass);
 
55
            });
 
56
        }
 
57
 
 
58
     });
 
59
 
 
60
     var myPg = new MyPaginator({
 
61
                    totalItems: 100,
 
62
                    pageUrl: '?pg={page}'
 
63
                });
 
64
 
 
65
     myPg.render();
 
66
 });
 
67
 </code></pre>
 
68
 
 
69
 @module paginator
 
70
 @main paginator
 
71
 @class Paginator
 
72
 @constructor
 
73
 @since 3.11.0
 
74
 */
 
75
 
 
76
Y.Paginator = Y.mix(
 
77
    Y.Base.create('paginator', Y.Base, [Y.Paginator.Core]),
 
78
    Y.Paginator
 
79
);
 
80
 
 
81
 
 
82
}, '3.13.0', {"requires": ["paginator-core"]});