From d2bbfbe8ce4c80a4950683ed3300da15f6bb0f21 Mon Sep 17 00:00:00 2001 From: DBinaghi <39097246+DBinaghi@users.noreply.github.com> Date: Fri, 19 Jun 2020 16:57:45 +0200 Subject: [PATCH 1/3] Added 2 extra columns + sortability to files list Added 2 extra columns (type, aka extension, and size) to files list, and chance to sort them by clicking on column header, as for Items browse list. TODO: it would be nice to manage number format localization (line 101) --- views/admin/index/dropboxlist.php | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/views/admin/index/dropboxlist.php b/views/admin/index/dropboxlist.php index be1c012..cd32e04 100644 --- a/views/admin/index/dropboxlist.php +++ b/views/admin/index/dropboxlist.php @@ -55,7 +55,23 @@ function dropboxNoEnter(e) { jQuery('.dropbox-js').show(); jQuery('#dropbox-show-all').hide(); + + jQuery('th').click(function(){ + var table = jQuery(this).parents('table').eq(0) + var rows = table.find('tr:gt(0)').toArray().sort(comparer(jQuery(this).index())) + this.asc = !this.asc + if (!this.asc){rows = rows.reverse()} + for (var i = 0; i < rows.length; i++){table.append(rows[i])} + }) }); + + function comparer(index) { + return function(a, b) { + var valA = getCellValue(a, index), valB = getCellValue(b, index) + return jQuery.isNumeric(valA) && jQuery.isNumeric(valB) ? valA - valB : valA.toString().localeCompare(valB) + } + } + function getCellValue(row, index){ return jQuery(row).children('td').eq(index).text() }