effective_datatables 4.17.4 → 4.18.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  /*! Bootstrap 4 integration for DataTables' Responsive
2
- * ©2016 SpryMedia Ltd - datatables.net/license
2
+ * © SpryMedia Ltd - datatables.net/license
3
3
  */
4
4
 
5
5
  (function( factory ){
@@ -11,21 +11,37 @@
11
11
  }
12
12
  else if ( typeof exports === 'object' ) {
13
13
  // CommonJS
14
- module.exports = function (root, $) {
15
- if ( ! root ) {
16
- root = window;
17
- }
18
-
19
- if ( ! $ || ! $.fn.dataTable ) {
20
- $ = require('datatables.net-bs4')(root, $).$;
14
+ var jq = require('jquery');
15
+ var cjsRequires = function (root, $) {
16
+ if ( ! $.fn.dataTable ) {
17
+ require('datatables.net-bs4')(root, $);
21
18
  }
22
19
 
23
20
  if ( ! $.fn.dataTable.Responsive ) {
24
21
  require('datatables.net-responsive')(root, $);
25
22
  }
26
-
27
- return factory( $, root, root.document );
28
23
  };
24
+
25
+ if (typeof window === 'undefined') {
26
+ module.exports = function (root, $) {
27
+ if ( ! root ) {
28
+ // CommonJS environments without a window global must pass a
29
+ // root. This will give an error otherwise
30
+ root = window;
31
+ }
32
+
33
+ if ( ! $ ) {
34
+ $ = jq( root );
35
+ }
36
+
37
+ cjsRequires( root, $ );
38
+ return factory( $, root, root.document );
39
+ };
40
+ }
41
+ else {
42
+ cjsRequires( window, jq );
43
+ module.exports = factory( jq, window, window.document );
44
+ }
29
45
  }
30
46
  else {
31
47
  // Browser
@@ -36,50 +52,62 @@
36
52
  var DataTable = $.fn.dataTable;
37
53
 
38
54
 
55
+
39
56
  var _display = DataTable.Responsive.display;
40
57
  var _original = _display.modal;
41
58
  var _modal = $(
42
- '<div class="modal fade dtr-bs-modal" role="dialog">'+
43
- '<div class="modal-dialog" role="document">'+
44
- '<div class="modal-content">'+
45
- '<div class="modal-header">'+
46
- '<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>'+
47
- '</div>'+
48
- '<div class="modal-body"/>'+
49
- '</div>'+
50
- '</div>'+
51
- '</div>'
59
+ '<div class="modal fade dtr-bs-modal" role="dialog">' +
60
+ '<div class="modal-dialog" role="document">' +
61
+ '<div class="modal-content">' +
62
+ '<div class="modal-header">' +
63
+ '<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>' +
64
+ '</div>' +
65
+ '<div class="modal-body"/>' +
66
+ '</div>' +
67
+ '</div>' +
68
+ '</div>'
52
69
  );
53
70
 
54
- _display.modal = function ( options ) {
55
- return function ( row, update, render ) {
56
- if ( ! $.fn.modal ) {
57
- _original( row, update, render );
71
+ _display.modal = function (options) {
72
+ return function (row, update, render, closeCallback) {
73
+ if (!$.fn.modal) {
74
+ return _original(row, update, render, closeCallback);
58
75
  }
59
76
  else {
60
- if ( ! update ) {
61
- if ( options && options.header ) {
77
+ if (!update) {
78
+ if (options && options.header) {
62
79
  var header = _modal.find('div.modal-header');
63
80
  var button = header.find('button').detach();
64
81
 
65
82
  header
66
83
  .empty()
67
- .append( '<h4 class="modal-title">'+options.header( row )+'</h4>' )
68
- .append( button );
84
+ .append('<h4 class="modal-title">' + options.header(row) + '</h4>')
85
+ .append(button);
69
86
  }
70
87
 
71
- _modal.find( 'div.modal-body' )
72
- .empty()
73
- .append( render() );
88
+ _modal.find('div.modal-body').empty().append(render());
74
89
 
75
90
  _modal
76
- .appendTo( 'body' )
91
+ .data('dtr-row-idx', row.index())
92
+ .one('hidden.bs.modal', closeCallback)
93
+ .appendTo('body')
77
94
  .modal();
78
95
  }
96
+ else {
97
+ if ($.contains(document, _modal[0]) && row.index() === _modal.data('dtr-row-idx')) {
98
+ _modal.find('div.modal-body').empty().append(render());
99
+ }
100
+ else {
101
+ // Modal not shown - do nothing
102
+ return null;
103
+ }
104
+ }
105
+
106
+ return true;
79
107
  }
80
108
  };
81
109
  };
82
110
 
83
111
 
84
- return DataTable.Responsive;
112
+ return DataTable;
85
113
  }));