From 3e8e9b1f2446038433e23b804cb418f3e1b51c27 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Fri, 22 Mar 2013 16:11:09 -0400 Subject: [PATCH] Bug 9916 - Use DataTables in the OPAC The OPAC still uses the old tablesorter plugin which isn't being actively maintained. We use DataTables in the staff client and should in the OPAC too. The plugin was added a while ago but never implemented on any pages. This patch upgrades the plugin to the latest version and places it in opac-tmpl/lib for cross-theme access. The patch implements DataTables on all pages which previously used the tablesorter plugin. The old tablesorter plugin is removed. The customized DataTable configuration script, datatables.js, has been trimmed-down from the staff client version in order to limit it to only that functionality required in the OPAC. Sorting based on date is done based on the data's enclosing title attribute as it is in the staff client: [% date | $KohaDates %] Slight modifications to Serials.pm and opac-search-history.pl have been made to accommodate this change. To test, view each page in the OPAC which uses JS-based table sorting: - The bibliographic detail page - The cart - The search history page - The suggestions page - The tags page (logged in as a user who has entered tags) - The "most popular" page (opac-topissues.pl) - The logged in user summary page (opac-user.pl) - The subscription "full history" page (opac-serial-issues.pl?selectview=full) - The self-checkout main page (with existing checkouts) Table sorting should work correctly on all pages in both the prog and ccsr themes. Sorting should work for dates whatever your dateformat system preference setting. Tables listing titles should exclude articles ("a," "an," and "the" in English) when sorting. Also test the serial collection page in the staff client, which is affected by the change to Serials.pm. Confirm that dates are displayed and sorted correctly. Signed-off-by: Srdjan --- C4/Serials.pm | 3 - .../prog/en/modules/serials/serials-collection.tt | 11 +- koha-tmpl/opac-tmpl/ccsr/en/css/opac.css | 19 + koha-tmpl/opac-tmpl/ccsr/en/css/sco.css | 33 +- koha-tmpl/opac-tmpl/ccsr/en/js/datatables.js | 406 ++++----------------- .../lib/jquery/plugins/jquery.tablesorter.min.js | 2 - .../lib/jquery/plugins/jquery.dataTables.min.js | 155 ++++++++ koha-tmpl/opac-tmpl/prog/en/css/opac.css | 19 + koha-tmpl/opac-tmpl/prog/en/css/sco.css | 33 +- .../{datatables-strings.inc => datatables.inc} | 3 + koha-tmpl/opac-tmpl/prog/en/js/datatables.js | 406 ++++----------------- .../en/lib/jquery/plugins/jquery.dataTables.min.js | 153 -------- .../lib/jquery/plugins/jquery.tablesorter.min.js | 2 - koha-tmpl/opac-tmpl/prog/en/modules/opac-basket.tt | 37 +- koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt | 31 +- .../prog/en/modules/opac-full-serial-issues.tt | 36 +- .../prog/en/modules/opac-search-history.tt | 22 +- .../opac-tmpl/prog/en/modules/opac-shelves.tt | 1 - .../opac-tmpl/prog/en/modules/opac-suggestions.tt | 41 +-- koha-tmpl/opac-tmpl/prog/en/modules/opac-tags.tt | 24 +- .../opac-tmpl/prog/en/modules/opac-topissues.tt | 27 +- koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt | 74 ++-- .../opac-tmpl/prog/en/modules/sco/sco-main.tt | 41 +-- opac/opac-search-history.pl | 4 +- 24 files changed, 545 insertions(+), 1038 deletions(-) delete mode 100644 koha-tmpl/opac-tmpl/ccsr/en/lib/jquery/plugins/jquery.tablesorter.min.js create mode 100644 koha-tmpl/opac-tmpl/lib/jquery/plugins/jquery.dataTables.min.js rename koha-tmpl/opac-tmpl/prog/en/includes/{datatables-strings.inc => datatables.inc} (74%) delete mode 100644 koha-tmpl/opac-tmpl/prog/en/lib/jquery/plugins/jquery.dataTables.min.js delete mode 100644 koha-tmpl/opac-tmpl/prog/en/lib/jquery/plugins/jquery.tablesorter.min.js diff --git a/C4/Serials.pm b/C4/Serials.pm index 4589a70..a1ce054 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -419,9 +419,6 @@ sub PrepareSerialsData { if (!defined $subs->{$datefield} or $subs->{$datefield}=~m/^00/) { $subs->{$datefield} = 'XXX'; } - else { - $subs->{$datefield} = format_date( $subs->{$datefield} ); - } } $subs->{ "status" . $subs->{'status'} } = 1; $subs->{"checked"} = $subs->{'status'} =~ /1|3|4|7/; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt index b833795..0885f4a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt @@ -1,8 +1,10 @@ +[% USE KohaDates %] [% INCLUDE 'doc-head-open.inc' %] Koha › Serials › Serial collection information for [% bibliotitle %] [% INCLUDE 'doc-head-close.inc' %] +[% INCLUDE 'datatables-strings.inc' %] @@ -66,6 +68,7 @@ $(document).ready(function() { $(".subscription-year-table").dataTable($.extend(true, {}, dataTablesDefaults, { "aoColumnDefs": [ { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false }, + { "sType": "title-string", "aTargets" : [ "title-string" ] } ], "aaSorting": [[0, 'desc']], "sDom": 't', @@ -250,9 +253,9 @@ $(document).ready(function() { [% IF ( subscriptions.size > 1 ) %] # Subs [% END %] - Date published + Date published - Date received + Date received Number @@ -289,10 +292,10 @@ $(document).ready(function() { [% serial.subscriptionid %] [% END %] - [% serial.publisheddate %] + [% serial.publisheddate | $KohaDates %] - [% serial.planneddate %] + [% serial.planneddate | $KohaDates %] [% serial.serialseq %] diff --git a/koha-tmpl/opac-tmpl/ccsr/en/css/opac.css b/koha-tmpl/opac-tmpl/ccsr/en/css/opac.css index f66e11f..d8c289c 100644 --- a/koha-tmpl/opac-tmpl/ccsr/en/css/opac.css +++ b/koha-tmpl/opac-tmpl/ccsr/en/css/opac.css @@ -2841,4 +2841,23 @@ a.reviewlink,a.reviewlink:visited { .branch-info-tooltip { display: none; +} +.sorting_asc { + padding-right: 19px; + background: url("../../images/asc.gif") no-repeat scroll right center #EEEEEE; +} +.sorting_desc { + padding-right: 19px; + background: url("../../images/desc.gif") no-repeat scroll right center #EEEEEE; +} +.sorting { + padding-right: 19px; + background: url("../../images/ascdesc.gif") no-repeat scroll right center #EEEEEE; +} +.nosort, +.nosort.sorting_asc, +.nosort.sorting_desc, +.nosort.sorting { + padding-right: 19px; + background: #EEEEEE none; } \ No newline at end of file diff --git a/koha-tmpl/opac-tmpl/ccsr/en/css/sco.css b/koha-tmpl/opac-tmpl/ccsr/en/css/sco.css index 5a79a47..17fc9aa 100644 --- a/koha-tmpl/opac-tmpl/ccsr/en/css/sco.css +++ b/koha-tmpl/opac-tmpl/ccsr/en/css/sco.css @@ -197,19 +197,6 @@ tr.even td, tr.even.highlight td { background-color: #FFF; } -.header { - background-image:url("../../images/ascdesc.gif"); - background-position:right center; - background-repeat:no-repeat; - cursor:pointer; -} -.headerSortUp { - background-image:url("../../images/asc.gif"); -} -.headerSortDown { - background-image:url("../../images/desc.gif"); -} - p { margin: .7em 0; } @@ -339,3 +326,23 @@ span.lang{ div.ft { clear : both; } + +.sorting_asc { + padding-right: 19px; + background: url("../../images/asc.gif") no-repeat scroll right center #EEEEEE; +} +.sorting_desc { + padding-right: 19px; + background: url("../../images/desc.gif") no-repeat scroll right center #EEEEEE; +} +.sorting { + padding-right: 19px; + background: url("../../images/ascdesc.gif") no-repeat scroll right center #EEEEEE; +} +.nosort, +.nosort.sorting_asc, +.nosort.sorting_desc, +.nosort.sorting { + padding-right: 19px; + background: #EEEEEE none; +} \ No newline at end of file diff --git a/koha-tmpl/opac-tmpl/ccsr/en/js/datatables.js b/koha-tmpl/opac-tmpl/ccsr/en/js/datatables.js index e0cc888..3c4ffdf 100644 --- a/koha-tmpl/opac-tmpl/ccsr/en/js/datatables.js +++ b/koha-tmpl/opac-tmpl/ccsr/en/js/datatables.js @@ -23,362 +23,78 @@ var dataTablesDefaults = { "sSearch" : window.MSG_DT_SEARCH || "Search:", "sZeroRecords" : window.MSG_DT_ZERO_RECORDS || "No matching records found" }, - "sDom": '<"top pager"ilpf>t<"bottom pager"ip>' + // "aaSorting": [$(" - select row position of th -")], + "sDom": 't', + "bPaginate": false, + // "fnHeaderCallback": function() { + // return $('th.sorting.nosort,th.sorting_desc.nosort,th.sorting_asc.nosort').removeClass("sorting sorting_desc sorting_asc").unbind("click"); + // } }; +/* Plugin to allow sorting on data stored in a span's title attribute + * + * Ex: [% formatted_date %] + * + * In DataTables config: + * "aoColumns": [ + * { "sType": "title-string" }, + * ] + * http://datatables.net/plug-ins/sorting#hidden_title_string + */ +jQuery.extend( jQuery.fn.dataTableExt.oSort, { + "title-string-pre": function ( a ) { + return a.match(/title="(.*?)"/)[1].toLowerCase(); + }, -// Return an array of string containing the values of a particular column -$.fn.dataTableExt.oApi.fnGetColumnData = function ( oSettings, iColumn, bUnique, bFiltered, bIgnoreEmpty ) { - // check that we have a column id - if ( typeof iColumn == "undefined" ) return new Array(); - // by default we only wany unique data - if ( typeof bUnique == "undefined" ) bUnique = true; - // by default we do want to only look at filtered data - if ( typeof bFiltered == "undefined" ) bFiltered = true; - // by default we do not wany to include empty values - if ( typeof bIgnoreEmpty == "undefined" ) bIgnoreEmpty = true; - // list of rows which we're going to loop through - var aiRows; - // use only filtered rows - if (bFiltered == true) aiRows = oSettings.aiDisplay; - // use all rows - else aiRows = oSettings.aiDisplayMaster; // all row numbers + "title-string-asc": function ( a, b ) { + return ((a < b) ? -1 : ((a > b) ? 1 : 0)); + }, - // set up data array - var asResultData = new Array(); - for (var i=0,c=aiRows.length; i -1) continue; - // else push the value onto the result data array - else asResultData.push(sValue); + "title-string-desc": function ( a, b ) { + return ((a < b) ? 1 : ((a > b) ? -1 : 0)); } - return asResultData; -} - -// List of unbind keys (Ctrl, Alt, Direction keys, etc.) -// These keys must not launch filtering -var blacklist_keys = new Array(0, 16, 17, 18, 37, 38, 39, 40); - -// Set a filtering delay for global search field -jQuery.fn.dataTableExt.oApi.fnSetFilteringDelay = function ( oSettings, iDelay ) { - /* - * Inputs: object:oSettings - dataTables settings object - automatically given - * integer:iDelay - delay in milliseconds - * Usage: $('#example').dataTable().fnSetFilteringDelay(250); - * Author: Zygimantas Berziunas (www.zygimantas.com) and Allan Jardine - * License: GPL v2 or BSD 3 point style - * Contact: zygimantas.berziunas /AT\ hotmail.com +} ); + +(function() { + + /* Plugin to allow text sorting to ignore articles + * + * In DataTables config: + * "aoColumns": [ + * { "sType": "anti-the" }, + * ] + * Based on the plugin found here: + * http://datatables.net/plug-ins/sorting#anti_the + * Modified to exclude HTML tags from sorting + * Extended to accept a string of space-separated articles + * from a configuration file (in English, "a," "an," and "the") */ - var - _that = this, - iDelay = (typeof iDelay == 'undefined') ? 250 : iDelay; - - this.each( function ( i ) { - $.fn.dataTableExt.iApiIndex = i; - var - $this = this, - oTimerId = null, - sPreviousSearch = null, - anControl = $( 'input', _that.fnSettings().aanFeatures.f ); - - anControl.unbind( 'keyup.DT' ).bind( 'keyup.DT', function(event) { - var $$this = $this; - if (blacklist_keys.indexOf(event.keyCode) != -1) { - return this; - }else if ( event.keyCode == '13' ) { - $.fn.dataTableExt.iApiIndex = i; - _that.fnFilter( $(this).val() ); - } else { - if (sPreviousSearch === null || sPreviousSearch != anControl.val()) { - window.clearTimeout(oTimerId); - sPreviousSearch = anControl.val(); - oTimerId = window.setTimeout(function() { - $.fn.dataTableExt.iApiIndex = i; - _that.fnFilter( anControl.val() ); - }, iDelay); - } - } - }); - - return this; - } ); - return this; -} - -// Add a filtering delay on general search and on all input (with a class 'filter') -jQuery.fn.dataTableExt.oApi.fnAddFilters = function ( oSettings, sClass, iDelay ) { - var table = this; - this.fnSetFilteringDelay(iDelay); - var filterTimerId = null; - $("input."+sClass).keyup(function(event) { - if (blacklist_keys.indexOf(event.keyCode) != -1) { - return this; - }else if ( event.keyCode == '13' ) { - table.fnFilter( $(this).val(), $(this).attr('data-column_num') ); - } else { - window.clearTimeout(filterTimerId); - var input = this; - filterTimerId = window.setTimeout(function() { - table.fnFilter($(input).val(), $(input).attr('data-column_num')); - }, 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; + if(CONFIG_EXCLUDE_ARTICLES_FROM_SORT){ + var articles = CONFIG_EXCLUDE_ARTICLES_FROM_SORT.split(" "); + var rpattern = ""; + for(i=0;i y) ? 1 : 0)); - }; - - jQuery.fn.dataTableExt.oSort['uk_date-desc'] = function(a,b) { - var re = /(\d{2}\/\d{2}\/\d{4})/; - a.match(re); - var ukDatea = RegExp.$1.split("/"); - b.match(re); - var ukDateb = RegExp.$1.split("/"); - - var x = (ukDatea[2] + ukDatea[1] + ukDatea[0]) * 1; - var y = (ukDateb[2] + ukDateb[1] + ukDateb[0]) * 1; - return ((x < y) ? 1 : ((x > y) ? -1 : 0)); - }; -} - -// Sorting on html contains -// bar sort on 'bar' -function dt_overwrite_html_sorting_localeCompare() { - jQuery.fn.dataTableExt.oSort['html-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['html-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); - } - }; -} - -// 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 - * Purpose: Initalise dom elements required for pagination with a list of the pages - * Returns: - - * Inputs: object:oSettings - dataTables settings object - * node:nPaging - the DIV which contains this pagination control - * function:fnCallbackDraw - draw function which must be called on update - */ - "fnInit": function ( oSettings, nPaging, fnCallbackDraw ) - { - nFirst = document.createElement( 'span' ); - nPrevious = document.createElement( 'span' ); - nNext = document.createElement( 'span' ); - nLast = document.createElement( 'span' ); - -/* nFirst.appendChild( document.createTextNode( oSettings.oLanguage.oPaginate.sFirst ) ); - nPrevious.appendChild( document.createTextNode( oSettings.oLanguage.oPaginate.sPrevious ) ); - nNext.appendChild( document.createTextNode( oSettings.oLanguage.oPaginate.sNext ) ); - nLast.appendChild( document.createTextNode( oSettings.oLanguage.oPaginate.sLast ) );*/ - - nFirst.className = "paginate_button first"; - nPrevious.className = "paginate_button previous"; - nNext.className="paginate_button next"; - nLast.className = "paginate_button last"; - - nPaging.appendChild( nFirst ); - nPaging.appendChild( nPrevious ); - nPaging.appendChild( nNext ); - nPaging.appendChild( nLast ); - - $(nFirst).click( function () { - oSettings.oApi._fnPageChange( oSettings, "first" ); - fnCallbackDraw( oSettings ); - } ); - - $(nPrevious).click( function() { - oSettings.oApi._fnPageChange( oSettings, "previous" ); - fnCallbackDraw( oSettings ); - } ); - - $(nNext).click( function() { - oSettings.oApi._fnPageChange( oSettings, "next" ); - fnCallbackDraw( oSettings ); - } ); - - $(nLast).click( function() { - oSettings.oApi._fnPageChange( oSettings, "last" ); - fnCallbackDraw( oSettings ); - } ); + jQuery.extend( jQuery.fn.dataTableExt.oSort, { + "anti-the-pre": function ( a ) { + var x = String(a).replace( /<[\s\S]*?>/g, "" ); + var y = x.trim(); + var z = y.replace(re, "").toLowerCase(); + return z; + }, - /* Disallow text selection */ - $(nFirst).bind( 'selectstart', function () { return false; } ); - $(nPrevious).bind( 'selectstart', function () { return false; } ); - $(nNext).bind( 'selectstart', function () { return false; } ); - $(nLast).bind( 'selectstart', function () { return false; } ); - }, + "anti-the-asc": function ( a, b ) { + return ((a < b) ? -1 : ((a > b) ? 1 : 0)); + }, - /* - * Function: oPagination.four_button.fnUpdate - * Purpose: Update the list of page buttons shows - * Returns: - - * Inputs: object:oSettings - dataTables settings object - * function:fnCallbackDraw - draw function which must be called on update - */ - "fnUpdate": function ( oSettings, fnCallbackDraw ) - { - if ( !oSettings.aanFeatures.p ) - { - return; + "anti-the-desc": function ( a, b ) { + return ((a < b) ? 1 : ((a > b) ? -1 : 0)); } + }); - /* Loop over each instance of the pager */ - var an = oSettings.aanFeatures.p; - for ( var i=0, iLen=an.length ; i1){arr=arr.concat(checkCellColSpan(table,headerArr,row++));}else{if(table.tHead.length==1||(cell.rowSpan>1||!r[row+1])){arr.push(cell);}}}return arr;};function checkHeaderMetadata(cell){if(($.metadata)&&($(cell).metadata().sorter===false)){return true;};return false;}function checkHeaderOptions(table,i){if((table.config.headers[i])&&(table.config.headers[i].sorter===false)){return true;};return false;}function applyWidget(table){var c=table.config.widgets;var l=c.length;for(var i=0;i');$("tr:first td",table.tBodies[0]).each(function(){colgroup.append($('').css('width',$(this).width()));});$(table).prepend(colgroup);};}function updateHeaderSortCount(table,sortList){var c=table.config,l=sortList.length;for(var i=0;ib)?1:0));};function sortTextDesc(a,b){return((ba)?1:0));};function sortNumeric(a,b){return a-b;};function sortNumericDesc(a,b){return b-a;};function getCachedSortType(parsers,i){return parsers[i].type;};this.construct=function(settings){return this.each(function(){if(!this.tHead||!this.tBodies)return;var $this,$document,$headers,cache,config,shiftDown=0,sortOrder;this.config={};config=$.extend(this.config,$.tablesorter.defaults,settings);$this=$(this);$headers=buildHeaders(this);this.config.parsers=buildParserCache(this,$headers);cache=buildCache(this);var sortCSS=[config.cssDesc,config.cssAsc];fixColumnWidth(this);$headers.click(function(e){$this.trigger("sortStart");var totalRows=($this[0].tBodies[0]&&$this[0].tBodies[0].rows.length)||0;if(!this.sortDisabled&&totalRows>0){var $cell=$(this);var i=this.column;this.order=this.count++%2;if(!e[config.sortMultiSortKey]){config.sortList=[];if(config.sortForce!=null){var a=config.sortForce;for(var j=0;j0){$this.trigger("sorton",[config.sortList]);}applyWidget(this);});};this.addParser=function(parser){var l=parsers.length,a=true;for(var i=0;ij[f])d(a.aoColumns.length+j[f],b[i]);else if("string"===typeof j[f]){e=0;for(w=a.aoColumns.length;eb&&a[d]--; -1!=c&&a.splice(c,1)}function S(a,b,c){var d=a.aoColumns[c];return d.fnRender({iDataRow:b,iDataColumn:c,oSettings:a,aData:a.aoData[b]._aData,mDataProp:d.mData},v(a,b,c,"display"))}function ea(a,b){var c=a.aoData[b],d;if(null===c.nTr){c.nTr=l.createElement("tr");c.nTr._DT_RowIndex=b;c._aData.DT_RowId&&(c.nTr.id=c._aData.DT_RowId);c._aData.DT_RowClass&& +(c.nTr.className=c._aData.DT_RowClass);for(var i=0,f=a.aoColumns.length;i=a.fnRecordsDisplay()?0:a.iInitDisplayStart,a.iInitDisplayStart=-1,y(a));if(a.bDeferLoading)a.bDeferLoading=!1,a.iDraw++;else if(a.oFeatures.bServerSide){if(!a.bDestroying&&!wa(a))return}else a.iDraw++;if(0!==a.aiDisplay.length){var g= +a._iDisplayStart;d=a._iDisplayEnd;a.oFeatures.bServerSide&&(g=0,d=a.aoData.length);for(;g")[0];a.nTable.parentNode.insertBefore(b,a.nTable);a.nTableWrapper=h('
')[0];a.nTableReinsertBefore=a.nTable.nextSibling;for(var c=a.nTableWrapper,d=a.sDom.split(""),i,f,g,e,w,o,k,m=0;m")[0];w=d[m+ +1];if("'"==w||'"'==w){o="";for(k=2;d[m+k]!=w;)o+=d[m+k],k++;"H"==o?o=a.oClasses.sJUIHeader:"F"==o&&(o=a.oClasses.sJUIFooter);-1!=o.indexOf(".")?(w=o.split("."),e.id=w[0].substr(1,w[0].length-1),e.className=w[1]):"#"==o.charAt(0)?e.id=o.substr(1,o.length-1):e.className=o;m+=k}c.appendChild(e);c=e}else if(">"==g)c=c.parentNode;else if("l"==g&&a.oFeatures.bPaginate&&a.oFeatures.bLengthChange)i=ya(a),f=1;else if("f"==g&&a.oFeatures.bFilter)i=za(a),f=1;else if("r"==g&&a.oFeatures.bProcessing)i=Aa(a),f= +1;else if("t"==g)i=Ba(a),f=1;else if("i"==g&&a.oFeatures.bInfo)i=Ca(a),f=1;else if("p"==g&&a.oFeatures.bPaginate)i=Da(a),f=1;else if(0!==j.ext.aoFeatures.length){e=j.ext.aoFeatures;k=0;for(w=e.length;k'):""===c?'':c+' ',d=l.createElement("div");d.className=a.oClasses.sFilter;d.innerHTML="";a.aanFeatures.f||(d.id=a.sTableId+"_filter");c=h('input[type="text"]',d);d._DT_Input=c[0];c.val(b.sSearch.replace('"',"""));c.bind("keyup.DT",function(){for(var c=a.aanFeatures.f,d=this.value===""?"":this.value, +g=0,e=c.length;g=b.length)a.aiDisplay.splice(0,a.aiDisplay.length),a.aiDisplay=a.aiDisplayMaster.slice();else if(a.aiDisplay.length==a.aiDisplayMaster.length||i.sSearch.length>b.length||1==c||0!==b.indexOf(i.sSearch)){a.aiDisplay.splice(0, +a.aiDisplay.length);la(a,1);for(b=0;b").html(c).text()); +return c.replace(/[\n\r]/g," ")}function ma(a,b,c,d){if(c)return a=b?a.split(" "):oa(a).split(" "),a="^(?=.*?"+a.join(")(?=.*?")+").*$",RegExp(a,d?"i":"");a=b?a:oa(a);return RegExp(a,d?"i":"")}function Ja(a,b){return"function"===typeof j.ext.ofnSearch[b]?j.ext.ofnSearch[b](a):null===a?"":"html"==b?a.replace(/[\r\n]/g," ").replace(/<.*?>/g,""):"string"===typeof a?a.replace(/[\r\n]/g," "):a}function oa(a){return a.replace(RegExp("(\\/|\\.|\\*|\\+|\\?|\\||\\(|\\)|\\[|\\]|\\{|\\}|\\\\|\\$|\\^|\\-)","g"), +"\\$1")}function Ca(a){var b=l.createElement("div");b.className=a.oClasses.sInfo;a.aanFeatures.i||(a.aoDrawCallback.push({fn:Ka,sName:"information"}),b.id=a.sTableId+"_info");a.nTable.setAttribute("aria-describedby",a.sTableId+"_info");return b}function Ka(a){if(a.oFeatures.bInfo&&0!==a.aanFeatures.i.length){var b=a.oLanguage,c=a._iDisplayStart+1,d=a.fnDisplayEnd(),i=a.fnRecordsTotal(),f=a.fnRecordsDisplay(),g;g=0===f?b.sInfoEmpty:b.sInfo;f!=i&&(g+=" "+b.sInfoFiltered);g+=b.sInfoPostFix;g=ja(a,g); +null!==b.fnInfoCallback&&(g=b.fnInfoCallback.call(a.oInstance,a,c,d,i,f,g));a=a.aanFeatures.i;b=0;for(c=a.length;b",c,d,i=a.aLengthMenu;if(2==i.length&&"object"===typeof i[0]&&"object"===typeof i[1]){c=0;for(d=i[0].length;c'+i[1][c]+""}else{c=0;for(d=i.length;c'+i[c]+""}b+="";i=l.createElement("div");a.aanFeatures.l|| +(i.id=a.sTableId+"_length");i.className=a.oClasses.sLength;i.innerHTML="";h('select option[value="'+a._iDisplayLength+'"]',i).attr("selected",!0);h("select",i).bind("change.DT",function(){var b=h(this).val(),i=a.aanFeatures.l;c=0;for(d=i.length;ca.aiDisplay.length||-1==a._iDisplayLength?a.aiDisplay.length:a._iDisplayStart+a._iDisplayLength}function Da(a){if(a.oScroll.bInfinite)return null;var b=l.createElement("div");b.className=a.oClasses.sPaging+a.sPaginationType;j.ext.oPagination[a.sPaginationType].fnInit(a, +b,function(a){y(a);x(a)});a.aanFeatures.p||a.aoDrawCallback.push({fn:function(a){j.ext.oPagination[a.sPaginationType].fnUpdate(a,function(a){y(a);x(a)})},sName:"pagination"});return b}function qa(a,b){var c=a._iDisplayStart;if("number"===typeof b)a._iDisplayStart=b*a._iDisplayLength,a._iDisplayStart>a.fnRecordsDisplay()&&(a._iDisplayStart=0);else if("first"==b)a._iDisplayStart=0;else if("previous"==b)a._iDisplayStart=0<=a._iDisplayLength?a._iDisplayStart-a._iDisplayLength:0,0>a._iDisplayStart&&(a._iDisplayStart= +0);else if("next"==b)0<=a._iDisplayLength?a._iDisplayStart+a._iDisplayLengthh(a.nTable).height()-a.oScroll.iLoadGap&&a.fnDisplayEnd()d.offsetHeight||"scroll"==h(d).css("overflow-y")))a.nTable.style.width=q(h(a.nTable).outerWidth()-a.oScroll.iBarWidth)}else""!==a.oScroll.sXInner?a.nTable.style.width= +q(a.oScroll.sXInner):i==h(d).width()&&h(d).height()i-a.oScroll.iBarWidth&&(a.nTable.style.width=q(i))):a.nTable.style.width=q(i);i=h(a.nTable).outerWidth();C(s,e);C(function(a){p.push(q(h(a).width()))},e);C(function(a,b){a.style.width=p[b]},g);h(e).height(0);null!==a.nTFoot&&(C(s,j),C(function(a){n.push(q(h(a).width()))},j),C(function(a,b){a.style.width=n[b]},o),h(j).height(0));C(function(a,b){a.innerHTML= +"";a.style.width=p[b]},e);null!==a.nTFoot&&C(function(a,b){a.innerHTML="";a.style.width=n[b]},j);if(h(a.nTable).outerWidth()d.offsetHeight||"scroll"==h(d).css("overflow-y")?i+a.oScroll.iBarWidth:i;if(r&&(d.scrollHeight>d.offsetHeight||"scroll"==h(d).css("overflow-y")))a.nTable.style.width=q(g-a.oScroll.iBarWidth);d.style.width=q(g);a.nScrollHead.style.width=q(g);null!==a.nTFoot&&(a.nScrollFoot.style.width=q(g));""===a.oScroll.sX?D(a,1,"The table cannot fit into the current element which will cause column misalignment. The table has been drawn at its minimum possible width."): +""!==a.oScroll.sXInner&&D(a,1,"The table cannot fit into the current element which will cause column misalignment. Increase the sScrollXInner value or remove it to allow automatic calculation")}else d.style.width=q("100%"),a.nScrollHead.style.width=q("100%"),null!==a.nTFoot&&(a.nScrollFoot.style.width=q("100%"));""===a.oScroll.sY&&r&&(d.style.height=q(a.nTable.offsetHeight+a.oScroll.iBarWidth));""!==a.oScroll.sY&&a.oScroll.bCollapse&&(d.style.height=q(a.oScroll.sY),r=""!==a.oScroll.sX&&a.nTable.offsetWidth> +d.offsetWidth?a.oScroll.iBarWidth:0,a.nTable.offsetHeightd.clientHeight||"scroll"==h(d).css("overflow-y");b.style.paddingRight=c?a.oScroll.iBarWidth+"px":"0px";null!==a.nTFoot&&(R.style.width=q(r),l.style.width=q(r),l.style.paddingRight=c?a.oScroll.iBarWidth+"px":"0px");h(d).scroll();if(a.bSorted||a.bFiltered)d.scrollTop=0}function C(a,b,c){for(var d= +0,i=0,f=b.length,g,e;itd",b));j=N(a,f);for(f=d=0;fc)return null;if(null===a.aoData[c].nTr){var d=l.createElement("td");d.innerHTML=v(a,c,b,"");return d}return J(a,c)[b]}function Pa(a,b){for(var c=-1,d=-1,i=0;i/g,"");e.length>c&&(c=e.length,d=i)}return d}function q(a){if(null===a)return"0px";if("number"==typeof a)return 0>a?"0px":a+"px";var b=a.charCodeAt(a.length-1); +return 48>b||57/g,""),i=q[c].nTh,i.removeAttribute("aria-sort"),i.removeAttribute("aria-label"),q[c].bSortable?0d&&d++;f=RegExp(f+"[123]");var o;b=0;for(c=a.length;b
')[0];l.body.appendChild(b);a.oBrowser.bScrollOversize= +100===h("#DT_BrowserTest",b)[0].offsetWidth?!0:!1;l.body.removeChild(b)}function Va(a){return function(){var b=[s(this[j.ext.iApiIndex])].concat(Array.prototype.slice.call(arguments));return j.ext.oApi[a].apply(this,b)}}var U=/\[.*?\]$/,Wa=X.JSON?JSON.stringify:function(a){var b=typeof a;if("object"!==b||null===a)return"string"===b&&(a='"'+a+'"'),a+"";var c,d,e=[],f=h.isArray(a);for(c in a)d=a[c],b=typeof d,"string"===b?d='"'+d+'"':"object"===b&&null!==d&&(d=Wa(d)),e.push((f?"":'"'+c+'":')+d);return(f? +"[":"{")+e+(f?"]":"}")};this.$=function(a,b){var c,d,e=[],f;d=s(this[j.ext.iApiIndex]);var g=d.aoData,o=d.aiDisplay,k=d.aiDisplayMaster;b||(b={});b=h.extend({},{filter:"none",order:"current",page:"all"},b);if("current"==b.page){c=d._iDisplayStart;for(d=d.fnDisplayEnd();c=d.fnRecordsDisplay()&&(d._iDisplayStart-=d._iDisplayLength,0>d._iDisplayStart&&(d._iDisplayStart=0));if(c===n||c)y(d),x(d);return g};this.fnDestroy=function(a){var b=s(this[j.ext.iApiIndex]),c=b.nTableWrapper.parentNode,d=b.nTBody,i,f,a=a===n?!1:a;b.bDestroying=!0;A(b,"aoDestroyCallback","destroy",[b]);if(!a){i=0;for(f=b.aoColumns.length;itr>td."+b.oClasses.sRowEmpty,b.nTable).parent().remove();b.nTable!=b.nTHead.parentNode&&(h(b.nTable).children("thead").remove(),b.nTable.appendChild(b.nTHead));b.nTFoot&&b.nTable!=b.nTFoot.parentNode&&(h(b.nTable).children("tfoot").remove(),b.nTable.appendChild(b.nTFoot));b.nTable.parentNode.removeChild(b.nTable);h(b.nTableWrapper).remove();b.aaSorting=[];b.aaSortingFixed=[];P(b);h(T(b)).removeClass(b.asStripeClasses.join(" "));h("th, td",b.nTHead).removeClass([b.oClasses.sSortable,b.oClasses.sSortableAsc, +b.oClasses.sSortableDesc,b.oClasses.sSortableNone].join(" "));b.bJUI&&(h("th span."+b.oClasses.sSortIcon+", td span."+b.oClasses.sSortIcon,b.nTHead).remove(),h("th, td",b.nTHead).each(function(){var a=h("div."+b.oClasses.sSortJUIWrapper,this),c=a.contents();h(this).append(c);a.remove()}));!a&&b.nTableReinsertBefore?c.insertBefore(b.nTable,b.nTableReinsertBefore):a||c.appendChild(b.nTable);i=0;for(f=b.aoData.length;i=t(d);if(!m)for(e=a;et<"F"ip>')):h.extend(g.oClasses,j.ext.oStdClasses);h(this).addClass(g.oClasses.sTable);if(""!==g.oScroll.sX||""!==g.oScroll.sY)g.oScroll.iBarWidth=Qa();g.iInitDisplayStart===n&&(g.iInitDisplayStart=e.iDisplayStart, +g._iDisplayStart=e.iDisplayStart);e.bStateSave&&(g.oFeatures.bStateSave=!0,Sa(g,e),z(g,"aoDrawCallback",ra,"state_save"));null!==e.iDeferLoading&&(g.bDeferLoading=!0,a=h.isArray(e.iDeferLoading),g._iRecordsDisplay=a?e.iDeferLoading[0]:e.iDeferLoading,g._iRecordsTotal=a?e.iDeferLoading[1]:e.iDeferLoading);null!==e.aaData&&(f=!0);""!==e.oLanguage.sUrl?(g.oLanguage.sUrl=e.oLanguage.sUrl,h.getJSON(g.oLanguage.sUrl,null,function(a){pa(a);h.extend(true,g.oLanguage,e.oLanguage,a);ba(g)}),i=!0):h.extend(!0, +g.oLanguage,e.oLanguage);null===e.asStripeClasses&&(g.asStripeClasses=[g.oClasses.sStripeOdd,g.oClasses.sStripeEven]);b=g.asStripeClasses.length;g.asDestroyStripes=[];if(b){c=!1;d=h(this).children("tbody").children("tr:lt("+b+")");for(a=0;a=g.aoColumns.length&&(g.aaSorting[a][0]=0);var k=g.aoColumns[g.aaSorting[a][0]];g.aaSorting[a][2]===n&&(g.aaSorting[a][2]=0);e.aaSorting===n&&g.saved_aaSorting===n&&(g.aaSorting[a][1]= +k.asSorting[0]);c=0;for(d=k.asSorting.length;c=parseInt(n,10)};j.fnIsDataTable=function(e){for(var h=j.settings,m=0;me)return e;for(var h=e+"",e=h.split(""),j="",h=h.length,k=0;k'+k.sPrevious+''+k.sNext+"":'';h(j).append(k);var l=h("a",j), +k=l[0],l=l[1];e.oApi._fnBindAction(k,{action:"previous"},n);e.oApi._fnBindAction(l,{action:"next"},n);e.aanFeatures.p||(j.id=e.sTableId+"_paginate",k.id=e.sTableId+"_previous",l.id=e.sTableId+"_next",k.setAttribute("aria-controls",e.sTableId),l.setAttribute("aria-controls",e.sTableId))},fnUpdate:function(e){if(e.aanFeatures.p)for(var h=e.oClasses,j=e.aanFeatures.p,k,l=0,n=j.length;l'+k.sFirst+''+k.sPrevious+''+k.sNext+''+k.sLast+"");var t=h("a",j),k=t[0],l=t[1],r=t[2],t=t[3];e.oApi._fnBindAction(k,{action:"first"},n);e.oApi._fnBindAction(l,{action:"previous"},n);e.oApi._fnBindAction(r,{action:"next"},n);e.oApi._fnBindAction(t,{action:"last"},n);e.aanFeatures.p||(j.id=e.sTableId+"_paginate",k.id=e.sTableId+"_first",l.id=e.sTableId+"_previous",r.id=e.sTableId+"_next",t.id=e.sTableId+"_last")}, +fnUpdate:function(e,o){if(e.aanFeatures.p){var m=j.ext.oPagination.iFullNumbersShowPages,k=Math.floor(m/2),l=Math.ceil(e.fnRecordsDisplay()/e._iDisplayLength),n=Math.ceil(e._iDisplayStart/e._iDisplayLength)+1,t="",r,B=e.oClasses,u,M=e.aanFeatures.p,L=function(h){e.oApi._fnBindAction(this,{page:h+r-1},function(h){e.oApi._fnPageChange(e,h.data.page);o(e);h.preventDefault()})};-1===e._iDisplayLength?n=k=r=1:l=l-k?(r=l-m+1,k=l):(r=n-Math.ceil(m/2)+1,k=r+m-1);for(m=r;m<=k;m++)t+= +n!==m?''+e.fnFormatNumber(m)+"":''+e.fnFormatNumber(m)+"";m=0;for(k=M.length;mh?1:0},"string-desc":function(e,h){return eh?-1:0},"html-pre":function(e){return e.replace(/<.*?>/g,"").toLowerCase()},"html-asc":function(e,h){return eh?1:0},"html-desc":function(e,h){return e< +h?1:e>h?-1:0},"date-pre":function(e){e=Date.parse(e);if(isNaN(e)||""===e)e=Date.parse("01/01/1970 00:00:00");return e},"date-asc":function(e,h){return e-h},"date-desc":function(e,h){return h-e},"numeric-pre":function(e){return"-"==e||""===e?0:1*e},"numeric-asc":function(e,h){return e-h},"numeric-desc":function(e,h){return h-e}});h.extend(j.ext.aTypes,[function(e){if("number"===typeof e)return"numeric";if("string"!==typeof e)return null;var h,j=!1;h=e.charAt(0);if(-1=="0123456789-".indexOf(h))return null; +for(var k=1;k")?"html":null}]);h.fn.DataTable=j;h.fn.dataTable=j;h.fn.dataTableSettings=j.settings;h.fn.dataTableExt=j.ext};"function"===typeof define&&define.amd?define(["jquery"],L):jQuery&&!jQuery.fn.dataTable&& +L(jQuery)})(window,document); diff --git a/koha-tmpl/opac-tmpl/prog/en/css/opac.css b/koha-tmpl/opac-tmpl/prog/en/css/opac.css index 6fd9a90..1ad5231 100644 --- a/koha-tmpl/opac-tmpl/prog/en/css/opac.css +++ b/koha-tmpl/opac-tmpl/prog/en/css/opac.css @@ -2967,3 +2967,22 @@ padding: 0.1em 0; .thumbnail-shelfbrowser span { margin: 0px auto; } +.sorting_asc { + padding-right: 19px; + background: url("../../images/asc.gif") no-repeat scroll right center #EEEEEE; +} +.sorting_desc { + padding-right: 19px; + background: url("../../images/desc.gif") no-repeat scroll right center #EEEEEE; +} +.sorting { + padding-right: 19px; + background: url("../../images/ascdesc.gif") no-repeat scroll right center #EEEEEE; +} +.nosort, +.nosort.sorting_asc, +.nosort.sorting_desc, +.nosort.sorting { + padding-right: 19px; + background: #EEEEEE none; +} \ No newline at end of file diff --git a/koha-tmpl/opac-tmpl/prog/en/css/sco.css b/koha-tmpl/opac-tmpl/prog/en/css/sco.css index 7e3abdb..7ef1046 100644 --- a/koha-tmpl/opac-tmpl/prog/en/css/sco.css +++ b/koha-tmpl/opac-tmpl/prog/en/css/sco.css @@ -198,19 +198,6 @@ tr.even td, tr.even.highlight td { background-color: #FFF; } -.header { - background-image:url("../../images/ascdesc.gif"); - background-position:right center; - background-repeat:no-repeat; - cursor:pointer; -} -.headerSortUp { - background-image:url("../../images/asc.gif"); -} -.headerSortDown { - background-image:url("../../images/desc.gif"); -} - p { margin: .7em 0; } @@ -344,3 +331,23 @@ div.ft { .inline { display: inline; } + +.sorting_asc { + padding-right: 19px; + background: url("../../images/asc.gif") no-repeat scroll right center #EEEEEE; +} +.sorting_desc { + padding-right: 19px; + background: url("../../images/desc.gif") no-repeat scroll right center #EEEEEE; +} +.sorting { + padding-right: 19px; + background: url("../../images/ascdesc.gif") no-repeat scroll right center #EEEEEE; +} +.nosort, +.nosort.sorting_asc, +.nosort.sorting_desc, +.nosort.sorting { + padding-right: 19px; + background: #EEEEEE none; +} \ No newline at end of file diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/datatables-strings.inc b/koha-tmpl/opac-tmpl/prog/en/includes/datatables.inc similarity index 74% rename from koha-tmpl/opac-tmpl/prog/en/includes/datatables-strings.inc rename to koha-tmpl/opac-tmpl/prog/en/includes/datatables.inc index 183f511..703d1e3 100644 --- a/koha-tmpl/opac-tmpl/prog/en/includes/datatables-strings.inc +++ b/koha-tmpl/opac-tmpl/prog/en/includes/datatables.inc @@ -1,3 +1,4 @@ + + \ No newline at end of file diff --git a/koha-tmpl/opac-tmpl/prog/en/js/datatables.js b/koha-tmpl/opac-tmpl/prog/en/js/datatables.js index e0cc888..3c4ffdf 100644 --- a/koha-tmpl/opac-tmpl/prog/en/js/datatables.js +++ b/koha-tmpl/opac-tmpl/prog/en/js/datatables.js @@ -23,362 +23,78 @@ var dataTablesDefaults = { "sSearch" : window.MSG_DT_SEARCH || "Search:", "sZeroRecords" : window.MSG_DT_ZERO_RECORDS || "No matching records found" }, - "sDom": '<"top pager"ilpf>t<"bottom pager"ip>' + // "aaSorting": [$(" - select row position of th -")], + "sDom": 't', + "bPaginate": false, + // "fnHeaderCallback": function() { + // return $('th.sorting.nosort,th.sorting_desc.nosort,th.sorting_asc.nosort').removeClass("sorting sorting_desc sorting_asc").unbind("click"); + // } }; +/* Plugin to allow sorting on data stored in a span's title attribute + * + * Ex: [% formatted_date %] + * + * In DataTables config: + * "aoColumns": [ + * { "sType": "title-string" }, + * ] + * http://datatables.net/plug-ins/sorting#hidden_title_string + */ +jQuery.extend( jQuery.fn.dataTableExt.oSort, { + "title-string-pre": function ( a ) { + return a.match(/title="(.*?)"/)[1].toLowerCase(); + }, -// Return an array of string containing the values of a particular column -$.fn.dataTableExt.oApi.fnGetColumnData = function ( oSettings, iColumn, bUnique, bFiltered, bIgnoreEmpty ) { - // check that we have a column id - if ( typeof iColumn == "undefined" ) return new Array(); - // by default we only wany unique data - if ( typeof bUnique == "undefined" ) bUnique = true; - // by default we do want to only look at filtered data - if ( typeof bFiltered == "undefined" ) bFiltered = true; - // by default we do not wany to include empty values - if ( typeof bIgnoreEmpty == "undefined" ) bIgnoreEmpty = true; - // list of rows which we're going to loop through - var aiRows; - // use only filtered rows - if (bFiltered == true) aiRows = oSettings.aiDisplay; - // use all rows - else aiRows = oSettings.aiDisplayMaster; // all row numbers + "title-string-asc": function ( a, b ) { + return ((a < b) ? -1 : ((a > b) ? 1 : 0)); + }, - // set up data array - var asResultData = new Array(); - for (var i=0,c=aiRows.length; i -1) continue; - // else push the value onto the result data array - else asResultData.push(sValue); + "title-string-desc": function ( a, b ) { + return ((a < b) ? 1 : ((a > b) ? -1 : 0)); } - return asResultData; -} - -// List of unbind keys (Ctrl, Alt, Direction keys, etc.) -// These keys must not launch filtering -var blacklist_keys = new Array(0, 16, 17, 18, 37, 38, 39, 40); - -// Set a filtering delay for global search field -jQuery.fn.dataTableExt.oApi.fnSetFilteringDelay = function ( oSettings, iDelay ) { - /* - * Inputs: object:oSettings - dataTables settings object - automatically given - * integer:iDelay - delay in milliseconds - * Usage: $('#example').dataTable().fnSetFilteringDelay(250); - * Author: Zygimantas Berziunas (www.zygimantas.com) and Allan Jardine - * License: GPL v2 or BSD 3 point style - * Contact: zygimantas.berziunas /AT\ hotmail.com +} ); + +(function() { + + /* Plugin to allow text sorting to ignore articles + * + * In DataTables config: + * "aoColumns": [ + * { "sType": "anti-the" }, + * ] + * Based on the plugin found here: + * http://datatables.net/plug-ins/sorting#anti_the + * Modified to exclude HTML tags from sorting + * Extended to accept a string of space-separated articles + * from a configuration file (in English, "a," "an," and "the") */ - var - _that = this, - iDelay = (typeof iDelay == 'undefined') ? 250 : iDelay; - - this.each( function ( i ) { - $.fn.dataTableExt.iApiIndex = i; - var - $this = this, - oTimerId = null, - sPreviousSearch = null, - anControl = $( 'input', _that.fnSettings().aanFeatures.f ); - - anControl.unbind( 'keyup.DT' ).bind( 'keyup.DT', function(event) { - var $$this = $this; - if (blacklist_keys.indexOf(event.keyCode) != -1) { - return this; - }else if ( event.keyCode == '13' ) { - $.fn.dataTableExt.iApiIndex = i; - _that.fnFilter( $(this).val() ); - } else { - if (sPreviousSearch === null || sPreviousSearch != anControl.val()) { - window.clearTimeout(oTimerId); - sPreviousSearch = anControl.val(); - oTimerId = window.setTimeout(function() { - $.fn.dataTableExt.iApiIndex = i; - _that.fnFilter( anControl.val() ); - }, iDelay); - } - } - }); - - return this; - } ); - return this; -} - -// Add a filtering delay on general search and on all input (with a class 'filter') -jQuery.fn.dataTableExt.oApi.fnAddFilters = function ( oSettings, sClass, iDelay ) { - var table = this; - this.fnSetFilteringDelay(iDelay); - var filterTimerId = null; - $("input."+sClass).keyup(function(event) { - if (blacklist_keys.indexOf(event.keyCode) != -1) { - return this; - }else if ( event.keyCode == '13' ) { - table.fnFilter( $(this).val(), $(this).attr('data-column_num') ); - } else { - window.clearTimeout(filterTimerId); - var input = this; - filterTimerId = window.setTimeout(function() { - table.fnFilter($(input).val(), $(input).attr('data-column_num')); - }, 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; + if(CONFIG_EXCLUDE_ARTICLES_FROM_SORT){ + var articles = CONFIG_EXCLUDE_ARTICLES_FROM_SORT.split(" "); + var rpattern = ""; + for(i=0;i y) ? 1 : 0)); - }; - - jQuery.fn.dataTableExt.oSort['uk_date-desc'] = function(a,b) { - var re = /(\d{2}\/\d{2}\/\d{4})/; - a.match(re); - var ukDatea = RegExp.$1.split("/"); - b.match(re); - var ukDateb = RegExp.$1.split("/"); - - var x = (ukDatea[2] + ukDatea[1] + ukDatea[0]) * 1; - var y = (ukDateb[2] + ukDateb[1] + ukDateb[0]) * 1; - return ((x < y) ? 1 : ((x > y) ? -1 : 0)); - }; -} - -// Sorting on html contains -// bar sort on 'bar' -function dt_overwrite_html_sorting_localeCompare() { - jQuery.fn.dataTableExt.oSort['html-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['html-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); - } - }; -} - -// 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 - * Purpose: Initalise dom elements required for pagination with a list of the pages - * Returns: - - * Inputs: object:oSettings - dataTables settings object - * node:nPaging - the DIV which contains this pagination control - * function:fnCallbackDraw - draw function which must be called on update - */ - "fnInit": function ( oSettings, nPaging, fnCallbackDraw ) - { - nFirst = document.createElement( 'span' ); - nPrevious = document.createElement( 'span' ); - nNext = document.createElement( 'span' ); - nLast = document.createElement( 'span' ); - -/* nFirst.appendChild( document.createTextNode( oSettings.oLanguage.oPaginate.sFirst ) ); - nPrevious.appendChild( document.createTextNode( oSettings.oLanguage.oPaginate.sPrevious ) ); - nNext.appendChild( document.createTextNode( oSettings.oLanguage.oPaginate.sNext ) ); - nLast.appendChild( document.createTextNode( oSettings.oLanguage.oPaginate.sLast ) );*/ - - nFirst.className = "paginate_button first"; - nPrevious.className = "paginate_button previous"; - nNext.className="paginate_button next"; - nLast.className = "paginate_button last"; - - nPaging.appendChild( nFirst ); - nPaging.appendChild( nPrevious ); - nPaging.appendChild( nNext ); - nPaging.appendChild( nLast ); - - $(nFirst).click( function () { - oSettings.oApi._fnPageChange( oSettings, "first" ); - fnCallbackDraw( oSettings ); - } ); - - $(nPrevious).click( function() { - oSettings.oApi._fnPageChange( oSettings, "previous" ); - fnCallbackDraw( oSettings ); - } ); - - $(nNext).click( function() { - oSettings.oApi._fnPageChange( oSettings, "next" ); - fnCallbackDraw( oSettings ); - } ); - - $(nLast).click( function() { - oSettings.oApi._fnPageChange( oSettings, "last" ); - fnCallbackDraw( oSettings ); - } ); + jQuery.extend( jQuery.fn.dataTableExt.oSort, { + "anti-the-pre": function ( a ) { + var x = String(a).replace( /<[\s\S]*?>/g, "" ); + var y = x.trim(); + var z = y.replace(re, "").toLowerCase(); + return z; + }, - /* Disallow text selection */ - $(nFirst).bind( 'selectstart', function () { return false; } ); - $(nPrevious).bind( 'selectstart', function () { return false; } ); - $(nNext).bind( 'selectstart', function () { return false; } ); - $(nLast).bind( 'selectstart', function () { return false; } ); - }, + "anti-the-asc": function ( a, b ) { + return ((a < b) ? -1 : ((a > b) ? 1 : 0)); + }, - /* - * Function: oPagination.four_button.fnUpdate - * Purpose: Update the list of page buttons shows - * Returns: - - * Inputs: object:oSettings - dataTables settings object - * function:fnCallbackDraw - draw function which must be called on update - */ - "fnUpdate": function ( oSettings, fnCallbackDraw ) - { - if ( !oSettings.aanFeatures.p ) - { - return; + "anti-the-desc": function ( a, b ) { + return ((a < b) ? 1 : ((a > b) ? -1 : 0)); } + }); - /* Loop over each instance of the pager */ - var an = oSettings.aanFeatures.p; - for ( var i=0, iLen=an.length ; i=w-s){s=w-r+1;x=w}else{s=y-Math.ceil(r/2)+1;x=s+r-1}for(r=s;r<=x;r++)G+=y!=r?''+r+"":''+r+"";x=g.aanFeatures.p;var z,Y=function(L){g._iDisplayStart=(this.innerHTML*1-1)*g._iDisplayLength;l(g);L.preventDefault()},V=function(){return false};r=0;for(s=x.length;rl?1:0},"string-desc":function(g,l){if(typeof g!="string")g="";if(typeof l!="string")l="";g=g.toLowerCase();l=l.toLowerCase();return gl?-1:0},"html-asc":function(g,l){g=g.replace(/<.*?>/g,"").toLowerCase();l=l.replace(/<.*?>/g,"").toLowerCase();return g< -l?-1:g>l?1:0},"html-desc":function(g,l){g=g.replace(/<.*?>/g,"").toLowerCase();l=l.replace(/<.*?>/g,"").toLowerCase();return gl?-1:0},"date-asc":function(g,l){g=Date.parse(g);l=Date.parse(l);if(isNaN(g)||g==="")g=Date.parse("01/01/1970 00:00:00");if(isNaN(l)||l==="")l=Date.parse("01/01/1970 00:00:00");return g-l},"date-desc":function(g,l){g=Date.parse(g);l=Date.parse(l);if(isNaN(g)||g==="")g=Date.parse("01/01/1970 00:00:00");if(isNaN(l)||l==="")l=Date.parse("01/01/1970 00:00:00");return l- -g},"numeric-asc":function(g,l){return(g=="-"||g===""?0:g*1)-(l=="-"||l===""?0:l*1)},"numeric-desc":function(g,l){return(l=="-"||l===""?0:l*1)-(g=="-"||g===""?0:g*1)}};o.aTypes=[function(g){if(typeof g=="number")return"numeric";else if(typeof g!="string")return null;var l,r=false;l=g.charAt(0);if("0123456789-".indexOf(l)==-1)return null;for(var s=1;s")!=-1)return"html";return null}];o.fnVersionCheck=function(g){var l=function(x,v){for(;x.length=parseInt(w,10)};o._oExternConfig={iNextUnique:0};i.fn.dataTable=function(g){function l(){this.fnRecordsTotal= -function(){return this.oFeatures.bServerSide?parseInt(this._iRecordsTotal,10):this.aiDisplayMaster.length};this.fnRecordsDisplay=function(){return this.oFeatures.bServerSide?parseInt(this._iRecordsDisplay,10):this.aiDisplay.length};this.fnDisplayEnd=function(){return this.oFeatures.bServerSide?this.oFeatures.bPaginate===false||this._iDisplayLength==-1?this._iDisplayStart+this.aiDisplay.length:Math.min(this._iDisplayStart+this._iDisplayLength,this._iRecordsDisplay):this._iDisplayEnd};this.sInstance= -this.oInstance=null;this.oFeatures={bPaginate:true,bLengthChange:true,bFilter:true,bSort:true,bInfo:true,bAutoWidth:true,bProcessing:false,bSortClasses:true,bStateSave:false,bServerSide:false,bDeferRender:false};this.oScroll={sX:"",sXInner:"",sY:"",bCollapse:false,bInfinite:false,iLoadGap:100,iBarWidth:0,bAutoCss:true};this.aanFeatures=[];this.oLanguage={sProcessing:"Processing...",sLengthMenu:"Show _MENU_ entries",sZeroRecords:"No matching records found",sEmptyTable:"No data available in table", -sLoadingRecords:"Loading...",sInfo:"Showing _START_ to _END_ of _TOTAL_ entries",sInfoEmpty:"Showing 0 to 0 of 0 entries",sInfoFiltered:"(filtered from _MAX_ total entries)",sInfoPostFix:"",sSearch:"Search:",sUrl:"",oPaginate:{sFirst:"First",sPrevious:"Previous",sNext:"Next",sLast:"Last"},fnInfoCallback:null};this.aoData=[];this.aiDisplay=[];this.aiDisplayMaster=[];this.aoColumns=[];this.aoHeader=[];this.aoFooter=[];this.iNextId=0;this.asDataSearch=[];this.oPreviousSearch={sSearch:"",bRegex:false, -bSmart:true};this.aoPreSearchCols=[];this.aaSorting=[[0,"asc",0]];this.aaSortingFixed=null;this.asStripClasses=[];this.asDestoryStrips=[];this.sDestroyWidth=0;this.fnFooterCallback=this.fnHeaderCallback=this.fnRowCallback=null;this.aoDrawCallback=[];this.fnInitComplete=this.fnPreDrawCallback=null;this.sTableId="";this.nTableWrapper=this.nTBody=this.nTFoot=this.nTHead=this.nTable=null;this.bInitialised=this.bDeferLoading=false;this.aoOpenRows=[];this.sDom="lfrtip";this.sPaginationType="two_button"; -this.iCookieDuration=7200;this.sCookiePrefix="SpryMedia_DataTables_";this.fnCookieCallback=null;this.aoStateSave=[];this.aoStateLoad=[];this.sAjaxSource=this.oLoadedState=null;this.sAjaxDataProp="aaData";this.bAjaxDataGet=true;this.jqXHR=null;this.fnServerData=function(a,b,c,d){d.jqXHR=i.ajax({url:a,data:b,success:c,dataType:"json",cache:false,error:function(f,e){e=="parsererror"&&alert("DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error.")}})}; -this.fnFormatNumber=function(a){if(a<1E3)return a;else{var b=a+"";a=b.split("");var c="";b=b.length;for(var d=0;dtr>th",a.nTFoot).addClass(a.oClasses.sFooterTH);if(a.nTFoot!==null){c=S(a,null,a.aoFooter);b=0;for(d=a.aoColumns.length;b=0;e--)!a.aoColumns[e].bVisible&&!c&&h[d].splice(e,1);j.push([])}d=0;for(f=h.length;d=a.fnRecordsDisplay()?0:a.iInitDisplayStart;a.iInitDisplayStart=-1;E(a)}if(a.bDeferLoading){a.bDeferLoading=false;a.iDraw++}else if(a.oFeatures.bServerSide){if(!a.bDestroying&&!za(a))return}else a.iDraw++;if(a.aiDisplay.length!==0){var h=a._iDisplayStart,j=a._iDisplayEnd;if(a.oFeatures.bServerSide){h=0;j=a.aoData.length}for(h=h;htr",a.nTHead)[0],aa(a),a._iDisplayStart,a.fnDisplayEnd(),a.aiDisplay);typeof a.fnFooterCallback== -"function"&&a.fnFooterCallback.call(a.oInstance,i(">tr",a.nTFoot)[0],aa(a),a._iDisplayStart,a.fnDisplayEnd(),a.aiDisplay);f=p.createDocumentFragment();b=p.createDocumentFragment();if(a.nTBody){e=a.nTBody.parentNode;b.appendChild(a.nTBody);if(!a.oScroll.bInfinite||!a._bInitComplete||a.bSorted||a.bFiltered){c=a.nTBody.childNodes;for(b=c.length-1;b>=0;b--)c[b].parentNode.removeChild(c[b])}b=0;for(c=d.length;b=0;b--)a.aoDrawCallback[b].fn.call(a.oInstance,a);a.bSorted=false;a.bFiltered=false;a.bDrawing=false;if(a.oFeatures.bServerSide){K(a,false);typeof a._bInitComplete=="undefined"&&w(a)}}}function ba(a){if(a.oFeatures.bSort)R(a,a.oPreviousSearch);else if(a.oFeatures.bFilter)M(a,a.oPreviousSearch);else{E(a);C(a)}}function za(a){if(a.bAjaxDataGet){K(a,true);var b=a.aoColumns.length,c=[],d,f;a.iDraw++;c.push({name:"sEcho",value:a.iDraw});c.push({name:"iColumns",value:b});c.push({name:"sColumns",value:ha(a)}); -c.push({name:"iDisplayStart",value:a._iDisplayStart});c.push({name:"iDisplayLength",value:a.oFeatures.bPaginate!==false?a._iDisplayLength:-1});for(f=0;f")c=c.parentNode;else if(h=="l"&&a.oFeatures.bPaginate&&a.oFeatures.bLengthChange){f=Ca(a);e=1}else if(h=="f"&&a.oFeatures.bFilter){f=Da(a);e=1}else if(h=="r"&&a.oFeatures.bProcessing){f=Ea(a);e=1}else if(h=="t"){f=Fa(a);e=1}else if(h=="i"&&a.oFeatures.bInfo){f=Ga(a);e=1}else if(h=="p"&&a.oFeatures.bPaginate){f=Ha(a);e=1}else if(o.aoFeatures.length!== -0){j=o.aoFeatures;t=0;for(k=j.length;tcaption",a.nTable);h=0;for(k=d.length;hi(a.nTable).height()-a.oScroll.iLoadGap)if(a.fnDisplayEnd()0&&a.nTable.removeChild(h[0]);if(a.nTFoot!==null){k=a.nTable.getElementsByTagName("tfoot");k.length>0&&a.nTable.removeChild(k[0])}h=a.nTHead.cloneNode(true);a.nTable.insertBefore(h,a.nTable.childNodes[0]);if(a.nTFoot!==null){k=a.nTFoot.cloneNode(true); -a.nTable.insertBefore(k,a.nTable.childNodes[1])}if(a.oScroll.sX===""){d.style.width="100%";b.parentNode.style.width="100%"}var O=S(a,h);f=0;for(e=O.length;ff-a.oScroll.iBarWidth)a.nTable.style.width=u(f)}else a.nTable.style.width=u(f);f=i(a.nTable).outerWidth();if(a.oScroll.sX===""){d.style.width=u(f+a.oScroll.iBarWidth);b.parentNode.style.width=u(f+a.oScroll.iBarWidth)}e=a.nTHead.getElementsByTagName("tr");h=h.getElementsByTagName("tr");P(function(B,F){m=B.style;m.paddingTop= -"0";m.paddingBottom="0";m.borderTopWidth="0";m.borderBottomWidth="0";m.height=0;q=i(B).width();F.style.width=u(q);I.push(q)},h,e);i(h).height(0);if(a.nTFoot!==null){j=k.getElementsByTagName("tr");k=a.nTFoot.getElementsByTagName("tr");P(function(B,F){m=B.style;m.paddingTop="0";m.paddingBottom="0";m.borderTopWidth="0";m.borderBottomWidth="0";m.height=0;q=i(B).width();F.style.width=u(q);I.push(q)},j,k);i(j).height(0)}P(function(B){B.innerHTML="";B.style.width=u(I.shift())},h);a.nTFoot!==null&&P(function(B){B.innerHTML= -"";B.style.width=u(I.shift())},j);if(i(a.nTable).outerWidth()d.offsetWidth?a.oScroll.iBarWidth:0;if(a.nTable.offsetHeight'):b===""?'':b+' '; -var c=p.createElement("div");c.className=a.oClasses.sFilter;c.innerHTML="";a.sTableId!==""&&typeof a.aanFeatures.f=="undefined"&&c.setAttribute("id",a.sTableId+"_filter");b=i("input",c);b.val(a.oPreviousSearch.sSearch.replace('"',"""));b.bind("keyup.DT",function(){for(var d=a.aanFeatures.f,f=0,e=d.length;f=0;d--){f=ma(H(a,a.aiDisplay[d],c,"filter"),a.aoColumns[c].sType);if(!b.test(f)){a.aiDisplay.splice(d,1);e++}}}}function Ka(a,b,c,d,f){var e=la(b,d,f);if(typeof c=="undefined"||c===null)c=0;if(o.afnFiltering.length!==0)c=1;if(b.length<=0){a.aiDisplay.splice(0,a.aiDisplay.length);a.aiDisplay=a.aiDisplayMaster.slice()}else if(a.aiDisplay.length==a.aiDisplayMaster.length||a.oPreviousSearch.sSearch.length> -b.length||c==1||b.indexOf(a.oPreviousSearch.sSearch)!==0){a.aiDisplay.splice(0,a.aiDisplay.length);ka(a,1);for(c=0;c/g,"");else if(typeof a=="string")return a.replace(/\n/g," ");else if(a===null)return"";return a}function R(a,b){var c,d,f,e,h=[],j=[],k=o.oSort;d=a.aoData;var m=a.aoColumns;if(!a.oFeatures.bServerSide&&(a.aaSorting.length!==0||a.aaSortingFixed!==null)){h=a.aaSortingFixed!== -null?a.aaSortingFixed.concat(a.aaSorting):a.aaSorting.slice();for(c=0;c=h)for(b=0;b=0?a._iDisplayStart-a._iDisplayLength:0;if(a._iDisplayStart<0)a._iDisplayStart=0}else if(b=="next")if(a._iDisplayLength>=0){if(a._iDisplayStart+a._iDisplayLength=0){b=parseInt((a.fnRecordsDisplay()-1)/a._iDisplayLength,10)+1;a._iDisplayStart=(b-1)*a._iDisplayLength}else a._iDisplayStart= -0;else J(a,0,"Unknown paging action: "+b);return c!=a._iDisplayStart}function Ga(a){var b=p.createElement("div");b.className=a.oClasses.sInfo;if(typeof a.aanFeatures.i=="undefined"){a.aoDrawCallback.push({fn:Na,sName:"information"});a.sTableId!==""&&b.setAttribute("id",a.sTableId+"_info")}return b}function Na(a){if(!(!a.oFeatures.bInfo||a.aanFeatures.i.length===0)){var b=a._iDisplayStart+1,c=a.fnDisplayEnd(),d=a.fnRecordsTotal(),f=a.fnRecordsDisplay(),e=a.fnFormatNumber(b),h=a.fnFormatNumber(c),j= -a.fnFormatNumber(d),k=a.fnFormatNumber(f);if(a.oScroll.bInfinite)e=a.fnFormatNumber(1);e=a.fnRecordsDisplay()===0&&a.fnRecordsDisplay()==a.fnRecordsTotal()?a.oLanguage.sInfoEmpty+a.oLanguage.sInfoPostFix:a.fnRecordsDisplay()===0?a.oLanguage.sInfoEmpty+" "+a.oLanguage.sInfoFiltered.replace("_MAX_",j)+a.oLanguage.sInfoPostFix:a.fnRecordsDisplay()==a.fnRecordsTotal()?a.oLanguage.sInfo.replace("_START_",e).replace("_END_",h).replace("_TOTAL_",k)+a.oLanguage.sInfoPostFix:a.oLanguage.sInfo.replace("_START_", -e).replace("_END_",h).replace("_TOTAL_",k)+" "+a.oLanguage.sInfoFiltered.replace("_MAX_",a.fnFormatNumber(a.fnRecordsTotal()))+a.oLanguage.sInfoPostFix;if(a.oLanguage.fnInfoCallback!==null)e=a.oLanguage.fnInfoCallback(a,b,c,d,f,e);a=a.aanFeatures.i;b=0;for(c=a.length;b",c,d;if(a.aLengthMenu.length==2&&typeof a.aLengthMenu[0]=="object"&&typeof a.aLengthMenu[1]== -"object"){c=0;for(d=a.aLengthMenu[0].length;c'+a.aLengthMenu[1][c]+""}else{c=0;for(d=a.aLengthMenu.length;c'+a.aLengthMenu[c]+""}b+="";var f=p.createElement("div");a.sTableId!==""&&typeof a.aanFeatures.l=="undefined"&&f.setAttribute("id",a.sTableId+"_length");f.className=a.oClasses.sLength;f.innerHTML="";i('select option[value="'+ -a._iDisplayLength+'"]',f).attr("selected",true);i("select",f).bind("change.DT",function(){var e=i(this).val(),h=a.aanFeatures.l;c=0;for(d=h.length;ca.aiDisplay.length|| -a._iDisplayLength==-1?a.aiDisplay.length:a._iDisplayStart+a._iDisplayLength}function Oa(a,b){if(!a||a===null||a==="")return 0;if(typeof b=="undefined")b=p.getElementsByTagName("body")[0];var c=p.createElement("div");c.style.width=u(a);b.appendChild(c);a=c.offsetWidth;b.removeChild(c);return a}function ea(a){var b=0,c,d=0,f=a.aoColumns.length,e,h=i("th",a.nTHead);for(e=0;etd",b);h=S(a,e);for(e=d=0;e0)a.aoColumns[e].sWidth=u(c);d++}a.nTable.style.width=u(i(b).outerWidth());b.parentNode.removeChild(b)}}function Qa(a,b){if(a.oScroll.sX===""&&a.oScroll.sY!==""){i(b).width();b.style.width=u(i(b).outerWidth()-a.oScroll.iBarWidth)}else if(a.oScroll.sX!=="")b.style.width=u(i(b).outerWidth())}function Pa(a,b){var c= -Ra(a,b);if(c<0)return null;if(a.aoData[c].nTr===null){var d=p.createElement("td");d.innerHTML=H(a,c,b,"");return d}return Q(a,c)[b]}function Ra(a,b){for(var c=-1,d=-1,f=0;f/g,"");if(e.length>c){c=e.length;d=f}}return d}function u(a){if(a===null)return"0px";if(typeof a=="number"){if(a<0)return"0px";return a+"px"}var b=a.charCodeAt(a.length-1);if(b<48||b>57)return a;return a+"px"}function Va(a,b){if(a.length!=b.length)return 1;for(var c= -0;cb&&a[d]--;c!=-1&&a.splice(c,1)}function Ba(a,b){b=b.split(",");for(var c=[],d=0,f=a.aoColumns.length;d4096){a=p.cookie.split(";");for(var j=0,k=a.length;j=d.aiDisplay.length){d._iDisplayStart-=d._iDisplayLength;if(d._iDisplayStart<0)d._iDisplayStart=0}if(typeof c=="undefined"||c){E(d);C(d)}return f};this.fnClearTable=function(a){var b=A(this[o.iApiIndex]);ia(b);if(typeof a=="undefined"||a)C(b)};this.fnOpen=function(a,b,c){var d=A(this[o.iApiIndex]);this.fnClose(a);var f=p.createElement("tr"),e=p.createElement("td");f.appendChild(e);e.className=c;e.colSpan=X(d);if(typeof b.jquery!="undefined"||typeof b== -"object")e.appendChild(b);else e.innerHTML=b;b=i("tr",d.nTBody);i.inArray(a,b)!=-1&&i(f).insertAfter(a);d.aoOpenRows.push({nTr:f,nParent:a});return f};this.fnClose=function(a){for(var b=A(this[o.iApiIndex]),c=0;c=X(d);if(!j)for(f=a;ftr>td."+a.oClasses.sRowEmpty,a.nTable).parent().remove();if(a.nTable!=a.nTHead.parentNode){i(">thead",a.nTable).remove();a.nTable.appendChild(a.nTHead)}if(a.nTFoot&& -a.nTable!=a.nTFoot.parentNode){i(">tfoot",a.nTable).remove();a.nTable.appendChild(a.nTFoot)}a.nTable.parentNode.removeChild(a.nTable);i(a.nTableWrapper).remove();a.aaSorting=[];a.aaSortingFixed=[];T(a);i($(a)).removeClass(a.asStripClasses.join(" "));if(a.bJUI){i("th",a.nTHead).removeClass([o.oStdClasses.sSortable,o.oJUIClasses.sSortableAsc,o.oJUIClasses.sSortableDesc,o.oJUIClasses.sSortableNone].join(" "));i("th span."+o.oJUIClasses.sSortIcon,a.nTHead).remove();i("th",a.nTHead).each(function(){var e= -i("div."+o.oJUIClasses.sSortJUIWrapper,this),h=e.contents();i(this).append(h);e.remove()})}else i("th",a.nTHead).removeClass([o.oStdClasses.sSortable,o.oStdClasses.sSortableAsc,o.oStdClasses.sSortableDesc,o.oStdClasses.sSortableNone].join(" "));a.nTableReinsertBefore?b.insertBefore(a.nTable,a.nTableReinsertBefore):b.appendChild(a.nTable);d=0;for(f=a.aoData.length;dtr:even",c).addClass(a.asDestoryStrips[0]);i(">tr:odd",c).addClass(a.asDestoryStrips[1]);d=0;for(f=D.length;dt<"F"ip>'}if(e.oScroll.sX!==""||e.oScroll.sY!=="")e.oScroll.iBarWidth=Ua();if(typeof g.iDisplayStart!="undefined"&&typeof e.iInitDisplayStart=="undefined"){e.iInitDisplayStart= -g.iDisplayStart;e._iDisplayStart=g.iDisplayStart}if(typeof g.bStateSave!="undefined"){e.oFeatures.bStateSave=g.bStateSave;Ta(e,g);e.aoDrawCallback.push({fn:sa,sName:"state_save"})}if(typeof g.iDeferLoading!="undefined"){e.bDeferLoading=true;e._iRecordsTotal=g.iDeferLoading;e._iRecordsDisplay=g.iDeferLoading}if(typeof g.aaData!="undefined")j=true;if(typeof g!="undefined"&&typeof g.aoData!="undefined")g.aoColumns=g.aoData;if(typeof g.oLanguage!="undefined")if(typeof g.oLanguage.sUrl!="undefined"&&g.oLanguage.sUrl!== -""){e.oLanguage.sUrl=g.oLanguage.sUrl;i.getJSON(e.oLanguage.sUrl,null,function(t){y(e,t,true)});h=true}else y(e,g.oLanguage,false)}else g={};if(typeof g.asStripClasses=="undefined"){e.asStripClasses.push(e.oClasses.sStripOdd);e.asStripClasses.push(e.oClasses.sStripEven)}c=false;d=i(">tbody>tr",this);a=0;for(b=e.asStripClasses.length;a=0;a--){var m=g.aoColumnDefs[a].aTargets;i.isArray(m)||J(e,1,"aTargets must be an array of targets, not a "+typeof m);c=0;for(d=m.length;c=0){for(;e.aoColumns.length<=m[c];)G(e);x(e,m[c],g.aoColumnDefs[a])}else if(typeof m[c]== -"number"&&m[c]<0)x(e,e.aoColumns.length+m[c],g.aoColumnDefs[a]);else if(typeof m[c]=="string"){b=0;for(f=e.aoColumns.length;b=e.aoColumns.length)e.aaSorting[a][0]=0;k=e.aoColumns[e.aaSorting[a][0]];if(typeof e.aaSorting[a][2]=="undefined")e.aaSorting[a][2]=0;if(typeof g.aaSorting=="undefined"&& -typeof e.saved_aaSorting=="undefined")e.aaSorting[a][1]=k.asSorting[0];c=0;for(d=k.asSorting.length;cthead",this);if(a.length===0){a=[p.createElement("thead")];this.appendChild(a[0])}e.nTHead=a[0];a=i(">tbody",this);if(a.length===0){a=[p.createElement("tbody")];this.appendChild(a[0])}e.nTBody=a[0];a=i(">tfoot",this);if(a.length>0){e.nTFoot=a[0];W(e.aoFooter,e.nTFoot)}if(j)for(a=0;a1){arr=arr.concat(checkCellColSpan(table,headerArr,row++));}else{if(table.tHead.length==1||(cell.rowSpan>1||!r[row+1])){arr.push(cell);}}}return arr;};function checkHeaderMetadata(cell){if(($.metadata)&&($(cell).metadata().sorter===false)){return true;};return false;}function checkHeaderOptions(table,i){if((table.config.headers[i])&&(table.config.headers[i].sorter===false)){return true;};return false;}function applyWidget(table){var c=table.config.widgets;var l=c.length;for(var i=0;i');$("tr:first td",table.tBodies[0]).each(function(){colgroup.append($('').css('width',$(this).width()));});$(table).prepend(colgroup);};}function updateHeaderSortCount(table,sortList){var c=table.config,l=sortList.length;for(var i=0;ib)?1:0));};function sortTextDesc(a,b){return((ba)?1:0));};function sortNumeric(a,b){return a-b;};function sortNumericDesc(a,b){return b-a;};function getCachedSortType(parsers,i){return parsers[i].type;};this.construct=function(settings){return this.each(function(){if(!this.tHead||!this.tBodies)return;var $this,$document,$headers,cache,config,shiftDown=0,sortOrder;this.config={};config=$.extend(this.config,$.tablesorter.defaults,settings);$this=$(this);$headers=buildHeaders(this);this.config.parsers=buildParserCache(this,$headers);cache=buildCache(this);var sortCSS=[config.cssDesc,config.cssAsc];fixColumnWidth(this);$headers.click(function(e){$this.trigger("sortStart");var totalRows=($this[0].tBodies[0]&&$this[0].tBodies[0].rows.length)||0;if(!this.sortDisabled&&totalRows>0){var $cell=$(this);var i=this.column;this.order=this.count++%2;if(!e[config.sortMultiSortKey]){config.sortList=[];if(config.sortForce!=null){var a=config.sortForce;for(var j=0;j0){$this.trigger("sorton",[config.sortList]);}applyWidget(this);});};this.addParser=function(parser){var l=parsers.length,a=true;for(var i=0;i [% ELSE %] - + [% INCLUDE 'datatables.inc' %] +[% INCLUDE 'datatables.inc' %] [% IF ( SocialNetworks ) %] +[% INCLUDE 'datatables.inc' %] +[% INCLUDE 'datatables.inc' %] @@ -47,7 +51,7 @@ [% FOREACH recentSearche IN recentSearches %] - [% recentSearche.time %] + [% recentSearche.time |$KohaDates with_hours => 1 %] [% recentSearche.query_desc |html %] [% recentSearche.total %] @@ -65,7 +69,7 @@ [% FOREACH previousSearche IN previousSearches %] - [% previousSearche.time %] + [% previousSearche.time |$KohaDates with_hours => 1 %] [% previousSearche.query_desc |html %] [% previousSearche.total %] diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tt index c9c0bca..ba3870c 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tt @@ -3,7 +3,6 @@ [% SET TagsInputEnabled = ( opacuserlogin && TagsEnabled && TagsInputOnList ) %] [% INCLUDE 'doc-head-open.inc' %][% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › [% IF ( viewshelf ) %]Contents of [% shelfname |html %][% ELSE %]Your lists[% END %][% INCLUDE 'doc-head-close.inc' %] - - +[% INCLUDE 'datatables.inc' %] +[% INCLUDE 'datatables.inc' %] @@ -98,7 +106,7 @@ [% MY_TAG.bib_summary |html %] - [% MY_TAG.date_created | $KohaDates %] + [% MY_TAG.date_created | $KohaDates %] [% END %] diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-topissues.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-topissues.tt index b7e94e6..6482168 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-topissues.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-topissues.tt @@ -1,23 +1,22 @@ [% USE Koha %] [% INCLUDE 'doc-head-open.inc' %][% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › Most popular titles [% INCLUDE 'doc-head-close.inc' %] - +[% INCLUDE 'datatables.inc' %] - +[% INCLUDE 'datatables.inc' %] - + +[% INCLUDE 'datatables.inc' %] [% IF ( opacuserjs ) %][% END %] [% IF ( SCOUserJS ) %][% END %] @@ -262,7 +253,7 @@ Sorry, this self-checkout station has lost authentication. Please contact the a - [% UNLESS ( nofines ) %][% END %] + [% UNLESS ( nofines ) %][% END %] @@ -272,7 +263,7 @@ Sorry, this self-checkout station has lost authentication. Please contact the a - [% IF ( ISSUE.overdue ) %][% ELSE %][% END %] + [% IF ( ISSUE.overdue ) %][% ELSE %][% END %]
Checkouts for [% borrowername %] ([% issues_count %] total)
TitleCall no.DueRenewFines
TitleCall no.DueRenewFines
[% UNLESS ( noitemlinks ) %][% ISSUE.title |html %][% ELSE %][% ISSUE.title |html %][% END %] [% ISSUE.author %] ([% ISSUE.barcode %]) [% ISSUE.itemcallnumber %][% ISSUE.date_due | $KohaDates %][% ISSUE.date_due | $KohaDates %][% ISSUE.date_due | $KohaDates %][% ISSUE.date_due | $KohaDates %]
diff --git a/opac/opac-search-history.pl b/opac/opac-search-history.pl index 67c620b..52477c5 100755 --- a/opac/opac-search-history.pl +++ b/opac/opac-search-history.pl @@ -111,7 +111,7 @@ if (!$loggedinuser) { my $dateformat = $date->DHTMLcalendar() . " %H:%i:%S"; # Current syspref date format + standard time format # Getting the data with date format work done by mysql - my $query = "SELECT userid, sessionid, query_desc, query_cgi, total, DATE_FORMAT(time, \"$dateformat\") as time FROM search_history WHERE userid = ? AND sessionid = ?"; + my $query = "SELECT userid, sessionid, query_desc, query_cgi, total, time FROM search_history WHERE userid = ? AND sessionid = ?"; my $sth = $dbh->prepare($query); $sth->execute($loggedinuser, $cgi->cookie("CGISESSID")); my $searches = $sth->fetchall_arrayref({}); @@ -124,7 +124,7 @@ if (!$loggedinuser) { # If at least one search from previous sessions has been performed if ($sth->fetchrow_array > 0) { - $query = "SELECT userid, sessionid, query_desc, query_cgi, total, DATE_FORMAT(time, \"$dateformat\") as time FROM search_history WHERE userid = ? AND sessionid != ?"; + $query = "SELECT userid, sessionid, query_desc, query_cgi, total, time FROM search_history WHERE userid = ? AND sessionid != ?"; $sth = $dbh->prepare($query); $sth->execute($loggedinuser, $cgi->cookie("CGISESSID")); my $previoussearches = $sth->fetchall_arrayref({}); -- 1.8.1.2