From adba302dc714351ef366066e131b3be3d5170080 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Wed, 6 Jan 2016 15:30:41 +0100 Subject: [PATCH] Bug 15481: Remove dead code in datatables.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This removes the following functions that are not used anywhere: - dt_add_rangedate_filter - dt_overwrite_string_sorting_localeCompare - replace_html - replace_html_date Test plan: 1. Search for calls to the above functions in the code. There should be none. 2. Check that existing tables using DataTables are not broken. Signed-off-by: Marc VĂ©ron Signed-off-by: Jonathan Druart --- koha-tmpl/intranet-tmpl/prog/en/js/datatables.js | 87 ------------------------ 1 file changed, 87 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/en/js/datatables.js index e42918c..f1623dc 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/datatables.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/datatables.js @@ -135,34 +135,6 @@ jQuery.fn.dataTableExt.oApi.fnAddFilters = function ( oSettings, sClass, iDelay }); } -// Useful if you want to filter on dates with 2 inputs (start date and end date) -// You have to include calendar.inc to use it -function dt_add_rangedate_filter(begindate_id, enddate_id, dateCol) { - $.fn.dataTableExt.afnFiltering.push( - function( oSettings, aData, iDataIndex ) { - - var beginDate = Date_from_syspref($("#"+begindate_id).val()).getTime(); - var endDate = Date_from_syspref($("#"+enddate_id).val()).getTime(); - - var data = Date_from_syspref(aData[dateCol]).getTime(); - - if ( !parseInt(beginDate) && ! parseInt(endDate) ) { - return true; - } - else if ( beginDate <= data && !parseInt(endDate) ) { - return true; - } - else if ( data <= endDate && !parseInt(beginDate) ) { - return true; - } - else if ( beginDate <= data && data <= endDate) { - return true; - } - return false; - } - ); -} - // Sorting on html contains // bar sort on 'bar' function dt_overwrite_html_sorting_localeCompare() { @@ -203,65 +175,6 @@ function dt_overwrite_html_sorting_localeCompare() { }; } -// Sorting on string without accentued characters -function dt_overwrite_string_sorting_localeCompare() { - jQuery.fn.dataTableExt.oSort['string-asc'] = function(a,b) { - a = a.replace(/<.*?>/g, "").replace(/\s+/g, " "); - b = b.replace(/<.*?>/g, "").replace(/\s+/g, " "); - if (typeof(a.localeCompare == "function")) { - return a.localeCompare(b); - } else { - return (a > b) ? 1 : ((a < b) ? -1 : 0); - } - }; - - jQuery.fn.dataTableExt.oSort['string-desc'] = function(a,b) { - a = a.replace(/<.*?>/g, "").replace(/\s+/g, " "); - b = b.replace(/<.*?>/g, "").replace(/\s+/g, " "); - if(typeof(b.localeCompare == "function")) { - return b.localeCompare(a); - } else { - return (b > a) ? 1 : ((b < a) ? -1 : 0); - } - }; -} - -// Replace a node with a html and js contain. -function replace_html( original_node, type ) { - switch ( $(original_node).attr('data-type') ) { - case "range_dates": - var id = $(original_node).attr("data-id"); - var format = $(original_node).attr("data-format"); - replace_html_date( original_node, id, format ); - break; - default: - alert(_("This node can't be replaced")); - } -} - -// Replace a node with a "From [date] To [date]" element -// Used on tfoot > td -function replace_html_date( original_node, id, format ) { - var node = $('' + _("From") + '×
' + _("To") + '×'); - $(original_node).replaceWith(node); - var script = document.createElement( 'script' ); - script.type = 'text/javascript'; - var script_content = "Calendar.setup({"; - script_content += " inputField: \"" + id + "from\","; - script_content += " ifFormat: \"" + format + "\","; - script_content += " button: \"" + id + "from\","; - script_content += " onClose: function(){ $(\"#" + id + "from\").change(); this.hide();}"; - script_content += " });"; - script_content += " Calendar.setup({"; - script_content += " inputField: \"" + id + "to\","; - script_content += " ifFormat: \"" + format + "\","; - script_content += " button: \"" + id + "to\","; - script_content += " onClose: function(){ $(\"#" + id + "to\").change(); this.hide();}"; - script_content += " });"; - script.text = script_content; - $(original_node).append( script ); -} - $.fn.dataTableExt.oPagination.four_button = { /* * Function: oPagination.four_button.fnInit -- 2.1.0