Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
YUI.add('paginator-url', function (Y, NAME) {
2
 
3
/**
4
 Adds in URL options for paginator links.
5
 
6
 @module paginator
7
 @submodule paginator-url
8
 @class Paginator.Url
9
 @since 3.10.0
10
 */
11
 
12
function PaginatorUrl () {}
13
 
14
PaginatorUrl.ATTRS = {
15
    /**
16
    URL to return formatted with the page number. URL uses `Y.Lang.sub` for page number stubstitutions.
17
 
18
    For example, if the page number is `3`, setting the `pageUrl` to `"?pg={page}"`, will result in `?pg=3`
19
 
20
    @attribute pageUrl
21
    @type String
22
    **/
23
    pageUrl: {}
24
};
25
 
26
PaginatorUrl.prototype = {
27
    /**
28
     Returns a formated URL for the previous page.
29
     @method prevPageUrl
30
     @return {String | null} Formatted URL for the previous page, or `null` if there is no previous page.
31
     */
32
    prevPageUrl: function () {
33
        return (this.hasPrevPage() && this.formatPageUrl(this.get('page') - 1)) || null;
34
    },
35
 
36
    /**
37
     Returns a formated URL for the next page.
38
     @method nextPageUrl
39
     @return {String | null} Formatted URL for the next page or `null` if there is no next page.
40
     */
41
    nextPageUrl: function () {
42
        return (this.hasNextPage() && this.formatPageUrl(this.get('page') + 1)) || null;
43
    },
44
 
45
    /**
46
     Returns a formated URL for the provided page number.
47
     @method formatPageUrl
48
     @param {Number} [page] Page value to be used in the formatted URL. If empty, page will be the value of the `page` ATTRS.
49
     @return {String | null} Formatted URL for the page or `null` if there is not a `pageUrl` set.
50
     */
51
    formatPageUrl: function (page) {
52
        var pageUrl = this.get('pageUrl');
53
        if (pageUrl) {
54
            return Y.Lang.sub(pageUrl, {
55
                page: page || this.get('page')
56
            });
57
        }
58
        return null;
59
    }
60
};
61
 
62
Y.namespace('Paginator').Url = PaginatorUrl;
63
 
64
Y.Base.mix(Y.Paginator, [PaginatorUrl]);
65
 
66
 
67
}, '3.18.1', {"requires": ["paginator"]});