From 0050e6c9337d28a5c52d2cdac9fa93f9c5fcd3ac Mon Sep 17 00:00:00 2001 From: Colin Marks Date: Thu, 10 May 2018 07:07:40 +0100 Subject: [PATCH 01/16] New sorting plugin for book chapter numbering --- sorting/chapter.js | 50 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 sorting/chapter.js diff --git a/sorting/chapter.js b/sorting/chapter.js new file mode 100644 index 0000000..30f53ce --- /dev/null +++ b/sorting/chapter.js @@ -0,0 +1,50 @@ +/** + * Sorts a column containing chapter numbers. This can be most useful when + * using DataTables for a book or book reference style application. By + * default, five sections are supported (a.b.c.d.e) with each being upto + * four-digits long. Those defaults are controlled by constMaxSections and + * constMaxSectionDigits respectively, and can be easily changed + * + * @name chapter + * @summary Sort book chapters numerically + * @author Colin Marks + * + * @example + * $('#example').dataTable( { + * columnDefs: [ + * { type: 'chapter', targets: 0 } + * ] + * } ); + */ + +jQuery.extend(jQuery.fn.dataTableExt.oSort, { + 'chapter-pre': function(a) { + function makeFiller(count) { + return count === 0 ? '' : Array(count + 1).join('0'); + } + + var constMaxSections = 5; + var constMaxSectionDigits = 4; + + var filler; + var result = ''; + var sections = a.split('.'); + + for (var i = 0; i < constMaxSections; i++) { + filler = i < sections.length ? constMaxSectionDigits - sections[i].length : constMaxSectionDigits; + + result += filler === 0 ? '' : Array(filler + 1).join('0'); + result += i < sections.length ? sections[i] : ''; + } + + return result; + }, + + 'chapter-asc': function(a, b) { + return a < b ? -1 : a > b ? 1 : 0; + }, + + 'chapter-desc': function(a, b) { + return a < b ? 1 : a > b ? -1 : 0; + } +}); From da67f99c240f1c80a51487e00808a97ea48971cb Mon Sep 17 00:00:00 2001 From: Allan Jardine Date: Fri, 11 May 2018 09:55:33 +0100 Subject: [PATCH 02/16] Fix: Update for jQuery 3.3 deprecated functions --- .../conditionalPaging/dataTables.conditionalPaging.js | 2 +- type-detection/formatted-num.js | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/features/conditionalPaging/dataTables.conditionalPaging.js b/features/conditionalPaging/dataTables.conditionalPaging.js index 7326351..4fb7fae 100644 --- a/features/conditionalPaging/dataTables.conditionalPaging.js +++ b/features/conditionalPaging/dataTables.conditionalPaging.js @@ -70,7 +70,7 @@ } }; - if ($.isNumeric(config.speed) || $.type(config.speed) === 'string') { + if ( config.speed !== undefined ) { speed = config.speed; } diff --git a/type-detection/formatted-num.js b/type-detection/formatted-num.js index 24d7349..27ff033 100644 --- a/type-detection/formatted-num.js +++ b/type-detection/formatted-num.js @@ -19,9 +19,10 @@ jQuery.fn.dataTableExt.aTypes.unshift( function ( sData ) { var deformatted = sData.replace(/[^\d\-\.\/a-zA-Z]/g,''); - if ( $.isNumeric( deformatted ) || deformatted === "-" ) { - return 'formatted-num'; - } - return null; + var isNumeric = !isNaN( deformatted - parseFloat( deformatted ) ); + + return isNumeric || deformatted === "-" ? + 'formatted-num' : + null; } ); From a46b1b3331434b773de8fe9a735324c9863c039e Mon Sep 17 00:00:00 2001 From: AnixPasBesoin Date: Sun, 13 May 2018 21:31:48 +0200 Subject: [PATCH 03/16] Added translation for row selection Added missing translation for row selection. https://datatables.net/forums/discussion/35398/i18n-translation-for-n-rows-selected --- i18n/French.lang | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/i18n/French.lang b/i18n/French.lang index e744bd8..a46dbb8 100644 --- a/i18n/French.lang +++ b/i18n/French.lang @@ -25,5 +25,12 @@ "oAria": { "sSortAscending": ": activer pour trier la colonne par ordre croissant", "sSortDescending": ": activer pour trier la colonne par ordre décroissant" + }, + "select": { + "rows": { + _: "%d lignes séléctionnées", + 0: "Aucune ligne séléctionnée", + 1: "1 ligne séléctionnée" + } } } From 18cbcbb5d9673e32912a25ac2eb473f467f56bb9 Mon Sep 17 00:00:00 2001 From: Allan Jardine Date: Mon, 14 May 2018 11:05:48 +0100 Subject: [PATCH 04/16] Fix: Attempt to use the second row in the table to allow for top and bottom borders on rows --- features/pageResize/dataTables.pageResize.js | 3 ++- features/pageResize/dataTables.pageResize.min.js | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/features/pageResize/dataTables.pageResize.js b/features/pageResize/dataTables.pageResize.js index 52d3015..f5a9496 100644 --- a/features/pageResize/dataTables.pageResize.js +++ b/features/pageResize/dataTables.pageResize.js @@ -69,7 +69,8 @@ PageResize.prototype = { var dt = settings.dt; var t = dt.table(); var offsetTop = $( settings.table ).offset().top; - var rowHeight = $( 'tr', settings.body ).eq(0).height(); + var rows = $( 'tr', settings.body ); + var rowHeight = rows.eq( rows.length > 1 ? 1 : 0 ).height(); // Attempt to use the second row if poss, for top and bottom border var availableHeight = settings.host.height(); var scrolling = t.header().parentNode !== t.body().parentNode; var delta = settings.delta; diff --git a/features/pageResize/dataTables.pageResize.min.js b/features/pageResize/dataTables.pageResize.min.js index 29ff760..ed0ef5d 100644 --- a/features/pageResize/dataTables.pageResize.min.js +++ b/features/pageResize/dataTables.pageResize.min.js @@ -25,6 +25,6 @@ PageResize for DataTables v1.0.0 2015 SpryMedia Ltd - datatables.net/license */ -(function(b){var e=function(a,c){var d=a.table();this.s={dt:a,host:b(d.container()).parent(),header:b(d.header()),footer:b(d.footer()),body:b(d.body()),container:b(d.container()),table:b(d.node()),delta:c};a=this.s.host;"static"===a.css("position")&&a.css("position","relative");this._attach();this._size()};e.prototype={_size:function(){var a=this.s,c=a.dt,d=c.table(),h=b(a.table).offset().top,e=b("tr",a.body).eq(0).height(),f=a.host.height(),k=d.header().parentNode!==d.body().parentNode,g=a.delta; -k||(d.header()&&(f-=a.header.height()),d.footer()&&(f-=a.footer.height()));f=f-h-(a.container.height()-(h+a.table.height()));!isNaN(parseFloat(g))&&isFinite(g)&&(f-=g);a=Math.floor(f/e);Infinity!==a&&-Infinity!==a&&!isNaN(a)&&0").css({position:"absolute",top:0,left:0,height:"100%",width:"100%",zIndex:-1}).attr("type","text/html");c[0].onload=function(){var b=this.contentDocument.body,c=b.offsetHeight;this.contentDocument.defaultView.onresize= -function(){var d=b.clientHeight||b.offsetHeight;d!==c&&(c=d,a._size())}};c.appendTo(this.s.host).attr("data","about:blank")}};b.fn.dataTable.PageResize=e;b.fn.DataTable.PageResize=e;b(document).on("init.dt",function(a,c){"dt"===a.namespace&&(a=new b.fn.dataTable.Api(c),(b(a.table().node()).hasClass("pageResize")||c.oInit.pageResize||b.fn.dataTable.defaults.pageResize)&&new e(a,c.oInit.pageResizeManualDelta))})})(jQuery); +(function(b){var e=function(a,c){var d=a.table();this.s={dt:a,host:b(d.container()).parent(),header:b(d.header()),footer:b(d.footer()),body:b(d.body()),container:b(d.container()),table:b(d.node()),delta:c};a=this.s.host;"static"===a.css("position")&&a.css("position","relative");this._attach();this._size()};e.prototype={_size:function(){var a=this.s,c=a.dt,d=c.table(),k=b(a.table).offset().top,g=b("tr",a.body),g=g.eq(1").css({position:"absolute",top:0,left:0,height:"100%",width:"100%",zIndex:-1}).attr("type","text/html");c[0].onload=function(){var b=this.contentDocument.body,c=b.offsetHeight; +this.contentDocument.defaultView.onresize=function(){var d=b.clientHeight||b.offsetHeight;d!==c&&(c=d,a._size())}};c.appendTo(this.s.host).attr("data","about:blank")}};b.fn.dataTable.PageResize=e;b.fn.DataTable.PageResize=e;b(document).on("init.dt",function(a,c){"dt"===a.namespace&&(a=new b.fn.dataTable.Api(c),(b(a.table().node()).hasClass("pageResize")||c.oInit.pageResize||b.fn.dataTable.defaults.pageResize)&&new e(a,c.oInit.pageResizeManualDelta))})})(jQuery); From 5695ffe40c238bf3f73074fa57e585b4b0fc3f3a Mon Sep 17 00:00:00 2001 From: Allan Jardine Date: Tue, 15 May 2018 09:48:26 +0100 Subject: [PATCH 05/16] Features: UMD for pageResize and scrollResize --- features/pageResize/dataTables.pageResize.js | 30 ++++++++++++++++-- .../pageResize/dataTables.pageResize.min.js | 7 +++-- features/pageResize/index.html | 6 ++-- features/pageResize/scrolling.html | 6 ++-- .../scrollResize/dataTables.scrollResize.js | 31 +++++++++++++++++-- .../dataTables.scrollResize.min.js | 7 +++-- .../searchPane/dataTables.searchPane.min.js | 6 ++-- 7 files changed, 73 insertions(+), 20 deletions(-) diff --git a/features/pageResize/dataTables.pageResize.js b/features/pageResize/dataTables.pageResize.js index f5a9496..a63ee24 100644 --- a/features/pageResize/dataTables.pageResize.js +++ b/features/pageResize/dataTables.pageResize.js @@ -34,8 +34,34 @@ * For more detailed information please see: * http://datatables.net/blog/2015-04-10 */ +(function( factory ){ + if ( typeof define === 'function' && define.amd ) { + // AMD + define( ['jquery', 'datatables.net'], function ( $ ) { + return factory( $, window, document ); + } ); + } + else if ( typeof exports === 'object' ) { + // CommonJS + module.exports = function (root, $) { + if ( ! root ) { + root = window; + } + + if ( ! $ || ! $.fn.dataTable ) { + $ = require('datatables.net')(root, $).$; + } + + return factory( $, root, root.document ); + }; + } + else { + // Browser + factory( jQuery, window, document ); + } +}(function( $, window, document, undefined ) { +'use strict'; -(function($){ var PageResize = function ( dt, pageResizeManualDelta ) { @@ -160,5 +186,5 @@ $(document).on( 'init.dt', function ( e, settings ) { } } ); -}(jQuery)); +})); diff --git a/features/pageResize/dataTables.pageResize.min.js b/features/pageResize/dataTables.pageResize.min.js index ed0ef5d..754d86e 100644 --- a/features/pageResize/dataTables.pageResize.min.js +++ b/features/pageResize/dataTables.pageResize.min.js @@ -25,6 +25,7 @@ PageResize for DataTables v1.0.0 2015 SpryMedia Ltd - datatables.net/license */ -(function(b){var e=function(a,c){var d=a.table();this.s={dt:a,host:b(d.container()).parent(),header:b(d.header()),footer:b(d.footer()),body:b(d.body()),container:b(d.container()),table:b(d.node()),delta:c};a=this.s.host;"static"===a.css("position")&&a.css("position","relative");this._attach();this._size()};e.prototype={_size:function(){var a=this.s,c=a.dt,d=c.table(),k=b(a.table).offset().top,g=b("tr",a.body),g=g.eq(1").css({position:"absolute",top:0,left:0,height:"100%",width:"100%",zIndex:-1}).attr("type","text/html");c[0].onload=function(){var b=this.contentDocument.body,c=b.offsetHeight; -this.contentDocument.defaultView.onresize=function(){var d=b.clientHeight||b.offsetHeight;d!==c&&(c=d,a._size())}};c.appendTo(this.s.host).attr("data","about:blank")}};b.fn.dataTable.PageResize=e;b.fn.DataTable.PageResize=e;b(document).on("init.dt",function(a,c){"dt"===a.namespace&&(a=new b.fn.dataTable.Api(c),(b(a.table().node()).hasClass("pageResize")||c.oInit.pageResize||b.fn.dataTable.defaults.pageResize)&&new e(a,c.oInit.pageResizeManualDelta))})})(jQuery); +(function(b){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(d){return b(d,window,document)}):"object"===typeof exports?module.exports=function(d,c){d||(d=window);c&&c.fn.dataTable||(c=require("datatables.net")(d,c).$);return b(c,d,d.document)}:b(jQuery,window,document)})(function(b,d,c,l){var f=function(a,h){var e=a.table();this.s={dt:a,host:b(e.container()).parent(),header:b(e.header()),footer:b(e.footer()),body:b(e.body()),container:b(e.container()),table:b(e.node()), +delta:h};a=this.s.host;"static"===a.css("position")&&a.css("position","relative");this._attach();this._size()};f.prototype={_size:function(){var a=this.s,h=a.dt,e=h.table(),d=b(a.table).offset().top,c=b("tr",a.body),c=c.eq(1").css({position:"absolute",top:0,left:0,height:"100%",width:"100%",zIndex:-1}).attr("type","text/html");c[0].onload=function(){var b=this.contentDocument.body,c=b.offsetHeight;this.contentDocument.defaultView.onresize=function(){var d=b.clientHeight||b.offsetHeight;d!==c&&(c=d,a._size())}};c.appendTo(this.s.host).attr("data","about:blank")}};b.fn.dataTable.PageResize= +f;b.fn.DataTable.PageResize=f;b(c).on("init.dt",function(a,c){"dt"===a.namespace&&(a=new b.fn.dataTable.Api(c),(b(a.table().node()).hasClass("pageResize")||c.oInit.pageResize||b.fn.dataTable.defaults.pageResize)&&new f(a,c.oInit.pageResizeManualDelta))})}); diff --git a/features/pageResize/index.html b/features/pageResize/index.html index d1cadbe..83ab2ff 100644 --- a/features/pageResize/index.html +++ b/features/pageResize/index.html @@ -5,7 +5,7 @@ DataTables page resize example - + - - + + - + +