responsive.foundation.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*! Foundation integration for DataTables' Responsive
  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-responsive'], 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.Responsive ) {
  21. require('datatables.net-responsive')(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. var _display = DataTable.Responsive.display;
  34. var _original = _display.modal;
  35. _display.modal = function ( options ) {
  36. return function ( row, update, render ) {
  37. if ( ! $.fn.foundation ) {
  38. _original( row, update, render );
  39. }
  40. else {
  41. if ( ! update ) {
  42. $( '<div class="reveal-modal" data-reveal/>' )
  43. .append( '<a class="close-reveal-modal" aria-label="Close">&#215;</a>' )
  44. .append( options && options.header ? '<h4>'+options.header( row )+'</h4>' : null )
  45. .append( render() )
  46. .appendTo( 'body' )
  47. .foundation( 'reveal', 'open' );
  48. }
  49. }
  50. };
  51. };
  52. return DataTable.Responsive;
  53. }));