responsive.bootstrap.js 1.8 KB

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