buttons.foundation.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*! Foundation integration for DataTables' Buttons
  2. * ©2015 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. },
  48. buttonLiner: {
  49. tag: 'a'
  50. }
  51. };
  52. $.extend( true, DataTable.Buttons.defaults, {
  53. dom: {
  54. container: {
  55. tag: 'div',
  56. className: 'dt-buttons button-group'
  57. },
  58. buttonContainer: {
  59. tag: null,
  60. className: ''
  61. },
  62. button: {
  63. tag: 'a',
  64. className: 'button small'
  65. },
  66. buttonLiner: {
  67. tag: null
  68. },
  69. collection: collection
  70. }
  71. } );
  72. DataTable.ext.buttons.collection.className = 'buttons-collection dropdown';
  73. return DataTable.Buttons;
  74. }));