From 470bc63512fb47d1788576fa68978355b641167f Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 7 May 2013 12:24:56 -0400 Subject: [PATCH] Bug 9456: (follow-up) move sort filters to datatables.js Signed-off-by: Kyle M Hall Signed-off-by: Jonathan Druart Signed-off-by: Galen Charlton --- .../intranet-tmpl/prog/en/js/datatables.js | 35 +++++++++++++++++++ .../prog/en/modules/basket/basket.tt | 35 ------------------- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/en/js/datatables.js index cca389d8db..5015da2b9f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/datatables.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/datatables.js @@ -580,3 +580,38 @@ $.fn.dataTableExt.oSort['nsb-nse-desc'] = function(a,b) { b = b.replace(pattern, ""); return (b > a) ? 1 : ((b < a) ? -1 : 0); } + +/* Define two custom functions (asc and desc) for basket callnumber sorting */ +jQuery.fn.dataTableExt.oSort['callnumbers-asc'] = function(x,y) { + var x_array = x.split("
"); + var y_array = y.split("
"); + + /* Pop the first elements, they are empty strings */ + x_array.shift(); + y_array.shift(); + + x_array.sort(); + y_array.sort(); + + x = x_array.shift(); + y = y_array.shift(); + + return ((x < y) ? -1 : ((x > y) ? 1 : 0)); +}; + +jQuery.fn.dataTableExt.oSort['callnumbers-desc'] = function(x,y) { + var x_array = x.split("
"); + var y_array = y.split("
"); + + /* Pop the first elements, they are empty strings */ + x_array.shift(); + y_array.shift(); + + x_array.sort(); + y_array.sort(); + + x = x_array.pop(); + y = y_array.pop(); + + return ((x < y) ? 1 : ((x > y) ? -1 : 0)); +}; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt index b2fecc7731..81ace5366a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt @@ -90,41 +90,6 @@ function placeHold () { $(".hold").text(_("Place Hold")); $("#downloadcartc").empty(); - /* Define two custom functions (asc and desc) for string sorting */ - jQuery.fn.dataTableExt.oSort['callnumbers-asc'] = function(x,y) { - var x_array = x.split("
"); - var y_array = y.split("
"); - - /* Pop the first elements, they are empty strings */ - x_array.shift(); - y_array.shift(); - - x_array.sort(); - y_array.sort(); - - x = x_array.shift(); - y = y_array.shift(); - - return ((x < y) ? -1 : ((x > y) ? 1 : 0)); - }; - - jQuery.fn.dataTableExt.oSort['callnumbers-desc'] = function(x,y) { - var x_array = x.split("
"); - var y_array = y.split("
"); - - /* Pop the first elements, they are empty strings */ - x_array.shift(); - y_array.shift(); - - x_array.sort(); - y_array.sort(); - - x = x_array.pop(); - y = y_array.pop(); - - return ((x < y) ? 1 : ((x > y) ? -1 : 0)); - }; - $("#itemst").dataTable($.extend(true, {}, dataTablesDefaults, { "sDom": 't', "aoColumnDefs": [ -- 2.39.5