diff options
author | AlisaLinUwU <alisalinuwu@gmail.com> | 2025-01-26 10:42:28 +0500 |
---|---|---|
committer | AlisaLinUwU <alisalinuwu@gmail.com> | 2025-01-26 10:42:28 +0500 |
commit | 0225bdb772d1334cc1aa7ab0fc3678df0864df6b (patch) | |
tree | 85a8c8e4fcf1d935fcbad54886b73410c8cb2e26 /src/main/resources/static/plugins/datatables-responsive |
Initializemain
Diffstat (limited to 'src/main/resources/static/plugins/datatables-responsive')
6 files changed, 1805 insertions, 0 deletions
diff --git a/src/main/resources/static/plugins/datatables-responsive/css/responsive.bootstrap4.css b/src/main/resources/static/plugins/datatables-responsive/css/responsive.bootstrap4.css new file mode 100644 index 0000000..7152fc3 --- /dev/null +++ b/src/main/resources/static/plugins/datatables-responsive/css/responsive.bootstrap4.css @@ -0,0 +1,185 @@ +table.dataTable.dtr-inline.collapsed > tbody > tr > td.child, +table.dataTable.dtr-inline.collapsed > tbody > tr > th.child, +table.dataTable.dtr-inline.collapsed > tbody > tr > td.dataTables_empty { + cursor: default !important; +} +table.dataTable.dtr-inline.collapsed > tbody > tr > td.child:before, +table.dataTable.dtr-inline.collapsed > tbody > tr > th.child:before, +table.dataTable.dtr-inline.collapsed > tbody > tr > td.dataTables_empty:before { + display: none !important; +} +table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control, +table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control { + position: relative; + padding-left: 30px; + cursor: pointer; +} +table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control:before, +table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control:before { + top: 50%; + left: 5px; + height: 1em; + width: 1em; + margin-top: -9px; + display: block; + position: absolute; + color: white; + border: 0.15em solid white; + border-radius: 1em; + box-shadow: 0 0 0.2em #444; + box-sizing: content-box; + text-align: center; + text-indent: 0 !important; + font-family: "Courier New", Courier, monospace; + line-height: 1em; + content: "+"; + background-color: #0275d8; +} +table.dataTable.dtr-inline.collapsed > tbody > tr.parent > td.dtr-control:before, +table.dataTable.dtr-inline.collapsed > tbody > tr.parent > th.dtr-control:before { + content: "-"; + background-color: #d33333; +} +table.dataTable.dtr-inline.collapsed.compact > tbody > tr > td.dtr-control, +table.dataTable.dtr-inline.collapsed.compact > tbody > tr > th.dtr-control { + padding-left: 27px; +} +table.dataTable.dtr-inline.collapsed.compact > tbody > tr > td.dtr-control:before, +table.dataTable.dtr-inline.collapsed.compact > tbody > tr > th.dtr-control:before { + left: 4px; + height: 14px; + width: 14px; + border-radius: 14px; + line-height: 14px; + text-indent: 3px; +} +table.dataTable.dtr-column > tbody > tr > td.dtr-control, +table.dataTable.dtr-column > tbody > tr > th.dtr-control, +table.dataTable.dtr-column > tbody > tr > td.control, +table.dataTable.dtr-column > tbody > tr > th.control { + position: relative; + cursor: pointer; +} +table.dataTable.dtr-column > tbody > tr > td.dtr-control:before, +table.dataTable.dtr-column > tbody > tr > th.dtr-control:before, +table.dataTable.dtr-column > tbody > tr > td.control:before, +table.dataTable.dtr-column > tbody > tr > th.control:before { + top: 50%; + left: 50%; + height: 0.8em; + width: 0.8em; + margin-top: -0.5em; + margin-left: -0.5em; + display: block; + position: absolute; + color: white; + border: 0.15em solid white; + border-radius: 1em; + box-shadow: 0 0 0.2em #444; + box-sizing: content-box; + text-align: center; + text-indent: 0 !important; + font-family: "Courier New", Courier, monospace; + line-height: 1em; + content: "+"; + background-color: #0275d8; +} +table.dataTable.dtr-column > tbody > tr.parent td.dtr-control:before, +table.dataTable.dtr-column > tbody > tr.parent th.dtr-control:before, +table.dataTable.dtr-column > tbody > tr.parent td.control:before, +table.dataTable.dtr-column > tbody > tr.parent th.control:before { + content: "-"; + background-color: #d33333; +} +table.dataTable > tbody > tr.child { + padding: 0.5em 1em; +} +table.dataTable > tbody > tr.child:hover { + background: transparent !important; +} +table.dataTable > tbody > tr.child ul.dtr-details { + display: inline-block; + list-style-type: none; + margin: 0; + padding: 0; +} +table.dataTable > tbody > tr.child ul.dtr-details > li { + border-bottom: 1px solid #efefef; + padding: 0.5em 0; +} +table.dataTable > tbody > tr.child ul.dtr-details > li:first-child { + padding-top: 0; +} +table.dataTable > tbody > tr.child ul.dtr-details > li:last-child { + border-bottom: none; +} +table.dataTable > tbody > tr.child span.dtr-title { + display: inline-block; + min-width: 75px; + font-weight: bold; +} +div.dtr-modal { + position: fixed; + box-sizing: border-box; + top: 0; + left: 0; + height: 100%; + width: 100%; + z-index: 100; + padding: 10em 1em; +} +div.dtr-modal div.dtr-modal-display { + position: absolute; + top: 0; + left: 0; + bottom: 0; + right: 0; + width: 50%; + height: 50%; + overflow: auto; + margin: auto; + z-index: 102; + overflow: auto; + background-color: #f5f5f7; + border: 1px solid black; + border-radius: 0.5em; + box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6); +} +div.dtr-modal div.dtr-modal-content { + position: relative; + padding: 1em; +} +div.dtr-modal div.dtr-modal-close { + position: absolute; + top: 6px; + right: 6px; + width: 22px; + height: 22px; + border: 1px solid #eaeaea; + background-color: #f9f9f9; + text-align: center; + border-radius: 3px; + cursor: pointer; + z-index: 12; +} +div.dtr-modal div.dtr-modal-close:hover { + background-color: #eaeaea; +} +div.dtr-modal div.dtr-modal-background { + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + z-index: 101; + background: rgba(0, 0, 0, 0.6); +} + +@media screen and (max-width: 767px) { + div.dtr-modal div.dtr-modal-display { + width: 95%; + } +} +div.dtr-bs-modal table.table tr:first-child td { + border-top: none; +} diff --git a/src/main/resources/static/plugins/datatables-responsive/css/responsive.bootstrap4.min.css b/src/main/resources/static/plugins/datatables-responsive/css/responsive.bootstrap4.min.css new file mode 100644 index 0000000..28959af --- /dev/null +++ b/src/main/resources/static/plugins/datatables-responsive/css/responsive.bootstrap4.min.css @@ -0,0 +1 @@ +table.dataTable.dtr-inline.collapsed>tbody>tr>td.child,table.dataTable.dtr-inline.collapsed>tbody>tr>th.child,table.dataTable.dtr-inline.collapsed>tbody>tr>td.dataTables_empty{cursor:default !important}table.dataTable.dtr-inline.collapsed>tbody>tr>td.child:before,table.dataTable.dtr-inline.collapsed>tbody>tr>th.child:before,table.dataTable.dtr-inline.collapsed>tbody>tr>td.dataTables_empty:before{display:none !important}table.dataTable.dtr-inline.collapsed>tbody>tr>td.dtr-control,table.dataTable.dtr-inline.collapsed>tbody>tr>th.dtr-control{position:relative;padding-left:30px;cursor:pointer}table.dataTable.dtr-inline.collapsed>tbody>tr>td.dtr-control:before,table.dataTable.dtr-inline.collapsed>tbody>tr>th.dtr-control:before{top:50%;left:5px;height:1em;width:1em;margin-top:-9px;display:block;position:absolute;color:white;border:.15em solid white;border-radius:1em;box-shadow:0 0 .2em #444;box-sizing:content-box;text-align:center;text-indent:0 !important;font-family:"Courier New",Courier,monospace;line-height:1em;content:"+";background-color:#0275d8}table.dataTable.dtr-inline.collapsed>tbody>tr.parent>td.dtr-control:before,table.dataTable.dtr-inline.collapsed>tbody>tr.parent>th.dtr-control:before{content:"-";background-color:#d33333}table.dataTable.dtr-inline.collapsed.compact>tbody>tr>td.dtr-control,table.dataTable.dtr-inline.collapsed.compact>tbody>tr>th.dtr-control{padding-left:27px}table.dataTable.dtr-inline.collapsed.compact>tbody>tr>td.dtr-control:before,table.dataTable.dtr-inline.collapsed.compact>tbody>tr>th.dtr-control:before{left:4px;height:14px;width:14px;border-radius:14px;line-height:14px;text-indent:3px}table.dataTable.dtr-column>tbody>tr>td.dtr-control,table.dataTable.dtr-column>tbody>tr>th.dtr-control,table.dataTable.dtr-column>tbody>tr>td.control,table.dataTable.dtr-column>tbody>tr>th.control{position:relative;cursor:pointer}table.dataTable.dtr-column>tbody>tr>td.dtr-control:before,table.dataTable.dtr-column>tbody>tr>th.dtr-control:before,table.dataTable.dtr-column>tbody>tr>td.control:before,table.dataTable.dtr-column>tbody>tr>th.control:before{top:50%;left:50%;height:.8em;width:.8em;margin-top:-0.5em;margin-left:-0.5em;display:block;position:absolute;color:white;border:.15em solid white;border-radius:1em;box-shadow:0 0 .2em #444;box-sizing:content-box;text-align:center;text-indent:0 !important;font-family:"Courier New",Courier,monospace;line-height:1em;content:"+";background-color:#0275d8}table.dataTable.dtr-column>tbody>tr.parent td.dtr-control:before,table.dataTable.dtr-column>tbody>tr.parent th.dtr-control:before,table.dataTable.dtr-column>tbody>tr.parent td.control:before,table.dataTable.dtr-column>tbody>tr.parent th.control:before{content:"-";background-color:#d33333}table.dataTable>tbody>tr.child{padding:.5em 1em}table.dataTable>tbody>tr.child:hover{background:transparent !important}table.dataTable>tbody>tr.child ul.dtr-details{display:inline-block;list-style-type:none;margin:0;padding:0}table.dataTable>tbody>tr.child ul.dtr-details>li{border-bottom:1px solid #efefef;padding:.5em 0}table.dataTable>tbody>tr.child ul.dtr-details>li:first-child{padding-top:0}table.dataTable>tbody>tr.child ul.dtr-details>li:last-child{border-bottom:none}table.dataTable>tbody>tr.child span.dtr-title{display:inline-block;min-width:75px;font-weight:bold}div.dtr-modal{position:fixed;box-sizing:border-box;top:0;left:0;height:100%;width:100%;z-index:100;padding:10em 1em}div.dtr-modal div.dtr-modal-display{position:absolute;top:0;left:0;bottom:0;right:0;width:50%;height:50%;overflow:auto;margin:auto;z-index:102;overflow:auto;background-color:#f5f5f7;border:1px solid black;border-radius:.5em;box-shadow:0 12px 30px rgba(0, 0, 0, 0.6)}div.dtr-modal div.dtr-modal-content{position:relative;padding:1em}div.dtr-modal div.dtr-modal-close{position:absolute;top:6px;right:6px;width:22px;height:22px;border:1px solid #eaeaea;background-color:#f9f9f9;text-align:center;border-radius:3px;cursor:pointer;z-index:12}div.dtr-modal div.dtr-modal-close:hover{background-color:#eaeaea}div.dtr-modal div.dtr-modal-background{position:fixed;top:0;left:0;right:0;bottom:0;z-index:101;background:rgba(0, 0, 0, 0.6)}@media screen and (max-width: 767px){div.dtr-modal div.dtr-modal-display{width:95%}}div.dtr-bs-modal table.table tr:first-child td{border-top:none} diff --git a/src/main/resources/static/plugins/datatables-responsive/js/dataTables.responsive.js b/src/main/resources/static/plugins/datatables-responsive/js/dataTables.responsive.js new file mode 100644 index 0000000..bc35b1b --- /dev/null +++ b/src/main/resources/static/plugins/datatables-responsive/js/dataTables.responsive.js @@ -0,0 +1,1474 @@ +/*! Responsive 2.2.9 + * 2014-2021 SpryMedia Ltd - datatables.net/license + */ + +/** + * @summary Responsive + * @description Responsive tables plug-in for DataTables + * @version 2.2.9 + * @file dataTables.responsive.js + * @author SpryMedia Ltd (www.sprymedia.co.uk) + * @contact www.sprymedia.co.uk/contact + * @copyright Copyright 2014-2021 SpryMedia Ltd. + * + * This source file is free software, available under the following license: + * MIT license - http://datatables.net/license/mit + * + * This source file is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details. + * + * For details please refer to: http://www.datatables.net + */ +(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'; +var DataTable = $.fn.dataTable; + + +/** + * Responsive is a plug-in for the DataTables library that makes use of + * DataTables' ability to change the visibility of columns, changing the + * visibility of columns so the displayed columns fit into the table container. + * The end result is that complex tables will be dynamically adjusted to fit + * into the viewport, be it on a desktop, tablet or mobile browser. + * + * Responsive for DataTables has two modes of operation, which can used + * individually or combined: + * + * * Class name based control - columns assigned class names that match the + * breakpoint logic can be shown / hidden as required for each breakpoint. + * * Automatic control - columns are automatically hidden when there is no + * room left to display them. Columns removed from the right. + * + * In additional to column visibility control, Responsive also has built into + * options to use DataTables' child row display to show / hide the information + * from the table that has been hidden. There are also two modes of operation + * for this child row display: + * + * * Inline - when the control element that the user can use to show / hide + * child rows is displayed inside the first column of the table. + * * Column - where a whole column is dedicated to be the show / hide control. + * + * Initialisation of Responsive is performed by: + * + * * Adding the class `responsive` or `dt-responsive` to the table. In this case + * Responsive will automatically be initialised with the default configuration + * options when the DataTable is created. + * * Using the `responsive` option in the DataTables configuration options. This + * can also be used to specify the configuration options, or simply set to + * `true` to use the defaults. + * + * @class + * @param {object} settings DataTables settings object for the host table + * @param {object} [opts] Configuration options + * @requires jQuery 1.7+ + * @requires DataTables 1.10.3+ + * + * @example + * $('#example').DataTable( { + * responsive: true + * } ); + * } ); + */ +var Responsive = function ( settings, opts ) { + // Sanity check that we are using DataTables 1.10 or newer + if ( ! DataTable.versionCheck || ! DataTable.versionCheck( '1.10.10' ) ) { + throw 'DataTables Responsive requires DataTables 1.10.10 or newer'; + } + + this.s = { + dt: new DataTable.Api( settings ), + columns: [], + current: [] + }; + + // Check if responsive has already been initialised on this table + if ( this.s.dt.settings()[0].responsive ) { + return; + } + + // details is an object, but for simplicity the user can give it as a string + // or a boolean + if ( opts && typeof opts.details === 'string' ) { + opts.details = { type: opts.details }; + } + else if ( opts && opts.details === false ) { + opts.details = { type: false }; + } + else if ( opts && opts.details === true ) { + opts.details = { type: 'inline' }; + } + + this.c = $.extend( true, {}, Responsive.defaults, DataTable.defaults.responsive, opts ); + settings.responsive = this; + this._constructor(); +}; + +$.extend( Responsive.prototype, { + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Constructor + */ + + /** + * Initialise the Responsive instance + * + * @private + */ + _constructor: function () + { + var that = this; + var dt = this.s.dt; + var dtPrivateSettings = dt.settings()[0]; + var oldWindowWidth = $(window).innerWidth(); + + dt.settings()[0]._responsive = this; + + // Use DataTables' throttle function to avoid processor thrashing on + // resize + $(window).on( 'resize.dtr orientationchange.dtr', DataTable.util.throttle( function () { + // iOS has a bug whereby resize can fire when only scrolling + // See: http://stackoverflow.com/questions/8898412 + var width = $(window).innerWidth(); + + if ( width !== oldWindowWidth ) { + that._resize(); + oldWindowWidth = width; + } + } ) ); + + // DataTables doesn't currently trigger an event when a row is added, so + // we need to hook into its private API to enforce the hidden rows when + // new data is added + dtPrivateSettings.oApi._fnCallbackReg( dtPrivateSettings, 'aoRowCreatedCallback', function (tr, data, idx) { + if ( $.inArray( false, that.s.current ) !== -1 ) { + $('>td, >th', tr).each( function ( i ) { + var idx = dt.column.index( 'toData', i ); + + if ( that.s.current[idx] === false ) { + $(this).css('display', 'none'); + } + } ); + } + } ); + + // Destroy event handler + dt.on( 'destroy.dtr', function () { + dt.off( '.dtr' ); + $( dt.table().body() ).off( '.dtr' ); + $(window).off( 'resize.dtr orientationchange.dtr' ); + dt.cells('.dtr-control').nodes().to$().removeClass('dtr-control'); + + // Restore the columns that we've hidden + $.each( that.s.current, function ( i, val ) { + if ( val === false ) { + that._setColumnVis( i, true ); + } + } ); + } ); + + // Reorder the breakpoints array here in case they have been added out + // of order + this.c.breakpoints.sort( function (a, b) { + return a.width < b.width ? 1 : + a.width > b.width ? -1 : 0; + } ); + + this._classLogic(); + this._resizeAuto(); + + // Details handler + var details = this.c.details; + + if ( details.type !== false ) { + that._detailsInit(); + + // DataTables will trigger this event on every column it shows and + // hides individually + dt.on( 'column-visibility.dtr', function () { + // Use a small debounce to allow multiple columns to be set together + if ( that._timer ) { + clearTimeout( that._timer ); + } + + that._timer = setTimeout( function () { + that._timer = null; + + that._classLogic(); + that._resizeAuto(); + that._resize(true); + + that._redrawChildren(); + }, 100 ); + } ); + + // Redraw the details box on each draw which will happen if the data + // has changed. This is used until DataTables implements a native + // `updated` event for rows + dt.on( 'draw.dtr', function () { + that._redrawChildren(); + } ); + + $(dt.table().node()).addClass( 'dtr-'+details.type ); + } + + dt.on( 'column-reorder.dtr', function (e, settings, details) { + that._classLogic(); + that._resizeAuto(); + that._resize(true); + } ); + + // Change in column sizes means we need to calc + dt.on( 'column-sizing.dtr', function () { + that._resizeAuto(); + that._resize(); + }); + + // On Ajax reload we want to reopen any child rows which are displayed + // by responsive + dt.on( 'preXhr.dtr', function () { + var rowIds = []; + dt.rows().every( function () { + if ( this.child.isShown() ) { + rowIds.push( this.id(true) ); + } + } ); + + dt.one( 'draw.dtr', function () { + that._resizeAuto(); + that._resize(); + + dt.rows( rowIds ).every( function () { + that._detailsDisplay( this, false ); + } ); + } ); + }); + + dt + .on( 'draw.dtr', function () { + that._controlClass(); + }) + .on( 'init.dtr', function (e, settings, details) { + if ( e.namespace !== 'dt' ) { + return; + } + + that._resizeAuto(); + that._resize(); + + // If columns were hidden, then DataTables needs to adjust the + // column sizing + if ( $.inArray( false, that.s.current ) ) { + dt.columns.adjust(); + } + } ); + + // First pass - draw the table for the current viewport size + this._resize(); + }, + + + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Private methods + */ + + /** + * Calculate the visibility for the columns in a table for a given + * breakpoint. The result is pre-determined based on the class logic if + * class names are used to control all columns, but the width of the table + * is also used if there are columns which are to be automatically shown + * and hidden. + * + * @param {string} breakpoint Breakpoint name to use for the calculation + * @return {array} Array of boolean values initiating the visibility of each + * column. + * @private + */ + _columnsVisiblity: function ( breakpoint ) + { + var dt = this.s.dt; + var columns = this.s.columns; + var i, ien; + + // Create an array that defines the column ordering based first on the + // column's priority, and secondly the column index. This allows the + // columns to be removed from the right if the priority matches + var order = columns + .map( function ( col, idx ) { + return { + columnIdx: idx, + priority: col.priority + }; + } ) + .sort( function ( a, b ) { + if ( a.priority !== b.priority ) { + return a.priority - b.priority; + } + return a.columnIdx - b.columnIdx; + } ); + + // Class logic - determine which columns are in this breakpoint based + // on the classes. If no class control (i.e. `auto`) then `-` is used + // to indicate this to the rest of the function + var display = $.map( columns, function ( col, i ) { + if ( dt.column(i).visible() === false ) { + return 'not-visible'; + } + return col.auto && col.minWidth === null ? + false : + col.auto === true ? + '-' : + $.inArray( breakpoint, col.includeIn ) !== -1; + } ); + + // Auto column control - first pass: how much width is taken by the + // ones that must be included from the non-auto columns + var requiredWidth = 0; + for ( i=0, ien=display.length ; i<ien ; i++ ) { + if ( display[i] === true ) { + requiredWidth += columns[i].minWidth; + } + } + + // Second pass, use up any remaining width for other columns. For + // scrolling tables we need to subtract the width of the scrollbar. It + // may not be requires which makes this sub-optimal, but it would + // require another full redraw to make complete use of those extra few + // pixels + var scrolling = dt.settings()[0].oScroll; + var bar = scrolling.sY || scrolling.sX ? scrolling.iBarWidth : 0; + var widthAvailable = dt.table().container().offsetWidth - bar; + var usedWidth = widthAvailable - requiredWidth; + + // Control column needs to always be included. This makes it sub- + // optimal in terms of using the available with, but to stop layout + // thrashing or overflow. Also we need to account for the control column + // width first so we know how much width is available for the other + // columns, since the control column might not be the first one shown + for ( i=0, ien=display.length ; i<ien ; i++ ) { + if ( columns[i].control ) { + usedWidth -= columns[i].minWidth; + } + } + + // Allow columns to be shown (counting by priority and then right to + // left) until we run out of room + var empty = false; + for ( i=0, ien=order.length ; i<ien ; i++ ) { + var colIdx = order[i].columnIdx; + + if ( display[colIdx] === '-' && ! columns[colIdx].control && columns[colIdx].minWidth ) { + // Once we've found a column that won't fit we don't let any + // others display either, or columns might disappear in the + // middle of the table + if ( empty || usedWidth - columns[colIdx].minWidth < 0 ) { + empty = true; + display[colIdx] = false; + } + else { + display[colIdx] = true; + } + + usedWidth -= columns[colIdx].minWidth; + } + } + + // Determine if the 'control' column should be shown (if there is one). + // This is the case when there is a hidden column (that is not the + // control column). The two loops look inefficient here, but they are + // trivial and will fly through. We need to know the outcome from the + // first , before the action in the second can be taken + var showControl = false; + + for ( i=0, ien=columns.length ; i<ien ; i++ ) { + if ( ! columns[i].control && ! columns[i].never && display[i] === false ) { + showControl = true; + break; + } + } + + for ( i=0, ien=columns.length ; i<ien ; i++ ) { + if ( columns[i].control ) { + display[i] = showControl; + } + + // Replace not visible string with false from the control column detection above + if ( display[i] === 'not-visible' ) { + display[i] = false; + } + } + + // Finally we need to make sure that there is at least one column that + // is visible + if ( $.inArray( true, display ) === -1 ) { + display[0] = true; + } + + return display; + }, + + + /** + * Create the internal `columns` array with information about the columns + * for the table. This includes determining which breakpoints the column + * will appear in, based upon class names in the column, which makes up the + * vast majority of this method. + * + * @private + */ + _classLogic: function () + { + var that = this; + var calc = {}; + var breakpoints = this.c.breakpoints; + var dt = this.s.dt; + var columns = dt.columns().eq(0).map( function (i) { + var column = this.column(i); + var className = column.header().className; + var priority = dt.settings()[0].aoColumns[i].responsivePriority; + var dataPriority = column.header().getAttribute('data-priority'); + + if ( priority === undefined ) { + priority = dataPriority === undefined || dataPriority === null? + 10000 : + dataPriority * 1; + } + + return { + className: className, + includeIn: [], + auto: false, + control: false, + never: className.match(/\bnever\b/) ? true : false, + priority: priority + }; + } ); + + // Simply add a breakpoint to `includeIn` array, ensuring that there are + // no duplicates + var add = function ( colIdx, name ) { + var includeIn = columns[ colIdx ].includeIn; + + if ( $.inArray( name, includeIn ) === -1 ) { + includeIn.push( name ); + } + }; + + var column = function ( colIdx, name, operator, matched ) { + var size, i, ien; + + if ( ! operator ) { + columns[ colIdx ].includeIn.push( name ); + } + else if ( operator === 'max-' ) { + // Add this breakpoint and all smaller + size = that._find( name ).width; + + for ( i=0, ien=breakpoints.length ; i<ien ; i++ ) { + if ( breakpoints[i].width <= size ) { + add( colIdx, breakpoints[i].name ); + } + } + } + else if ( operator === 'min-' ) { + // Add this breakpoint and all larger + size = that._find( name ).width; + + for ( i=0, ien=breakpoints.length ; i<ien ; i++ ) { + if ( breakpoints[i].width >= size ) { + add( colIdx, breakpoints[i].name ); + } + } + } + else if ( operator === 'not-' ) { + // Add all but this breakpoint + for ( i=0, ien=breakpoints.length ; i<ien ; i++ ) { + if ( breakpoints[i].name.indexOf( matched ) === -1 ) { + add( colIdx, breakpoints[i].name ); + } + } + } + }; + + // Loop over each column and determine if it has a responsive control + // class + columns.each( function ( col, i ) { + var classNames = col.className.split(' '); + var hasClass = false; + + // Split the class name up so multiple rules can be applied if needed + for ( var k=0, ken=classNames.length ; k<ken ; k++ ) { + var className = classNames[k].trim(); + + if ( className === 'all' ) { + // Include in all + hasClass = true; + col.includeIn = $.map( breakpoints, function (a) { + return a.name; + } ); + return; + } + else if ( className === 'none' || col.never ) { + // Include in none (default) and no auto + hasClass = true; + return; + } + else if ( className === 'control' || className === 'dtr-control' ) { + // Special column that is only visible, when one of the other + // columns is hidden. This is used for the details control + hasClass = true; + col.control = true; + return; + } + + $.each( breakpoints, function ( j, breakpoint ) { + // Does this column have a class that matches this breakpoint? + var brokenPoint = breakpoint.name.split('-'); + var re = new RegExp( '(min\\-|max\\-|not\\-)?('+brokenPoint[0]+')(\\-[_a-zA-Z0-9])?' ); + var match = className.match( re ); + + if ( match ) { + hasClass = true; + + if ( match[2] === brokenPoint[0] && match[3] === '-'+brokenPoint[1] ) { + // Class name matches breakpoint name fully + column( i, breakpoint.name, match[1], match[2]+match[3] ); + } + else if ( match[2] === brokenPoint[0] && ! match[3] ) { + // Class name matched primary breakpoint name with no qualifier + column( i, breakpoint.name, match[1], match[2] ); + } + } + } ); + } + + // If there was no control class, then automatic sizing is used + if ( ! hasClass ) { + col.auto = true; + } + } ); + + this.s.columns = columns; + }, + + /** + * Update the cells to show the correct control class / button + * @private + */ + _controlClass: function () + { + if ( this.c.details.type === 'inline' ) { + var dt = this.s.dt; + var columnsVis = this.s.current; + var firstVisible = $.inArray(true, columnsVis); + + // Remove from any cells which shouldn't have it + dt.cells( + null, + function(idx) { + return idx !== firstVisible; + }, + {page: 'current'} + ) + .nodes() + .to$() + .filter('.dtr-control') + .removeClass('dtr-control'); + + dt.cells(null, firstVisible, {page: 'current'}) + .nodes() + .to$() + .addClass('dtr-control'); + } + }, + + /** + * Show the details for the child row + * + * @param {DataTables.Api} row API instance for the row + * @param {boolean} update Update flag + * @private + */ + _detailsDisplay: function ( row, update ) + { + var that = this; + var dt = this.s.dt; + var details = this.c.details; + + if ( details && details.type !== false ) { + var res = details.display( row, update, function () { + return details.renderer( + dt, row[0], that._detailsObj(row[0]) + ); + } ); + + if ( res === true || res === false ) { + $(dt.table().node()).triggerHandler( 'responsive-display.dt', [dt, row, res, update] ); + } + } + }, + + + /** + * Initialisation for the details handler + * + * @private + */ + _detailsInit: function () + { + var that = this; + var dt = this.s.dt; + var details = this.c.details; + + // The inline type always uses the first child as the target + if ( details.type === 'inline' ) { + details.target = 'td.dtr-control, th.dtr-control'; + } + + // Keyboard accessibility + dt.on( 'draw.dtr', function () { + that._tabIndexes(); + } ); + that._tabIndexes(); // Initial draw has already happened + + $( dt.table().body() ).on( 'keyup.dtr', 'td, th', function (e) { + if ( e.keyCode === 13 && $(this).data('dtr-keyboard') ) { + $(this).click(); + } + } ); + + // type.target can be a string jQuery selector or a column index + var target = details.target; + var selector = typeof target === 'string' ? target : 'td, th'; + + if ( target !== undefined || target !== null ) { + // Click handler to show / hide the details rows when they are available + $( dt.table().body() ) + .on( 'click.dtr mousedown.dtr mouseup.dtr', selector, function (e) { + // If the table is not collapsed (i.e. there is no hidden columns) + // then take no action + if ( ! $(dt.table().node()).hasClass('collapsed' ) ) { + return; + } + + // Check that the row is actually a DataTable's controlled node + if ( $.inArray( $(this).closest('tr').get(0), dt.rows().nodes().toArray() ) === -1 ) { + return; + } + + // For column index, we determine if we should act or not in the + // handler - otherwise it is already okay + if ( typeof target === 'number' ) { + var targetIdx = target < 0 ? + dt.columns().eq(0).length + target : + target; + + if ( dt.cell( this ).index().column !== targetIdx ) { + return; + } + } + + // $().closest() includes itself in its check + var row = dt.row( $(this).closest('tr') ); + + // Check event type to do an action + if ( e.type === 'click' ) { + // The renderer is given as a function so the caller can execute it + // only when they need (i.e. if hiding there is no point is running + // the renderer) + that._detailsDisplay( row, false ); + } + else if ( e.type === 'mousedown' ) { + // For mouse users, prevent the focus ring from showing + $(this).css('outline', 'none'); + } + else if ( e.type === 'mouseup' ) { + // And then re-allow at the end of the click + $(this).trigger('blur').css('outline', ''); + } + } ); + } + }, + + + /** + * Get the details to pass to a renderer for a row + * @param {int} rowIdx Row index + * @private + */ + _detailsObj: function ( rowIdx ) + { + var that = this; + var dt = this.s.dt; + + return $.map( this.s.columns, function( col, i ) { + // Never and control columns should not be passed to the renderer + if ( col.never || col.control ) { + return; + } + + var dtCol = dt.settings()[0].aoColumns[ i ]; + + return { + className: dtCol.sClass, + columnIndex: i, + data: dt.cell( rowIdx, i ).render( that.c.orthogonal ), + hidden: dt.column( i ).visible() && !that.s.current[ i ], + rowIndex: rowIdx, + title: dtCol.sTitle !== null ? + dtCol.sTitle : + $(dt.column(i).header()).text() + }; + } ); + }, + + + /** + * Find a breakpoint object from a name + * + * @param {string} name Breakpoint name to find + * @return {object} Breakpoint description object + * @private + */ + _find: function ( name ) + { + var breakpoints = this.c.breakpoints; + + for ( var i=0, ien=breakpoints.length ; i<ien ; i++ ) { + if ( breakpoints[i].name === name ) { + return breakpoints[i]; + } + } + }, + + + /** + * Re-create the contents of the child rows as the display has changed in + * some way. + * + * @private + */ + _redrawChildren: function () + { + var that = this; + var dt = this.s.dt; + + dt.rows( {page: 'current'} ).iterator( 'row', function ( settings, idx ) { + var row = dt.row( idx ); + + that._detailsDisplay( dt.row( idx ), true ); + } ); + }, + + + /** + * Alter the table display for a resized viewport. This involves first + * determining what breakpoint the window currently is in, getting the + * column visibilities to apply and then setting them. + * + * @param {boolean} forceRedraw Force a redraw + * @private + */ + _resize: function (forceRedraw) + { + var that = this; + var dt = this.s.dt; + var width = $(window).innerWidth(); + var breakpoints = this.c.breakpoints; + var breakpoint = breakpoints[0].name; + var columns = this.s.columns; + var i, ien; + var oldVis = this.s.current.slice(); + + // Determine what breakpoint we are currently at + for ( i=breakpoints.length-1 ; i>=0 ; i-- ) { + if ( width <= breakpoints[i].width ) { + breakpoint = breakpoints[i].name; + break; + } + } + + // Show the columns for that break point + var columnsVis = this._columnsVisiblity( breakpoint ); + this.s.current = columnsVis; + + // Set the class before the column visibility is changed so event + // listeners know what the state is. Need to determine if there are + // any columns that are not visible but can be shown + var collapsedClass = false; + + for ( i=0, ien=columns.length ; i<ien ; i++ ) { + if ( columnsVis[i] === false && ! columns[i].never && ! columns[i].control && ! dt.column(i).visible() === false ) { + collapsedClass = true; + break; + } + } + + $( dt.table().node() ).toggleClass( 'collapsed', collapsedClass ); + + var changed = false; + var visible = 0; + + dt.columns().eq(0).each( function ( colIdx, i ) { + if ( columnsVis[i] === true ) { + visible++; + } + + if ( forceRedraw || columnsVis[i] !== oldVis[i] ) { + changed = true; + that._setColumnVis( colIdx, columnsVis[i] ); + } + } ); + + if ( changed ) { + this._redrawChildren(); + + // Inform listeners of the change + $(dt.table().node()).trigger( 'responsive-resize.dt', [dt, this.s.current] ); + + // If no records, update the "No records" display element + if ( dt.page.info().recordsDisplay === 0 ) { + $('td', dt.table().body()).eq(0).attr('colspan', visible); + } + } + + that._controlClass(); + }, + + + /** + * Determine the width of each column in the table so the auto column hiding + * has that information to work with. This method is never going to be 100% + * perfect since column widths can change slightly per page, but without + * seriously compromising performance this is quite effective. + * + * @private + */ + _resizeAuto: function () + { + var dt = this.s.dt; + var columns = this.s.columns; + + // Are we allowed to do auto sizing? + if ( ! this.c.auto ) { + return; + } + + // Are there any columns that actually need auto-sizing, or do they all + // have classes defined + if ( $.inArray( true, $.map( columns, function (c) { return c.auto; } ) ) === -1 ) { + return; + } + + // Need to restore all children. They will be reinstated by a re-render + if ( ! $.isEmptyObject( _childNodeStore ) ) { + $.each( _childNodeStore, function ( key ) { + var idx = key.split('-'); + + _childNodesRestore( dt, idx[0]*1, idx[1]*1 ); + } ); + } + + // Clone the table with the current data in it + var tableWidth = dt.table().node().offsetWidth; + var columnWidths = dt.columns; + var clonedTable = dt.table().node().cloneNode( false ); + var clonedHeader = $( dt.table().header().cloneNode( false ) ).appendTo( clonedTable ); + var clonedBody = $( dt.table().body() ).clone( false, false ).empty().appendTo( clonedTable ); // use jQuery because of IE8 + + clonedTable.style.width = 'auto'; + + // Header + var headerCells = dt.columns() + .header() + .filter( function (idx) { + return dt.column(idx).visible(); + } ) + .to$() + .clone( false ) + .css( 'display', 'table-cell' ) + .css( 'width', 'auto' ) + .css( 'min-width', 0 ); + + // Body rows - we don't need to take account of DataTables' column + // visibility since we implement our own here (hence the `display` set) + $(clonedBody) + .append( $(dt.rows( { page: 'current' } ).nodes()).clone( false ) ) + .find( 'th, td' ).css( 'display', '' ); + + // Footer + var footer = dt.table().footer(); + if ( footer ) { + var clonedFooter = $( footer.cloneNode( false ) ).appendTo( clonedTable ); + var footerCells = dt.columns() + .footer() + .filter( function (idx) { + return dt.column(idx).visible(); + } ) + .to$() + .clone( false ) + .css( 'display', 'table-cell' ); + + $('<tr/>') + .append( footerCells ) + .appendTo( clonedFooter ); + } + + $('<tr/>') + .append( headerCells ) + .appendTo( clonedHeader ); + + // In the inline case extra padding is applied to the first column to + // give space for the show / hide icon. We need to use this in the + // calculation + if ( this.c.details.type === 'inline' ) { + $(clonedTable).addClass( 'dtr-inline collapsed' ); + } + + // It is unsafe to insert elements with the same name into the DOM + // multiple times. For example, cloning and inserting a checked radio + // clears the chcecked state of the original radio. + $( clonedTable ).find( '[name]' ).removeAttr( 'name' ); + + // A position absolute table would take the table out of the flow of + // our container element, bypassing the height and width (Scroller) + $( clonedTable ).css( 'position', 'relative' ) + + var inserted = $('<div/>') + .css( { + width: 1, + height: 1, + overflow: 'hidden', + clear: 'both' + } ) + .append( clonedTable ); + + inserted.insertBefore( dt.table().node() ); + + // The cloned header now contains the smallest that each column can be + headerCells.each( function (i) { + var idx = dt.column.index( 'fromVisible', i ); + columns[ idx ].minWidth = this.offsetWidth || 0; + } ); + + inserted.remove(); + }, + + /** + * Get the state of the current hidden columns - controlled by Responsive only + */ + _responsiveOnlyHidden: function () + { + var dt = this.s.dt; + + return $.map( this.s.current, function (v, i) { + // If the column is hidden by DataTables then it can't be hidden by + // Responsive! + if ( dt.column(i).visible() === false ) { + return true; + } + return v; + } ); + }, + + /** + * Set a column's visibility. + * + * We don't use DataTables' column visibility controls in order to ensure + * that column visibility can Responsive can no-exist. Since only IE8+ is + * supported (and all evergreen browsers of course) the control of the + * display attribute works well. + * + * @param {integer} col Column index + * @param {boolean} showHide Show or hide (true or false) + * @private + */ + _setColumnVis: function ( col, showHide ) + { + var dt = this.s.dt; + var display = showHide ? '' : 'none'; // empty string will remove the attr + + $( dt.column( col ).header() ).css( 'display', display ); + $( dt.column( col ).footer() ).css( 'display', display ); + dt.column( col ).nodes().to$().css( 'display', display ); + + // If the are child nodes stored, we might need to reinsert them + if ( ! $.isEmptyObject( _childNodeStore ) ) { + dt.cells( null, col ).indexes().each( function (idx) { + _childNodesRestore( dt, idx.row, idx.column ); + } ); + } + }, + + + /** + * Update the cell tab indexes for keyboard accessibility. This is called on + * every table draw - that is potentially inefficient, but also the least + * complex option given that column visibility can change on the fly. Its a + * shame user-focus was removed from CSS 3 UI, as it would have solved this + * issue with a single CSS statement. + * + * @private + */ + _tabIndexes: function () + { + var dt = this.s.dt; + var cells = dt.cells( { page: 'current' } ).nodes().to$(); + var ctx = dt.settings()[0]; + var target = this.c.details.target; + + cells.filter( '[data-dtr-keyboard]' ).removeData( '[data-dtr-keyboard]' ); + + if ( typeof target === 'number' ) { + dt.cells( null, target, { page: 'current' } ).nodes().to$() + .attr( 'tabIndex', ctx.iTabIndex ) + .data( 'dtr-keyboard', 1 ); + } + else { + // This is a bit of a hack - we need to limit the selected nodes to just + // those of this table + if ( target === 'td:first-child, th:first-child' ) { + target = '>td:first-child, >th:first-child'; + } + + $( target, dt.rows( { page: 'current' } ).nodes() ) + .attr( 'tabIndex', ctx.iTabIndex ) + .data( 'dtr-keyboard', 1 ); + } + } +} ); + + +/** + * List of default breakpoints. Each item in the array is an object with two + * properties: + * + * * `name` - the breakpoint name. + * * `width` - the breakpoint width + * + * @name Responsive.breakpoints + * @static + */ +Responsive.breakpoints = [ + { name: 'desktop', width: Infinity }, + { name: 'tablet-l', width: 1024 }, + { name: 'tablet-p', width: 768 }, + { name: 'mobile-l', width: 480 }, + { name: 'mobile-p', width: 320 } +]; + + +/** + * Display methods - functions which define how the hidden data should be shown + * in the table. + * + * @namespace + * @name Responsive.defaults + * @static + */ +Responsive.display = { + childRow: function ( row, update, render ) { + if ( update ) { + if ( $(row.node()).hasClass('parent') ) { + row.child( render(), 'child' ).show(); + + return true; + } + } + else { + if ( ! row.child.isShown() ) { + row.child( render(), 'child' ).show(); + $( row.node() ).addClass( 'parent' ); + + return true; + } + else { + row.child( false ); + $( row.node() ).removeClass( 'parent' ); + + return false; + } + } + }, + + childRowImmediate: function ( row, update, render ) { + if ( (! update && row.child.isShown()) || ! row.responsive.hasHidden() ) { + // User interaction and the row is show, or nothing to show + row.child( false ); + $( row.node() ).removeClass( 'parent' ); + + return false; + } + else { + // Display + row.child( render(), 'child' ).show(); + $( row.node() ).addClass( 'parent' ); + + return true; + } + }, + + // This is a wrapper so the modal options for Bootstrap and jQuery UI can + // have options passed into them. This specific one doesn't need to be a + // function but it is for consistency in the `modal` name + modal: function ( options ) { + return function ( row, update, render ) { + if ( ! update ) { + // Show a modal + var close = function () { + modal.remove(); // will tidy events for us + $(document).off( 'keypress.dtr' ); + }; + + var modal = $('<div class="dtr-modal"/>') + .append( $('<div class="dtr-modal-display"/>') + .append( $('<div class="dtr-modal-content"/>') + .append( render() ) + ) + .append( $('<div class="dtr-modal-close">×</div>' ) + .click( function () { + close(); + } ) + ) + ) + .append( $('<div class="dtr-modal-background"/>') + .click( function () { + close(); + } ) + ) + .appendTo( 'body' ); + + $(document).on( 'keyup.dtr', function (e) { + if ( e.keyCode === 27 ) { + e.stopPropagation(); + + close(); + } + } ); + } + else { + $('div.dtr-modal-content') + .empty() + .append( render() ); + } + + if ( options && options.header ) { + $('div.dtr-modal-content').prepend( + '<h2>'+options.header( row )+'</h2>' + ); + } + }; + } +}; + + +var _childNodeStore = {}; + +function _childNodes( dt, row, col ) { + var name = row+'-'+col; + + if ( _childNodeStore[ name ] ) { + return _childNodeStore[ name ]; + } + + // https://jsperf.com/childnodes-array-slice-vs-loop + var nodes = []; + var children = dt.cell( row, col ).node().childNodes; + for ( var i=0, ien=children.length ; i<ien ; i++ ) { + nodes.push( children[i] ); + } + + _childNodeStore[ name ] = nodes; + + return nodes; +} + +function _childNodesRestore( dt, row, col ) { + var name = row+'-'+col; + + if ( ! _childNodeStore[ name ] ) { + return; + } + + var node = dt.cell( row, col ).node(); + var store = _childNodeStore[ name ]; + var parent = store[0].parentNode; + var parentChildren = parent.childNodes; + var a = []; + + for ( var i=0, ien=parentChildren.length ; i<ien ; i++ ) { + a.push( parentChildren[i] ); + } + + for ( var j=0, jen=a.length ; j<jen ; j++ ) { + node.appendChild( a[j] ); + } + + _childNodeStore[ name ] = undefined; +} + + +/** + * Display methods - functions which define how the hidden data should be shown + * in the table. + * + * @namespace + * @name Responsive.defaults + * @static + */ +Responsive.renderer = { + listHiddenNodes: function () { + return function ( api, rowIdx, columns ) { + var ul = $('<ul data-dtr-index="'+rowIdx+'" class="dtr-details"/>'); + var found = false; + + var data = $.each( columns, function ( i, col ) { + if ( col.hidden ) { + var klass = col.className ? + 'class="'+ col.className +'"' : + ''; + + $( + '<li '+klass+' data-dtr-index="'+col.columnIndex+'" data-dt-row="'+col.rowIndex+'" data-dt-column="'+col.columnIndex+'">'+ + '<span class="dtr-title">'+ + col.title+ + '</span> '+ + '</li>' + ) + .append( $('<span class="dtr-data"/>').append( _childNodes( api, col.rowIndex, col.columnIndex ) ) )// api.cell( col.rowIndex, col.columnIndex ).node().childNodes ) ) + .appendTo( ul ); + + found = true; + } + } ); + + return found ? + ul : + false; + }; + }, + + listHidden: function () { + return function ( api, rowIdx, columns ) { + var data = $.map( columns, function ( col ) { + var klass = col.className ? + 'class="'+ col.className +'"' : + ''; + + return col.hidden ? + '<li '+klass+' data-dtr-index="'+col.columnIndex+'" data-dt-row="'+col.rowIndex+'" data-dt-column="'+col.columnIndex+'">'+ + '<span class="dtr-title">'+ + col.title+ + '</span> '+ + '<span class="dtr-data">'+ + col.data+ + '</span>'+ + '</li>' : + ''; + } ).join(''); + + return data ? + $('<ul data-dtr-index="'+rowIdx+'" class="dtr-details"/>').append( data ) : + false; + } + }, + + tableAll: function ( options ) { + options = $.extend( { + tableClass: '' + }, options ); + + return function ( api, rowIdx, columns ) { + var data = $.map( columns, function ( col ) { + var klass = col.className ? + 'class="'+ col.className +'"' : + ''; + + return '<tr '+klass+' data-dt-row="'+col.rowIndex+'" data-dt-column="'+col.columnIndex+'">'+ + '<td>'+col.title+':'+'</td> '+ + '<td>'+col.data+'</td>'+ + '</tr>'; + } ).join(''); + + return $('<table class="'+options.tableClass+' dtr-details" width="100%"/>').append( data ); + } + } +}; + +/** + * Responsive default settings for initialisation + * + * @namespace + * @name Responsive.defaults + * @static + */ +Responsive.defaults = { + /** + * List of breakpoints for the instance. Note that this means that each + * instance can have its own breakpoints. Additionally, the breakpoints + * cannot be changed once an instance has been creased. + * + * @type {Array} + * @default Takes the value of `Responsive.breakpoints` + */ + breakpoints: Responsive.breakpoints, + + /** + * Enable / disable auto hiding calculations. It can help to increase + * performance slightly if you disable this option, but all columns would + * need to have breakpoint classes assigned to them + * + * @type {Boolean} + * @default `true` + */ + auto: true, + + /** + * Details control. If given as a string value, the `type` property of the + * default object is set to that value, and the defaults used for the rest + * of the object - this is for ease of implementation. + * + * The object consists of the following properties: + * + * * `display` - A function that is used to show and hide the hidden details + * * `renderer` - function that is called for display of the child row data. + * The default function will show the data from the hidden columns + * * `target` - Used as the selector for what objects to attach the child + * open / close to + * * `type` - `false` to disable the details display, `inline` or `column` + * for the two control types + * + * @type {Object|string} + */ + details: { + display: Responsive.display.childRow, + + renderer: Responsive.renderer.listHidden(), + + target: 0, + + type: 'inline' + }, + + /** + * Orthogonal data request option. This is used to define the data type + * requested when Responsive gets the data to show in the child row. + * + * @type {String} + */ + orthogonal: 'display' +}; + + +/* + * API + */ +var Api = $.fn.dataTable.Api; + +// Doesn't do anything - work around for a bug in DT... Not documented +Api.register( 'responsive()', function () { + return this; +} ); + +Api.register( 'responsive.index()', function ( li ) { + li = $(li); + + return { + column: li.data('dtr-index'), + row: li.parent().data('dtr-index') + }; +} ); + +Api.register( 'responsive.rebuild()', function () { + return this.iterator( 'table', function ( ctx ) { + if ( ctx._responsive ) { + ctx._responsive._classLogic(); + } + } ); +} ); + +Api.register( 'responsive.recalc()', function () { + return this.iterator( 'table', function ( ctx ) { + if ( ctx._responsive ) { + ctx._responsive._resizeAuto(); + ctx._responsive._resize(); + } + } ); +} ); + +Api.register( 'responsive.hasHidden()', function () { + var ctx = this.context[0]; + + return ctx._responsive ? + $.inArray( false, ctx._responsive._responsiveOnlyHidden() ) !== -1 : + false; +} ); + +Api.registerPlural( 'columns().responsiveHidden()', 'column().responsiveHidden()', function () { + return this.iterator( 'column', function ( settings, column ) { + return settings._responsive ? + settings._responsive._responsiveOnlyHidden()[ column ] : + false; + }, 1 ); +} ); + + +/** + * Version information + * + * @name Responsive.version + * @static + */ +Responsive.version = '2.2.9'; + + +$.fn.dataTable.Responsive = Responsive; +$.fn.DataTable.Responsive = Responsive; + +// Attach a listener to the document which listens for DataTables initialisation +// events so we can automatically initialise +$(document).on( 'preInit.dt.dtr', function (e, settings, json) { + if ( e.namespace !== 'dt' ) { + return; + } + + if ( $(settings.nTable).hasClass( 'responsive' ) || + $(settings.nTable).hasClass( 'dt-responsive' ) || + settings.oInit.responsive || + DataTable.defaults.responsive + ) { + var init = settings.oInit.responsive; + + if ( init !== false ) { + new Responsive( settings, $.isPlainObject( init ) ? init : {} ); + } + } +} ); + + +return Responsive; +})); diff --git a/src/main/resources/static/plugins/datatables-responsive/js/dataTables.responsive.min.js b/src/main/resources/static/plugins/datatables-responsive/js/dataTables.responsive.min.js new file mode 100644 index 0000000..05fb1aa --- /dev/null +++ b/src/main/resources/static/plugins/datatables-responsive/js/dataTables.responsive.min.js @@ -0,0 +1,48 @@ +/*! + Copyright 2014-2021 SpryMedia Ltd. + + This source file is free software, available under the following license: + MIT license - http://datatables.net/license/mit + + This source file is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details. + + For details please refer to: http://www.datatables.net + Responsive 2.2.9 + 2014-2021 SpryMedia Ltd - datatables.net/license +*/ +var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.findInternal=function(b,k,m){b instanceof String&&(b=String(b));for(var n=b.length,p=0;p<n;p++){var y=b[p];if(k.call(m,y,p,b))return{i:p,v:y}}return{i:-1,v:void 0}};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.SIMPLE_FROUND_POLYFILL=!1;$jscomp.ISOLATE_POLYFILLS=!1; +$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(b,k,m){if(b==Array.prototype||b==Object.prototype)return b;b[k]=m.value;return b};$jscomp.getGlobal=function(b){b=["object"==typeof globalThis&&globalThis,b,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var k=0;k<b.length;++k){var m=b[k];if(m&&m.Math==Math)return m}throw Error("Cannot find global object");};$jscomp.global=$jscomp.getGlobal(this); +$jscomp.IS_SYMBOL_NATIVE="function"===typeof Symbol&&"symbol"===typeof Symbol("x");$jscomp.TRUST_ES6_POLYFILLS=!$jscomp.ISOLATE_POLYFILLS||$jscomp.IS_SYMBOL_NATIVE;$jscomp.polyfills={};$jscomp.propertyToPolyfillSymbol={};$jscomp.POLYFILL_PREFIX="$jscp$";var $jscomp$lookupPolyfilledValue=function(b,k){var m=$jscomp.propertyToPolyfillSymbol[k];if(null==m)return b[k];m=b[m];return void 0!==m?m:b[k]}; +$jscomp.polyfill=function(b,k,m,n){k&&($jscomp.ISOLATE_POLYFILLS?$jscomp.polyfillIsolated(b,k,m,n):$jscomp.polyfillUnisolated(b,k,m,n))};$jscomp.polyfillUnisolated=function(b,k,m,n){m=$jscomp.global;b=b.split(".");for(n=0;n<b.length-1;n++){var p=b[n];if(!(p in m))return;m=m[p]}b=b[b.length-1];n=m[b];k=k(n);k!=n&&null!=k&&$jscomp.defineProperty(m,b,{configurable:!0,writable:!0,value:k})}; +$jscomp.polyfillIsolated=function(b,k,m,n){var p=b.split(".");b=1===p.length;n=p[0];n=!b&&n in $jscomp.polyfills?$jscomp.polyfills:$jscomp.global;for(var y=0;y<p.length-1;y++){var z=p[y];if(!(z in n))return;n=n[z]}p=p[p.length-1];m=$jscomp.IS_SYMBOL_NATIVE&&"es6"===m?n[p]:null;k=k(m);null!=k&&(b?$jscomp.defineProperty($jscomp.polyfills,p,{configurable:!0,writable:!0,value:k}):k!==m&&($jscomp.propertyToPolyfillSymbol[p]=$jscomp.IS_SYMBOL_NATIVE?$jscomp.global.Symbol(p):$jscomp.POLYFILL_PREFIX+p,p= +$jscomp.propertyToPolyfillSymbol[p],$jscomp.defineProperty(n,p,{configurable:!0,writable:!0,value:k})))};$jscomp.polyfill("Array.prototype.find",function(b){return b?b:function(k,m){return $jscomp.findInternal(this,k,m).v}},"es6","es3"); +(function(b){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(k){return b(k,window,document)}):"object"===typeof exports?module.exports=function(k,m){k||(k=window);m&&m.fn.dataTable||(m=require("datatables.net")(k,m).$);return b(m,k,k.document)}:b(jQuery,window,document)})(function(b,k,m,n){function p(a,c,d){var f=c+"-"+d;if(A[f])return A[f];var g=[];a=a.cell(c,d).node().childNodes;c=0;for(d=a.length;c<d;c++)g.push(a[c]);return A[f]=g}function y(a,c,d){var f=c+"-"+ +d;if(A[f]){a=a.cell(c,d).node();d=A[f][0].parentNode.childNodes;c=[];for(var g=0,l=d.length;g<l;g++)c.push(d[g]);d=0;for(g=c.length;d<g;d++)a.appendChild(c[d]);A[f]=n}}var z=b.fn.dataTable,u=function(a,c){if(!z.versionCheck||!z.versionCheck("1.10.10"))throw"DataTables Responsive requires DataTables 1.10.10 or newer";this.s={dt:new z.Api(a),columns:[],current:[]};this.s.dt.settings()[0].responsive||(c&&"string"===typeof c.details?c.details={type:c.details}:c&&!1===c.details?c.details={type:!1}:c&& +!0===c.details&&(c.details={type:"inline"}),this.c=b.extend(!0,{},u.defaults,z.defaults.responsive,c),a.responsive=this,this._constructor())};b.extend(u.prototype,{_constructor:function(){var a=this,c=this.s.dt,d=c.settings()[0],f=b(k).innerWidth();c.settings()[0]._responsive=this;b(k).on("resize.dtr orientationchange.dtr",z.util.throttle(function(){var g=b(k).innerWidth();g!==f&&(a._resize(),f=g)}));d.oApi._fnCallbackReg(d,"aoRowCreatedCallback",function(g,l,h){-1!==b.inArray(!1,a.s.current)&&b(">td, >th", +g).each(function(e){e=c.column.index("toData",e);!1===a.s.current[e]&&b(this).css("display","none")})});c.on("destroy.dtr",function(){c.off(".dtr");b(c.table().body()).off(".dtr");b(k).off("resize.dtr orientationchange.dtr");c.cells(".dtr-control").nodes().to$().removeClass("dtr-control");b.each(a.s.current,function(g,l){!1===l&&a._setColumnVis(g,!0)})});this.c.breakpoints.sort(function(g,l){return g.width<l.width?1:g.width>l.width?-1:0});this._classLogic();this._resizeAuto();d=this.c.details;!1!== +d.type&&(a._detailsInit(),c.on("column-visibility.dtr",function(){a._timer&&clearTimeout(a._timer);a._timer=setTimeout(function(){a._timer=null;a._classLogic();a._resizeAuto();a._resize(!0);a._redrawChildren()},100)}),c.on("draw.dtr",function(){a._redrawChildren()}),b(c.table().node()).addClass("dtr-"+d.type));c.on("column-reorder.dtr",function(g,l,h){a._classLogic();a._resizeAuto();a._resize(!0)});c.on("column-sizing.dtr",function(){a._resizeAuto();a._resize()});c.on("preXhr.dtr",function(){var g= +[];c.rows().every(function(){this.child.isShown()&&g.push(this.id(!0))});c.one("draw.dtr",function(){a._resizeAuto();a._resize();c.rows(g).every(function(){a._detailsDisplay(this,!1)})})});c.on("draw.dtr",function(){a._controlClass()}).on("init.dtr",function(g,l,h){"dt"===g.namespace&&(a._resizeAuto(),a._resize(),b.inArray(!1,a.s.current)&&c.columns.adjust())});this._resize()},_columnsVisiblity:function(a){var c=this.s.dt,d=this.s.columns,f,g=d.map(function(t,v){return{columnIdx:v,priority:t.priority}}).sort(function(t, +v){return t.priority!==v.priority?t.priority-v.priority:t.columnIdx-v.columnIdx}),l=b.map(d,function(t,v){return!1===c.column(v).visible()?"not-visible":t.auto&&null===t.minWidth?!1:!0===t.auto?"-":-1!==b.inArray(a,t.includeIn)}),h=0;var e=0;for(f=l.length;e<f;e++)!0===l[e]&&(h+=d[e].minWidth);e=c.settings()[0].oScroll;e=e.sY||e.sX?e.iBarWidth:0;h=c.table().container().offsetWidth-e-h;e=0;for(f=l.length;e<f;e++)d[e].control&&(h-=d[e].minWidth);var r=!1;e=0;for(f=g.length;e<f;e++){var q=g[e].columnIdx; +"-"===l[q]&&!d[q].control&&d[q].minWidth&&(r||0>h-d[q].minWidth?(r=!0,l[q]=!1):l[q]=!0,h-=d[q].minWidth)}g=!1;e=0;for(f=d.length;e<f;e++)if(!d[e].control&&!d[e].never&&!1===l[e]){g=!0;break}e=0;for(f=d.length;e<f;e++)d[e].control&&(l[e]=g),"not-visible"===l[e]&&(l[e]=!1);-1===b.inArray(!0,l)&&(l[0]=!0);return l},_classLogic:function(){var a=this,c=this.c.breakpoints,d=this.s.dt,f=d.columns().eq(0).map(function(h){var e=this.column(h),r=e.header().className;h=d.settings()[0].aoColumns[h].responsivePriority; +e=e.header().getAttribute("data-priority");h===n&&(h=e===n||null===e?1E4:1*e);return{className:r,includeIn:[],auto:!1,control:!1,never:r.match(/\bnever\b/)?!0:!1,priority:h}}),g=function(h,e){h=f[h].includeIn;-1===b.inArray(e,h)&&h.push(e)},l=function(h,e,r,q){if(!r)f[h].includeIn.push(e);else if("max-"===r)for(q=a._find(e).width,e=0,r=c.length;e<r;e++)c[e].width<=q&&g(h,c[e].name);else if("min-"===r)for(q=a._find(e).width,e=0,r=c.length;e<r;e++)c[e].width>=q&&g(h,c[e].name);else if("not-"===r)for(e= +0,r=c.length;e<r;e++)-1===c[e].name.indexOf(q)&&g(h,c[e].name)};f.each(function(h,e){for(var r=h.className.split(" "),q=!1,t=0,v=r.length;t<v;t++){var B=r[t].trim();if("all"===B){q=!0;h.includeIn=b.map(c,function(w){return w.name});return}if("none"===B||h.never){q=!0;return}if("control"===B||"dtr-control"===B){q=!0;h.control=!0;return}b.each(c,function(w,D){w=D.name.split("-");var x=B.match(new RegExp("(min\\-|max\\-|not\\-)?("+w[0]+")(\\-[_a-zA-Z0-9])?"));x&&(q=!0,x[2]===w[0]&&x[3]==="-"+w[1]?l(e, +D.name,x[1],x[2]+x[3]):x[2]!==w[0]||x[3]||l(e,D.name,x[1],x[2]))})}q||(h.auto=!0)});this.s.columns=f},_controlClass:function(){if("inline"===this.c.details.type){var a=this.s.dt,c=b.inArray(!0,this.s.current);a.cells(null,function(d){return d!==c},{page:"current"}).nodes().to$().filter(".dtr-control").removeClass("dtr-control");a.cells(null,c,{page:"current"}).nodes().to$().addClass("dtr-control")}},_detailsDisplay:function(a,c){var d=this,f=this.s.dt,g=this.c.details;if(g&&!1!==g.type){var l=g.display(a, +c,function(){return g.renderer(f,a[0],d._detailsObj(a[0]))});!0!==l&&!1!==l||b(f.table().node()).triggerHandler("responsive-display.dt",[f,a,l,c])}},_detailsInit:function(){var a=this,c=this.s.dt,d=this.c.details;"inline"===d.type&&(d.target="td.dtr-control, th.dtr-control");c.on("draw.dtr",function(){a._tabIndexes()});a._tabIndexes();b(c.table().body()).on("keyup.dtr","td, th",function(g){13===g.keyCode&&b(this).data("dtr-keyboard")&&b(this).click()});var f=d.target;d="string"===typeof f?f:"td, th"; +if(f!==n||null!==f)b(c.table().body()).on("click.dtr mousedown.dtr mouseup.dtr",d,function(g){if(b(c.table().node()).hasClass("collapsed")&&-1!==b.inArray(b(this).closest("tr").get(0),c.rows().nodes().toArray())){if("number"===typeof f){var l=0>f?c.columns().eq(0).length+f:f;if(c.cell(this).index().column!==l)return}l=c.row(b(this).closest("tr"));"click"===g.type?a._detailsDisplay(l,!1):"mousedown"===g.type?b(this).css("outline","none"):"mouseup"===g.type&&b(this).trigger("blur").css("outline","")}})}, +_detailsObj:function(a){var c=this,d=this.s.dt;return b.map(this.s.columns,function(f,g){if(!f.never&&!f.control)return f=d.settings()[0].aoColumns[g],{className:f.sClass,columnIndex:g,data:d.cell(a,g).render(c.c.orthogonal),hidden:d.column(g).visible()&&!c.s.current[g],rowIndex:a,title:null!==f.sTitle?f.sTitle:b(d.column(g).header()).text()}})},_find:function(a){for(var c=this.c.breakpoints,d=0,f=c.length;d<f;d++)if(c[d].name===a)return c[d]},_redrawChildren:function(){var a=this,c=this.s.dt;c.rows({page:"current"}).iterator("row", +function(d,f){c.row(f);a._detailsDisplay(c.row(f),!0)})},_resize:function(a){var c=this,d=this.s.dt,f=b(k).innerWidth(),g=this.c.breakpoints,l=g[0].name,h=this.s.columns,e,r=this.s.current.slice();for(e=g.length-1;0<=e;e--)if(f<=g[e].width){l=g[e].name;break}var q=this._columnsVisiblity(l);this.s.current=q;g=!1;e=0;for(f=h.length;e<f;e++)if(!1===q[e]&&!h[e].never&&!h[e].control&&!1===!d.column(e).visible()){g=!0;break}b(d.table().node()).toggleClass("collapsed",g);var t=!1,v=0;d.columns().eq(0).each(function(B, +w){!0===q[w]&&v++;if(a||q[w]!==r[w])t=!0,c._setColumnVis(B,q[w])});t&&(this._redrawChildren(),b(d.table().node()).trigger("responsive-resize.dt",[d,this.s.current]),0===d.page.info().recordsDisplay&&b("td",d.table().body()).eq(0).attr("colspan",v));c._controlClass()},_resizeAuto:function(){var a=this.s.dt,c=this.s.columns;if(this.c.auto&&-1!==b.inArray(!0,b.map(c,function(e){return e.auto}))){b.isEmptyObject(A)||b.each(A,function(e){e=e.split("-");y(a,1*e[0],1*e[1])});a.table().node();var d=a.table().node().cloneNode(!1), +f=b(a.table().header().cloneNode(!1)).appendTo(d),g=b(a.table().body()).clone(!1,!1).empty().appendTo(d);d.style.width="auto";var l=a.columns().header().filter(function(e){return a.column(e).visible()}).to$().clone(!1).css("display","table-cell").css("width","auto").css("min-width",0);b(g).append(b(a.rows({page:"current"}).nodes()).clone(!1)).find("th, td").css("display","");if(g=a.table().footer()){g=b(g.cloneNode(!1)).appendTo(d);var h=a.columns().footer().filter(function(e){return a.column(e).visible()}).to$().clone(!1).css("display", +"table-cell");b("<tr/>").append(h).appendTo(g)}b("<tr/>").append(l).appendTo(f);"inline"===this.c.details.type&&b(d).addClass("dtr-inline collapsed");b(d).find("[name]").removeAttr("name");b(d).css("position","relative");d=b("<div/>").css({width:1,height:1,overflow:"hidden",clear:"both"}).append(d);d.insertBefore(a.table().node());l.each(function(e){e=a.column.index("fromVisible",e);c[e].minWidth=this.offsetWidth||0});d.remove()}},_responsiveOnlyHidden:function(){var a=this.s.dt;return b.map(this.s.current, +function(c,d){return!1===a.column(d).visible()?!0:c})},_setColumnVis:function(a,c){var d=this.s.dt;c=c?"":"none";b(d.column(a).header()).css("display",c);b(d.column(a).footer()).css("display",c);d.column(a).nodes().to$().css("display",c);b.isEmptyObject(A)||d.cells(null,a).indexes().each(function(f){y(d,f.row,f.column)})},_tabIndexes:function(){var a=this.s.dt,c=a.cells({page:"current"}).nodes().to$(),d=a.settings()[0],f=this.c.details.target;c.filter("[data-dtr-keyboard]").removeData("[data-dtr-keyboard]"); +"number"===typeof f?a.cells(null,f,{page:"current"}).nodes().to$().attr("tabIndex",d.iTabIndex).data("dtr-keyboard",1):("td:first-child, th:first-child"===f&&(f=">td:first-child, >th:first-child"),b(f,a.rows({page:"current"}).nodes()).attr("tabIndex",d.iTabIndex).data("dtr-keyboard",1))}});u.breakpoints=[{name:"desktop",width:Infinity},{name:"tablet-l",width:1024},{name:"tablet-p",width:768},{name:"mobile-l",width:480},{name:"mobile-p",width:320}];u.display={childRow:function(a,c,d){if(c){if(b(a.node()).hasClass("parent"))return a.child(d(), +"child").show(),!0}else{if(a.child.isShown())return a.child(!1),b(a.node()).removeClass("parent"),!1;a.child(d(),"child").show();b(a.node()).addClass("parent");return!0}},childRowImmediate:function(a,c,d){if(!c&&a.child.isShown()||!a.responsive.hasHidden())return a.child(!1),b(a.node()).removeClass("parent"),!1;a.child(d(),"child").show();b(a.node()).addClass("parent");return!0},modal:function(a){return function(c,d,f){if(d)b("div.dtr-modal-content").empty().append(f());else{var g=function(){l.remove(); +b(m).off("keypress.dtr")},l=b('<div class="dtr-modal"/>').append(b('<div class="dtr-modal-display"/>').append(b('<div class="dtr-modal-content"/>').append(f())).append(b('<div class="dtr-modal-close">×</div>').click(function(){g()}))).append(b('<div class="dtr-modal-background"/>').click(function(){g()})).appendTo("body");b(m).on("keyup.dtr",function(h){27===h.keyCode&&(h.stopPropagation(),g())})}a&&a.header&&b("div.dtr-modal-content").prepend("<h2>"+a.header(c)+"</h2>")}}};var A={};u.renderer= +{listHiddenNodes:function(){return function(a,c,d){var f=b('<ul data-dtr-index="'+c+'" class="dtr-details"/>'),g=!1;b.each(d,function(l,h){h.hidden&&(b("<li "+(h.className?'class="'+h.className+'"':"")+' data-dtr-index="'+h.columnIndex+'" data-dt-row="'+h.rowIndex+'" data-dt-column="'+h.columnIndex+'"><span class="dtr-title">'+h.title+"</span> </li>").append(b('<span class="dtr-data"/>').append(p(a,h.rowIndex,h.columnIndex))).appendTo(f),g=!0)});return g?f:!1}},listHidden:function(){return function(a, +c,d){return(a=b.map(d,function(f){var g=f.className?'class="'+f.className+'"':"";return f.hidden?"<li "+g+' data-dtr-index="'+f.columnIndex+'" data-dt-row="'+f.rowIndex+'" data-dt-column="'+f.columnIndex+'"><span class="dtr-title">'+f.title+'</span> <span class="dtr-data">'+f.data+"</span></li>":""}).join(""))?b('<ul data-dtr-index="'+c+'" class="dtr-details"/>').append(a):!1}},tableAll:function(a){a=b.extend({tableClass:""},a);return function(c,d,f){c=b.map(f,function(g){return"<tr "+(g.className? +'class="'+g.className+'"':"")+' data-dt-row="'+g.rowIndex+'" data-dt-column="'+g.columnIndex+'"><td>'+g.title+":</td> <td>"+g.data+"</td></tr>"}).join("");return b('<table class="'+a.tableClass+' dtr-details" width="100%"/>').append(c)}}};u.defaults={breakpoints:u.breakpoints,auto:!0,details:{display:u.display.childRow,renderer:u.renderer.listHidden(),target:0,type:"inline"},orthogonal:"display"};var C=b.fn.dataTable.Api;C.register("responsive()",function(){return this});C.register("responsive.index()", +function(a){a=b(a);return{column:a.data("dtr-index"),row:a.parent().data("dtr-index")}});C.register("responsive.rebuild()",function(){return this.iterator("table",function(a){a._responsive&&a._responsive._classLogic()})});C.register("responsive.recalc()",function(){return this.iterator("table",function(a){a._responsive&&(a._responsive._resizeAuto(),a._responsive._resize())})});C.register("responsive.hasHidden()",function(){var a=this.context[0];return a._responsive?-1!==b.inArray(!1,a._responsive._responsiveOnlyHidden()): +!1});C.registerPlural("columns().responsiveHidden()","column().responsiveHidden()",function(){return this.iterator("column",function(a,c){return a._responsive?a._responsive._responsiveOnlyHidden()[c]:!1},1)});u.version="2.2.9";b.fn.dataTable.Responsive=u;b.fn.DataTable.Responsive=u;b(m).on("preInit.dt.dtr",function(a,c,d){"dt"===a.namespace&&(b(c.nTable).hasClass("responsive")||b(c.nTable).hasClass("dt-responsive")||c.oInit.responsive||z.defaults.responsive)&&(a=c.oInit.responsive,!1!==a&&new u(c, +b.isPlainObject(a)?a:{}))});return u}); diff --git a/src/main/resources/static/plugins/datatables-responsive/js/responsive.bootstrap4.js b/src/main/resources/static/plugins/datatables-responsive/js/responsive.bootstrap4.js new file mode 100644 index 0000000..bfbecf1 --- /dev/null +++ b/src/main/resources/static/plugins/datatables-responsive/js/responsive.bootstrap4.js @@ -0,0 +1,85 @@ +/*! Bootstrap 4 integration for DataTables' Responsive + * ©2016 SpryMedia Ltd - datatables.net/license + */ + +(function( factory ){ + if ( typeof define === 'function' && define.amd ) { + // AMD + define( ['jquery', 'datatables.net-bs4', 'datatables.net-responsive'], 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-bs4')(root, $).$; + } + + if ( ! $.fn.dataTable.Responsive ) { + require('datatables.net-responsive')(root, $); + } + + return factory( $, root, root.document ); + }; + } + else { + // Browser + factory( jQuery, window, document ); + } +}(function( $, window, document, undefined ) { +'use strict'; +var DataTable = $.fn.dataTable; + + +var _display = DataTable.Responsive.display; +var _original = _display.modal; +var _modal = $( + '<div class="modal fade dtr-bs-modal" role="dialog">'+ + '<div class="modal-dialog" role="document">'+ + '<div class="modal-content">'+ + '<div class="modal-header">'+ + '<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>'+ + '</div>'+ + '<div class="modal-body"/>'+ + '</div>'+ + '</div>'+ + '</div>' +); + +_display.modal = function ( options ) { + return function ( row, update, render ) { + if ( ! $.fn.modal ) { + _original( row, update, render ); + } + else { + if ( ! update ) { + if ( options && options.header ) { + var header = _modal.find('div.modal-header'); + var button = header.find('button').detach(); + + header + .empty() + .append( '<h4 class="modal-title">'+options.header( row )+'</h4>' ) + .append( button ); + } + + _modal.find( 'div.modal-body' ) + .empty() + .append( render() ); + + _modal + .appendTo( 'body' ) + .modal(); + } + } + }; +}; + + +return DataTable.Responsive; +})); diff --git a/src/main/resources/static/plugins/datatables-responsive/js/responsive.bootstrap4.min.js b/src/main/resources/static/plugins/datatables-responsive/js/responsive.bootstrap4.min.js new file mode 100644 index 0000000..aa467aa --- /dev/null +++ b/src/main/resources/static/plugins/datatables-responsive/js/responsive.bootstrap4.min.js @@ -0,0 +1,12 @@ +/*! + Bootstrap 4 integration for DataTables' Responsive + ©2016 SpryMedia Ltd - datatables.net/license +*/ +var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.findInternal=function(a,b,c){a instanceof String&&(a=String(a));for(var e=a.length,d=0;d<e;d++){var f=a[d];if(b.call(c,f,d,a))return{i:d,v:f}}return{i:-1,v:void 0}};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.SIMPLE_FROUND_POLYFILL=!1;$jscomp.ISOLATE_POLYFILLS=!1; +$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){if(a==Array.prototype||a==Object.prototype)return a;a[b]=c.value;return a};$jscomp.getGlobal=function(a){a=["object"==typeof globalThis&&globalThis,a,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var b=0;b<a.length;++b){var c=a[b];if(c&&c.Math==Math)return c}throw Error("Cannot find global object");};$jscomp.global=$jscomp.getGlobal(this); +$jscomp.IS_SYMBOL_NATIVE="function"===typeof Symbol&&"symbol"===typeof Symbol("x");$jscomp.TRUST_ES6_POLYFILLS=!$jscomp.ISOLATE_POLYFILLS||$jscomp.IS_SYMBOL_NATIVE;$jscomp.polyfills={};$jscomp.propertyToPolyfillSymbol={};$jscomp.POLYFILL_PREFIX="$jscp$";var $jscomp$lookupPolyfilledValue=function(a,b){var c=$jscomp.propertyToPolyfillSymbol[b];if(null==c)return a[b];c=a[c];return void 0!==c?c:a[b]}; +$jscomp.polyfill=function(a,b,c,e){b&&($jscomp.ISOLATE_POLYFILLS?$jscomp.polyfillIsolated(a,b,c,e):$jscomp.polyfillUnisolated(a,b,c,e))};$jscomp.polyfillUnisolated=function(a,b,c,e){c=$jscomp.global;a=a.split(".");for(e=0;e<a.length-1;e++){var d=a[e];if(!(d in c))return;c=c[d]}a=a[a.length-1];e=c[a];b=b(e);b!=e&&null!=b&&$jscomp.defineProperty(c,a,{configurable:!0,writable:!0,value:b})}; +$jscomp.polyfillIsolated=function(a,b,c,e){var d=a.split(".");a=1===d.length;e=d[0];e=!a&&e in $jscomp.polyfills?$jscomp.polyfills:$jscomp.global;for(var f=0;f<d.length-1;f++){var g=d[f];if(!(g in e))return;e=e[g]}d=d[d.length-1];c=$jscomp.IS_SYMBOL_NATIVE&&"es6"===c?e[d]:null;b=b(c);null!=b&&(a?$jscomp.defineProperty($jscomp.polyfills,d,{configurable:!0,writable:!0,value:b}):b!==c&&($jscomp.propertyToPolyfillSymbol[d]=$jscomp.IS_SYMBOL_NATIVE?$jscomp.global.Symbol(d):$jscomp.POLYFILL_PREFIX+d,d= +$jscomp.propertyToPolyfillSymbol[d],$jscomp.defineProperty(e,d,{configurable:!0,writable:!0,value:b})))};$jscomp.polyfill("Array.prototype.find",function(a){return a?a:function(b,c){return $jscomp.findInternal(this,b,c).v}},"es6","es3"); +(function(a){"function"===typeof define&&define.amd?define(["jquery","datatables.net-bs4","datatables.net-responsive"],function(b){return a(b,window,document)}):"object"===typeof exports?module.exports=function(b,c){b||(b=window);c&&c.fn.dataTable||(c=require("datatables.net-bs4")(b,c).$);c.fn.dataTable.Responsive||require("datatables.net-responsive")(b,c);return a(c,b,b.document)}:a(jQuery,window,document)})(function(a,b,c,e){b=a.fn.dataTable;c=b.Responsive.display;var d=c.modal,f=a('<div class="modal fade dtr-bs-modal" role="dialog"><div class="modal-dialog" role="document"><div class="modal-content"><div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button></div><div class="modal-body"/></div></div></div>'); +c.modal=function(g){return function(k,h,l){if(!a.fn.modal)d(k,h,l);else if(!h){if(g&&g.header){h=f.find("div.modal-header");var m=h.find("button").detach();h.empty().append('<h4 class="modal-title">'+g.header(k)+"</h4>").append(m)}f.find("div.modal-body").empty().append(l());f.appendTo("body").modal()}}};return b.Responsive}); |