Component-Builder/media/footable/js/footable.paging.min.js

8 lines
8.3 KiB
JavaScript
Raw Normal View History

/*
* FooTable v3 - FooTable is a jQuery plugin that aims to make HTML tables on smaller devices look awesome.
* @version 3.0.6
* @link http://fooplugins.com
* @copyright Steven Usher & Brad Vincent 2015
* @license Released under the GPLv3 license.
*/
!function(a,b){b.Pager=b.Class.extend({construct:function(a,b,c,d,e){this.total=a,this.current=b,this.size=c,this.page=d,this.forward=e}})}(jQuery,FooTable),function(a,b){b.Paging=b.Component.extend({construct:function(a){this._super(a,a.o.paging.enabled),this.strings=a.o.paging.strings,this.current=a.o.paging.current,this.size=a.o.paging.size,this.limit=a.o.paging.limit,this.position=a.o.paging.position,this.countFormat=a.o.paging.countFormat,this.total=-1,this.$row=null,this.$cell=null,this.$pagination=null,this.$count=null,this._previous=1,this._total=0},preinit:function(a){var c=this;this.ft.raise("preinit.ft.paging",[a]).then(function(){c.ft.$el.hasClass("footable-paging")&&(c.enabled=!0),c.enabled=b.is["boolean"](a.paging)?a.paging:c.enabled,c.enabled&&(c.size=b.is.number(a.pagingSize)?a.pagingSize:c.size,c.current=b.is.number(a.pagingCurrent)?a.pagingCurrent:c.current,c.limit=b.is.number(a.pagingLimit)?a.pagingLimit:c.limit,c.ft.$el.hasClass("footable-paging-left")&&(c.position="left"),c.ft.$el.hasClass("footable-paging-center")&&(c.position="center"),c.ft.$el.hasClass("footable-paging-right")&&(c.position="right"),c.position=b.is.string(a.pagingPosition)?a.pagingPosition:c.position,c.countFormat=b.is.string(a.pagingCountFormat)?a.pagingCountFormat:c.countFormat,c.total=Math.ceil(c.ft.rows.array.length/c.size),c._total=c.total)},function(){c.enabled=!1})},init:function(){var a=this;this.ft.raise("init.ft.paging").then(function(){a.$create()},function(){a.enabled=!1})},destroy:function(){var a=this;this.ft.raise("destroy.ft.paging").then(function(){a.ft.$el.removeClass("footable-paging").find("tfoot > tr.footable-paging").remove()})},predraw:function(){this.total=Math.ceil(this.ft.rows.array.length/this.size),this.current=this.current>this.total?this.total:this.current<1?1:this.current,this._total=this.ft.rows.array.length,this.ft.rows.array.length>this.size&&(this.ft.rows.array=this.ft.rows.array.splice((this.current-1)*this.size,this.size))},draw:function(){this.$cell.attr("colspan",this.ft.columns.visibleColspan),this._setVisible(this.current,this.current>this._previous),this._setNavigation(!0)},$create:function(){var b,c=this,d=c.total>1,e=function(b,c,d){return a("<li/>",{"class":d}).attr("data-page",b).append(a("<a/>",{"class":"footable-page-link",href:"#"}).data("page",b).html(c))};if(d){switch(c.position){case"left":b="footable-paging-left";break;case"right":b="footable-paging-right";break;default:b="footable-paging-center"}c.ft.$el.addClass("footable-paging").addClass(b),c.$cell=a("<td/>").attr("colspan",c.ft.columns.visibleColspan);var f=c.ft.$el.children("tfoot");0==f.length&&(f=a("<tfoot/>"),c.ft.$el.append(f)),c.$row=a("<tr/>",{"class":"footable-paging"}).append(c.$cell).appendTo(f),c.$pagination=a("<ul/>",{"class":"pagination"}).on("click.footable","a.footable-page-link",{self:c},c._onPageClicked),c.$count=a("<span/>",{"class":"label label-default"}),c.$pagination.empty(),d&&(c.$pagination.append(e("first",c.strings.first,"footable-page-nav")),c.$pagination.append(e("prev",c.strings.prev,"footable-page-nav")),c.limit>0&&c.limit<c.total&&c.$pagination.append(e("prev-limit",c.strings.prevPages,"footable-page-nav")));for(var g,h=0;h<c.total;h++)g=e(h+1,h+1,"footable-page"),c.$pagination.append(g);d&&(c.limit>0&&c.limit<c.total&&c.$pagination.append(e("next-limit",c.strings.nextPages,"footable-page-nav")),c.$pagination.append(e("next",c.strings.next,"footable-page-nav")),c.$pagination.append(e("last",c.strings.last,"footable-page-nav"))),c.$cell.append(c.$pagination,a("<div/>",{"class":"divider"}),c.$count),c._total=c.total}},first:function(){return this._set(1)},prev:function(){return this._set(this.current-1>0?this.current-1:1)},next:function(){return this._set(this.current+1<this.total?this.current+1:this.total)},last:function(){return this._set(this.total)},"goto":function(a){return this._set(a>this.total?this.total:1>a?1:a)},prevPages:function(){var a=this.$pagination.children("li.footable-page.visible:first").data("page")-1;this._setVisible(a,!0),this._setNavigation(!1)},nextPages:function(){var a=