From ef6457e3e6a45d7477f7be1deeeed851201ccbd6 Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 12 Jan 2017 18:35:57 +0000 Subject: [PATCH 1/7] Create sliding-child.js I have never made a pull request on github before, so I plead ignorance if I am doing anything incorrectly. --- features/slidingChild/js/sliding-child.js | 109 ++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 features/slidingChild/js/sliding-child.js diff --git a/features/slidingChild/js/sliding-child.js b/features/slidingChild/js/sliding-child.js new file mode 100644 index 0000000..cad0464 --- /dev/null +++ b/features/slidingChild/js/sliding-child.js @@ -0,0 +1,109 @@ +/** + * @summary SlidingChild + * @description Show/Hide row child data plug-in + * @version 1.0.0 + * @file datatables-slidingchild.js + * @author datahandler (www.datahandler.uk) + * @copyright Copyright 2014 SpryMedia Ltd. + * + * License MIT - http://datatables.net/license/mit + */ +(function ($) { + var SlidingChild = function (dt, options) { + var opts = $.extend({}, SlidingChild.defaults, options); + + // bind to selector click + $(opts.selector).on('click', function () { + var $this = $(this); + var dtRow = $this.is('tr') ? $this : $this.closest('tr'); + + if (!dtRow.is('tr')) { return; } // throw error? + // check row belongs to this table? + + dtRow = dt.row(dtRow); + toggleChild(dtRow); + }); + + var toggleChild = function (dtRow) { + // if child already showing, close it. + if (dtRow.child.isShown()) { + closeChild(dtRow); + } + else { + // closes existing showing child, if any + if (opts.toggleChild) closeChild(dt.row('.shown')); + + showChildData(dtRow); + } + }; + // code borrowed from the resource at: https://datatables.net/blog/2014-10-02 + var closeChild = function (dtRow) { + if (dtRow) { + var showingRow = $(dtRow.node()); + $(opts.sliderSelector, dtRow.child()).slideUp(function () { + dtRow.child.remove(); + showingRow.removeClass('shown'); + $(dt.table().node()).trigger('rowClosed', [dtRow]); + }); + } + }; + + var showChildData = function (dtRow) { + if (opts.useRowData) { + showChildDataFromRow(dtRow); + } + else { + $.ajax({ + type: opts.ajax.requestType, + url: opts.ajax.requestUrl, + data: opts.ajax.requestData, + contentType: opts.ajax.contentType, + dataType: opts.ajax.dataType, + success: function (response) { + var data = response; + if (opts.dataCallback) { + data = opts.dataCallback(response); + } + showChild(dtRow, data); + }, + error: function (response) { showChild(dtRow, response); } + }); + } + }; + + var showChildDataFromRow = function(dtRow) { + if (!opts.dataCallback) { return; } // throw error? + var data = opts.dataCallback(dtRow.data()); + showChild(dtRow, data); + } + + var showChild = function(dtRow, data) { + var selectedRow = $(dtRow.node()); + dtRow.child(data).show(); + + $(opts.sliderSelector, dtRow.child()).slideDown(function () { + selectedRow.addClass('shown'); + + $(dt.table().node()).trigger('rowShown', [dtRow]); + }); + }; + }; + + SlidingChild.defaults = { + selector: "tr", + toggleChild: false, + useRowData: false, + ajax: { + requestType: "GET", + requestData: null, + requestUrl: null, + contentType: "application/json; charset=utf-8", + dataType: "json" + }, + dataCallback: null, + sliderSelector: 'div.slider' + }; + + $.fn.dataTable.SlidingChild = SlidingChild; + $.fn.DataTable.SlidingChild = SlidingChild; +}(jQuery)); From bf6d86d4243e0a84a4b1ed94eb6ca445324ac89a Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 14 Jan 2017 10:03:19 +0000 Subject: [PATCH 2/7] Update sliding-child.js Added ajax beforeSend to allow caller to specify data for request. --- features/slidingChild/js/sliding-child.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/features/slidingChild/js/sliding-child.js b/features/slidingChild/js/sliding-child.js index cad0464..14abf5c 100644 --- a/features/slidingChild/js/sliding-child.js +++ b/features/slidingChild/js/sliding-child.js @@ -56,7 +56,11 @@ $.ajax({ type: opts.ajax.requestType, url: opts.ajax.requestUrl, - data: opts.ajax.requestData, + beforeSend: function(xhr, settings) { + if (opts.ajax.getRequestData) { + this.data = opts.ajax.getRequestData(dtRow); + } + }, contentType: opts.ajax.contentType, dataType: opts.ajax.dataType, success: function (response) { From 0edd41aaddfe4c5b2a9ffb7841ae75ec57431d78 Mon Sep 17 00:00:00 2001 From: Nick Date: Sun, 15 Jan 2017 12:11:55 +0000 Subject: [PATCH 3/7] Update sliding-child.js Made some minor naming changes for clarity --- features/slidingChild/js/sliding-child.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/features/slidingChild/js/sliding-child.js b/features/slidingChild/js/sliding-child.js index 14abf5c..d6ff88e 100644 --- a/features/slidingChild/js/sliding-child.js +++ b/features/slidingChild/js/sliding-child.js @@ -1,6 +1,6 @@ /** * @summary SlidingChild - * @description Show/Hide row child data plug-in + * @description Plug-in to show/hide row child data * @version 1.0.0 * @file datatables-slidingchild.js * @author datahandler (www.datahandler.uk) @@ -43,7 +43,7 @@ $(opts.sliderSelector, dtRow.child()).slideUp(function () { dtRow.child.remove(); showingRow.removeClass('shown'); - $(dt.table().node()).trigger('rowClosed', [dtRow]); + $(dt.table().node()).trigger('childClosed', [dtRow]); }); } }; @@ -57,16 +57,16 @@ type: opts.ajax.requestType, url: opts.ajax.requestUrl, beforeSend: function(xhr, settings) { - if (opts.ajax.getRequestData) { - this.data = opts.ajax.getRequestData(dtRow); + if (opts.ajax.requestData) { + this.data = opts.ajax.requestData(dtRow); } }, contentType: opts.ajax.contentType, dataType: opts.ajax.dataType, success: function (response) { var data = response; - if (opts.dataCallback) { - data = opts.dataCallback(response); + if (opts.dataFormatCallback) { + data = opts.dataFormatCallback(response); } showChild(dtRow, data); }, @@ -76,8 +76,8 @@ }; var showChildDataFromRow = function(dtRow) { - if (!opts.dataCallback) { return; } // throw error? - var data = opts.dataCallback(dtRow.data()); + if (!opts.dataFormatCallback) { return; } // throw error? + var data = opts.dataFormatCallback(dtRow.data()); showChild(dtRow, data); } @@ -88,7 +88,7 @@ $(opts.sliderSelector, dtRow.child()).slideDown(function () { selectedRow.addClass('shown'); - $(dt.table().node()).trigger('rowShown', [dtRow]); + $(dt.table().node()).trigger('childShown', [dtRow]); }); }; }; @@ -104,7 +104,7 @@ contentType: "application/json; charset=utf-8", dataType: "json" }, - dataCallback: null, + dataFormatCallback: null, sliderSelector: 'div.slider' }; From 33c4867ef26ad36a649cb321e05cb94fde2db29a Mon Sep 17 00:00:00 2001 From: Nick Date: Sun, 15 Jan 2017 12:23:24 +0000 Subject: [PATCH 4/7] Update sliding-child.js Added example usage comment --- features/slidingChild/js/sliding-child.js | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/features/slidingChild/js/sliding-child.js b/features/slidingChild/js/sliding-child.js index d6ff88e..86fde8d 100644 --- a/features/slidingChild/js/sliding-child.js +++ b/features/slidingChild/js/sliding-child.js @@ -2,12 +2,27 @@ * @summary SlidingChild * @description Plug-in to show/hide row child data * @version 1.0.0 - * @file datatables-slidingchild.js + * @file slidingchild.js * @author datahandler (www.datahandler.uk) * @copyright Copyright 2014 SpryMedia Ltd. * * License MIT - http://datatables.net/license/mit */ + +/** + * Example usage + * @example + * var table = $('#table_id').DataTable(); + * slidingChild = + * new $.fn.dataTable.SlidingChild(table, { + * ajax: { + * requestType: 'POST', + * requestUrl: '/Home/GetChildData', + * dataType: 'HTML', + * requestDataCallback: myRequestDataCallback + * } + * }); + */ (function ($) { var SlidingChild = function (dt, options) { var opts = $.extend({}, SlidingChild.defaults, options); @@ -57,8 +72,8 @@ type: opts.ajax.requestType, url: opts.ajax.requestUrl, beforeSend: function(xhr, settings) { - if (opts.ajax.requestData) { - this.data = opts.ajax.requestData(dtRow); + if (opts.ajax.requestDataCallback) { + this.data = opts.ajax.requestDataCallback(dtRow); } }, contentType: opts.ajax.contentType, @@ -99,7 +114,7 @@ useRowData: false, ajax: { requestType: "GET", - requestData: null, + requestDataCallback: null, requestUrl: null, contentType: "application/json; charset=utf-8", dataType: "json" From b51aa60944148de04eb6bc5b52878ba28771bc57 Mon Sep 17 00:00:00 2001 From: Thibault34 Date: Wed, 5 Apr 2017 10:27:15 +0200 Subject: [PATCH 5/7] Add support dd/mm/YYYY hh:ii --- sorting/date-euro.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sorting/date-euro.js b/sorting/date-euro.js index 758fd5c..83aa8d2 100644 --- a/sorting/date-euro.js +++ b/sorting/date-euro.js @@ -1,5 +1,5 @@ /** - * This plug-in will provide date sorting for the "dd/mm/YYY hh:ii:ss" + * This plug-in will provide date sorting for the "dd/mm/YYYY hh:ii:ss" * formatting, which is common in France and other European countries. It can * also be quickly adapted for other formatting as required. Furthermore, this * date sorting plug-in allows for empty values in the column. @@ -8,8 +8,8 @@ * [datetime](//datatables.net/blog/2014-12-18) plug-in provides enhanced * functionality and flexibility. * - * @name Date (dd/mm/YYY hh:ii:ss) - * @summary Sort date / time in the format `dd/mm/YYY hh:ii:ss` + * @name Date (dd/mm/YYYY hh:ii:ss) + * @summary Sort date / time in the format `dd/mm/YYYY hh:ii:ss` * @author [Ronan Guilloux](http://coolforest.net/) * @deprecated * @@ -29,7 +29,7 @@ var frDatea = $.trim(a).split(' '); var frTimea = (undefined != frDatea[1]) ? frDatea[1].split(':') : [00,00,00]; var frDatea2 = frDatea[0].split('/'); - x = (frDatea2[2] + frDatea2[1] + frDatea2[0] + frTimea[0] + frTimea[1] + frTimea[2]) * 1; + x = (frDatea2[2] + frDatea2[1] + frDatea2[0] + frTimea[0] + frTimea[1] + ((undefined != frTimea[2]) ? frTimea[2] : 0)) * 1; } else { x = Infinity; From ef63e9fa47d58ca84309b892ac22569b0d144e62 Mon Sep 17 00:00:00 2001 From: Talgat Uspanov Date: Mon, 10 Apr 2017 17:41:39 +0600 Subject: [PATCH 6/7] add kazakh lang --- i18n/Kazakh.lang | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 i18n/Kazakh.lang diff --git a/i18n/Kazakh.lang b/i18n/Kazakh.lang new file mode 100644 index 0000000..e78b3de --- /dev/null +++ b/i18n/Kazakh.lang @@ -0,0 +1,28 @@ +/** + * Kazakh translation + * @name Kazakh + * @anchor Kazakh + * @author Talgat Uspanov + */ + { + "processing": "Күте тұрыңыз...", + "search": "Іздеу:", + "lengthMenu": "Жазбалар _MENU_ көрсету", + "info": "_TOTAL_ жазбалары бойынша _START_ бастап _END_ дейінгі жазбалар", + "infoEmpty": "0 жазбалары бойынша 0 бастап 0 дейінгі жазбалар", + "infoFiltered": "(_MAX_ жазбасынан сұрыпталды)", + "infoPostFix": "", + "loadingRecords": "Жазбалар жүктемесі...", + "zeroRecords": "Жазбалар жоқ", + "emptyTable": "Кестеде деректер жоқ", + "paginate": { + "first": "Бірінші", + "previous": "Алдыңғысы", + "next": "Келесі", + "last": "Соңғы" + }, + "aria": { + "sortAscending": ": өсімі бойынша бағанды сұрыптау үшін активациялау", + "sortDescending": ": кемуі бойынша бағанды сұрыптау үшін активациялау" + } +} From 4c6e7545b2e43a58e3ba3e2df1893204fa0ce6e3 Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 13 Apr 2017 18:38:58 +0300 Subject: [PATCH 7/7] Update sliding-child.js --- features/slidingChild/js/sliding-child.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/slidingChild/js/sliding-child.js b/features/slidingChild/js/sliding-child.js index 86fde8d..237815a 100644 --- a/features/slidingChild/js/sliding-child.js +++ b/features/slidingChild/js/sliding-child.js @@ -4,7 +4,7 @@ * @version 1.0.0 * @file slidingchild.js * @author datahandler (www.datahandler.uk) - * @copyright Copyright 2014 SpryMedia Ltd. + * @copyright Copyright datahandler (www.datahandler.uk) * * License MIT - http://datatables.net/license/mit */