-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpager.min.js
More file actions
1 lines (1 loc) · 1.23 KB
/
Copy pathpager.min.js
File metadata and controls
1 lines (1 loc) · 1.23 KB
1
!function(t,r){"use strict";"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?module.exports=r():t.Pager=r()}(this,function(){"use strict";function t(t,r){if(isNaN(t))throw'The "length" parameter must be a number';if("undefined"!=typeof r&&"boolean"!=typeof r)throw'The "circular" parameter must be a boolean';this.current=0,this.length=parseInt(t),this.circular="undefined"==typeof r?!0:r}return t.prototype={constructor:t,set:function(t){if(isNaN(t))throw'The "index" parameter must be a number';var r=this.getFirst(),e=this.getLast();this.current=t,r>=t?this.current=r:t>=e&&(this.current=e)},hasPrev:function(){return 0!==this.current},hasNext:function(){return this.current<this.getLast()},getPrev:function(){return this.hasPrev()?this.current-1:this.circular?this.getLast():!1},getNext:function(){return this.hasNext()?this.current+1:this.circular?0:!1},getFirst:function(){return 0},getLast:function(){return this.length-1},prev:function(){return this.hasPrev()?this.current--:this.circular&&this.last(),this.current},next:function(){return this.hasNext()?this.current++:this.circular&&this.first(),this.current},first:function(){return this.current=this.getFirst()},last:function(){return this.current=this.getLast()}},t});