@@ -, +, @@
---
.../bootstrap/en/modules/opac-topissues.tt | 4 +--
koha-tmpl/opac-tmpl/bootstrap/js/datatables.js | 26 ++++++++++++++++++++
2 files changed, 28 insertions(+), 2 deletions(-)
--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-topissues.tt
+++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-topissues.tt
@@ -87,7 +87,7 @@
[% results_loo.description %]
[% END %]
-
Checkouts: [% results_loo.tot %] |
+ Checkouts: [% results_loo.tot %] |
[% IF Koha.Preference( 'opacuserlogin' ) == 1 %][% IF Koha.Preference( 'RequestOnOpac' ) == 1 %][% UNLESS ( results_loo.norequests ) %]Place hold[% END %][% END %] | [% END %]
[% END %]
@@ -173,7 +173,7 @@
"aoColumns": [
{ "sType": "anti-the" },
null,
- null,
+ { "sType": "title-numeric" },
[% IF ( opacuserlogin ) %]null,[% END %]
]
}));
--- a/koha-tmpl/opac-tmpl/bootstrap/js/datatables.js
+++ a/koha-tmpl/opac-tmpl/bootstrap/js/datatables.js
@@ -55,6 +55,32 @@ jQuery.extend( jQuery.fn.dataTableExt.oSort, {
}
} );
+/* Plugin to allow sorting numerically on data stored in a span's title attribute
+ *
+ * Ex: Total: [% total %] |
+ *
+ * In DataTables config:
+ * "aoColumns": [
+ * { "sType": "title-numeric" }
+ * ]
+ * http://legacy.datatables.net/plug-ins/sorting#hidden_title
+ */
+jQuery.extend( jQuery.fn.dataTableExt.oSort, {
+ "title-numeric-pre": function ( a ) {
+ console.log(a);
+ var x = a.match(/title="*(-?[0-9\.]+)/)[1];
+ return parseFloat( x );
+ },
+
+ "title-numeric-asc": function ( a, b ) {
+ return ((a < b) ? -1 : ((a > b) ? 1 : 0));
+ },
+
+ "title-numeric-desc": function ( a, b ) {
+ return ((a < b) ? 1 : ((a > b) ? -1 : 0));
+ }
+} );
+
(function() {
/* Plugin to allow text sorting to ignore articles
--