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-url', function (Y, NAME) {
11 Adds in URL options for paginator links.
14 @submodule paginator-url
19 function PaginatorUrl () {}
21 PaginatorUrl.ATTRS = {
23 URL to return formatted with the page number. URL uses `Y.Lang.sub` for page number stubstitutions.
25 For example, if the page number is `3`, setting the `pageUrl` to `"?pg={page}"`, will result in `?pg=3`
33 PaginatorUrl.prototype = {
35 Returns a formated URL for the previous page.
37 @return {String | null} Formatted URL for the previous page, or `null` if there is no previous page.
39 prevPageUrl: function () {
40 return (this.hasPrevPage() && this.formatPageUrl(this.get('page') - 1)) || null;
44 Returns a formated URL for the next page.
46 @return {String | null} Formatted URL for the next page or `null` if there is no next page.
48 nextPageUrl: function () {
49 return (this.hasNextPage() && this.formatPageUrl(this.get('page') + 1)) || null;
53 Returns a formated URL for the provided page number.
55 @param {Number} [page] Page value to be used in the formatted URL. If empty, page will be the value of the `page` ATTRS.
56 @return {String | null} Formatted URL for the page or `null` if there is not a `pageUrl` set.
58 formatPageUrl: function (page) {
59 var pageUrl = this.get('pageUrl');
61 return Y.Lang.sub(pageUrl, {
62 page: page || this.get('page')
69 Y.namespace('Paginator').Url = PaginatorUrl;
71 Y.Base.mix(Y.Paginator, [PaginatorUrl]);
74 }, '3.13.0', {"requires": ["paginator"]});