buttons.bootstrap4.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*! Bootstrap integration for DataTables' Buttons
  2. * ©2016 SpryMedia Ltd - datatables.net/license
  3. */
  4. (function( factory ){
  5. if ( typeof define === 'function' && define.amd ) {
  6. // AMD
  7. define( ['jquery', 'datatables.net-bs4', 'datatables.net-buttons'], function ( $ ) {
  8. return factory( $, window, document );
  9. } );
  10. }
  11. else if ( typeof exports === 'object' ) {
  12. // CommonJS
  13. module.exports = function (root, $) {
  14. if ( ! root ) {
  15. root = window;
  16. }
  17. if ( ! $ || ! $.fn.dataTable ) {
  18. $ = require('datatables.net-bs4')(root, $).$;
  19. }
  20. if ( ! $.fn.dataTable.Buttons ) {
  21. require('datatables.net-buttons')(root, $);
  22. }
  23. return factory( $, root, root.document );
  24. };
  25. }
  26. else {
  27. // Browser
  28. factory( jQuery, window, document );
  29. }
  30. }(function( $, window, document, undefined ) {
  31. 'use strict';
  32. var DataTable = $.fn.dataTable;
  33. $.extend( true, DataTable.Buttons.defaults, {
  34. dom: {
  35. container: {
  36. className: 'dt-buttons btn-group flex-wrap'
  37. },
  38. button: {
  39. className: 'btn btn-secondary'
  40. },
  41. collection: {
  42. tag: 'div',
  43. className: 'dropdown-menu',
  44. closeButton: false,
  45. button: {
  46. tag: 'a',
  47. className: 'dt-button dropdown-item',
  48. active: 'active',
  49. disabled: 'disabled'
  50. }
  51. },
  52. splitWrapper: {
  53. tag: 'div',
  54. className: 'dt-btn-split-wrapper btn-group',
  55. closeButton: false,
  56. },
  57. splitDropdown: {
  58. tag: 'button',
  59. text: '',
  60. className: 'btn btn-secondary dt-btn-split-drop dropdown-toggle dropdown-toggle-split',
  61. closeButton: false,
  62. align: 'split-left',
  63. splitAlignClass: 'dt-button-split-left'
  64. },
  65. splitDropdownButton: {
  66. tag: 'button',
  67. className: 'dt-btn-split-drop-button btn btn-secondary',
  68. closeButton: false
  69. }
  70. },
  71. buttonCreated: function ( config, button ) {
  72. return config.buttons ?
  73. $('<div class="btn-group"/>').append(button) :
  74. button;
  75. }
  76. } );
  77. DataTable.ext.buttons.collection.className += ' dropdown-toggle';
  78. DataTable.ext.buttons.collection.rightAlignClassName = 'dropdown-menu-right';
  79. return DataTable.Buttons;
  80. }));