jquery-datatables 1.10.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +23 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +27 -0
- data/README.md +118 -0
- data/Rakefile +166 -0
- data/app/assets/images/datatables/sort_asc.png +0 -0
- data/app/assets/images/datatables/sort_asc_disabled.png +0 -0
- data/app/assets/images/datatables/sort_both.png +0 -0
- data/app/assets/images/datatables/sort_desc.png +0 -0
- data/app/assets/images/datatables/sort_desc_disabled.png +0 -0
- data/app/assets/javascripts/datatables/dataTables.bootstrap.js +182 -0
- data/app/assets/javascripts/datatables/dataTables.bootstrap4.js +184 -0
- data/app/assets/javascripts/datatables/dataTables.foundation.js +174 -0
- data/app/assets/javascripts/datatables/dataTables.jqueryui.js +164 -0
- data/app/assets/javascripts/datatables/dataTables.material.js +191 -0
- data/app/assets/javascripts/datatables/dataTables.semanticui.js +208 -0
- data/app/assets/javascripts/datatables/dataTables.uikit.js +176 -0
- data/app/assets/javascripts/datatables/extensions/AutoFill/autoFill.bootstrap.js +43 -0
- data/app/assets/javascripts/datatables/extensions/AutoFill/autoFill.bootstrap4.js +43 -0
- data/app/assets/javascripts/datatables/extensions/AutoFill/autoFill.foundation.js +43 -0
- data/app/assets/javascripts/datatables/extensions/AutoFill/autoFill.jqueryui.js +43 -0
- data/app/assets/javascripts/datatables/extensions/AutoFill/autoFill.semanticui.js +43 -0
- data/app/assets/javascripts/datatables/extensions/AutoFill/dataTables.autoFill.js +1036 -0
- data/app/assets/javascripts/datatables/extensions/Buttons/buttons.bootstrap.js +68 -0
- data/app/assets/javascripts/datatables/extensions/Buttons/buttons.bootstrap4.js +60 -0
- data/app/assets/javascripts/datatables/extensions/Buttons/buttons.colVis.js +199 -0
- data/app/assets/javascripts/datatables/extensions/Buttons/buttons.flash.js +1325 -0
- data/app/assets/javascripts/datatables/extensions/Buttons/buttons.foundation.js +85 -0
- data/app/assets/javascripts/datatables/extensions/Buttons/buttons.html5.js +1322 -0
- data/app/assets/javascripts/datatables/extensions/Buttons/buttons.jqueryui.js +62 -0
- data/app/assets/javascripts/datatables/extensions/Buttons/buttons.print.js +172 -0
- data/app/assets/javascripts/datatables/extensions/Buttons/buttons.semanticui.js +57 -0
- data/app/assets/javascripts/datatables/extensions/Buttons/dataTables.buttons.js +1634 -0
- data/app/assets/javascripts/datatables/extensions/ColReorder/dataTables.colReorder.js +1335 -0
- data/app/assets/javascripts/datatables/extensions/FixedColumns/dataTables.fixedColumns.js +1623 -0
- data/app/assets/javascripts/datatables/extensions/FixedHeader/dataTables.fixedHeader.js +672 -0
- data/app/assets/javascripts/datatables/extensions/KeyTable/dataTables.keyTable.js +883 -0
- data/app/assets/javascripts/datatables/extensions/Responsive/dataTables.responsive.js +1232 -0
- data/app/assets/javascripts/datatables/extensions/Responsive/responsive.bootstrap.js +81 -0
- data/app/assets/javascripts/datatables/extensions/Responsive/responsive.bootstrap4.js +81 -0
- data/app/assets/javascripts/datatables/extensions/Responsive/responsive.foundation.js +62 -0
- data/app/assets/javascripts/datatables/extensions/Responsive/responsive.jqueryui.js +63 -0
- data/app/assets/javascripts/datatables/extensions/Responsive/responsive.semanticui.js +77 -0
- data/app/assets/javascripts/datatables/extensions/RowReorder/dataTables.rowReorder.js +709 -0
- data/app/assets/javascripts/datatables/extensions/Scroller/dataTables.scroller.js +1349 -0
- data/app/assets/javascripts/datatables/extensions/Select/dataTables.select.js +1109 -0
- data/app/assets/javascripts/datatables/jquery.dataTables.js +15278 -0
- data/app/assets/media/swf/flashExport.swf +0 -0
- data/app/assets/stylesheets/datatables/dataTables.bootstrap.css +185 -0
- data/app/assets/stylesheets/datatables/dataTables.bootstrap4.css +193 -0
- data/app/assets/stylesheets/datatables/dataTables.foundation.css +116 -0
- data/app/assets/stylesheets/datatables/dataTables.jqueryui.css +481 -0
- data/app/assets/stylesheets/datatables/dataTables.material.css +87 -0
- data/app/assets/stylesheets/datatables/dataTables.semanticui.css +103 -0
- data/app/assets/stylesheets/datatables/dataTables.uikit.css +146 -0
- data/app/assets/stylesheets/datatables/extensions/AutoFill/autoFill.bootstrap.css +81 -0
- data/app/assets/stylesheets/datatables/extensions/AutoFill/autoFill.bootstrap4.css +81 -0
- data/app/assets/stylesheets/datatables/extensions/AutoFill/autoFill.dataTables.css +92 -0
- data/app/assets/stylesheets/datatables/extensions/AutoFill/autoFill.foundation.css +85 -0
- data/app/assets/stylesheets/datatables/extensions/AutoFill/autoFill.jqueryui.css +85 -0
- data/app/assets/stylesheets/datatables/extensions/AutoFill/autoFill.semanticui.css +81 -0
- data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.bootstrap.css +102 -0
- data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.bootstrap4.css +163 -0
- data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.dataTables.css +298 -0
- data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.foundation.css +129 -0
- data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.jqueryui.css +162 -0
- data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.semanticui.css +114 -0
- data/app/assets/stylesheets/datatables/extensions/Buttons/common.scss +27 -0
- data/app/assets/stylesheets/datatables/extensions/Buttons/mixins.scss +89 -0
- data/app/assets/stylesheets/datatables/extensions/ColReorder/colReorder.bootstrap.css +11 -0
- data/app/assets/stylesheets/datatables/extensions/ColReorder/colReorder.bootstrap4.css +11 -0
- data/app/assets/stylesheets/datatables/extensions/ColReorder/colReorder.dataTables.css +11 -0
- data/app/assets/stylesheets/datatables/extensions/ColReorder/colReorder.foundation.css +11 -0
- data/app/assets/stylesheets/datatables/extensions/ColReorder/colReorder.jqueryui.css +11 -0
- data/app/assets/stylesheets/datatables/extensions/ColReorder/colReorder.semanticui.css +11 -0
- data/app/assets/stylesheets/datatables/extensions/FixedColumns/fixedColumns.bootstrap.css +44 -0
- data/app/assets/stylesheets/datatables/extensions/FixedColumns/fixedColumns.bootstrap4.css +44 -0
- data/app/assets/stylesheets/datatables/extensions/FixedColumns/fixedColumns.dataTables.css +18 -0
- data/app/assets/stylesheets/datatables/extensions/FixedColumns/fixedColumns.foundation.css +27 -0
- data/app/assets/stylesheets/datatables/extensions/FixedColumns/fixedColumns.jqueryui.css +8 -0
- data/app/assets/stylesheets/datatables/extensions/FixedColumns/fixedColumns.semanticui.css +16 -0
- data/app/assets/stylesheets/datatables/extensions/FixedHeader/fixedHeader.bootstrap.css +20 -0
- data/app/assets/stylesheets/datatables/extensions/FixedHeader/fixedHeader.bootstrap4.css +20 -0
- data/app/assets/stylesheets/datatables/extensions/FixedHeader/fixedHeader.dataTables.css +19 -0
- data/app/assets/stylesheets/datatables/extensions/FixedHeader/fixedHeader.foundation.css +20 -0
- data/app/assets/stylesheets/datatables/extensions/FixedHeader/fixedHeader.jqueryui.css +15 -0
- data/app/assets/stylesheets/datatables/extensions/FixedHeader/fixedHeader.semanticui.css +14 -0
- data/app/assets/stylesheets/datatables/extensions/KeyTable/keyTable.bootstrap.css +5 -0
- data/app/assets/stylesheets/datatables/extensions/KeyTable/keyTable.bootstrap4.css +5 -0
- data/app/assets/stylesheets/datatables/extensions/KeyTable/keyTable.dataTables.css +5 -0
- data/app/assets/stylesheets/datatables/extensions/KeyTable/keyTable.foundation.css +5 -0
- data/app/assets/stylesheets/datatables/extensions/KeyTable/keyTable.jqueryui.css +5 -0
- data/app/assets/stylesheets/datatables/extensions/KeyTable/keyTable.semanticui.css +5 -0
- data/app/assets/stylesheets/datatables/extensions/Responsive/responsive.bootstrap.css +181 -0
- data/app/assets/stylesheets/datatables/extensions/Responsive/responsive.bootstrap4.css +181 -0
- data/app/assets/stylesheets/datatables/extensions/Responsive/responsive.dataTables.css +178 -0
- data/app/assets/stylesheets/datatables/extensions/Responsive/responsive.foundation.css +181 -0
- data/app/assets/stylesheets/datatables/extensions/Responsive/responsive.jqueryui.css +178 -0
- data/app/assets/stylesheets/datatables/extensions/Responsive/responsive.semanticui.css +181 -0
- data/app/assets/stylesheets/datatables/extensions/RowReorder/rowReorder.bootstrap.css +22 -0
- data/app/assets/stylesheets/datatables/extensions/RowReorder/rowReorder.bootstrap4.css +22 -0
- data/app/assets/stylesheets/datatables/extensions/RowReorder/rowReorder.dataTables.css +22 -0
- data/app/assets/stylesheets/datatables/extensions/RowReorder/rowReorder.foundation.css +22 -0
- data/app/assets/stylesheets/datatables/extensions/RowReorder/rowReorder.jqueryui.css +22 -0
- data/app/assets/stylesheets/datatables/extensions/RowReorder/rowReorder.semanticui.css +22 -0
- data/app/assets/stylesheets/datatables/extensions/RowReorder/semanticui.scss +5 -0
- data/app/assets/stylesheets/datatables/extensions/Scroller/scroller.bootstrap.css +24 -0
- data/app/assets/stylesheets/datatables/extensions/Scroller/scroller.bootstrap4.css +24 -0
- data/app/assets/stylesheets/datatables/extensions/Scroller/scroller.dataTables.css +20 -0
- data/app/assets/stylesheets/datatables/extensions/Scroller/scroller.foundation.css +17 -0
- data/app/assets/stylesheets/datatables/extensions/Scroller/scroller.jqueryui.css +20 -0
- data/app/assets/stylesheets/datatables/extensions/Scroller/scroller.semanticui.css +20 -0
- data/app/assets/stylesheets/datatables/extensions/Select/select.bootstrap.css +110 -0
- data/app/assets/stylesheets/datatables/extensions/Select/select.bootstrap4.css +110 -0
- data/app/assets/stylesheets/datatables/extensions/Select/select.dataTables.css +100 -0
- data/app/assets/stylesheets/datatables/extensions/Select/select.foundation.css +112 -0
- data/app/assets/stylesheets/datatables/extensions/Select/select.jqueryui.css +100 -0
- data/app/assets/stylesheets/datatables/extensions/Select/select.semanticui.css +105 -0
- data/app/assets/stylesheets/datatables/jquery.dataTables.css +452 -0
- data/app/assets/stylesheets/datatables/jquery.dataTables_themeroller.css +416 -0
- data/jquery-datatables.gemspec +27 -0
- data/lib/generators/jquery/datatables/install_generator.rb +63 -0
- data/lib/generators/jquery/datatables/templates/bootstrap.css.tt +15 -0
- data/lib/generators/jquery/datatables/templates/bootstrap.js.tt +22 -0
- data/lib/generators/jquery/datatables/templates/bootstrap4.css.tt +15 -0
- data/lib/generators/jquery/datatables/templates/bootstrap4.js.tt +22 -0
- data/lib/generators/jquery/datatables/templates/foundation.css.tt +15 -0
- data/lib/generators/jquery/datatables/templates/foundation.js.tt +24 -0
- data/lib/generators/jquery/datatables/templates/jqueryui.css.tt +15 -0
- data/lib/generators/jquery/datatables/templates/jqueryui.js.tt +18 -0
- data/lib/generators/jquery/datatables/templates/material.css.tt +15 -0
- data/lib/generators/jquery/datatables/templates/material.js.tt +19 -0
- data/lib/generators/jquery/datatables/templates/regular.css.tt +15 -0
- data/lib/generators/jquery/datatables/templates/regular.js.tt +18 -0
- data/lib/generators/jquery/datatables/templates/semanticui.css.tt +16 -0
- data/lib/generators/jquery/datatables/templates/semanticui.js.tt +22 -0
- data/lib/generators/jquery/datatables/templates/uikit.css.tt +15 -0
- data/lib/generators/jquery/datatables/templates/uikit.js.tt +19 -0
- data/lib/jquery-datatables.rb +26 -0
- data/lib/jquery-datatables/engine.rb +11 -0
- data/lib/jquery-datatables/version.rb +6 -0
- metadata +269 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/*! Bootstrap integration for DataTables' Responsive
|
|
2
|
+
* ©2015-2016 SpryMedia Ltd - datatables.net/license
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
(function( factory ){
|
|
6
|
+
if ( typeof define === 'function' && define.amd ) {
|
|
7
|
+
// AMD
|
|
8
|
+
define( ['jquery', 'datatables.net-bs', 'datatables.net-responsive'], function ( $ ) {
|
|
9
|
+
return factory( $, window, document );
|
|
10
|
+
} );
|
|
11
|
+
}
|
|
12
|
+
else if ( typeof exports === 'object' ) {
|
|
13
|
+
// CommonJS
|
|
14
|
+
module.exports = function (root, $) {
|
|
15
|
+
if ( ! root ) {
|
|
16
|
+
root = window;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if ( ! $ || ! $.fn.dataTable ) {
|
|
20
|
+
$ = require('datatables.net-bs')(root, $).$;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if ( ! $.fn.dataTable.Responsive ) {
|
|
24
|
+
require('datatables.net-responsive')(root, $);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return factory( $, root, root.document );
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
// Browser
|
|
32
|
+
factory( jQuery, window, document );
|
|
33
|
+
}
|
|
34
|
+
}(function( $, window, document, undefined ) {
|
|
35
|
+
'use strict';
|
|
36
|
+
var DataTable = $.fn.dataTable;
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
var _display = DataTable.Responsive.display;
|
|
40
|
+
var _original = _display.modal;
|
|
41
|
+
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">×</span></button>'+
|
|
47
|
+
'</div>'+
|
|
48
|
+
'<div class="modal-body"/>'+
|
|
49
|
+
'</div>'+
|
|
50
|
+
'</div>'+
|
|
51
|
+
'</div>'
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
_display.modal = function ( options ) {
|
|
55
|
+
return function ( row, update, render ) {
|
|
56
|
+
if ( ! $.fn.modal ) {
|
|
57
|
+
_original( row, update, render );
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
if ( ! update ) {
|
|
61
|
+
if ( options && options.header ) {
|
|
62
|
+
_modal.find('div.modal-header')
|
|
63
|
+
.empty()
|
|
64
|
+
.append( '<h4 class="modal-title">'+options.header( row )+'</h4>' );
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
_modal.find( 'div.modal-body' )
|
|
68
|
+
.empty()
|
|
69
|
+
.append( render() );
|
|
70
|
+
|
|
71
|
+
_modal
|
|
72
|
+
.appendTo( 'body' )
|
|
73
|
+
.modal();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
return DataTable.Responsive;
|
|
81
|
+
}));
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/*! Bootstrap 4 integration for DataTables' Responsive
|
|
2
|
+
* ©2016 SpryMedia Ltd - datatables.net/license
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
(function( factory ){
|
|
6
|
+
if ( typeof define === 'function' && define.amd ) {
|
|
7
|
+
// AMD
|
|
8
|
+
define( ['jquery', 'datatables.net-bs4', 'datatables.net-responsive'], function ( $ ) {
|
|
9
|
+
return factory( $, window, document );
|
|
10
|
+
} );
|
|
11
|
+
}
|
|
12
|
+
else if ( typeof exports === 'object' ) {
|
|
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, $).$;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if ( ! $.fn.dataTable.Responsive ) {
|
|
24
|
+
require('datatables.net-responsive')(root, $);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return factory( $, root, root.document );
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
// Browser
|
|
32
|
+
factory( jQuery, window, document );
|
|
33
|
+
}
|
|
34
|
+
}(function( $, window, document, undefined ) {
|
|
35
|
+
'use strict';
|
|
36
|
+
var DataTable = $.fn.dataTable;
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
var _display = DataTable.Responsive.display;
|
|
40
|
+
var _original = _display.modal;
|
|
41
|
+
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">×</span></button>'+
|
|
47
|
+
'</div>'+
|
|
48
|
+
'<div class="modal-body"/>'+
|
|
49
|
+
'</div>'+
|
|
50
|
+
'</div>'+
|
|
51
|
+
'</div>'
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
_display.modal = function ( options ) {
|
|
55
|
+
return function ( row, update, render ) {
|
|
56
|
+
if ( ! $.fn.modal ) {
|
|
57
|
+
_original( row, update, render );
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
if ( ! update ) {
|
|
61
|
+
if ( options && options.header ) {
|
|
62
|
+
_modal.find('div.modal-header')
|
|
63
|
+
.empty()
|
|
64
|
+
.append( '<h4 class="modal-title">'+options.header( row )+'</h4>' );
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
_modal.find( 'div.modal-body' )
|
|
68
|
+
.empty()
|
|
69
|
+
.append( render() );
|
|
70
|
+
|
|
71
|
+
_modal
|
|
72
|
+
.appendTo( 'body' )
|
|
73
|
+
.modal();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
return DataTable.Responsive;
|
|
81
|
+
}));
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/*! Foundation integration for DataTables' Responsive
|
|
2
|
+
* ©2015 SpryMedia Ltd - datatables.net/license
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
(function( factory ){
|
|
6
|
+
if ( typeof define === 'function' && define.amd ) {
|
|
7
|
+
// AMD
|
|
8
|
+
define( ['jquery', 'datatables.net-zf', 'datatables.net-responsive'], function ( $ ) {
|
|
9
|
+
return factory( $, window, document );
|
|
10
|
+
} );
|
|
11
|
+
}
|
|
12
|
+
else if ( typeof exports === 'object' ) {
|
|
13
|
+
// CommonJS
|
|
14
|
+
module.exports = function (root, $) {
|
|
15
|
+
if ( ! root ) {
|
|
16
|
+
root = window;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if ( ! $ || ! $.fn.dataTable ) {
|
|
20
|
+
$ = require('datatables.net-zf')(root, $).$;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if ( ! $.fn.dataTable.Responsive ) {
|
|
24
|
+
require('datatables.net-responsive')(root, $);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return factory( $, root, root.document );
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
// Browser
|
|
32
|
+
factory( jQuery, window, document );
|
|
33
|
+
}
|
|
34
|
+
}(function( $, window, document, undefined ) {
|
|
35
|
+
'use strict';
|
|
36
|
+
var DataTable = $.fn.dataTable;
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
var _display = DataTable.Responsive.display;
|
|
40
|
+
var _original = _display.modal;
|
|
41
|
+
|
|
42
|
+
_display.modal = function ( options ) {
|
|
43
|
+
return function ( row, update, render ) {
|
|
44
|
+
if ( ! $.fn.foundation ) {
|
|
45
|
+
_original( row, update, render );
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
if ( ! update ) {
|
|
49
|
+
$( '<div class="reveal-modal" data-reveal/>' )
|
|
50
|
+
.append( '<a class="close-reveal-modal" aria-label="Close">×</a>' )
|
|
51
|
+
.append( options && options.header ? '<h4>'+options.header( row )+'</h4>' : null )
|
|
52
|
+
.append( render() )
|
|
53
|
+
.appendTo( 'body' )
|
|
54
|
+
.foundation( 'reveal', 'open' );
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
return DataTable.Responsive;
|
|
62
|
+
}));
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/*! jQuery UI integration for DataTables' Responsive
|
|
2
|
+
* ©2015 SpryMedia Ltd - datatables.net/license
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
(function( factory ){
|
|
6
|
+
if ( typeof define === 'function' && define.amd ) {
|
|
7
|
+
// AMD
|
|
8
|
+
define( ['jquery', 'datatables.net-jqui', 'datatables.net-responsive'], function ( $ ) {
|
|
9
|
+
return factory( $, window, document );
|
|
10
|
+
} );
|
|
11
|
+
}
|
|
12
|
+
else if ( typeof exports === 'object' ) {
|
|
13
|
+
// CommonJS
|
|
14
|
+
module.exports = function (root, $) {
|
|
15
|
+
if ( ! root ) {
|
|
16
|
+
root = window;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if ( ! $ || ! $.fn.dataTable ) {
|
|
20
|
+
$ = require('datatables.net-jqui')(root, $).$;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if ( ! $.fn.dataTable.Responsive ) {
|
|
24
|
+
require('datatables.net-responsive')(root, $);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return factory( $, root, root.document );
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
// Browser
|
|
32
|
+
factory( jQuery, window, document );
|
|
33
|
+
}
|
|
34
|
+
}(function( $, window, document, undefined ) {
|
|
35
|
+
'use strict';
|
|
36
|
+
var DataTable = $.fn.dataTable;
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
var _display = DataTable.Responsive.display;
|
|
40
|
+
var _original = _display.modal;
|
|
41
|
+
|
|
42
|
+
_display.modal = function ( options ) {
|
|
43
|
+
return function ( row, update, render ) {
|
|
44
|
+
if ( ! $.fn.dialog ) {
|
|
45
|
+
_original( row, update, render );
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
if ( ! update ) {
|
|
49
|
+
$( '<div/>' )
|
|
50
|
+
.append( render() )
|
|
51
|
+
.appendTo( 'body' )
|
|
52
|
+
.dialog( $.extend( true, {
|
|
53
|
+
title: options && options.header ? options.header( row ) : '',
|
|
54
|
+
width: 500
|
|
55
|
+
}, options.dialog ) );
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
return DataTable.Responsive;
|
|
63
|
+
}));
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/*! Bootstrap integration for DataTables' Responsive
|
|
2
|
+
* ©2015-2016 SpryMedia Ltd - datatables.net/license
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
(function( factory ){
|
|
6
|
+
if ( typeof define === 'function' && define.amd ) {
|
|
7
|
+
// AMD
|
|
8
|
+
define( ['jquery', 'datatables.net-se', 'datatables.net-responsive'], function ( $ ) {
|
|
9
|
+
return factory( $, window, document );
|
|
10
|
+
} );
|
|
11
|
+
}
|
|
12
|
+
else if ( typeof exports === 'object' ) {
|
|
13
|
+
// CommonJS
|
|
14
|
+
module.exports = function (root, $) {
|
|
15
|
+
if ( ! root ) {
|
|
16
|
+
root = window;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if ( ! $ || ! $.fn.dataTable ) {
|
|
20
|
+
$ = require('datatables.net-se')(root, $).$;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if ( ! $.fn.dataTable.Responsive ) {
|
|
24
|
+
require('datatables.net-responsive')(root, $);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return factory( $, root, root.document );
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
// Browser
|
|
32
|
+
factory( jQuery, window, document );
|
|
33
|
+
}
|
|
34
|
+
}(function( $, window, document, undefined ) {
|
|
35
|
+
'use strict';
|
|
36
|
+
var DataTable = $.fn.dataTable;
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
var _display = DataTable.Responsive.display;
|
|
40
|
+
var _original = _display.modal;
|
|
41
|
+
var _modal = $(
|
|
42
|
+
'<div class="ui modal" role="dialog">'+
|
|
43
|
+
'<div class="header">'+
|
|
44
|
+
'<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>'+
|
|
45
|
+
'</div>'+
|
|
46
|
+
'<div class="content"/>'+
|
|
47
|
+
'</div>'
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
_display.modal = function ( options ) {
|
|
51
|
+
return function ( row, update, render ) {
|
|
52
|
+
if ( ! $.fn.modal ) {
|
|
53
|
+
_original( row, update, render );
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
if ( ! update ) {
|
|
57
|
+
if ( options && options.header ) {
|
|
58
|
+
_modal.find('div.header')
|
|
59
|
+
.empty()
|
|
60
|
+
.append( '<h4 class="title">'+options.header( row )+'</h4>' );
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
_modal.find( 'div.content' )
|
|
64
|
+
.empty()
|
|
65
|
+
.append( render() );
|
|
66
|
+
|
|
67
|
+
_modal
|
|
68
|
+
.appendTo( 'body' )
|
|
69
|
+
.modal('show');
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
return DataTable.Responsive;
|
|
77
|
+
}));
|
|
@@ -0,0 +1,709 @@
|
|
|
1
|
+
/*! RowReorder 1.1.2
|
|
2
|
+
* 2015-2016 SpryMedia Ltd - datatables.net/license
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @summary RowReorder
|
|
7
|
+
* @description Row reordering extension for DataTables
|
|
8
|
+
* @version 1.1.2
|
|
9
|
+
* @file dataTables.rowReorder.js
|
|
10
|
+
* @author SpryMedia Ltd (www.sprymedia.co.uk)
|
|
11
|
+
* @contact www.sprymedia.co.uk/contact
|
|
12
|
+
* @copyright Copyright 2015-2016 SpryMedia Ltd.
|
|
13
|
+
*
|
|
14
|
+
* This source file is free software, available under the following license:
|
|
15
|
+
* MIT license - http://datatables.net/license/mit
|
|
16
|
+
*
|
|
17
|
+
* This source file is distributed in the hope that it will be useful, but
|
|
18
|
+
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
19
|
+
* or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
|
|
20
|
+
*
|
|
21
|
+
* For details please refer to: http://www.datatables.net
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
(function( factory ){
|
|
25
|
+
if ( typeof define === 'function' && define.amd ) {
|
|
26
|
+
// AMD
|
|
27
|
+
define( ['jquery', 'datatables.net'], function ( $ ) {
|
|
28
|
+
return factory( $, window, document );
|
|
29
|
+
} );
|
|
30
|
+
}
|
|
31
|
+
else if ( typeof exports === 'object' ) {
|
|
32
|
+
// CommonJS
|
|
33
|
+
module.exports = function (root, $) {
|
|
34
|
+
if ( ! root ) {
|
|
35
|
+
root = window;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if ( ! $ || ! $.fn.dataTable ) {
|
|
39
|
+
$ = require('datatables.net')(root, $).$;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return factory( $, root, root.document );
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
// Browser
|
|
47
|
+
factory( jQuery, window, document );
|
|
48
|
+
}
|
|
49
|
+
}(function( $, window, document, undefined ) {
|
|
50
|
+
'use strict';
|
|
51
|
+
var DataTable = $.fn.dataTable;
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* RowReorder provides the ability in DataTables to click and drag rows to
|
|
56
|
+
* reorder them. When a row is dropped the data for the rows effected will be
|
|
57
|
+
* updated to reflect the change. Normally this data point should also be the
|
|
58
|
+
* column being sorted upon in the DataTable but this does not need to be the
|
|
59
|
+
* case. RowReorder implements a "data swap" method - so the rows being
|
|
60
|
+
* reordered take the value of the data point from the row that used to occupy
|
|
61
|
+
* the row's new position.
|
|
62
|
+
*
|
|
63
|
+
* Initialisation is done by either:
|
|
64
|
+
*
|
|
65
|
+
* * `rowReorder` parameter in the DataTable initialisation object
|
|
66
|
+
* * `new $.fn.dataTable.RowReorder( table, opts )` after DataTables
|
|
67
|
+
* initialisation.
|
|
68
|
+
*
|
|
69
|
+
* @class
|
|
70
|
+
* @param {object} settings DataTables settings object for the host table
|
|
71
|
+
* @param {object} [opts] Configuration options
|
|
72
|
+
* @requires jQuery 1.7+
|
|
73
|
+
* @requires DataTables 1.10.7+
|
|
74
|
+
*/
|
|
75
|
+
var RowReorder = function ( dt, opts ) {
|
|
76
|
+
// Sanity check that we are using DataTables 1.10 or newer
|
|
77
|
+
if ( ! DataTable.versionCheck || ! DataTable.versionCheck( '1.10.8' ) ) {
|
|
78
|
+
throw 'DataTables RowReorder requires DataTables 1.10.8 or newer';
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// User and defaults configuration object
|
|
82
|
+
this.c = $.extend( true, {},
|
|
83
|
+
DataTable.defaults.rowReorder,
|
|
84
|
+
RowReorder.defaults,
|
|
85
|
+
opts
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
// Internal settings
|
|
89
|
+
this.s = {
|
|
90
|
+
/** @type {integer} Scroll body top cache */
|
|
91
|
+
bodyTop: null,
|
|
92
|
+
|
|
93
|
+
/** @type {DataTable.Api} DataTables' API instance */
|
|
94
|
+
dt: new DataTable.Api( dt ),
|
|
95
|
+
|
|
96
|
+
/** @type {function} Data fetch function */
|
|
97
|
+
getDataFn: DataTable.ext.oApi._fnGetObjectDataFn( this.c.dataSrc ),
|
|
98
|
+
|
|
99
|
+
/** @type {array} Pixel positions for row insertion calculation */
|
|
100
|
+
middles: null,
|
|
101
|
+
|
|
102
|
+
/** @type {Object} Cached dimension information for use in the mouse move event handler */
|
|
103
|
+
scroll: {},
|
|
104
|
+
|
|
105
|
+
/** @type {integer} Interval object used for smooth scrolling */
|
|
106
|
+
scrollInterval: null,
|
|
107
|
+
|
|
108
|
+
/** @type {function} Data set function */
|
|
109
|
+
setDataFn: DataTable.ext.oApi._fnSetObjectDataFn( this.c.dataSrc ),
|
|
110
|
+
|
|
111
|
+
/** @type {Object} Mouse down information */
|
|
112
|
+
start: {
|
|
113
|
+
top: 0,
|
|
114
|
+
left: 0,
|
|
115
|
+
offsetTop: 0,
|
|
116
|
+
offsetLeft: 0,
|
|
117
|
+
nodes: []
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
/** @type {integer} Window height cached value */
|
|
121
|
+
windowHeight: 0
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// DOM items
|
|
125
|
+
this.dom = {
|
|
126
|
+
/** @type {jQuery} Cloned row being moved around */
|
|
127
|
+
clone: null,
|
|
128
|
+
|
|
129
|
+
/** @type {jQuery} DataTables scrolling container */
|
|
130
|
+
dtScroll: $('div.dataTables_scrollBody', this.s.dt.table().container())
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
// Check if row reorder has already been initialised on this table
|
|
134
|
+
var settings = this.s.dt.settings()[0];
|
|
135
|
+
var exisiting = settings.rowreorder;
|
|
136
|
+
if ( exisiting ) {
|
|
137
|
+
return exisiting;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
settings.rowreorder = this;
|
|
141
|
+
this._constructor();
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
$.extend( RowReorder.prototype, {
|
|
146
|
+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
147
|
+
* Constructor
|
|
148
|
+
*/
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Initialise the RowReorder instance
|
|
152
|
+
*
|
|
153
|
+
* @private
|
|
154
|
+
*/
|
|
155
|
+
_constructor: function ()
|
|
156
|
+
{
|
|
157
|
+
var that = this;
|
|
158
|
+
var dt = this.s.dt;
|
|
159
|
+
var table = $( dt.table().node() );
|
|
160
|
+
|
|
161
|
+
// Need to be able to calculate the row positions relative to the table
|
|
162
|
+
if ( table.css('position') === 'static' ) {
|
|
163
|
+
table.css( 'position', 'relative' );
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// listen for mouse down on the target column - we have to implement
|
|
167
|
+
// this rather than using HTML5 drag and drop as drag and drop doesn't
|
|
168
|
+
// appear to work on table rows at this time. Also mobile browsers are
|
|
169
|
+
// not supported.
|
|
170
|
+
// Use `table().container()` rather than just the table node for IE8 -
|
|
171
|
+
// otherwise it only works once...
|
|
172
|
+
$(dt.table().container()).on( 'mousedown.rowReorder touchstart.rowReorder', this.c.selector, function (e) {
|
|
173
|
+
var tr = $(this).closest('tr');
|
|
174
|
+
|
|
175
|
+
// Double check that it is a DataTable row
|
|
176
|
+
if ( dt.row( tr ).any() ) {
|
|
177
|
+
that._mouseDown( e, tr );
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
} );
|
|
181
|
+
|
|
182
|
+
dt.on( 'destroy.rowReorder', function () {
|
|
183
|
+
$(dt.table().container()).off( '.rowReorder' );
|
|
184
|
+
dt.off( '.rowReorder' );
|
|
185
|
+
} );
|
|
186
|
+
},
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
190
|
+
* Private methods
|
|
191
|
+
*/
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Cache the measurements that RowReorder needs in the mouse move handler
|
|
195
|
+
* to attempt to speed things up, rather than reading from the DOM.
|
|
196
|
+
*
|
|
197
|
+
* @private
|
|
198
|
+
*/
|
|
199
|
+
_cachePositions: function ()
|
|
200
|
+
{
|
|
201
|
+
var dt = this.s.dt;
|
|
202
|
+
|
|
203
|
+
// Frustratingly, if we add `position:relative` to the tbody, the
|
|
204
|
+
// position is still relatively to the parent. So we need to adjust
|
|
205
|
+
// for that
|
|
206
|
+
var headerHeight = $( dt.table().node() ).find('thead').outerHeight();
|
|
207
|
+
|
|
208
|
+
// Need to pass the nodes through jQuery to get them in document order,
|
|
209
|
+
// not what DataTables thinks it is, since we have been altering the
|
|
210
|
+
// order
|
|
211
|
+
var nodes = $.unique( dt.rows( { page: 'current' } ).nodes().toArray() );
|
|
212
|
+
var tops = $.map( nodes, function ( node, i ) {
|
|
213
|
+
return $(node).position().top - headerHeight;
|
|
214
|
+
} );
|
|
215
|
+
|
|
216
|
+
var middles = $.map( tops, function ( top, i ) {
|
|
217
|
+
return tops.length < i-1 ?
|
|
218
|
+
(top + tops[i+1]) / 2 :
|
|
219
|
+
(top + top + $( dt.row( ':last-child' ).node() ).outerHeight() ) / 2;
|
|
220
|
+
} );
|
|
221
|
+
|
|
222
|
+
this.s.middles = middles;
|
|
223
|
+
this.s.bodyTop = $( dt.table().body() ).offset().top;
|
|
224
|
+
this.s.windowHeight = $(window).height();
|
|
225
|
+
},
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Clone a row so it can be floated around the screen
|
|
230
|
+
*
|
|
231
|
+
* @param {jQuery} target Node to be cloned
|
|
232
|
+
* @private
|
|
233
|
+
*/
|
|
234
|
+
_clone: function ( target )
|
|
235
|
+
{
|
|
236
|
+
var dt = this.s.dt;
|
|
237
|
+
var clone = $( dt.table().node().cloneNode(false) )
|
|
238
|
+
.addClass( 'dt-rowReorder-float' )
|
|
239
|
+
.append('<tbody/>')
|
|
240
|
+
.append( target.clone( false ) );
|
|
241
|
+
|
|
242
|
+
// Match the table and column widths - read all sizes before setting
|
|
243
|
+
// to reduce reflows
|
|
244
|
+
var tableWidth = target.outerWidth();
|
|
245
|
+
var tableHeight = target.outerHeight();
|
|
246
|
+
var sizes = target.children().map( function () {
|
|
247
|
+
return $(this).width();
|
|
248
|
+
} );
|
|
249
|
+
|
|
250
|
+
clone
|
|
251
|
+
.width( tableWidth )
|
|
252
|
+
.height( tableHeight )
|
|
253
|
+
.find('tr').children().each( function (i) {
|
|
254
|
+
this.style.width = sizes[i]+'px';
|
|
255
|
+
} );
|
|
256
|
+
|
|
257
|
+
// Insert into the document to have it floating around
|
|
258
|
+
clone.appendTo( 'body' );
|
|
259
|
+
|
|
260
|
+
this.dom.clone = clone;
|
|
261
|
+
},
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Update the cloned item's position in the document
|
|
266
|
+
*
|
|
267
|
+
* @param {object} e Event giving the mouse's position
|
|
268
|
+
* @private
|
|
269
|
+
*/
|
|
270
|
+
_clonePosition: function ( e )
|
|
271
|
+
{
|
|
272
|
+
var start = this.s.start;
|
|
273
|
+
var topDiff = this._eventToPage( e, 'Y' ) - start.top;
|
|
274
|
+
var leftDiff = this._eventToPage( e, 'X' ) - start.left;
|
|
275
|
+
var snap = this.c.snapX;
|
|
276
|
+
var left;
|
|
277
|
+
|
|
278
|
+
if ( snap === true ) {
|
|
279
|
+
left = start.offsetLeft;
|
|
280
|
+
}
|
|
281
|
+
else if ( typeof snap === 'number' ) {
|
|
282
|
+
left = start.offsetLeft + snap;
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
left = leftDiff + start.offsetLeft;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
this.dom.clone.css( {
|
|
289
|
+
top: topDiff + start.offsetTop,
|
|
290
|
+
left: left
|
|
291
|
+
} );
|
|
292
|
+
},
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Emit an event on the DataTable for listeners
|
|
297
|
+
*
|
|
298
|
+
* @param {string} name Event name
|
|
299
|
+
* @param {array} args Event arguments
|
|
300
|
+
* @private
|
|
301
|
+
*/
|
|
302
|
+
_emitEvent: function ( name, args )
|
|
303
|
+
{
|
|
304
|
+
this.s.dt.iterator( 'table', function ( ctx, i ) {
|
|
305
|
+
$(ctx.nTable).triggerHandler( name+'.dt', args );
|
|
306
|
+
} );
|
|
307
|
+
},
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Get pageX/Y position from an event, regardless of if it is a mouse or
|
|
312
|
+
* touch event.
|
|
313
|
+
*
|
|
314
|
+
* @param {object} e Event
|
|
315
|
+
* @param {string} pos X or Y (must be a capital)
|
|
316
|
+
* @private
|
|
317
|
+
*/
|
|
318
|
+
_eventToPage: function ( e, pos )
|
|
319
|
+
{
|
|
320
|
+
if ( e.type.indexOf( 'touch' ) !== -1 ) {
|
|
321
|
+
return e.originalEvent.touches[0][ 'page'+pos ];
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
return e[ 'page'+pos ];
|
|
325
|
+
},
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Mouse down event handler. Read initial positions and add event handlers
|
|
330
|
+
* for the move.
|
|
331
|
+
*
|
|
332
|
+
* @param {object} e Mouse event
|
|
333
|
+
* @param {jQuery} target TR element that is to be moved
|
|
334
|
+
* @private
|
|
335
|
+
*/
|
|
336
|
+
_mouseDown: function ( e, target )
|
|
337
|
+
{
|
|
338
|
+
var that = this;
|
|
339
|
+
var dt = this.s.dt;
|
|
340
|
+
var start = this.s.start;
|
|
341
|
+
|
|
342
|
+
var offset = target.offset();
|
|
343
|
+
start.top = this._eventToPage( e, 'Y' );
|
|
344
|
+
start.left = this._eventToPage( e, 'X' );
|
|
345
|
+
start.offsetTop = offset.top;
|
|
346
|
+
start.offsetLeft = offset.left;
|
|
347
|
+
start.nodes = $.unique( dt.rows( { page: 'current' } ).nodes().toArray() );
|
|
348
|
+
|
|
349
|
+
this._cachePositions();
|
|
350
|
+
this._clone( target );
|
|
351
|
+
this._clonePosition( e );
|
|
352
|
+
|
|
353
|
+
this.dom.target = target;
|
|
354
|
+
target.addClass( 'dt-rowReorder-moving' );
|
|
355
|
+
|
|
356
|
+
$( document )
|
|
357
|
+
.on( 'mouseup.rowReorder touchend.rowReorder', function (e) {
|
|
358
|
+
that._mouseUp(e);
|
|
359
|
+
} )
|
|
360
|
+
.on( 'mousemove.rowReorder touchmove.rowReorder', function (e) {
|
|
361
|
+
that._mouseMove(e);
|
|
362
|
+
} );
|
|
363
|
+
|
|
364
|
+
// Check if window is x-scrolling - if not, disable it for the duration
|
|
365
|
+
// of the drag
|
|
366
|
+
if ( $(window).width() === $(document).width() ) {
|
|
367
|
+
$(document.body).addClass( 'dt-rowReorder-noOverflow' );
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// Cache scrolling information so mouse move doesn't need to read.
|
|
371
|
+
// This assumes that the window and DT scroller will not change size
|
|
372
|
+
// during an row drag, which I think is a fair assumption
|
|
373
|
+
var scrollWrapper = this.dom.dtScroll;
|
|
374
|
+
this.s.scroll = {
|
|
375
|
+
windowHeight: $(window).height(),
|
|
376
|
+
windowWidth: $(window).width(),
|
|
377
|
+
dtTop: scrollWrapper.length ? scrollWrapper.offset().top : null,
|
|
378
|
+
dtLeft: scrollWrapper.length ? scrollWrapper.offset().left : null,
|
|
379
|
+
dtHeight: scrollWrapper.length ? scrollWrapper.outerHeight() : null,
|
|
380
|
+
dtWidth: scrollWrapper.length ? scrollWrapper.outerWidth() : null
|
|
381
|
+
};
|
|
382
|
+
},
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Mouse move event handler - move the cloned row and shuffle the table's
|
|
387
|
+
* rows if required.
|
|
388
|
+
*
|
|
389
|
+
* @param {object} e Mouse event
|
|
390
|
+
* @private
|
|
391
|
+
*/
|
|
392
|
+
_mouseMove: function ( e )
|
|
393
|
+
{
|
|
394
|
+
this._clonePosition( e );
|
|
395
|
+
|
|
396
|
+
// Transform the mouse position into a position in the table's body
|
|
397
|
+
var bodyY = this._eventToPage( e, 'Y' ) - this.s.bodyTop;
|
|
398
|
+
var middles = this.s.middles;
|
|
399
|
+
var insertPoint = null;
|
|
400
|
+
var dt = this.s.dt;
|
|
401
|
+
var body = dt.table().body();
|
|
402
|
+
|
|
403
|
+
// Determine where the row should be inserted based on the mouse
|
|
404
|
+
// position
|
|
405
|
+
for ( var i=0, ien=middles.length ; i<ien ; i++ ) {
|
|
406
|
+
if ( bodyY < middles[i] ) {
|
|
407
|
+
insertPoint = i;
|
|
408
|
+
break;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
if ( insertPoint === null ) {
|
|
413
|
+
insertPoint = middles.length;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
// Perform the DOM shuffle if it has changed from last time
|
|
417
|
+
if ( this.s.lastInsert === null || this.s.lastInsert !== insertPoint ) {
|
|
418
|
+
if ( insertPoint === 0 ) {
|
|
419
|
+
this.dom.target.prependTo( body );
|
|
420
|
+
}
|
|
421
|
+
else {
|
|
422
|
+
var nodes = $.unique( dt.rows( { page: 'current' } ).nodes().toArray() );
|
|
423
|
+
|
|
424
|
+
if ( insertPoint > this.s.lastInsert ) {
|
|
425
|
+
this.dom.target.insertAfter( nodes[ insertPoint-1 ] );
|
|
426
|
+
}
|
|
427
|
+
else {
|
|
428
|
+
this.dom.target.insertBefore( nodes[ insertPoint ] );
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
this._cachePositions();
|
|
433
|
+
|
|
434
|
+
this.s.lastInsert = insertPoint;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
this._shiftScroll( e );
|
|
438
|
+
},
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Mouse up event handler - release the event handlers and perform the
|
|
443
|
+
* table updates
|
|
444
|
+
*
|
|
445
|
+
* @param {object} e Mouse event
|
|
446
|
+
* @private
|
|
447
|
+
*/
|
|
448
|
+
_mouseUp: function ( e )
|
|
449
|
+
{
|
|
450
|
+
var dt = this.s.dt;
|
|
451
|
+
var i, ien;
|
|
452
|
+
var dataSrc = this.c.dataSrc;
|
|
453
|
+
|
|
454
|
+
this.dom.clone.remove();
|
|
455
|
+
this.dom.clone = null;
|
|
456
|
+
|
|
457
|
+
this.dom.target.removeClass( 'dt-rowReorder-moving' );
|
|
458
|
+
//this.dom.target = null;
|
|
459
|
+
|
|
460
|
+
$(document).off( '.rowReorder' );
|
|
461
|
+
$(document.body).removeClass( 'dt-rowReorder-noOverflow' );
|
|
462
|
+
|
|
463
|
+
clearInterval( this.s.scrollInterval );
|
|
464
|
+
this.s.scrollInterval = null;
|
|
465
|
+
|
|
466
|
+
// Calculate the difference
|
|
467
|
+
var startNodes = this.s.start.nodes;
|
|
468
|
+
var endNodes = $.unique( dt.rows( { page: 'current' } ).nodes().toArray() );
|
|
469
|
+
var idDiff = {};
|
|
470
|
+
var fullDiff = [];
|
|
471
|
+
var diffNodes = [];
|
|
472
|
+
var getDataFn = this.s.getDataFn;
|
|
473
|
+
var setDataFn = this.s.setDataFn;
|
|
474
|
+
|
|
475
|
+
for ( i=0, ien=startNodes.length ; i<ien ; i++ ) {
|
|
476
|
+
if ( startNodes[i] !== endNodes[i] ) {
|
|
477
|
+
var id = dt.row( endNodes[i] ).id();
|
|
478
|
+
var endRowData = dt.row( endNodes[i] ).data();
|
|
479
|
+
var startRowData = dt.row( startNodes[i] ).data();
|
|
480
|
+
|
|
481
|
+
if ( id ) {
|
|
482
|
+
idDiff[ id ] = getDataFn( startRowData );
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
fullDiff.push( {
|
|
486
|
+
node: endNodes[i],
|
|
487
|
+
oldData: getDataFn( endRowData ),
|
|
488
|
+
newData: getDataFn( startRowData ),
|
|
489
|
+
newPosition: i,
|
|
490
|
+
oldPosition: $.inArray( endNodes[i], startNodes )
|
|
491
|
+
} );
|
|
492
|
+
|
|
493
|
+
diffNodes.push( endNodes[i] );
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
// Create event args
|
|
498
|
+
var eventArgs = [ fullDiff, {
|
|
499
|
+
dataSrc: dataSrc,
|
|
500
|
+
nodes: diffNodes,
|
|
501
|
+
values: idDiff,
|
|
502
|
+
triggerRow: dt.row( this.dom.target )
|
|
503
|
+
} ];
|
|
504
|
+
|
|
505
|
+
// Emit event
|
|
506
|
+
this._emitEvent( 'row-reorder', eventArgs );
|
|
507
|
+
|
|
508
|
+
// Editor interface
|
|
509
|
+
if ( this.c.editor ) {
|
|
510
|
+
this.c.editor
|
|
511
|
+
.edit( diffNodes, false, {
|
|
512
|
+
submit: 'changed'
|
|
513
|
+
} )
|
|
514
|
+
.multiSet( dataSrc, idDiff )
|
|
515
|
+
.submit();
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
// Do update if required
|
|
519
|
+
if ( this.c.update ) {
|
|
520
|
+
for ( i=0, ien=fullDiff.length ; i<ien ; i++ ) {
|
|
521
|
+
var row = dt.row( fullDiff[i].node );
|
|
522
|
+
var rowData = row.data();
|
|
523
|
+
|
|
524
|
+
setDataFn( rowData, fullDiff[i].newData );
|
|
525
|
+
|
|
526
|
+
// Invalidate the cell that has the same data source as the dataSrc
|
|
527
|
+
dt.columns().every( function () {
|
|
528
|
+
if ( this.dataSrc() === dataSrc ) {
|
|
529
|
+
dt.cell( fullDiff[i].node, this.index() ).invalidate( 'data' );
|
|
530
|
+
}
|
|
531
|
+
} );
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
// Trigger row reordered event
|
|
535
|
+
this._emitEvent( 'row-reordered', eventArgs );
|
|
536
|
+
|
|
537
|
+
dt.draw( false );
|
|
538
|
+
}
|
|
539
|
+
},
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* Move the window and DataTables scrolling during a drag to scroll new
|
|
544
|
+
* content into view.
|
|
545
|
+
*
|
|
546
|
+
* This matches the `_shiftScroll` method used in AutoFill, but only
|
|
547
|
+
* horizontal scrolling is considered here.
|
|
548
|
+
*
|
|
549
|
+
* @param {object} e Mouse move event object
|
|
550
|
+
* @private
|
|
551
|
+
*/
|
|
552
|
+
_shiftScroll: function ( e )
|
|
553
|
+
{
|
|
554
|
+
var that = this;
|
|
555
|
+
var dt = this.s.dt;
|
|
556
|
+
var scroll = this.s.scroll;
|
|
557
|
+
var runInterval = false;
|
|
558
|
+
var scrollSpeed = 5;
|
|
559
|
+
var buffer = 65;
|
|
560
|
+
var
|
|
561
|
+
windowY = e.pageY - document.body.scrollTop,
|
|
562
|
+
windowVert,
|
|
563
|
+
dtVert;
|
|
564
|
+
|
|
565
|
+
// Window calculations - based on the mouse position in the window,
|
|
566
|
+
// regardless of scrolling
|
|
567
|
+
if ( windowY < buffer ) {
|
|
568
|
+
windowVert = scrollSpeed * -1;
|
|
569
|
+
}
|
|
570
|
+
else if ( windowY > scroll.windowHeight - buffer ) {
|
|
571
|
+
windowVert = scrollSpeed;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
// DataTables scrolling calculations - based on the table's position in
|
|
575
|
+
// the document and the mouse position on the page
|
|
576
|
+
if ( scroll.dtTop !== null && e.pageY < scroll.dtTop + buffer ) {
|
|
577
|
+
dtVert = scrollSpeed * -1;
|
|
578
|
+
}
|
|
579
|
+
else if ( scroll.dtTop !== null && e.pageY > scroll.dtTop + scroll.dtHeight - buffer ) {
|
|
580
|
+
dtVert = scrollSpeed;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
// This is where it gets interesting. We want to continue scrolling
|
|
584
|
+
// without requiring a mouse move, so we need an interval to be
|
|
585
|
+
// triggered. The interval should continue until it is no longer needed,
|
|
586
|
+
// but it must also use the latest scroll commands (for example consider
|
|
587
|
+
// that the mouse might move from scrolling up to scrolling left, all
|
|
588
|
+
// with the same interval running. We use the `scroll` object to "pass"
|
|
589
|
+
// this information to the interval. Can't use local variables as they
|
|
590
|
+
// wouldn't be the ones that are used by an already existing interval!
|
|
591
|
+
if ( windowVert || dtVert ) {
|
|
592
|
+
scroll.windowVert = windowVert;
|
|
593
|
+
scroll.dtVert = dtVert;
|
|
594
|
+
runInterval = true;
|
|
595
|
+
}
|
|
596
|
+
else if ( this.s.scrollInterval ) {
|
|
597
|
+
// Don't need to scroll - remove any existing timer
|
|
598
|
+
clearInterval( this.s.scrollInterval );
|
|
599
|
+
this.s.scrollInterval = null;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
// If we need to run the interval to scroll and there is no existing
|
|
603
|
+
// interval (if there is an existing one, it will continue to run)
|
|
604
|
+
if ( ! this.s.scrollInterval && runInterval ) {
|
|
605
|
+
this.s.scrollInterval = setInterval( function () {
|
|
606
|
+
// Don't need to worry about setting scroll <0 or beyond the
|
|
607
|
+
// scroll bound as the browser will just reject that.
|
|
608
|
+
if ( scroll.windowVert ) {
|
|
609
|
+
document.body.scrollTop += scroll.windowVert;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
// DataTables scrolling
|
|
613
|
+
if ( scroll.dtVert ) {
|
|
614
|
+
var scroller = that.dom.dtScroll[0];
|
|
615
|
+
|
|
616
|
+
if ( scroll.dtVert ) {
|
|
617
|
+
scroller.scrollTop += scroll.dtVert;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
}, 20 );
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
} );
|
|
624
|
+
|
|
625
|
+
|
|
626
|
+
|
|
627
|
+
/**
|
|
628
|
+
* RowReorder default settings for initialisation
|
|
629
|
+
*
|
|
630
|
+
* @namespace
|
|
631
|
+
* @name RowReorder.defaults
|
|
632
|
+
* @static
|
|
633
|
+
*/
|
|
634
|
+
RowReorder.defaults = {
|
|
635
|
+
/**
|
|
636
|
+
* Data point in the host row's data source object for where to get and set
|
|
637
|
+
* the data to reorder. This will normally also be the sorting column.
|
|
638
|
+
*
|
|
639
|
+
* @type {Number}
|
|
640
|
+
*/
|
|
641
|
+
dataSrc: 0,
|
|
642
|
+
|
|
643
|
+
/**
|
|
644
|
+
* Editor instance that will be used to perform the update
|
|
645
|
+
*
|
|
646
|
+
* @type {DataTable.Editor}
|
|
647
|
+
*/
|
|
648
|
+
editor: null,
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* Drag handle selector. This defines the element that when dragged will
|
|
652
|
+
* reorder a row.
|
|
653
|
+
*
|
|
654
|
+
* @type {String}
|
|
655
|
+
*/
|
|
656
|
+
selector: 'td:first-child',
|
|
657
|
+
|
|
658
|
+
/**
|
|
659
|
+
* Optionally lock the dragged row's x-position. This can be `true` to
|
|
660
|
+
* fix the position match the host table's, `false` to allow free movement
|
|
661
|
+
* of the row, or a number to define an offset from the host table.
|
|
662
|
+
*
|
|
663
|
+
* @type {Boolean|number}
|
|
664
|
+
*/
|
|
665
|
+
snapX: false,
|
|
666
|
+
|
|
667
|
+
/**
|
|
668
|
+
* Update the table's data on drop
|
|
669
|
+
*
|
|
670
|
+
* @type {Boolean}
|
|
671
|
+
*/
|
|
672
|
+
update: true
|
|
673
|
+
};
|
|
674
|
+
|
|
675
|
+
|
|
676
|
+
/**
|
|
677
|
+
* Version information
|
|
678
|
+
*
|
|
679
|
+
* @name RowReorder.version
|
|
680
|
+
* @static
|
|
681
|
+
*/
|
|
682
|
+
RowReorder.version = '1.1.2';
|
|
683
|
+
|
|
684
|
+
|
|
685
|
+
$.fn.dataTable.RowReorder = RowReorder;
|
|
686
|
+
$.fn.DataTable.RowReorder = RowReorder;
|
|
687
|
+
|
|
688
|
+
// Attach a listener to the document which listens for DataTables initialisation
|
|
689
|
+
// events so we can automatically initialise
|
|
690
|
+
$(document).on( 'init.dt.dtr', function (e, settings, json) {
|
|
691
|
+
if ( e.namespace !== 'dt' ) {
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
var init = settings.oInit.rowReorder;
|
|
696
|
+
var defaults = DataTable.defaults.rowReorder;
|
|
697
|
+
|
|
698
|
+
if ( init || defaults ) {
|
|
699
|
+
var opts = $.extend( {}, init, defaults );
|
|
700
|
+
|
|
701
|
+
if ( init !== false ) {
|
|
702
|
+
new RowReorder( settings, opts );
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
} );
|
|
706
|
+
|
|
707
|
+
|
|
708
|
+
return RowReorder;
|
|
709
|
+
}));
|