responsive.bootstrap.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*! Bootstrap 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-bs', '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-bs')(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.modal ) {
  38. _original( row, update, render );
  39. }
  40. else {
  41. if ( ! update ) {
  42. var modal = $(
  43. '<div class="modal fade" role="dialog">'+
  44. '<div class="modal-dialog" role="document">'+
  45. '<div class="modal-content">'+
  46. '<div class="modal-header">'+
  47. '<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>'+
  48. '</div>'+
  49. '<div class="modal-body"/>'+
  50. '</div>'+
  51. '</div>'+
  52. '</div>'
  53. );
  54. if ( options && options.header ) {
  55. modal.find('div.modal-header')
  56. .append( '<h4 class="modal-title">'+options.header( row )+'</h4>' );
  57. }
  58. modal.find( 'div.modal-body' ).append( render() );
  59. modal
  60. .appendTo( 'body' )
  61. .modal();
  62. }
  63. }
  64. };
  65. };
  66. return DataTable.Responsive;
  67. }));