datatables.net-bs
Advanced tools
Comparing version 2.1.1 to 2.1.2
/*! DataTables Bootstrap 3 integration | ||
* ©2011-2015 SpryMedia Ltd - datatables.net/license | ||
* © SpryMedia Ltd - datatables.net/license | ||
*/ | ||
/** | ||
* DataTables integration for Bootstrap 3. This requires Bootstrap 3 and | ||
* DataTables 1.10 or newer. | ||
* | ||
* This file sets the defaults and adds options to DataTables to style its | ||
* controls using Bootstrap. See http://datatables.net/manual/styling/bootstrap | ||
* for further information. | ||
*/ | ||
(function( factory ){ | ||
@@ -22,16 +14,29 @@ if ( typeof define === 'function' && define.amd ) { | ||
// CommonJS | ||
module.exports = function (root, $) { | ||
if ( ! root ) { | ||
root = window; | ||
var jq = require('jquery'); | ||
var cjsRequires = function (root, $) { | ||
if ( ! $.fn.dataTable ) { | ||
require('datatables.net')(root, $); | ||
} | ||
}; | ||
if ( ! $ || ! $.fn.dataTable ) { | ||
// Require DataTables, which attaches to jQuery, including | ||
// jQuery if needed and have a $ property so we can access the | ||
// jQuery object that is used | ||
$ = require('datatables.net')(root, $).$; | ||
} | ||
if (typeof window === 'undefined') { | ||
module.exports = function (root, $) { | ||
if ( ! root ) { | ||
// CommonJS environments without a window global must pass a | ||
// root. This will give an error otherwise | ||
root = window; | ||
} | ||
return factory( $, root, root.document ); | ||
}; | ||
if ( ! $ ) { | ||
$ = jq( root ); | ||
} | ||
cjsRequires( root, $ ); | ||
return factory( $, root, root.document ); | ||
}; | ||
} | ||
else { | ||
cjsRequires( window, jq ); | ||
module.exports = factory( jq, window, window.document ); | ||
} | ||
} | ||
@@ -42,3 +47,3 @@ else { | ||
} | ||
}(function( $, window, document, undefined ) { | ||
}(function( $, window, document ) { | ||
'use strict'; | ||
@@ -48,8 +53,13 @@ var DataTable = $.fn.dataTable; | ||
/** | ||
* DataTables integration for Bootstrap 3. | ||
* | ||
* This file sets the defaults and adds options to DataTables to style its | ||
* controls using Bootstrap. See https://datatables.net/manual/styling/bootstrap | ||
* for further information. | ||
*/ | ||
/* Set the defaults for DataTables initialisation */ | ||
$.extend( true, DataTable.defaults, { | ||
dom: | ||
"<'row'<'col-sm-6'l><'col-sm-6'f>>" + | ||
"<'row'<'col-sm-12'tr>>" + | ||
"<'row'<'col-sm-5'i><'col-sm-7'p>>", | ||
renderer: 'bootstrap' | ||
@@ -60,123 +70,51 @@ } ); | ||
/* Default class modification */ | ||
$.extend( DataTable.ext.classes, { | ||
sWrapper: "dataTables_wrapper form-inline dt-bootstrap", | ||
sFilterInput: "form-control input-sm", | ||
sLengthSelect: "form-control input-sm", | ||
sProcessing: "dataTables_processing panel panel-default" | ||
$.extend( true, DataTable.ext.classes, { | ||
container: "dt-container form-inline dt-bootstrap", | ||
search: { | ||
input: "form-control input-sm" | ||
}, | ||
length: { | ||
select: "form-control input-sm" | ||
}, | ||
processing: { | ||
container: "dt-processing panel panel-default" | ||
}, | ||
layout: { | ||
row: 'row dt-layout-row', | ||
cell: 'dt-layout-cell', | ||
tableCell: 'col-12', | ||
start: 'dt-layout-start col-sm-6', | ||
end: 'dt-layout-end col-sm-6', | ||
full: 'dt-layout-full col-sm-12' | ||
} | ||
} ); | ||
/* Bootstrap paging button renderer */ | ||
DataTable.ext.renderer.pageButton.bootstrap = function ( settings, host, idx, buttons, page, pages ) { | ||
var api = new DataTable.Api( settings ); | ||
var classes = settings.oClasses; | ||
var lang = settings.oLanguage.oPaginate; | ||
var aria = settings.oLanguage.oAria.paginate || {}; | ||
var btnDisplay, btnClass, counter=0; | ||
DataTable.ext.renderer.pagingButton.bootstrap = function (settings, buttonType, content, active, disabled) { | ||
var btnClasses = ['dt-paging-button', 'page-item']; | ||
var attach = function( container, buttons ) { | ||
var i, ien, node, button; | ||
var clickHandler = function ( e ) { | ||
e.preventDefault(); | ||
if ( !$(e.currentTarget).hasClass('disabled') && api.page() != e.data.action ) { | ||
api.page( e.data.action ).draw( 'page' ); | ||
} | ||
}; | ||
if (active) { | ||
btnClasses.push('active'); | ||
} | ||
for ( i=0, ien=buttons.length ; i<ien ; i++ ) { | ||
button = buttons[i]; | ||
if (disabled) { | ||
btnClasses.push('disabled') | ||
} | ||
if ( $.isArray( button ) ) { | ||
attach( container, button ); | ||
} | ||
else { | ||
btnDisplay = ''; | ||
btnClass = ''; | ||
var li = $('<li>').addClass(btnClasses.join(' ')); | ||
var a = $('<a>', { | ||
'href': disabled ? null : '#', | ||
'class': 'page-link' | ||
}) | ||
.html(content) | ||
.appendTo(li); | ||
switch ( button ) { | ||
case 'ellipsis': | ||
btnDisplay = '…'; | ||
btnClass = 'disabled'; | ||
break; | ||
case 'first': | ||
btnDisplay = lang.sFirst; | ||
btnClass = button + (page > 0 ? | ||
'' : ' disabled'); | ||
break; | ||
case 'previous': | ||
btnDisplay = lang.sPrevious; | ||
btnClass = button + (page > 0 ? | ||
'' : ' disabled'); | ||
break; | ||
case 'next': | ||
btnDisplay = lang.sNext; | ||
btnClass = button + (page < pages-1 ? | ||
'' : ' disabled'); | ||
break; | ||
case 'last': | ||
btnDisplay = lang.sLast; | ||
btnClass = button + (page < pages-1 ? | ||
'' : ' disabled'); | ||
break; | ||
default: | ||
btnDisplay = button + 1; | ||
btnClass = page === button ? | ||
'active' : ''; | ||
break; | ||
} | ||
if ( btnDisplay ) { | ||
node = $('<li>', { | ||
'class': classes.sPageButton+' '+btnClass, | ||
'id': idx === 0 && typeof button === 'string' ? | ||
settings.sTableId +'_'+ button : | ||
null | ||
} ) | ||
.append( $('<a>', { | ||
'href': '#', | ||
'aria-controls': settings.sTableId, | ||
'aria-label': aria[ button ], | ||
'data-dt-idx': counter, | ||
'tabindex': settings.iTabIndex | ||
} ) | ||
.html( btnDisplay ) | ||
) | ||
.appendTo( container ); | ||
settings.oApi._fnBindAction( | ||
node, {action: button}, clickHandler | ||
); | ||
counter++; | ||
} | ||
} | ||
} | ||
return { | ||
display: li, | ||
clicker: a | ||
}; | ||
}; | ||
// IE9 throws an 'unknown error' if document.activeElement is used | ||
// inside an iframe or frame. | ||
var activeEl; | ||
try { | ||
// Because this approach is destroying and recreating the paging | ||
// elements, focus is lost on the select button which is bad for | ||
// accessibility. So we want to restore focus once the draw has | ||
// completed | ||
activeEl = $(host).find(document.activeElement).data('dt-idx'); | ||
} | ||
catch (e) {} | ||
attach( | ||
$(host).empty().html('<ul class="pagination"/>').children('ul'), | ||
buttons | ||
); | ||
if ( activeEl !== undefined ) { | ||
$(host).find( '[data-dt-idx='+activeEl+']' ).focus(); | ||
} | ||
DataTable.ext.renderer.pagingContainer.bootstrap = function (settings, buttonEls) { | ||
return $('<ul/>').addClass('pagination').append(buttonEls); | ||
}; | ||
@@ -183,0 +121,0 @@ |
{ | ||
"name": "datatables.net-bs", | ||
"version": "2.1.1", | ||
"description": "DataTables for jQuery with styling for [Bootstrap](http://getbootstrap.com/)", | ||
"description": "DataTables for jQuery with styling for [Bootstrap](https://getbootstrap.com/docs/3.3/)", | ||
"main": "js/dataTables.bootstrap.js", | ||
"module": "js/dataTables.bootstrap.mjs", | ||
"style": "css/dataTables.bootstrap.css", | ||
"types": "./types/dataTables.bootstrap.d.ts", | ||
"version": "2.1.2", | ||
"files": [ | ||
"js/dataTables.bootstrap.js", | ||
"css/dataTables.bootstrap.css" | ||
"css/**/*.css", | ||
"js/**/*.js", | ||
"js/**/*.mjs", | ||
"types/**/*.d.ts" | ||
], | ||
"main": "js/dataTables.bootstrap.js", | ||
"style": "css/dataTables.bootstrap.css", | ||
"keywords": [ | ||
"filter", | ||
"sort", | ||
"DataTables", | ||
"Bootstrap", | ||
"Datatables", | ||
"jQuery", | ||
"table", | ||
"Bootstrap" | ||
"filter", | ||
"sort" | ||
], | ||
"homepage": "https://datatables.net", | ||
"bugs": "https://datatables.net/forums", | ||
"license": "MIT", | ||
"dependencies": { | ||
"datatables.net": "2.1.2", | ||
"jquery": ">=1.7" | ||
}, | ||
"moduleType": [ | ||
"globals", | ||
"amd", | ||
"node" | ||
], | ||
"ignore": [ | ||
"composer.json", | ||
"datatables.json", | ||
"package.json" | ||
], | ||
"author": { | ||
@@ -26,6 +41,5 @@ "name": "SpryMedia Ltd", | ||
}, | ||
"dependencies": { | ||
"jquery": ">=1.7", | ||
"datatables.net": ">=1.10.9" | ||
}, | ||
"homepage": "https://datatables.net", | ||
"bugs": "https://datatables.net/forums", | ||
"license": "MIT", | ||
"repository": { | ||
@@ -32,0 +46,0 @@ "type": "git", |
@@ -1,4 +0,4 @@ | ||
# DataTables for jQuery with styling for [Bootstrap](http://getbootstrap.com/) | ||
# DataTables for jQuery with styling for [Bootstrap](https://getbootstrap.com/docs/3.3/) | ||
This package contains distribution files required to style [DataTables library](https://datatables.net) for [jQuery](http://jquery.com/) with styling for [Bootstrap](http://getbootstrap.com/). | ||
This package contains distribution files required to style [DataTables library](https://datatables.net) for [jQuery](http://jquery.com/) with styling for [Bootstrap](https://getbootstrap.com/docs/3.3/). | ||
@@ -20,2 +20,3 @@ DataTables is a table enhancing library which adds features such as paging, ordering, search, scrolling and many more to a static HTML page. A comprehensive API is also available that can be used to manipulate the table. Please refer to the [DataTables web-site](//datatables.net) for a full range of documentation and examples. | ||
ES3 Syntax | ||
``` | ||
@@ -26,2 +27,7 @@ var $ = require( 'jquery' ); | ||
ES6 Syntax | ||
``` | ||
import 'datatables.net-bs' | ||
``` | ||
### bower | ||
@@ -37,3 +43,3 @@ | ||
Full documentation of the DataTables options, API and plug-in interface are available on the DOCS_LINK. The site also contains information on the wide variety of plug-ins that are available for DataTables, which can be used to enhance and customise your table even further. | ||
Full documentation of the DataTables options, API and plug-in interface are available on the [website](https://datatables.net/reference/index). The site also contains information on the wide variety of plug-ins that are available for DataTables, which can be used to enhance and customise your table even further. | ||
@@ -54,1 +60,2 @@ | ||
This software is released under the [MIT license](//datatables.net/license). You are free to use, modify and distribute this software, but all copyright information must remain. | ||
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
43888
10
766
0
58
1
1
+ Addeddatatables.net@2.1.2(transitive)
- Removeddatatables.net@2.1.8(transitive)
Updateddatatables.net@2.1.2