AutorÃa | Ultima modificación | Ver Log |
YUI.add('paginator', function (Y, NAME) {/**The Paginator utility allows you to display an item or a group of itemsdepending on the number of items you wish to display at one time.Paginator's primary functionality is contained in `paginator-core` and is mixedinto `paginator` to allow `paginator` to have extra functionality added to itwhile leaving the core functionality untouched. This allows `paginator-core` toremain available for use later on or used in isolation if it is the only pieceyou need.Due to the vast number of interfaces a paginator could possibly consist of,`Paginator` does not contain any ready to use UIs. However, `Paginator` isready to be used in any Based-based, module such as a Widget, by extending yourdesired class and mixing in `Paginator`. This is displayed in the followingexample:<pre><code>YUI().use('paginator-url', 'widget', function (Y){var MyPaginator = Y.Base.create('my-paginator', Y.Widget, [Y.Paginator], {renderUI: function () {var numbers = '',i, numberOfPages = this.get('totalPages');for (i = 1; i <= numberOfPages; i++) {// use paginator-url's formatUrl methodnumbers += '<a href="' + this.formatUrl(i) + '">' + i + '</a>';}this.get('boundingBox').append(numbers);},bindUI: function () {this.get('boundingBox').delegate('click', function (e) {// let's not go to the page, just update internallye.preventDefault();this.set('page', parseInt(e.currentTarget.getContent(), 10));}, 'a', this);this.after('pageChange', function (e) {// mark the link selected when it's the page being displayedvar bb = this.get('boundingBox'),activeClass = 'selected';bb.all('a').removeClass(activeClass).item(e.newVal).addClass(activeClass);});}});var myPg = new MyPaginator({totalItems: 100,pageUrl: '?pg={page}'});myPg.render();});</code></pre>@module paginator@main paginator@class Paginator@constructor@since 3.11.0*/Y.Paginator = Y.mix(Y.Base.create('paginator', Y.Base, [Y.Paginator.Core]),Y.Paginator);}, '3.18.1', {"requires": ["paginator-core"]});