From eb73ee5dbb2f16952d908c322cff7ff6486766cb Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 16 Jun 2018 10:27:06 +0100 Subject: [PATCH 1/3] Update datatables.slidingChild.js New option name: displayLoadingIndicator type: boolean default: false description: if set to true, overlays the parent row with a div (see below) before requesting the child source, then removes the overlay before showing the child data. Overlay options name: loadingIndicatorClass type: string default: 'loading-indicator' name: loadingOverlayContent type: string, element, jQuery object default: '
Loading...
' --- .../slidingChild/datatables.slidingChild.js | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/features/slidingChild/datatables.slidingChild.js b/features/slidingChild/datatables.slidingChild.js index 10951ad..cfd23db 100644 --- a/features/slidingChild/datatables.slidingChild.js +++ b/features/slidingChild/datatables.slidingChild.js @@ -107,6 +107,10 @@ SlidingChild.prototype = { }.bind( this, dtRow ); }, _showChild: function(dtRow) { + var $tr = $(dtRow.node()); + if (this.s.displayLoadingIndicator) { + this._addLoadingIndicator($tr); + } this.s.source( $(dtRow.node() ), this._response(dtRow) ); }, _response: function(dtRow) { @@ -117,11 +121,16 @@ SlidingChild.prototype = { __showChild: function(dtRow, data) { var settings = this.s; var slider = settings.slider; + var $tr = $(dtRow.node()); + + if (settings.displayLoadingIndicator) { + $('.'+this.s.loadingIndicatorClass).remove(); + } slider.append(data); dtRow.child(slider, settings.childClass).show(); - $(dtRow.node()).toggleClass('shown'); + $tr.toggleClass('shown'); this._updateFadedRows(); if (settings.animateShow) { @@ -204,6 +213,16 @@ SlidingChild.prototype = { .to$() .css('opacity', 1) .removeClass('faded'); + }, + _addLoadingIndicator: function($tr) { + var position = $tr.position(); + var indicator = $(this.s.loadingIndicatorContent); + indicator.addClass(this.s.loadingIndicatorClass); + indicator.css('top', position.top); + indicator.css('left', position.left); + indicator.css('height', $tr.height()); + + $tr.append(indicator); } }; @@ -218,7 +237,10 @@ SlidingChild.defaults = { fadeOpacity: 0.4, animationSpeed: 200, onShown: function() {}, - onHidden: function() {} + onHidden: function() {}, + displayLoadingIndicator: false, + loadingIndicatorClass: 'loading-indicator', + loadingIndicatorContent: '
Loading...
' }; From e2331ddd5084120594c9e517434963e908e48c0f Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 16 Jun 2018 10:30:17 +0100 Subject: [PATCH 2/3] Update datatables.slidingChild.js removed duplicate jQuery call --- features/slidingChild/datatables.slidingChild.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/slidingChild/datatables.slidingChild.js b/features/slidingChild/datatables.slidingChild.js index cfd23db..5bb8331 100644 --- a/features/slidingChild/datatables.slidingChild.js +++ b/features/slidingChild/datatables.slidingChild.js @@ -111,7 +111,7 @@ SlidingChild.prototype = { if (this.s.displayLoadingIndicator) { this._addLoadingIndicator($tr); } - this.s.source( $(dtRow.node() ), this._response(dtRow) ); + this.s.source( $tr, this._response(dtRow) ); }, _response: function(dtRow) { return function( dtRow, childData ) { From 22fa64dc46226abdcdc47fdac9c3cbc45480a5cf Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 16 Jun 2018 10:31:11 +0100 Subject: [PATCH 3/3] Update datatables.slidingChild.js version number updated --- features/slidingChild/datatables.slidingChild.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/slidingChild/datatables.slidingChild.js b/features/slidingChild/datatables.slidingChild.js index 5bb8331..2c23b65 100644 --- a/features/slidingChild/datatables.slidingChild.js +++ b/features/slidingChild/datatables.slidingChild.js @@ -1,7 +1,7 @@ /** * @summary SlidingChild * @description Show / Hide row child plugin - * @version 2.0.1 + * @version 2.0.2 * @file dataTables.slidingChild.js * @author Nick Adkinson (https://github.com/data-handler) * @copyright Copyright 2018 Nick Adkinson