buttons.bulma.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*! Bulma integration for DataTables' Buttons
  2. * ©2021 SpryMedia Ltd - datatables.net/license
  3. */
  4. (function( factory ){
  5. if ( typeof define === 'function' && define.amd ) {
  6. // AMD
  7. define( ['jquery', 'datatables.net-bm', '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-bm')(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 field is-grouped'
  37. },
  38. button: {
  39. className: 'button is-light',
  40. active: 'is-active',
  41. disabled: 'is-disabled'
  42. },
  43. collection: {
  44. tag: 'div',
  45. closeButton: false,
  46. className: 'dropdown-content',
  47. button: {
  48. tag: 'a',
  49. className: 'dt-button dropdown-item',
  50. active: 'is-active',
  51. disabled: 'is-disabled'
  52. }
  53. },
  54. splitWrapper: {
  55. tag: 'div',
  56. className: 'dt-btn-split-wrapper dropdown-trigger buttons has-addons',
  57. closeButton: false
  58. },
  59. splitDropdownButton: {
  60. tag: 'button',
  61. className: 'dt-btn-split-drop-button button is-light',
  62. closeButton: false
  63. },
  64. splitDropdown: {
  65. tag: 'button',
  66. text: '▼',
  67. className: 'button is-light',
  68. closeButton: false,
  69. align: 'split-left',
  70. splitAlignClass: 'dt-button-split-left'
  71. }
  72. },
  73. buttonCreated: function ( config, button ) {
  74. // For collections
  75. if (config.buttons) {
  76. // Wrap the dropdown content in a menu element
  77. config._collection = $('<div class="dropdown-menu"/>')
  78. .append(config._collection);
  79. // And add the collection dropdown icon
  80. $(button).append(
  81. '<span class="icon is-small">' +
  82. '<i class="fa fa-angle-down" aria-hidden="true"></i>' +
  83. '</span>'
  84. );
  85. }
  86. return button;
  87. }
  88. } );
  89. return DataTable.Buttons;
  90. }));