buttons.foundation.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*! Foundation 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-zf', '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-zf')(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. // F6 has different requirements for the dropdown button set. We can use the
  34. // Foundation version found by DataTables in order to support both F5 and F6 in
  35. // the same file, but not that this requires DataTables 1.10.11+ for F6 support.
  36. var collection = DataTable.ext.foundationVersion === 6 ?
  37. {
  38. tag: 'div',
  39. className: 'dt-button-collection dropdown-pane is-open button-group stacked'
  40. } :
  41. {
  42. tag: 'ul',
  43. className: 'dt-button-collection f-dropdown open dropdown-pane is-open',
  44. button: {
  45. tag: 'li',
  46. className: 'small',
  47. active: 'active',
  48. disabled: 'disabled'
  49. },
  50. buttonLiner: {
  51. tag: 'a'
  52. }
  53. };
  54. $.extend( true, DataTable.Buttons.defaults, {
  55. dom: {
  56. container: {
  57. tag: 'div',
  58. className: 'dt-buttons button-group'
  59. },
  60. buttonContainer: {
  61. tag: null,
  62. className: ''
  63. },
  64. button: {
  65. tag: 'a',
  66. className: 'button small'
  67. },
  68. buttonLiner: {
  69. tag: null
  70. },
  71. collection: collection
  72. }
  73. } );
  74. DataTable.ext.buttons.collection.className = 'buttons-collection dropdown';
  75. return DataTable.Buttons;
  76. }));