Bug 14940: Fix sorting in opac-topissues.pl
There is hidden text in "Checkouts" cells that prevent DataTables to sort numerically. This patch adds the 'title-numeric' sort plugin and use it in opac-topissues.pl Column 'Checkouts' in Home > Most popular items sorts as expected Signed-off-by: Marc Véron <veron@veron.ch> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> (cherry picked from commit2f0e409f47) Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> (cherry picked from commite14557ecd9) Signed-off-by: Liz Rea <wizzyrea@gmail.com>
This commit is contained in:
parent
7f83431fb8
commit
d2ce611bf6
|
|
@ -86,7 +86,7 @@
|
|||
[% results_loo.description %]
|
||||
[% END %]
|
||||
</td>
|
||||
<td><span class="tdlabel">Checkouts: </span> [% results_loo.tot %]</td>
|
||||
<td><span class="tdlabel">Checkouts: </span> <span title="[% results_loo.tot %]">[% results_loo.tot %]</span></td>
|
||||
[% IF Koha.Preference( 'opacuserlogin' ) == 1 %]<td>[% IF Koha.Preference( 'RequestOnOpac' ) == 1 %][% UNLESS ( results_loo.norequests ) %]<a href="/cgi-bin/koha/opac-reserve.pl?biblionumber=[% results_loo.biblionumber %]">Place hold</a>[% END %][% END %]</td>[% END %]
|
||||
</tr>
|
||||
[% END %]
|
||||
|
|
@ -172,7 +172,7 @@
|
|||
"aoColumns": [
|
||||
{ "sType": "anti-the" },
|
||||
null,
|
||||
null,
|
||||
{ "sType": "title-numeric" },
|
||||
[% IF ( opacuserlogin ) %]null,[% END %]
|
||||
]
|
||||
}));
|
||||
|
|
|
|||
|
|
@ -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: <td><span title="[% total %]">Total: [% total %]</span></td>
|
||||
*
|
||||
* 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
|
||||
|
|
|
|||
Loading…
Reference in New Issue