Merge branch 'master' of github.com:DataTables/Plugins

pull/384/head
Allan Jardine 6 years ago
commit 19769588b9

@ -0,0 +1,22 @@
/**
* When using `-init deferRender` you might find that under a specific set of circumstances you
* need the `-tag tr` element for a row which hasn't yet been drawn. This method can be used to
* create the nodes for the rows which haven't yet been drawn.
*
* @name rows().generate()
* @summary Create tr elements for rows which have not yet had their nodes created.
* @author [Allan Jardine](http://datatables.net)
* @requires DataTables 1.10+
*
* @returns {DataTable.Api} DataTables API instance
*
* @example
* // Create nodes for all rows
* table.rows().generate();
*/
$.fn.dataTable.Api.register( 'rows().generate()', function () {
return this.iterator( 'row', function ( context, index ) {
context.oApi._fnCreateTr( context, index );
} );
} );

@ -70,7 +70,7 @@
}
};
if ($.isNumeric(config.speed) || $.type(config.speed) === 'string') {
if ( config.speed !== undefined ) {
speed = config.speed;
}

@ -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 )
{
@ -69,7 +95,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;
@ -159,5 +186,5 @@ $(document).on( 'init.dt', function ( e, settings ) {
}
} );
}(jQuery));
}));

@ -2,6 +2,7 @@
PageResize for DataTables v1.0.0
2015 SpryMedia Ltd - datatables.net/license
*/
(function(c){var f=function(a,d){var b=a.table();this.s={dt:a,host:c(b.container()).parent(),header:c(b.header()),footer:c(b.footer()),body:c(b.body()),container:c(b.container()),table:c(b.node()),delta:d};b=this.s.host;"static"===b.css("position")&&b.css("position","relative");this._attach();this._size()};f.prototype={_size:function(){var a=this.s,d=a.dt,b=d.table(),h=c(a.table).offset().top,f=c("tr",a.body).eq(0).height(),e=a.host.height(),i=b.header().parentNode!==b.body().parentNode,g=a.delta;
i||(b.header()&&(e-=a.header.height()),b.footer()&&(e-=a.footer.height()));e=e-h-(a.container.height()-(h+a.table.height()));!isNaN(parseFloat(g))&&isFinite(g)&&(e-=g);a=Math.floor(e/f);Infinity!==a&&(-Infinity!==a&&!isNaN(a)&&0<a&&a!==d.page.len())&&d.page.len(a).draw()},_attach:function(){var a=this,d=c("<object/>").css({position:"absolute",top:0,left:0,height:"100%",width:"100%",zIndex:-1}).attr("type","text/html");d[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())}};d.appendTo(this.s.host).attr("data","about:blank")}};c.fn.dataTable.PageResize=f;c.fn.DataTable.PageResize=f;c(document).on("init.dt",function(a,d){if("dt"===a.namespace){var b=new c.fn.dataTable.Api(d);(c(b.table().node()).hasClass("pageResize")||d.oInit.pageResize||c.fn.dataTable.defaults.pageResize)&&new f(b,d.oInit.pageResizeManualDelta)}})})(jQuery);
(function(b){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(e){return b(e,window,document)}):"object"===typeof exports?module.exports=function(e,c){e||(e=window);if(!c||!c.fn.dataTable)c=require("datatables.net")(e,c).$;return b(c,e,e.document)}:b(jQuery,window,document)})(function(b,e,c){var g=function(a,h){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:h};d=this.s.host;"static"===d.css("position")&&d.css("position","relative");this._attach();this._size()};g.prototype={_size:function(){var a=this.s,h=a.dt,d=h.table(),e=b(a.table).offset().top,c=b("tr",a.body),c=c.eq(1<c.length?1:0).height(),f=a.host.height(),g=d.header().parentNode!==d.body().parentNode,i=a.delta;g||(d.header()&&(f-=a.header.height()),d.footer()&&(f-=a.footer.height()));f=f-e-(a.container.height()-(e+a.table.height()));!isNaN(parseFloat(i))&&isFinite(i)&&(f-=i);a=Math.floor(f/
c);Infinity!==a&&(-Infinity!==a&&!isNaN(a)&&0<a&&a!==h.page.len())&&h.page.len(a).draw()},_attach:function(){var a=this,c=b("<object/>").css({position:"absolute",top:0,left:0,height:"100%",width:"100%",zIndex:-1}).attr("type","text/html");c[0].onload=function(){var d=this.contentDocument.body,b=d.offsetHeight;this.contentDocument.defaultView.onresize=function(){var c=d.clientHeight||d.offsetHeight;c!==b&&(b=c,a._size())}};c.appendTo(this.s.host).attr("data","about:blank")}};b.fn.dataTable.PageResize=
g;b.fn.DataTable.PageResize=g;b(c).on("init.dt",function(a,c){if("dt"===a.namespace){var d=new b.fn.dataTable.Api(c);(b(d.table().node()).hasClass("pageResize")||c.oInit.pageResize||b.fn.dataTable.defaults.pageResize)&&new g(d,c.oInit.pageResizeManualDelta)}})});

@ -5,7 +5,7 @@
<title>DataTables page resize example</title>
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.6/css/jquery.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.6/css/jquery.dataTables.min.css">
<style type="text/css">
div.container {
margin: 0 auto;
@ -47,8 +47,8 @@
}
</style>
<script type="text/javascript" language="javascript" src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript" language="javascript" src="//cdn.datatables.net/1.10.6/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" language="javascript" src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript" language="javascript" src="https://cdn.datatables.net/1.10.6/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" language="javascript" src="dataTables.pageResize.js"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready( function () {

@ -5,7 +5,7 @@
<title>DataTables page resize example</title>
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.6/css/jquery.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.6/css/jquery.dataTables.min.css">
<style type="text/css">
div.container {
margin: 0 auto;
@ -47,8 +47,8 @@
}
</style>
<script type="text/javascript" language="javascript" src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript" language="javascript" src="//cdn.datatables.net/1.10.6/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" language="javascript" src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript" language="javascript" src="https://cdn.datatables.net/1.10.6/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" language="javascript" src="dataTables.pageResize.js"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready( function () {

@ -30,8 +30,34 @@
* * Creating a new instance: `new $.fn.dataTable.ScrollResize( table );` where
* `table` is a DataTable's API instance.
*/
(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 ScrollResize = function ( dt )
{
@ -152,5 +178,4 @@ $(document).on( 'init.dt', function ( e, settings ) {
}
} );
}(jQuery));
}));

@ -2,6 +2,7 @@
ScrollResize for DataTables v1.0.0
2015 SpryMedia Ltd - datatables.net/license
*/
(function(a){var e=function(d){var c=this,b=d.table();this.s={dt:d,host:a(b.container()).parent(),header:a(b.header()),footer:a(b.footer()),body:a(b.body()),container:a(b.container()),table:a(b.node())};b=this.s.host;"static"===b.css("position")&&b.css("position","relative");d.on("draw",function(){c._size()});this._attach();this._size()};e.prototype={_size:function(){var d=this.s,c=d.dt,b=c.table(),h=a(d.table).offset().top,g=d.host.height(),f=a("div.dataTables_scrollBody",b.container()),g=g-h-(d.container.height()-
(h+f.height()));a("div.dataTables_scrollBody",b.container()).css({maxHeight:g,height:g});c.fixedColumns&&c.fixedColumns().relayout()},_attach:function(){var d=this,c=a("<iframe/>").css({position:"absolute",top:0,left:0,height:"100%",width:"100%",zIndex:-1,border:0}).attr("frameBorder","0").attr("src","about:blank");c[0].onload=function(){var b=this.contentDocument.body,a=b.offsetHeight,c=this.contentDocument;(c.defaultView||c.parentWindow).onresize=function(){var f=b.clientHeight||b.offsetHeight,
e=c.documentElement.clientHeight;!f&&e&&(f=e);f!==a&&(a=f,d._size())}};c.appendTo(this.s.host).attr("data","about:blank")}};a.fn.dataTable.ScrollResize=e;a.fn.DataTable.ScrollResize=e;a(document).on("init.dt",function(d,c){if("dt"===d.namespace){var b=new a.fn.dataTable.Api(c);(c.oInit.scrollResize||a.fn.dataTable.defaults.scrollResize)&&new e(b)}})})(jQuery);
(function(a){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(b){return a(b,window,document)}):"object"===typeof exports?module.exports=function(b,c){b||(b=window);if(!c||!c.fn.dataTable)c=require("datatables.net")(b,c).$;return a(c,b,b.document)}:a(jQuery,window,document)})(function(a,b,c){var g=function(e){var f=this,d=e.table();this.s={dt:e,host:a(d.container()).parent(),header:a(d.header()),footer:a(d.footer()),body:a(d.body()),container:a(d.container()),table:a(d.node())};
d=this.s.host;"static"===d.css("position")&&d.css("position","relative");e.on("draw",function(){f._size()});this._attach();this._size()};g.prototype={_size:function(){var e=this.s,f=e.dt,d=f.table(),b=a(e.table).offset().top,h=e.host.height(),c=a("div.dataTables_scrollBody",d.container()),h=h-b-(e.container.height()-(b+c.height()));a("div.dataTables_scrollBody",d.container()).css({maxHeight:h,height:h});f.fixedColumns&&f.fixedColumns().relayout()},_attach:function(){var e=this,b=a("<iframe/>").css({position:"absolute",
top:0,left:0,height:"100%",width:"100%",zIndex:-1,border:0}).attr("frameBorder","0").attr("src","about:blank");b[0].onload=function(){var a=this.contentDocument.body,b=a.offsetHeight,c=this.contentDocument;(c.defaultView||c.parentWindow).onresize=function(){var f=a.clientHeight||a.offsetHeight,g=c.documentElement.clientHeight;!f&&g&&(f=g);f!==b&&(b=f,e._size())}};b.appendTo(this.s.host).attr("data","about:blank")}};a.fn.dataTable.ScrollResize=g;a.fn.DataTable.ScrollResize=g;a(c).on("init.dt",function(b,
c){if("dt"===b.namespace){var d=new a.fn.dataTable.Api(c);(c.oInit.scrollResize||a.fn.dataTable.defaults.scrollResize)&&new g(d)}})});

@ -0,0 +1,245 @@
/**
* @summary SlidingChild
* @description Show / Hide row child plugin
* @version 2.0.1
* @file dataTables.slidingChild.js
* @author Nick Adkinson (https://github.com/data-handler)
* @copyright Copyright 2018 Nick Adkinson
*
* License MIT - http://datatables.net/license/mit
*
* This feature plug-in provides functionality for showing and hiding row child
* information in DataTables. This can be particularly useful for displaying
* hierarchical data as a drill-down, or where you wish to convey more information
* about a row than there is space for in the host table.
*
* @example
* $('#myTable').DataTable({
* slidingChild: {
* source: function(parent, response) {
* $.get('/Child/GetByParentId/' + parent.data('id'), response);
* }
* }
* });
*
*/
(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, document );
}
}(function( $, document ) {
'use strict';
var SlidingChild = function (dt, options)
{
var that = this;
dt.on('draw', function() {
that._updateFadedRows();
});
var table = dt.table();
var sliderElement = document.createElement('div');
sliderElement.className = 'slider';
this.s = $.extend({},
{
dt: dt,
table: $(table.node()),
slider: $(sliderElement)
},
SlidingChild.defaults,
options
);
this._bind();
};
SlidingChild.prototype = {
_bind: function() {
var that = this;
var settings = that.s;
$(settings.table, '> tbody').on('click', settings.selector, function() {
var $this = $(this);
var tr = $this.is('tr') ? $this : $this.closest('tr');
if (!tr.is('tr')) { return; } // throw error?
var dtRow = settings.dt.row(tr);
that._toggleChild(dtRow);
});
},
_toggleChild: function(dtRow) {
var settings = this.s;
if (dtRow.child.isShown()) {
this._hideChild(dtRow, function() {});
} else {
var existingShownDtRow = settings.dt.row('.shown');
if (existingShownDtRow.length && settings.toggle) {
this._hideChild(existingShownDtRow, this._showChildCallback(dtRow));
} else {
this._showChild(dtRow);
}
}
},
_showChildCallback: function(dtRow) {
return function( dtRow ) {
this._showChild(dtRow);
}.bind( this, dtRow );
},
_showChild: function(dtRow) {
this.s.source( $(dtRow.node() ), this._response(dtRow) );
},
_response: function(dtRow) {
return function( dtRow, childData ) {
this.__showChild( dtRow, childData );
}.bind( this, dtRow );
},
__showChild: function(dtRow, data) {
var settings = this.s;
var slider = settings.slider;
slider.append(data);
dtRow.child(slider, settings.childClass).show();
$(dtRow.node()).toggleClass('shown');
this._updateFadedRows();
if (settings.animateShow) {
this._showChildWithAnimation(dtRow);
} else {
this._showChildWithoutAnimation(dtRow);
}
},
_showChildWithAnimation: function(dtRow) {
var settings = this.s;
$(settings.slider, dtRow.child()).slideDown(settings.animationSpeed, function () {
settings.onShown(dtRow);
});
},
_showChildWithoutAnimation: function(dtRow) {
var settings = this.s;
$(settings.slider, dtRow.child()).show();
settings.onShown(dtRow);
},
_hideChild: function(dtRow, callback) {
var settings = this.s;
$(dtRow.node()).toggleClass('shown');
this._updateFadedRows();
if (settings.animateHide) {
this._hideChildWithAnimation(dtRow, callback);
} else {
this._hideChildWithoutAnimation(dtRow, callback);
}
},
_hideChildWithAnimation: function(dtRow, callback) {
var settings = this.s;
var slider = settings.slider;
$(slider, dtRow.child()).slideUp(settings.animationSpeed, function () {
dtRow.child.remove();
slider.empty();
settings.onHidden(dtRow);
callback();
});
},
_hideChildWithoutAnimation: function(dtRow, callback) {
var settings = this.s;
var slider = settings.slider;
$(slider, dtRow.child()).hide();
dtRow.child.remove();
slider.empty();
settings.onHidden(dtRow);
callback();
},
_updateFadedRows: function() {
if (this.s.fadeNonShowingRows) {
this._fadeNonShowingRows();
this._removeFadeFromShowingRows();
} else {
this._removeFadeFromRows();
}
},
_fadeNonShowingRows: function() {
if (this.s.dt.rows('.shown:visible').count()) {
this.s.dt.rows(':visible:not(.shown):not(.faded)')
.nodes()
.to$()
.css('opacity', this.s.fadeOpacity)
.addClass('faded');
} else {
this._removeFadeFromRows();
}
},
_removeFadeFromShowingRows: function() {
this.s.dt.rows('.shown.faded:visible')
.nodes()
.to$()
.css('opacity', 1)
.removeClass('faded');
},
_removeFadeFromRows: function() {
this.s.dt.rows('.faded')
.nodes()
.to$()
.css('opacity', 1)
.removeClass('faded');
}
};
SlidingChild.defaults = {
selector: "tr",
childClass: 'child',
source: function() {},
toggle: true,
animateShow: true,
animateHide: true,
fadeNonShowingRows: false,
fadeOpacity: 0.4,
animationSpeed: 200,
onShown: function() {},
onHidden: function() {}
};
$.fn.dataTable.SlidingChild = SlidingChild;
$.fn.DataTable.SlidingChild = SlidingChild;
// Automatic initialisation listener
$(document).on( 'init.dt', function ( e, settings ) {
if ( e.namespace !== 'dt' ) {
return;
}
var api = new $.fn.dataTable.Api( settings );
if ( $( api.table().node() ).hasClass( 'slidingChild' ) ||
settings.oInit.slidingChild ||
$.fn.dataTable.defaults.slidingChild )
{
new SlidingChild( api, settings.oInit.slidingChild );
}
} );
}));

@ -0,0 +1,7 @@
(function(d){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(f){return d(f,window,document)}):"object"===typeof exports?module.exports=function(f,e){f||(f=window);if(!e||!e.fn.dataTable)e=require("datatables.net")(f,e).$;return d(e,f,f.document)}:d(jQuery,document)})(function(d,f){var e=function(a,c){var b=this;a.on("draw",function(){b._updateFadedRows()});var h=a.table(),g=f.createElement("div");g.className="slider";this.s=d.extend({},{dt:a,table:d(h.node()),slider:d(g)},
e.defaults,c);this._bind()};e.prototype={_bind:function(){var a=this,c=a.s;d(c.table,"> tbody").on("click",c.selector,function(){var b=d(this),b=b.is("tr")?b:b.closest("tr");b.is("tr")&&(b=c.dt.row(b),a._toggleChild(b))})},_toggleChild:function(a){var c=this.s;if(a.child.isShown())this._hideChild(a,function(){});else{var b=c.dt.row(".shown");b.length&&c.toggle?this._hideChild(b,this._showChildCallback(a)):this._showChild(a)}},_showChildCallback:function(a){return function(a){this._showChild(a)}.bind(this,
a)},_showChild:function(a){this.s.source(d(a.node()),this._response(a))},_response:function(a){return function(a,b){this.__showChild(a,b)}.bind(this,a)},__showChild:function(a,c){var b=this.s,e=b.slider;e.append(c);a.child(e,b.childClass).show();d(a.node()).toggleClass("shown");this._updateFadedRows();b.animateShow?this._showChildWithAnimation(a):this._showChildWithoutAnimation(a)},_showChildWithAnimation:function(a){var c=this.s;d(c.slider,a.child()).slideDown(c.animationSpeed,function(){c.onShown(a)})},
_showChildWithoutAnimation:function(a){var c=this.s;d(c.slider,a.child()).show();c.onShown(a)},_hideChild:function(a,c){var b=this.s;d(a.node()).toggleClass("shown");this._updateFadedRows();b.animateHide?this._hideChildWithAnimation(a,c):this._hideChildWithoutAnimation(a,c)},_hideChildWithAnimation:function(a,c){var b=this.s,e=b.slider;d(e,a.child()).slideUp(b.animationSpeed,function(){a.child.remove();e.empty();b.onHidden(a);c()})},_hideChildWithoutAnimation:function(a,c){var b=this.s,e=b.slider;
d(e,a.child()).hide();a.child.remove();e.empty();b.onHidden(a);c()},_updateFadedRows:function(){this.s.fadeNonShowingRows?(this._fadeNonShowingRows(),this._removeFadeFromShowingRows()):this._removeFadeFromRows()},_fadeNonShowingRows:function(){this.s.dt.rows(".shown:visible").count()?this.s.dt.rows(":visible:not(.shown):not(.faded)").nodes().to$().css("opacity",this.s.fadeOpacity).addClass("faded"):this._removeFadeFromRows()},_removeFadeFromShowingRows:function(){this.s.dt.rows(".shown.faded:visible").nodes().to$().css("opacity",
1).removeClass("faded")},_removeFadeFromRows:function(){this.s.dt.rows(".faded").nodes().to$().css("opacity",1).removeClass("faded")}};e.defaults={selector:"tr",childClass:"child",source:function(){},toggle:!0,animateShow:!0,animateHide:!0,fadeNonShowingRows:!1,fadeOpacity:0.4,animationSpeed:200,onShown:function(){},onHidden:function(){}};d.fn.dataTable.SlidingChild=e;d.fn.DataTable.SlidingChild=e;d(f).on("init.dt",function(a,c){if("dt"===a.namespace){var b=new d.fn.dataTable.Api(c);(d(b.table().node()).hasClass("slidingChild")||
c.oInit.slidingChild||d.fn.dataTable.defaults.slidingChild)&&new e(b,c.oInit.slidingChild)}})});

@ -1,128 +0,0 @@
/**
* @summary SlidingChild
* @description Plug-in to show/hide row child data
* @version 1.0.0
* @file slidingchild.js
* @author datahandler (www.datahandler.uk)
* @copyright Copyright datahandler (www.datahandler.uk)
*
* 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);
// 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('childClosed', [dtRow]);
});
}
};
var showChildData = function (dtRow) {
if (opts.useRowData) {
showChildDataFromRow(dtRow);
}
else {
$.ajax({
type: opts.ajax.requestType,
url: opts.ajax.requestUrl,
beforeSend: function(xhr, settings) {
if (opts.ajax.requestDataCallback) {
this.data = opts.ajax.requestDataCallback(dtRow);
}
},
contentType: opts.ajax.contentType,
dataType: opts.ajax.dataType,
success: function (response) {
var data = response;
if (opts.dataFormatCallback) {
data = opts.dataFormatCallback(response);
}
showChild(dtRow, data);
},
error: function (response) { showChild(dtRow, response); }
});
}
};
var showChildDataFromRow = function(dtRow) {
if (!opts.dataFormatCallback) { return; } // throw error?
var data = opts.dataFormatCallback(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('childShown', [dtRow]);
});
};
};
SlidingChild.defaults = {
selector: "tr",
toggleChild: false,
useRowData: false,
ajax: {
requestType: "GET",
requestDataCallback: null,
requestUrl: null,
contentType: "application/json; charset=utf-8",
dataType: "json"
},
dataFormatCallback: null,
sliderSelector: 'div.slider'
};
$.fn.dataTable.SlidingChild = SlidingChild;
$.fn.DataTable.SlidingChild = SlidingChild;
}(jQuery));

@ -25,5 +25,12 @@
"oAria": {
"sSortAscending": ": activer pour trier la colonne par ordre croissant",
"sSortDescending": ": activer pour trier la colonne par ordre d&eacute;croissant"
},
"select": {
"rows": {
_: "%d lignes séléctionnées",
0: "Aucune ligne séléctionnée",
1: "1 ligne séléctionnée"
}
}
}

@ -30,11 +30,11 @@
"sSortDescending": ": aktivieren, um Spalte absteigend zu sortieren"
},
"select": {
"rows": {
"rows": {
"_": "%d Zeilen ausgewählt",
"0": "Zum Auswählen auf eine Zeile klicken",
"0": "",
"1": "1 Zeile ausgewählt"
}
}
},
"buttons": {
"print": "Drucken",

@ -6,6 +6,7 @@
*/
{
"sEmptyTable": "Tidak ada data yang tersedia pada tabel ini",
"sProcessing": "Sedang memproses...",
"sLengthMenu": "Tampilkan _MENU_ entri",
"sZeroRecords": "Tidak ditemukan data yang sesuai",
@ -21,4 +22,4 @@
"sNext": "Selanjutnya",
"sLast": "Terakhir"
}
}
}

@ -27,5 +27,12 @@
"oAria": {
"sSortAscending": ": artan sütun sıralamasını aktifleştir",
"sSortDescending": ": azalan sütun sıralamasını aktifleştir"
},
"select": {
"rows": {
"_": "%d kayıt seçildi",
"0": "",
"1": "1 kayıt seçildi"
}
}
}

@ -30,6 +30,8 @@ scss_compile $DT_SRC/extensions/Plugins/features/searchPane/dataTables.searchPan
js_compress $DT_SRC/extensions/Plugins/features/searchFade/dataTables.searchFade.js
css_compress $DT_SRC/extensions/Plugins/features/searchFade/dataTables.searchFade
js_compress $DT_SRC/extensions/Plugins/features/slidingChild/dataTables.slidingChild.js
# Only copying the integration files
rsync -r integration $OUT_DIR

@ -98,7 +98,13 @@ var _setup = function ( values ) {
// Ascending ordering method
o.asc = function ( a, b, isNumber ) {
if ( o.alwaysTop[ a ] || o.alwaysBottom[ b ] ) {
if ( o.alwaysTop[ a ] && o.alwaysTop[ b ] ) {
return 0;
}
else if ( o.alwaysBottom[ a ] && o.alwaysBottom[ b ] ) {
return 0;
}
else if ( o.alwaysTop[ a ] || o.alwaysBottom[ b ] ) {
return -1;
}
else if ( o.alwaysBottom[ a ] || o.alwaysTop[ b ] ) {
@ -120,7 +126,13 @@ var _setup = function ( values ) {
// Descending ordering method
o.desc = function ( a, b, isNumber ) {
if ( o.alwaysTop[ a ] || o.alwaysBottom[ b ] ) {
if ( o.alwaysTop[ a ] && o.alwaysTop[ b ] ) {
return 0;
}
else if ( o.alwaysBottom[ a ] && o.alwaysBottom[ b ] ) {
return 0;
}
else if ( o.alwaysTop[ a ] || o.alwaysBottom[ b ] ) {
return -1;
}
else if ( o.alwaysBottom[ a ] || o.alwaysTop[ b ] ) {

@ -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;
}
});

@ -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;
}
);

Loading…
Cancel
Save