From d950e509ff1049d2837a574f8e97b2e023d8c60f Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Delaune?= Date: Tue, 31 Aug 2010 11:59:26 +0200 Subject: [PATCH] (MT #1654) Adding jquery.tablesorter and jquery.tablesorter.pager support for authorised_values.pl --- .../plugins/jquery.tablesorter.pager.js | 184 ++++++++++++++++++ .../en/modules/admin/authorised_values.tmpl | 48 +++-- koha-tmpl/intranet-tmpl/prog/img/first.png | Bin 0 -> 720 bytes koha-tmpl/intranet-tmpl/prog/img/last.png | Bin 0 -> 737 bytes koha-tmpl/intranet-tmpl/prog/img/next.png | Bin 0 -> 736 bytes koha-tmpl/intranet-tmpl/prog/img/prev.png | Bin 0 -> 745 bytes 6 files changed, 220 insertions(+), 12 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/lib/jquery/plugins/jquery.tablesorter.pager.js create mode 100644 koha-tmpl/intranet-tmpl/prog/img/first.png create mode 100644 koha-tmpl/intranet-tmpl/prog/img/last.png create mode 100644 koha-tmpl/intranet-tmpl/prog/img/next.png create mode 100644 koha-tmpl/intranet-tmpl/prog/img/prev.png diff --git a/koha-tmpl/intranet-tmpl/prog/en/lib/jquery/plugins/jquery.tablesorter.pager.js b/koha-tmpl/intranet-tmpl/prog/en/lib/jquery/plugins/jquery.tablesorter.pager.js new file mode 100644 index 0000000000..5a34d82517 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/lib/jquery/plugins/jquery.tablesorter.pager.js @@ -0,0 +1,184 @@ +(function($) { + $.extend({ + tablesorterPager: new function() { + + function updatePageDisplay(c) { + var s = $(c.cssPageDisplay,c.container).val((c.page+1) + c.seperator + c.totalPages); + } + + function setPageSize(table,size) { + var c = table.config; + c.size = size; + c.totalPages = Math.ceil(c.totalRows / c.size); + c.pagerPositionSet = false; + moveToPage(table); + fixPosition(table); + } + + function fixPosition(table) { + var c = table.config; + if(!c.pagerPositionSet && c.positionFixed) { + var c = table.config, o = $(table); + if(o.offset) { + c.container.css({ + top: o.offset().top + o.height() + 'px', + position: 'absolute' + }); + } + c.pagerPositionSet = true; + } + } + + function moveToFirstPage(table) { + var c = table.config; + c.page = 0; + moveToPage(table); + } + + function moveToLastPage(table) { + var c = table.config; + c.page = (c.totalPages-1); + moveToPage(table); + } + + function moveToNextPage(table) { + var c = table.config; + c.page++; + if(c.page >= (c.totalPages-1)) { + c.page = (c.totalPages-1); + } + moveToPage(table); + } + + function moveToPrevPage(table) { + var c = table.config; + c.page--; + if(c.page <= 0) { + c.page = 0; + } + moveToPage(table); + } + + + function moveToPage(table) { + var c = table.config; + if(c.page < 0 || c.page > (c.totalPages-1)) { + c.page = 0; + } + + renderTable(table,c.rowsCopy); + } + + function renderTable(table,rows) { + + var c = table.config; + var l = rows.length; + var s = (c.page * c.size); + var e = (s + c.size); + if(e > rows.length ) { + e = rows.length; + } + + + var tableBody = $(table.tBodies[0]); + + // clear the table body + + $.tablesorter.clearTableBody(table); + + for(var i = s; i < e; i++) { + + //tableBody.append(rows[i]); + + var o = rows[i]; + var l = o.length; + for(var j=0; j < l; j++) { + + tableBody[0].appendChild(o[j]); + + } + } + + fixPosition(table,tableBody); + + $(table).trigger("applyWidgets"); + + if( c.page >= c.totalPages ) { + moveToLastPage(table); + } + + updatePageDisplay(c); + } + + this.appender = function(table,rows) { + + var c = table.config; + + c.rowsCopy = rows; + c.totalRows = rows.length; + c.totalPages = Math.ceil(c.totalRows / c.size); + + renderTable(table,rows); + }; + + this.defaults = { + size: 10, + offset: 0, + page: 0, + totalRows: 0, + totalPages: 0, + container: null, + cssNext: '.next', + cssPrev: '.prev', + cssFirst: '.first', + cssLast: '.last', + cssPageDisplay: '.pagedisplay', + cssPageSize: '.pagesize', + seperator: "/", + positionFixed: true, + appender: this.appender + }; + + this.construct = function(settings) { + + return this.each(function() { + + config = $.extend(this.config, $.tablesorterPager.defaults, settings); + + var table = this, pager = config.container; + + $(this).trigger("appendCache"); + + config.size = parseInt($(".pagesize",pager).val()); + + $(config.cssFirst,pager).click(function() { + moveToFirstPage(table); + return false; + }); + $(config.cssNext,pager).click(function() { + moveToNextPage(table); + return false; + }); + $(config.cssPrev,pager).click(function() { + moveToPrevPage(table); + return false; + }); + $(config.cssLast,pager).click(function() { + moveToLastPage(table); + return false; + }); + $(config.cssPageSize,pager).change(function() { + setPageSize(table,parseInt($(this).val())); + return false; + }); + }); + }; + + } + }); + // extend plugin scope + $.fn.extend({ + tablesorterPager: $.tablesorterPager.construct + }); + +})(jQuery); \ No newline at end of file diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tmpl index bef0caec90..859cdceeba 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tmpl @@ -5,6 +5,16 @@ › Confirm Deletion Authorized values + + + +