(function() { Pager = (function() { function Pager(table){ // Init pager if(typeof($LIMIT_PER_PAGE) != "undefined") this.init($LIMIT_PER_PAGE, $CMS_TABLE_PAGES); if(typeof(table) != "undefined") this.oTable = table; }; Pager.prototype.fields = new Object(); Pager.prototype.page = 1; Pager.prototype.sortWay = true; Pager.prototype.sortName = ""; Pager.prototype.limit = 0; Pager.prototype.pages = 0; Pager.prototype.oTable = {}; Pager.prototype.bInfinite = false; Pager.prototype.next = function(){ if(this.page < this.pages){ this.page++; return true; } return false; }; Pager.prototype.prev = function(){ if(this.page>1){ this.page--; return true; } return false; }; Pager.prototype.reset = function(sort){ this.page = 1; sort = $.isDefined(sort)?sort:true; if(sort){ this.sortWay = true; this.sortName = ""; } }; Pager.prototype.init = function($limitPerPage, $pagesCount){ this.pages = $pagesCount; this.limit = $limitPerPage; }; Pager.prototype.addPagerBottom = function(object){ var _this = this; if(typeof(object) == "undefined"){ object = $(".recordset-drop-marker"); } object.find(".pager-cnt").html(""); var i, pg = this.calculatePagerArray(); for(i in pg){ object.find(".pager-cnt").append("
  • "+pg[i]["nr"]+"
  • "); } if(object.find(".pager-cnt li").length > 1){ object.find(".pager-cnt").show(); }else{ object.find(".pager-cnt").hide(); } object.find(".pager-cnt li:first").addClass("first"); object.find(".pager-cnt li:last").addClass("last"); if(this.page != 1 && this.pages > 1 && pg[0].left == true){ object.find(".pager-cnt li:first a").html(($.isDefined(CBase.gM.prevp)?CBase.gM.prevp:"‹‹")).addClass("prev"); } if(this.page != this.pages && this.page != this.pages-1 && this.pages > 1 && pg[i].right == true){ object.find(".pager-cnt li:last a").html(($.isDefined(CBase.gM.nextp)?CBase.gM.nextp:"››")).addClass("next"); } // Bind pager clicks object.find(".pager-cnt li").click(function(){ _this.page = parseInt($(this).attr("id")); // Reset selected page $(this).closest("ul").find("li.sel").removeClass("sel"); $(this).addClass("sel"); _this.oTable.filterTableData(true); }); // Bind hoverer if(typeof(CBase) != "undefined" && !CBase.browser.idevice){ object.find(".pager-cnt li a").bind({ mouseover : function(){ $(this).addClass("hover"); }, mouseout : function(){ $(this).removeClass("hover"); } }); } _this.recalculateRecordsShown(object); }; Pager.prototype.recalculateRecordsShown = function(object) { var _this = this; // Set pager row count object.parent().find(".table-rows").each(function(){ var str = (_this.page - 1) * _this.limit+1 + "-" + ($(this).parent().find("ul.dxr:not(.thead)").length + (_this.page - 1)*_this.limit); var bPager = $(this).closest(".table-data").find(".pager .rcount").hide(); bPager.find("span").html(str).parent(); // Clone data to top pager $(this).closest(".table-data").find(".tpager .rcount").hide().html(bPager.html()).add(bPager).fadeIn(); }); } Pager.prototype.calculatePagerArray = function() { var $from, $till, $i; var left, maxShown = 7; // Must be odd number var right = left = Math.round((maxShown-1)/2); var t = 0; var $Pages = new Object(); if(this.pages>maxShown){ var $page = this.page; if($page > left && $page <= this.pages - right){ $from = $page - left; $till = $page + right; }else if($page > this.pages - right){ $from = $page - left - ($page - (this.pages - right)); $till = this.pages; }else{ $from = 1; $till = $page + right + (left - $page) + 1; } }else{ $from = 1; $till = this.pages; } for ($i = $from; $i <= $till; $i++) { $Pages[t++] = { 'nr' : $i, 'active' : (this.page == $i?true:false) }; } // Set arrows if($from>1){ $Pages[0]['left'] = true; $Pages[0]['nr'] = $page-1; } if($till