You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Plugins/features/slidingChild/datatables.slidingChild.min.js

2 lines
4.1 KiB
JavaScript

/*! © Nick Adkinson, SpryMedia Ltd - datatables.net/license */
!function(t){var n,e;"function"==typeof define&&define.amd?define(["jquery","datatables.net"],function(i){return t(i,window,document)}):"object"==typeof exports?(n=require("jquery"),e=function(i,o){o.fn.dataTable||require("datatables.net")(i,o)},"undefined"!=typeof window?module.exports=function(i,o){return i=i||window,o=o||n(i),e(i,o),t(o,0,i.document)}:(e(window,n),module.exports=t(n,window,window.document))):t(jQuery,window,document)}(function(d,i,s,o){"use strict";function a(i,o){var t=this,n=(i.on("draw",function(){t._updateFadedRows()}),i.table()),e=s.createElement("div");e.className="slider",this.s=d.extend({},{dt:i,table:d(n.node()),slider:d(e)},a.defaults,o),this._bind()}var t=d.fn.dataTable;a.prototype._bind=function(){var o=this,t=o.s;d(t.table,"> tbody").on("click",t.selector,function(){var i=d(this),i=i.is("tr")?i:i.closest("tr");i.is("tr")&&(i=t.dt.row(i),o._toggleChild(i))})},a.prototype._toggleChild=function(i){var o,t=this.s;i.child.isShown()?this._hideChild(i,function(){}):(o=t.dt.row(".shown")).length&&t.toggle?this._hideChild(o,this._showChildCallback(i)):this._showChild(i)},a.prototype._showChildCallback=function(i){return function(i){this._showChild(i)}.bind(this,i)},a.prototype._showChild=function(i){var o=d(i.node());this.s.displayLoadingIndicator&&this._addLoadingIndicator(o),this.s.source(o,this._response(i))},a.prototype._response=function(i){return function(i,o){this.__showChild(i,o)}.bind(this,i)},a.prototype.__showChild=function(i,o){var t=this.s,n=t.slider,e=d(i.node());t.displayLoadingIndicator&&d("."+this.s.loadingIndicatorClass).remove(),n.append(o),i.child(n,t.childClass).show(),e.toggleClass("shown"),this._updateFadedRows(),t.animateShow?this._showChildWithAnimation(i):this._showChildWithoutAnimation(i)},a.prototype._showChildWithAnimation=function(i){var o=this.s;d(o.slider,i.child()).slideDown(o.animationSpeed,function(){o.onShown(i)})},a.prototype._showChildWithoutAnimation=function(i){var o=this.s;d(o.slider,i.child()).show(),o.onShown(i)},a.prototype._hideChild=function(i,o){var t=this.s;d(i.node()).toggleClass("shown"),this._updateFadedRows(),t.animateHide?this._hideChildWithAnimation(i,o):this._hideChildWithoutAnimation(i,o)},a.prototype._hideChildWithAnimation=function(i,o){var t=this.s,n=t.slider;d(n,i.child()).slideUp(t.animationSpeed,function(){i.child.remove(),n.empty(),t.onHidden(i),o()})},a.prototype._hideChildWithoutAnimation=function(i,o){var t=this.s,n=t.slider;d(n,i.child()).hide(),i.child.remove(),n.empty(),t.onHidden(i),o()},a.prototype._updateFadedRows=function(){this.s.fadeNonShowingRows?(this._fadeNonShowingRows(),this._removeFadeFromShowingRows()):this._removeFadeFromRows()},a.prototype._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()},a.prototype._removeFadeFromShowingRows=function(){this.s.dt.rows(".shown.faded:visible").nodes().to$().css("opacity",1).removeClass("faded")},a.prototype._removeFadeFromRows=function(){this.s.dt.rows(".faded").nodes().to$().css("opacity",1).removeClass("faded")},a.prototype._addLoadingIndicator=function(i){var o=i.position(),t=d(this.s.loadingIndicatorContent);t.addClass(this.s.loadingIndicatorClass),t.css("top",o.top),t.css("left",o.left),t.css("height",i.height()),i.append(t)};return a.defaults={selector:"tr",childClass:"child",source:function(){},toggle:!0,animateShow:!0,animateHide:!0,fadeNonShowingRows:!1,fadeOpacity:.4,animationSpeed:200,onShown:function(){},onHidden:function(){},displayLoadingIndicator:!1,loadingIndicatorClass:"loading-indicator",loadingIndicatorContent:'<div style="background: black; color: white; display: flex; align-items: center; justify-content: center; opacity: 0.5; position: absolute; width: 100%; z-index: 100;">Loading...</div>'},t.SlidingChild=a,d(s).on("init.dt",function(i,o){"dt"===i.namespace&&(i=new t.Api(o),d(i.table().node()).hasClass("slidingChild")||o.oInit.slidingChild||t.defaults.slidingChild)&&new a(i,o.oInit.slidingChild)