datatables.net-buttons-se
Version:
Buttons for DataTables with styling for [SemanticUI](https://semantic-ui.com/)
134 lines (122 loc) • 2.75 kB
JavaScript
/*! Bootstrap integration for DataTables' Buttons
* © SpryMedia Ltd - datatables.net/license
*/
(function( factory ){
if ( typeof define === 'function' && define.amd ) {
// AMD
define( ['jquery', 'datatables.net-se', 'datatables.net-buttons'], function ( $ ) {
return factory( $, window, document );
} );
}
else if ( typeof exports === 'object' ) {
// CommonJS
var jq = require('jquery');
var cjsRequires = function (root, $) {
if ( ! $.fn.dataTable ) {
require('datatables.net-se')(root, $);
}
if ( ! $.fn.dataTable.Buttons ) {
require('datatables.net-buttons')(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;
}
if ( ! $ ) {
$ = jq( root );
}
cjsRequires( root, $ );
return factory( $, root, root.document );
};
}
else {
cjsRequires( window, jq );
module.exports = factory( jq, window, window.document );
}
}
else {
// Browser
factory( jQuery, window, document );
}
}(function( $, window, document ) {
'use strict';
var DataTable = $.fn.dataTable;
$.extend(true, DataTable.Buttons.defaults, {
dom: {
container: {
className: 'dt-buttons ui buttons'
},
button: {
tag: 'button',
active: 'active',
className: 'dt-button ui button',
spacerClass: 'dt-button ui button',
dropHtml: '<i class="dropdown icon"></i>',
dropClass: ''
},
collection: {
container: {
tag: 'div',
className: 'ui dropdown active visible dt-button-collection',
content: {
className: 'menu'
}
},
closeButton: false,
button: {
tag: 'div',
className: 'dt-button item',
active: 'dt-button-active',
spacer: {
className: 'divider',
tag: 'div'
}
},
split: {
action: {
tag: 'div',
className: ''
},
dropdown: {
tag: 'span',
className: 'dt-button-split-drop dropdown icon'
},
wrapper: {
tag: 'div',
className: 'dt-button-split'
}
}
},
split: {
action: {
tag: 'button',
className: 'dt-button-split-drop-button ui button'
},
dropdown: {
tag: 'button',
className: 'ui floating button dt-button-split-drop dropdown icon'
},
wrapper: {
tag: 'div',
className: 'dt-button-split buttons'
}
}
}
});
$(document).on('buttons-popover.dt', function () {
var notButton = false;
$('.dtsp-panesContainer').each(function () {
if (!$(this).is('button')) {
notButton = true;
}
});
if (notButton) {
$('.dtsp-panesContainer').removeClass('vertical buttons');
}
});
return DataTable;
}));