new ui with AdminLTE
This commit is contained in:
@ -0,0 +1,20 @@
|
||||
table.dataTable.fixedHeader-floating,
|
||||
table.dataTable.fixedHeader-locked {
|
||||
background-color: white;
|
||||
margin-top: 0 !important;
|
||||
margin-bottom: 0 !important;
|
||||
}
|
||||
|
||||
table.dataTable.fixedHeader-floating {
|
||||
position: fixed !important;
|
||||
}
|
||||
|
||||
table.dataTable.fixedHeader-locked {
|
||||
position: absolute !important;
|
||||
}
|
||||
|
||||
@media print {
|
||||
table.fixedHeader-floating {
|
||||
display: none;
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
table.dataTable.fixedHeader-floating,table.dataTable.fixedHeader-locked{background-color:white;margin-top:0 !important;margin-bottom:0 !important}table.dataTable.fixedHeader-floating{position:fixed !important}table.dataTable.fixedHeader-locked{position:absolute !important}@media print{table.fixedHeader-floating{display:none}}
|
@ -0,0 +1,726 @@
|
||||
/*! FixedHeader 3.1.6-dev
|
||||
* ©2009-2018 SpryMedia Ltd - datatables.net/license
|
||||
*/
|
||||
|
||||
/**
|
||||
* @summary FixedHeader
|
||||
* @description Fix a table's header or footer, so it is always visible while
|
||||
* scrolling
|
||||
* @version 3.1.6-dev
|
||||
* @file dataTables.fixedHeader.js
|
||||
* @author SpryMedia Ltd (www.sprymedia.co.uk)
|
||||
* @contact www.sprymedia.co.uk/contact
|
||||
* @copyright Copyright 2009-2018 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;
|
||||
|
||||
|
||||
var _instCounter = 0;
|
||||
|
||||
var FixedHeader = function ( dt, config ) {
|
||||
// Sanity check - you just know it will happen
|
||||
if ( ! (this instanceof FixedHeader) ) {
|
||||
throw "FixedHeader must be initialised with the 'new' keyword.";
|
||||
}
|
||||
|
||||
// Allow a boolean true for defaults
|
||||
if ( config === true ) {
|
||||
config = {};
|
||||
}
|
||||
|
||||
dt = new DataTable.Api( dt );
|
||||
|
||||
this.c = $.extend( true, {}, FixedHeader.defaults, config );
|
||||
|
||||
this.s = {
|
||||
dt: dt,
|
||||
position: {
|
||||
theadTop: 0,
|
||||
tbodyTop: 0,
|
||||
tfootTop: 0,
|
||||
tfootBottom: 0,
|
||||
width: 0,
|
||||
left: 0,
|
||||
tfootHeight: 0,
|
||||
theadHeight: 0,
|
||||
windowHeight: $(window).height(),
|
||||
visible: true
|
||||
},
|
||||
headerMode: null,
|
||||
footerMode: null,
|
||||
autoWidth: dt.settings()[0].oFeatures.bAutoWidth,
|
||||
namespace: '.dtfc'+(_instCounter++),
|
||||
scrollLeft: {
|
||||
header: -1,
|
||||
footer: -1
|
||||
},
|
||||
enable: true
|
||||
};
|
||||
|
||||
this.dom = {
|
||||
floatingHeader: null,
|
||||
thead: $(dt.table().header()),
|
||||
tbody: $(dt.table().body()),
|
||||
tfoot: $(dt.table().footer()),
|
||||
header: {
|
||||
host: null,
|
||||
floating: null,
|
||||
placeholder: null
|
||||
},
|
||||
footer: {
|
||||
host: null,
|
||||
floating: null,
|
||||
placeholder: null
|
||||
}
|
||||
};
|
||||
|
||||
this.dom.header.host = this.dom.thead.parent();
|
||||
this.dom.footer.host = this.dom.tfoot.parent();
|
||||
|
||||
var dtSettings = dt.settings()[0];
|
||||
if ( dtSettings._fixedHeader ) {
|
||||
throw "FixedHeader already initialised on table "+dtSettings.nTable.id;
|
||||
}
|
||||
|
||||
dtSettings._fixedHeader = this;
|
||||
|
||||
this._constructor();
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Variable: FixedHeader
|
||||
* Purpose: Prototype for FixedHeader
|
||||
* Scope: global
|
||||
*/
|
||||
$.extend( FixedHeader.prototype, {
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* API methods
|
||||
*/
|
||||
|
||||
/**
|
||||
* Kill off FH and any events
|
||||
*/
|
||||
destroy: function () {
|
||||
this.s.dt.off( '.dtfc' );
|
||||
$(window).off( this.s.namespace );
|
||||
|
||||
if ( this.c.header ) {
|
||||
this._modeChange( 'in-place', 'header', true );
|
||||
}
|
||||
|
||||
if ( this.c.footer && this.dom.tfoot.length ) {
|
||||
this._modeChange( 'in-place', 'footer', true );
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Enable / disable the fixed elements
|
||||
*
|
||||
* @param {boolean} enable `true` to enable, `false` to disable
|
||||
*/
|
||||
enable: function ( enable, update )
|
||||
{
|
||||
this.s.enable = enable;
|
||||
|
||||
if ( update || update === undefined ) {
|
||||
this._positions();
|
||||
this._scroll( true );
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Get enabled status
|
||||
*/
|
||||
enabled: function ()
|
||||
{
|
||||
return this.s.enable;
|
||||
},
|
||||
|
||||
/**
|
||||
* Set header offset
|
||||
*
|
||||
* @param {int} new value for headerOffset
|
||||
*/
|
||||
headerOffset: function ( offset )
|
||||
{
|
||||
if ( offset !== undefined ) {
|
||||
this.c.headerOffset = offset;
|
||||
this.update();
|
||||
}
|
||||
|
||||
return this.c.headerOffset;
|
||||
},
|
||||
|
||||
/**
|
||||
* Set footer offset
|
||||
*
|
||||
* @param {int} new value for footerOffset
|
||||
*/
|
||||
footerOffset: function ( offset )
|
||||
{
|
||||
if ( offset !== undefined ) {
|
||||
this.c.footerOffset = offset;
|
||||
this.update();
|
||||
}
|
||||
|
||||
return this.c.footerOffset;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Recalculate the position of the fixed elements and force them into place
|
||||
*/
|
||||
update: function ()
|
||||
{
|
||||
var table = this.s.dt.table().node();
|
||||
|
||||
if ( $(table).is(':visible') ) {
|
||||
this.enable( true, false );
|
||||
}
|
||||
else {
|
||||
this.enable( false, false );
|
||||
}
|
||||
|
||||
this._positions();
|
||||
this._scroll( true );
|
||||
},
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Constructor
|
||||
*/
|
||||
|
||||
/**
|
||||
* FixedHeader constructor - adding the required event listeners and
|
||||
* simple initialisation
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
_constructor: function ()
|
||||
{
|
||||
var that = this;
|
||||
var dt = this.s.dt;
|
||||
|
||||
$(window)
|
||||
.on( 'scroll'+this.s.namespace, function () {
|
||||
that._scroll();
|
||||
} )
|
||||
.on( 'resize'+this.s.namespace, DataTable.util.throttle( function () {
|
||||
that.s.position.windowHeight = $(window).height();
|
||||
that.update();
|
||||
}, 50 ) );
|
||||
|
||||
var autoHeader = $('.fh-fixedHeader');
|
||||
if ( ! this.c.headerOffset && autoHeader.length ) {
|
||||
this.c.headerOffset = autoHeader.outerHeight();
|
||||
}
|
||||
|
||||
var autoFooter = $('.fh-fixedFooter');
|
||||
if ( ! this.c.footerOffset && autoFooter.length ) {
|
||||
this.c.footerOffset = autoFooter.outerHeight();
|
||||
}
|
||||
|
||||
dt.on( 'column-reorder.dt.dtfc column-visibility.dt.dtfc draw.dt.dtfc column-sizing.dt.dtfc responsive-display.dt.dtfc', function () {
|
||||
that.update();
|
||||
} );
|
||||
|
||||
dt.on( 'destroy.dtfc', function () {
|
||||
that.destroy();
|
||||
} );
|
||||
|
||||
this._positions();
|
||||
this._scroll();
|
||||
},
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Private methods
|
||||
*/
|
||||
|
||||
/**
|
||||
* Clone a fixed item to act as a place holder for the original element
|
||||
* which is moved into a clone of the table element, and moved around the
|
||||
* document to give the fixed effect.
|
||||
*
|
||||
* @param {string} item 'header' or 'footer'
|
||||
* @param {boolean} force Force the clone to happen, or allow automatic
|
||||
* decision (reuse existing if available)
|
||||
* @private
|
||||
*/
|
||||
_clone: function ( item, force )
|
||||
{
|
||||
var dt = this.s.dt;
|
||||
var itemDom = this.dom[ item ];
|
||||
var itemElement = item === 'header' ?
|
||||
this.dom.thead :
|
||||
this.dom.tfoot;
|
||||
|
||||
if ( ! force && itemDom.floating ) {
|
||||
// existing floating element - reuse it
|
||||
itemDom.floating.removeClass( 'fixedHeader-floating fixedHeader-locked' );
|
||||
}
|
||||
else {
|
||||
if ( itemDom.floating ) {
|
||||
itemDom.placeholder.remove();
|
||||
this._unsize( item );
|
||||
itemDom.floating.children().detach();
|
||||
itemDom.floating.remove();
|
||||
}
|
||||
|
||||
itemDom.floating = $( dt.table().node().cloneNode( false ) )
|
||||
.css( 'table-layout', 'fixed' )
|
||||
.attr( 'aria-hidden', 'true' )
|
||||
.removeAttr( 'id' )
|
||||
.append( itemElement )
|
||||
.appendTo( 'body' );
|
||||
|
||||
// Insert a fake thead/tfoot into the DataTable to stop it jumping around
|
||||
itemDom.placeholder = itemElement.clone( false );
|
||||
itemDom.placeholder
|
||||
.find( '*[id]' )
|
||||
.removeAttr( 'id' );
|
||||
|
||||
itemDom.host.prepend( itemDom.placeholder );
|
||||
|
||||
// Clone widths
|
||||
this._matchWidths( itemDom.placeholder, itemDom.floating );
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Copy widths from the cells in one element to another. This is required
|
||||
* for the footer as the footer in the main table takes its sizes from the
|
||||
* header columns. That isn't present in the footer so to have it still
|
||||
* align correctly, the sizes need to be copied over. It is also required
|
||||
* for the header when auto width is not enabled
|
||||
*
|
||||
* @param {jQuery} from Copy widths from
|
||||
* @param {jQuery} to Copy widths to
|
||||
* @private
|
||||
*/
|
||||
_matchWidths: function ( from, to ) {
|
||||
var get = function ( name ) {
|
||||
return $(name, from)
|
||||
.map( function () {
|
||||
return $(this).width();
|
||||
} ).toArray();
|
||||
};
|
||||
|
||||
var set = function ( name, toWidths ) {
|
||||
$(name, to).each( function ( i ) {
|
||||
$(this).css( {
|
||||
width: toWidths[i],
|
||||
minWidth: toWidths[i]
|
||||
} );
|
||||
} );
|
||||
};
|
||||
|
||||
var thWidths = get( 'th' );
|
||||
var tdWidths = get( 'td' );
|
||||
|
||||
set( 'th', thWidths );
|
||||
set( 'td', tdWidths );
|
||||
},
|
||||
|
||||
/**
|
||||
* Remove assigned widths from the cells in an element. This is required
|
||||
* when inserting the footer back into the main table so the size is defined
|
||||
* by the header columns and also when auto width is disabled in the
|
||||
* DataTable.
|
||||
*
|
||||
* @param {string} item The `header` or `footer`
|
||||
* @private
|
||||
*/
|
||||
_unsize: function ( item ) {
|
||||
var el = this.dom[ item ].floating;
|
||||
|
||||
if ( el && (item === 'footer' || (item === 'header' && ! this.s.autoWidth)) ) {
|
||||
$('th, td', el).css( {
|
||||
width: '',
|
||||
minWidth: ''
|
||||
} );
|
||||
}
|
||||
else if ( el && item === 'header' ) {
|
||||
$('th, td', el).css( 'min-width', '' );
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Reposition the floating elements to take account of horizontal page
|
||||
* scroll
|
||||
*
|
||||
* @param {string} item The `header` or `footer`
|
||||
* @param {int} scrollLeft Document scrollLeft
|
||||
* @private
|
||||
*/
|
||||
_horizontal: function ( item, scrollLeft )
|
||||
{
|
||||
var itemDom = this.dom[ item ];
|
||||
var position = this.s.position;
|
||||
var lastScrollLeft = this.s.scrollLeft;
|
||||
|
||||
if ( itemDom.floating && lastScrollLeft[ item ] !== scrollLeft ) {
|
||||
itemDom.floating.css( 'left', position.left - scrollLeft );
|
||||
|
||||
lastScrollLeft[ item ] = scrollLeft;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Change from one display mode to another. Each fixed item can be in one
|
||||
* of:
|
||||
*
|
||||
* * `in-place` - In the main DataTable
|
||||
* * `in` - Floating over the DataTable
|
||||
* * `below` - (Header only) Fixed to the bottom of the table body
|
||||
* * `above` - (Footer only) Fixed to the top of the table body
|
||||
*
|
||||
* @param {string} mode Mode that the item should be shown in
|
||||
* @param {string} item 'header' or 'footer'
|
||||
* @param {boolean} forceChange Force a redraw of the mode, even if already
|
||||
* in that mode.
|
||||
* @private
|
||||
*/
|
||||
_modeChange: function ( mode, item, forceChange )
|
||||
{
|
||||
var dt = this.s.dt;
|
||||
var itemDom = this.dom[ item ];
|
||||
var position = this.s.position;
|
||||
|
||||
// Record focus. Browser's will cause input elements to loose focus if
|
||||
// they are inserted else where in the doc
|
||||
var tablePart = this.dom[ item==='footer' ? 'tfoot' : 'thead' ];
|
||||
var focus = $.contains( tablePart[0], document.activeElement ) ?
|
||||
document.activeElement :
|
||||
null;
|
||||
|
||||
if ( focus ) {
|
||||
focus.blur();
|
||||
}
|
||||
|
||||
if ( mode === 'in-place' ) {
|
||||
// Insert the header back into the table's real header
|
||||
if ( itemDom.placeholder ) {
|
||||
itemDom.placeholder.remove();
|
||||
itemDom.placeholder = null;
|
||||
}
|
||||
|
||||
this._unsize( item );
|
||||
|
||||
if ( item === 'header' ) {
|
||||
itemDom.host.prepend( tablePart );
|
||||
}
|
||||
else {
|
||||
itemDom.host.append( tablePart );
|
||||
}
|
||||
|
||||
if ( itemDom.floating ) {
|
||||
itemDom.floating.remove();
|
||||
itemDom.floating = null;
|
||||
}
|
||||
}
|
||||
else if ( mode === 'in' ) {
|
||||
// Remove the header from the read header and insert into a fixed
|
||||
// positioned floating table clone
|
||||
this._clone( item, forceChange );
|
||||
|
||||
itemDom.floating
|
||||
.addClass( 'fixedHeader-floating' )
|
||||
.css( item === 'header' ? 'top' : 'bottom', this.c[item+'Offset'] )
|
||||
.css( 'left', position.left+'px' )
|
||||
.css( 'width', position.width+'px' );
|
||||
|
||||
if ( item === 'footer' ) {
|
||||
itemDom.floating.css( 'top', '' );
|
||||
}
|
||||
}
|
||||
else if ( mode === 'below' ) { // only used for the header
|
||||
// Fix the position of the floating header at base of the table body
|
||||
this._clone( item, forceChange );
|
||||
|
||||
itemDom.floating
|
||||
.addClass( 'fixedHeader-locked' )
|
||||
.css( 'top', position.tfootTop - position.theadHeight )
|
||||
.css( 'left', position.left+'px' )
|
||||
.css( 'width', position.width+'px' );
|
||||
}
|
||||
else if ( mode === 'above' ) { // only used for the footer
|
||||
// Fix the position of the floating footer at top of the table body
|
||||
this._clone( item, forceChange );
|
||||
|
||||
itemDom.floating
|
||||
.addClass( 'fixedHeader-locked' )
|
||||
.css( 'top', position.tbodyTop )
|
||||
.css( 'left', position.left+'px' )
|
||||
.css( 'width', position.width+'px' );
|
||||
}
|
||||
|
||||
// Restore focus if it was lost
|
||||
if ( focus && focus !== document.activeElement ) {
|
||||
setTimeout( function () {
|
||||
focus.focus();
|
||||
}, 10 );
|
||||
}
|
||||
|
||||
this.s.scrollLeft.header = -1;
|
||||
this.s.scrollLeft.footer = -1;
|
||||
this.s[item+'Mode'] = mode;
|
||||
},
|
||||
|
||||
/**
|
||||
* Cache the positional information that is required for the mode
|
||||
* calculations that FixedHeader performs.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
_positions: function ()
|
||||
{
|
||||
var dt = this.s.dt;
|
||||
var table = dt.table();
|
||||
var position = this.s.position;
|
||||
var dom = this.dom;
|
||||
var tableNode = $(table.node());
|
||||
|
||||
// Need to use the header and footer that are in the main table,
|
||||
// regardless of if they are clones, since they hold the positions we
|
||||
// want to measure from
|
||||
var thead = tableNode.children('thead');
|
||||
var tfoot = tableNode.children('tfoot');
|
||||
var tbody = dom.tbody;
|
||||
|
||||
position.visible = tableNode.is(':visible');
|
||||
position.width = tableNode.outerWidth();
|
||||
position.left = tableNode.offset().left;
|
||||
position.theadTop = thead.offset().top;
|
||||
position.tbodyTop = tbody.offset().top;
|
||||
position.tbodyHeight = tbody.outerHeight();
|
||||
position.theadHeight = position.tbodyTop - position.theadTop;
|
||||
|
||||
if ( tfoot.length ) {
|
||||
position.tfootTop = tfoot.offset().top;
|
||||
position.tfootBottom = position.tfootTop + tfoot.outerHeight();
|
||||
position.tfootHeight = position.tfootBottom - position.tfootTop;
|
||||
}
|
||||
else {
|
||||
position.tfootTop = position.tbodyTop + tbody.outerHeight();
|
||||
position.tfootBottom = position.tfootTop;
|
||||
position.tfootHeight = position.tfootTop;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Mode calculation - determine what mode the fixed items should be placed
|
||||
* into.
|
||||
*
|
||||
* @param {boolean} forceChange Force a redraw of the mode, even if already
|
||||
* in that mode.
|
||||
* @private
|
||||
*/
|
||||
_scroll: function ( forceChange )
|
||||
{
|
||||
var windowTop = $(document).scrollTop();
|
||||
var windowLeft = $(document).scrollLeft();
|
||||
var position = this.s.position;
|
||||
var headerMode, footerMode;
|
||||
|
||||
if ( this.c.header ) {
|
||||
if ( ! this.s.enable ) {
|
||||
headerMode = 'in-place';
|
||||
}
|
||||
else if ( ! position.visible || windowTop <= position.theadTop - this.c.headerOffset ) {
|
||||
headerMode = 'in-place';
|
||||
}
|
||||
else if ( windowTop <= position.tfootTop - position.theadHeight - this.c.headerOffset ) {
|
||||
headerMode = 'in';
|
||||
}
|
||||
else {
|
||||
headerMode = 'below';
|
||||
}
|
||||
|
||||
if ( forceChange || headerMode !== this.s.headerMode ) {
|
||||
this._modeChange( headerMode, 'header', forceChange );
|
||||
}
|
||||
|
||||
this._horizontal( 'header', windowLeft );
|
||||
}
|
||||
|
||||
if ( this.c.footer && this.dom.tfoot.length ) {
|
||||
if ( ! this.s.enable ) {
|
||||
headerMode = 'in-place';
|
||||
}
|
||||
else if ( ! position.visible || windowTop + position.windowHeight >= position.tfootBottom + this.c.footerOffset ) {
|
||||
footerMode = 'in-place';
|
||||
}
|
||||
else if ( position.windowHeight + windowTop > position.tbodyTop + position.tfootHeight + this.c.footerOffset ) {
|
||||
footerMode = 'in';
|
||||
}
|
||||
else {
|
||||
footerMode = 'above';
|
||||
}
|
||||
|
||||
if ( forceChange || footerMode !== this.s.footerMode ) {
|
||||
this._modeChange( footerMode, 'footer', forceChange );
|
||||
}
|
||||
|
||||
this._horizontal( 'footer', windowLeft );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
|
||||
/**
|
||||
* Version
|
||||
* @type {String}
|
||||
* @static
|
||||
*/
|
||||
FixedHeader.version = "3.1.6-dev";
|
||||
|
||||
/**
|
||||
* Defaults
|
||||
* @type {Object}
|
||||
* @static
|
||||
*/
|
||||
FixedHeader.defaults = {
|
||||
header: true,
|
||||
footer: false,
|
||||
headerOffset: 0,
|
||||
footerOffset: 0
|
||||
};
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* DataTables interfaces
|
||||
*/
|
||||
|
||||
// Attach for constructor access
|
||||
$.fn.dataTable.FixedHeader = FixedHeader;
|
||||
$.fn.DataTable.FixedHeader = FixedHeader;
|
||||
|
||||
|
||||
// DataTables creation - check if the FixedHeader option has been defined on the
|
||||
// table and if so, initialise
|
||||
$(document).on( 'init.dt.dtfh', function (e, settings, json) {
|
||||
if ( e.namespace !== 'dt' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var init = settings.oInit.fixedHeader;
|
||||
var defaults = DataTable.defaults.fixedHeader;
|
||||
|
||||
if ( (init || defaults) && ! settings._fixedHeader ) {
|
||||
var opts = $.extend( {}, defaults, init );
|
||||
|
||||
if ( init !== false ) {
|
||||
new FixedHeader( settings, opts );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
// DataTables API methods
|
||||
DataTable.Api.register( 'fixedHeader()', function () {} );
|
||||
|
||||
DataTable.Api.register( 'fixedHeader.adjust()', function () {
|
||||
return this.iterator( 'table', function ( ctx ) {
|
||||
var fh = ctx._fixedHeader;
|
||||
|
||||
if ( fh ) {
|
||||
fh.update();
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
DataTable.Api.register( 'fixedHeader.enable()', function ( flag ) {
|
||||
return this.iterator( 'table', function ( ctx ) {
|
||||
var fh = ctx._fixedHeader;
|
||||
|
||||
flag = ( flag !== undefined ? flag : true );
|
||||
if ( fh && flag !== fh.enabled() ) {
|
||||
fh.enable( flag );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
DataTable.Api.register( 'fixedHeader.enabled()', function () {
|
||||
if ( this.context.length ) {
|
||||
var fx = this.content[0]._fixedHeader;
|
||||
|
||||
if ( fh ) {
|
||||
return fh.enabled();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
} );
|
||||
|
||||
DataTable.Api.register( 'fixedHeader.disable()', function ( ) {
|
||||
return this.iterator( 'table', function ( ctx ) {
|
||||
var fh = ctx._fixedHeader;
|
||||
|
||||
if ( fh && fh.enabled() ) {
|
||||
fh.enable( false );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
$.each( ['header', 'footer'], function ( i, el ) {
|
||||
DataTable.Api.register( 'fixedHeader.'+el+'Offset()', function ( offset ) {
|
||||
var ctx = this.context;
|
||||
|
||||
if ( offset === undefined ) {
|
||||
return ctx.length && ctx[0]._fixedHeader ?
|
||||
ctx[0]._fixedHeader[el +'Offset']() :
|
||||
undefined;
|
||||
}
|
||||
|
||||
return this.iterator( 'table', function ( ctx ) {
|
||||
var fh = ctx._fixedHeader;
|
||||
|
||||
if ( fh ) {
|
||||
fh[ el +'Offset' ]( offset );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
|
||||
|
||||
return FixedHeader;
|
||||
}));
|
18
resources/wwwroot/lib/AdminLTE/plugins/datatables-fixedheader/js/dataTables.fixedHeader.min.js
vendored
Normal file
18
resources/wwwroot/lib/AdminLTE/plugins/datatables-fixedheader/js/dataTables.fixedHeader.min.js
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
/*!
|
||||
FixedHeader 3.1.6-dev
|
||||
©2009-2018 SpryMedia Ltd - datatables.net/license
|
||||
*/
|
||||
(function(d){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(g){return d(g,window,document)}):"object"===typeof exports?module.exports=function(g,i){g||(g=window);if(!i||!i.fn.dataTable)i=require("datatables.net")(g,i).$;return d(i,g,g.document)}:d(jQuery,window,document)})(function(d,g,i,k){var h=d.fn.dataTable,l=0,j=function(a,b){if(!(this instanceof j))throw"FixedHeader must be initialised with the 'new' keyword.";!0===b&&(b={});a=new h.Api(a);this.c=d.extend(!0,
|
||||
{},j.defaults,b);this.s={dt:a,position:{theadTop:0,tbodyTop:0,tfootTop:0,tfootBottom:0,width:0,left:0,tfootHeight:0,theadHeight:0,windowHeight:d(g).height(),visible:!0},headerMode:null,footerMode:null,autoWidth:a.settings()[0].oFeatures.bAutoWidth,namespace:".dtfc"+l++,scrollLeft:{header:-1,footer:-1},enable:!0};this.dom={floatingHeader:null,thead:d(a.table().header()),tbody:d(a.table().body()),tfoot:d(a.table().footer()),header:{host:null,floating:null,placeholder:null},footer:{host:null,floating:null,
|
||||
placeholder:null}};this.dom.header.host=this.dom.thead.parent();this.dom.footer.host=this.dom.tfoot.parent();var e=a.settings()[0];if(e._fixedHeader)throw"FixedHeader already initialised on table "+e.nTable.id;e._fixedHeader=this;this._constructor()};d.extend(j.prototype,{destroy:function(){this.s.dt.off(".dtfc");d(g).off(this.s.namespace);this.c.header&&this._modeChange("in-place","header",!0);this.c.footer&&this.dom.tfoot.length&&this._modeChange("in-place","footer",!0)},enable:function(a,b){this.s.enable=
|
||||
a;if(b||b===k)this._positions(),this._scroll(!0)},enabled:function(){return this.s.enable},headerOffset:function(a){a!==k&&(this.c.headerOffset=a,this.update());return this.c.headerOffset},footerOffset:function(a){a!==k&&(this.c.footerOffset=a,this.update());return this.c.footerOffset},update:function(){var a=this.s.dt.table().node();d(a).is(":visible")?this.enable(!0,!1):this.enable(!1,!1);this._positions();this._scroll(!0)},_constructor:function(){var a=this,b=this.s.dt;d(g).on("scroll"+this.s.namespace,
|
||||
function(){a._scroll()}).on("resize"+this.s.namespace,h.util.throttle(function(){a.s.position.windowHeight=d(g).height();a.update()},50));var e=d(".fh-fixedHeader");!this.c.headerOffset&&e.length&&(this.c.headerOffset=e.outerHeight());e=d(".fh-fixedFooter");!this.c.footerOffset&&e.length&&(this.c.footerOffset=e.outerHeight());b.on("column-reorder.dt.dtfc column-visibility.dt.dtfc draw.dt.dtfc column-sizing.dt.dtfc responsive-display.dt.dtfc",function(){a.update()});b.on("destroy.dtfc",function(){a.destroy()});
|
||||
this._positions();this._scroll()},_clone:function(a,b){var e=this.s.dt,c=this.dom[a],f="header"===a?this.dom.thead:this.dom.tfoot;!b&&c.floating?c.floating.removeClass("fixedHeader-floating fixedHeader-locked"):(c.floating&&(c.placeholder.remove(),this._unsize(a),c.floating.children().detach(),c.floating.remove()),c.floating=d(e.table().node().cloneNode(!1)).css("table-layout","fixed").attr("aria-hidden","true").removeAttr("id").append(f).appendTo("body"),c.placeholder=f.clone(!1),c.placeholder.find("*[id]").removeAttr("id"),
|
||||
c.host.prepend(c.placeholder),this._matchWidths(c.placeholder,c.floating))},_matchWidths:function(a,b){var e=function(b){return d(b,a).map(function(){return d(this).width()}).toArray()},c=function(a,c){d(a,b).each(function(a){d(this).css({width:c[a],minWidth:c[a]})})},f=e("th"),e=e("td");c("th",f);c("td",e)},_unsize:function(a){var b=this.dom[a].floating;b&&("footer"===a||"header"===a&&!this.s.autoWidth)?d("th, td",b).css({width:"",minWidth:""}):b&&"header"===a&&d("th, td",b).css("min-width","")},
|
||||
_horizontal:function(a,b){var e=this.dom[a],c=this.s.position,d=this.s.scrollLeft;e.floating&&d[a]!==b&&(e.floating.css("left",c.left-b),d[a]=b)},_modeChange:function(a,b,e){var c=this.dom[b],f=this.s.position,g=this.dom["footer"===b?"tfoot":"thead"],h=d.contains(g[0],i.activeElement)?i.activeElement:null;h&&h.blur();if("in-place"===a){if(c.placeholder&&(c.placeholder.remove(),c.placeholder=null),this._unsize(b),"header"===b?c.host.prepend(g):c.host.append(g),c.floating)c.floating.remove(),c.floating=
|
||||
null}else"in"===a?(this._clone(b,e),c.floating.addClass("fixedHeader-floating").css("header"===b?"top":"bottom",this.c[b+"Offset"]).css("left",f.left+"px").css("width",f.width+"px"),"footer"===b&&c.floating.css("top","")):"below"===a?(this._clone(b,e),c.floating.addClass("fixedHeader-locked").css("top",f.tfootTop-f.theadHeight).css("left",f.left+"px").css("width",f.width+"px")):"above"===a&&(this._clone(b,e),c.floating.addClass("fixedHeader-locked").css("top",f.tbodyTop).css("left",f.left+"px").css("width",
|
||||
f.width+"px"));h&&h!==i.activeElement&&setTimeout(function(){h.focus()},10);this.s.scrollLeft.header=-1;this.s.scrollLeft.footer=-1;this.s[b+"Mode"]=a},_positions:function(){var a=this.s.dt.table(),b=this.s.position,e=this.dom,a=d(a.node()),c=a.children("thead"),f=a.children("tfoot"),e=e.tbody;b.visible=a.is(":visible");b.width=a.outerWidth();b.left=a.offset().left;b.theadTop=c.offset().top;b.tbodyTop=e.offset().top;b.tbodyHeight=e.outerHeight();b.theadHeight=b.tbodyTop-b.theadTop;f.length?(b.tfootTop=
|
||||
f.offset().top,b.tfootBottom=b.tfootTop+f.outerHeight(),b.tfootHeight=b.tfootBottom-b.tfootTop):(b.tfootTop=b.tbodyTop+e.outerHeight(),b.tfootBottom=b.tfootTop,b.tfootHeight=b.tfootTop)},_scroll:function(a){var b=d(i).scrollTop(),e=d(i).scrollLeft(),c=this.s.position,f,g;this.c.header&&(f=this.s.enable?!c.visible||b<=c.theadTop-this.c.headerOffset?"in-place":b<=c.tfootTop-c.theadHeight-this.c.headerOffset?"in":"below":"in-place",(a||f!==this.s.headerMode)&&this._modeChange(f,"header",a),this._horizontal("header",
|
||||
e));this.c.footer&&this.dom.tfoot.length&&(this.s.enable&&(g=!c.visible||b+c.windowHeight>=c.tfootBottom+this.c.footerOffset?"in-place":c.windowHeight+b>c.tbodyTop+c.tfootHeight+this.c.footerOffset?"in":"above"),(a||g!==this.s.footerMode)&&this._modeChange(g,"footer",a),this._horizontal("footer",e))}});j.version="3.1.6-dev";j.defaults={header:!0,footer:!1,headerOffset:0,footerOffset:0};d.fn.dataTable.FixedHeader=j;d.fn.DataTable.FixedHeader=j;d(i).on("init.dt.dtfh",function(a,b){if("dt"===a.namespace){var e=
|
||||
b.oInit.fixedHeader,c=h.defaults.fixedHeader;if((e||c)&&!b._fixedHeader)c=d.extend({},c,e),!1!==e&&new j(b,c)}});h.Api.register("fixedHeader()",function(){});h.Api.register("fixedHeader.adjust()",function(){return this.iterator("table",function(a){(a=a._fixedHeader)&&a.update()})});h.Api.register("fixedHeader.enable()",function(a){return this.iterator("table",function(b){b=b._fixedHeader;a=a!==k?a:!0;b&&a!==b.enabled()&&b.enable(a)})});h.Api.register("fixedHeader.enabled()",function(){return this.context.length&&
|
||||
fh?fh.enabled():!1});h.Api.register("fixedHeader.disable()",function(){return this.iterator("table",function(a){(a=a._fixedHeader)&&a.enabled()&&a.enable(!1)})});d.each(["header","footer"],function(a,b){h.Api.register("fixedHeader."+b+"Offset()",function(a){var c=this.context;return a===k?c.length&&c[0]._fixedHeader?c[0]._fixedHeader[b+"Offset"]():k:this.iterator("table",function(c){if(c=c._fixedHeader)c[b+"Offset"](a)})})});return j});
|
@ -0,0 +1,38 @@
|
||||
/*! Bootstrap 4 styling wrapper for FixedHeader
|
||||
* ©2018 SpryMedia Ltd - datatables.net/license
|
||||
*/
|
||||
|
||||
(function( factory ){
|
||||
if ( typeof define === 'function' && define.amd ) {
|
||||
// AMD
|
||||
define( ['jquery', 'datatables.net-bs4', 'datatables.net-fixedheader'], 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.FixedHeader ) {
|
||||
require('datatables.net-fixedheader')(root, $);
|
||||
}
|
||||
|
||||
return factory( $, root, root.document );
|
||||
};
|
||||
}
|
||||
else {
|
||||
// Browser
|
||||
factory( jQuery, window, document );
|
||||
}
|
||||
}(function( $, window, document, undefined ) {
|
||||
|
||||
return $.fn.dataTable;
|
||||
|
||||
}));
|
@ -0,0 +1,5 @@
|
||||
/*!
|
||||
Bootstrap 4 styling wrapper for FixedHeader
|
||||
©2018 SpryMedia Ltd - datatables.net/license
|
||||
*/
|
||||
(function(c){"function"===typeof define&&define.amd?define(["jquery","datatables.net-bs4","datatables.net-fixedheader"],function(a){return c(a,window,document)}):"object"===typeof exports?module.exports=function(a,b){a||(a=window);if(!b||!b.fn.dataTable)b=require("datatables.net-bs4")(a,b).$;b.fn.dataTable.FixedHeader||require("datatables.net-fixedheader")(a,b);return c(b,a,a.document)}:c(jQuery,window,document)})(function(c){return c.fn.dataTable});
|
Reference in New Issue
Block a user