effective_datatables 3.7.10 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/MIT-LICENSE +1 -1
- data/README.md +32 -32
- data/app/assets/images/dataTables/sort-down.svg +1 -0
- data/app/assets/images/dataTables/sort-up.svg +1 -0
- data/app/assets/images/dataTables/sort.svg +1 -0
- data/app/assets/javascripts/dataTables/buttons/{buttons.bootstrap.js → buttons.bootstrap4.js} +7 -15
- data/app/assets/javascripts/dataTables/dataTables.bootstrap4.js +184 -0
- data/app/assets/javascripts/dataTables/responsive/dataTables.responsive.js +30 -11
- data/app/assets/javascripts/dataTables/responsive/{responsive.bootstrap.js → responsive.bootstrap4.js} +6 -6
- data/app/assets/javascripts/effective_datatables/bulk_actions.js.coffee +43 -43
- data/app/assets/javascripts/effective_datatables/events.js.coffee +7 -4
- data/app/assets/javascripts/effective_datatables/filters.js.coffee +0 -1
- data/app/assets/javascripts/effective_datatables/initialize.js.coffee +45 -49
- data/app/assets/javascripts/effective_datatables/overrides.js +12 -0
- data/app/assets/javascripts/effective_datatables/reset.js.coffee +1 -1
- data/app/assets/javascripts/effective_datatables.js +4 -4
- data/app/assets/stylesheets/dataTables/buttons/{buttons.bootstrap.scss → buttons.bootstrap4.css} +68 -1
- data/app/assets/stylesheets/dataTables/{dataTables.bootstrap.scss → dataTables.bootstrap4.css} +44 -29
- data/app/assets/stylesheets/dataTables/responsive/{responsive.bootstrap.scss → responsive.bootstrap4.css} +3 -3
- data/app/assets/stylesheets/effective_datatables/_overrides.scss +72 -152
- data/app/assets/stylesheets/effective_datatables.scss +3 -4
- data/app/controllers/effective/datatables_controller.rb +6 -39
- data/app/helpers/effective_datatables_helper.rb +55 -50
- data/app/helpers/effective_datatables_private_helper.rb +47 -179
- data/app/models/effective/datatable.rb +16 -44
- data/app/models/effective/datatable_column.rb +0 -1
- data/app/models/effective/datatable_column_tool.rb +2 -4
- data/app/models/effective/datatable_dsl_tool.rb +3 -11
- data/app/models/effective/datatable_value_tool.rb +23 -23
- data/app/models/effective/effective_datatable/attributes.rb +13 -5
- data/app/models/effective/effective_datatable/collection.rb +3 -18
- data/app/models/effective/effective_datatable/compute.rb +6 -17
- data/app/models/effective/effective_datatable/cookie.rb +20 -19
- data/app/models/effective/effective_datatable/dsl/bulk_actions.rb +25 -14
- data/app/models/effective/effective_datatable/dsl/datatable.rb +28 -70
- data/app/models/effective/effective_datatable/dsl/filters.rb +5 -5
- data/app/models/effective/effective_datatable/dsl.rb +3 -8
- data/app/models/effective/effective_datatable/format.rb +50 -95
- data/app/models/effective/effective_datatable/params.rb +3 -8
- data/app/models/effective/effective_datatable/resource.rb +76 -137
- data/app/models/effective/effective_datatable/state.rb +15 -30
- data/app/views/effective/datatables/_actions_column.html.haml +8 -1
- data/app/views/effective/datatables/_bulk_actions_column.html.haml +1 -1
- data/app/views/effective/datatables/_filters.html.haml +11 -12
- data/app/views/effective/datatables/_resource_column.html.haml +8 -11
- data/config/effective_datatables.rb +14 -12
- data/config/routes.rb +0 -1
- data/lib/effective_datatables/engine.rb +4 -14
- data/lib/effective_datatables/version.rb +1 -1
- data/lib/effective_datatables.rb +4 -57
- metadata +20 -31
- data/app/assets/config/effective_datatables_manifest.js +0 -3
- data/app/assets/images/dataTables/sort_asc.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/javascripts/dataTables/dataTables.bootstrap.js +0 -182
- data/app/assets/javascripts/dataTables/locales/en.lang +0 -33
- data/app/assets/javascripts/dataTables/locales/es.lang +0 -36
- data/app/assets/javascripts/dataTables/locales/nl.lang +0 -30
- data/app/assets/javascripts/effective_datatables/flash.js.coffee +0 -31
- data/app/assets/javascripts/effective_datatables/inline_crud.js.coffee +0 -217
- data/app/assets/javascripts/effective_datatables/overrides.js.coffee +0 -7
- data/app/assets/javascripts/effective_datatables/reorder.js.coffee +0 -43
- data/app/assets/stylesheets/effective_datatables/_filters.scss +0 -7
- data/app/views/effective/datatables/_reorder_column.html.haml +0 -5
- data/config/locales/en.yml +0 -12
- data/config/locales/es.yml +0 -12
- data/config/locales/nl.yml +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 409a99e8dc9284b103bbbcd90ef5e66e4945c4fe
|
4
|
+
data.tar.gz: 5e320731bec22af5f939b6dd35c9358df9e41b08
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d568242347b2c0656e993305a296284fb0f2731f4d2f4177725f992db7891bdf5e5f873b52cb57b0301c0b0807cb90917147d3a42abb59d8932ff7e1c0a50f5
|
7
|
+
data.tar.gz: a5147ebee2cc69002e0da8e7682e9fe84909da9e7726ea3a61a0887df2e644617324bd36066b1e36a99b1a385b596dc48118fde79bfd3ee85bcacd747eb867dc
|
data/MIT-LICENSE
CHANGED
data/README.md
CHANGED
@@ -12,23 +12,22 @@ Other features include aggregate (total/average) footer rows, bulk actions, show
|
|
12
12
|
|
13
13
|
This gem includes the jQuery DataTables assets.
|
14
14
|
|
15
|
-
For use with any Rails 3, 4, 5 application already using Twitter Bootstrap 3.
|
16
15
|
|
17
16
|
Works with postgres, mysql, sqlite3 and arrays.
|
18
17
|
|
19
|
-
##
|
18
|
+
## effective_datatables 4.0
|
20
19
|
|
21
|
-
This is the
|
20
|
+
This is the 4.0 series of effective_datatables.
|
22
21
|
|
23
|
-
|
22
|
+
This requires Twitter Bootstrap 4 and Rails 5.1+
|
24
23
|
|
25
|
-
|
24
|
+
Please check out [Effective Datatables 3.x](https://github.com/code-and-effect/effective_datatables/tree/bootstrap3) for more information using this gem with Bootstrap 3.
|
26
25
|
|
27
26
|
# Getting Started
|
28
27
|
|
29
28
|
```ruby
|
30
29
|
gem 'haml-rails' # or try using gem 'hamlit-rails'
|
31
|
-
gem 'effective_datatables'
|
30
|
+
gem 'effective_datatables'
|
32
31
|
```
|
33
32
|
|
34
33
|
Run the bundle command to install it:
|
@@ -45,6 +44,8 @@ rails generate effective_datatables:install
|
|
45
44
|
|
46
45
|
The generator will install an initializer which describes all configuration options.
|
47
46
|
|
47
|
+
Make sure you have [Twitter Bootstrap 4](https://github.com/twbs/bootstrap-rubygem) installed.
|
48
|
+
|
48
49
|
Require the javascript on the asset pipeline by adding the following to your application.js:
|
49
50
|
|
50
51
|
```ruby
|
@@ -91,7 +92,7 @@ We're going to display this DataTable on the posts#index action.
|
|
91
92
|
```ruby
|
92
93
|
class PostsController < ApplicationController
|
93
94
|
def index
|
94
|
-
@datatable = PostsDatatable.new
|
95
|
+
@datatable = PostsDatatable.new(self)
|
95
96
|
end
|
96
97
|
end
|
97
98
|
```
|
@@ -234,13 +235,13 @@ class PostsDatatable < Effective::Datatable
|
|
234
235
|
aggregate :total
|
235
236
|
|
236
237
|
# Uses effective_resources gem to discover the resource path and authorization actions
|
237
|
-
# Puts
|
238
|
+
# Puts in icons to show/edit/destroy actions, if authorized to those actions.
|
238
239
|
# Use the actions_col block to add additional actions
|
239
|
-
|
240
|
-
|
241
|
-
|
240
|
+
actions_col show: false do |post|
|
241
|
+
if !post.approved? && can?(:approve, Post)
|
242
|
+
link_to 'Approve', approve_post_path(post) data: { method: :post, confirm: 'Really approve?'}
|
243
|
+
end
|
242
244
|
end
|
243
|
-
|
244
245
|
end
|
245
246
|
|
246
247
|
end
|
@@ -255,7 +256,7 @@ In the above example, when `attributes[:user_id]` is present, the table displays
|
|
255
256
|
```ruby
|
256
257
|
class PostsController < ApplicationController
|
257
258
|
def index
|
258
|
-
@datatable = PostsDatatable.new(user_id: current_user.id)
|
259
|
+
@datatable = PostsDatatable.new(self, user_id: current_user.id)
|
259
260
|
end
|
260
261
|
end
|
261
262
|
```
|
@@ -311,7 +312,7 @@ Attributes cannot be changed by search, filter, or state in any way. They're gua
|
|
311
312
|
```ruby
|
312
313
|
class PostsController < ApplicationController
|
313
314
|
def index
|
314
|
-
@datatable = PostsDatatable.new(user_id: current_user.id, admin: true)
|
315
|
+
@datatable = PostsDatatable.new(self, user_id: current_user.id, admin: true)
|
315
316
|
end
|
316
317
|
end
|
317
318
|
```
|
@@ -407,7 +408,7 @@ Sometimes it's handy to call `.reorder(nil)` on a scope.
|
|
407
408
|
|
408
409
|
The `datatable do ... end` block configures a table of data.
|
409
410
|
|
410
|
-
Initialize the datatable in your controller or view, `@datatable = PostsDatatable.new`, and render it in your view `<%= render_datatable(@datatable) %>`
|
411
|
+
Initialize the datatable in your controller or view, `@datatable = PostsDatatable.new(self)`, and render it in your view `<%= render_datatable(@datatable) %>`
|
411
412
|
|
412
413
|
### col
|
413
414
|
|
@@ -514,36 +515,35 @@ You can only have one `bulk_actions_col` per datatable.
|
|
514
515
|
|
515
516
|
### actions_col
|
516
517
|
|
517
|
-
When working with an ActiveRecord based collection, this column will consider the `current_user`'s authorization, and generate
|
518
|
+
When working with an ActiveRecord based collection, this column will consider the `current_user`'s authorization, and generate
|
519
|
+
glyphicon links to edit, show and destroy actions for any collection class.
|
518
520
|
|
519
521
|
The authorization method is configured via the `config/initializers/effective_datatables.rb` initializer file.
|
520
522
|
|
521
523
|
There are just a few options:
|
522
524
|
|
523
525
|
```ruby
|
524
|
-
show: true|false
|
525
|
-
edit: true|false
|
526
|
-
destroy: true|false
|
526
|
+
show: true|false|:authorize
|
527
|
+
edit: true|false|:authorize
|
528
|
+
destroy: true|false|:authorize
|
529
|
+
|
527
530
|
visible: true|false
|
528
|
-
actions_partial: :glyphicons
|
529
531
|
```
|
530
532
|
|
531
|
-
|
533
|
+
When the show, edit and destroy actions are `true` (default), the permission check will be made just once, authorizing the class.
|
534
|
+
When set to `:authorize`, permission to each individual object will be checked.
|
532
535
|
|
533
|
-
|
534
|
-
|
535
|
-
It's all very complicated.
|
536
|
-
|
537
|
-
If you just want to override this entire column with your own actions implementation, you can pass `actions_col partial: 'my_partial'` and roll your own.
|
538
|
-
|
539
|
-
Otherwise, use the following block syntax to add additional actions. This helper comes from `effective_form_inputs` gem.
|
536
|
+
Use the block syntax to add additional actions
|
540
537
|
|
541
538
|
```ruby
|
542
|
-
actions_col do |post|
|
543
|
-
|
539
|
+
actions_col show: false do |post|
|
540
|
+
(post.approved? ? link_to('Approve', approve_post_path(post)) : '') +
|
541
|
+
glyphicon_to('print', print_ticket_path(ticket), title: 'Print')
|
544
542
|
end
|
545
543
|
```
|
546
544
|
|
545
|
+
The `glyphicon_to` helper is part of the [effective_resources](https://github.com/code-and-effect/effective_resources) gem, which is a dependency of this gem.
|
546
|
+
|
547
547
|
### length
|
548
548
|
|
549
549
|
Sets the default number of rows per page. Valid lengths are `5`, `10`, `25`, `50`, `100`, `250`, `500`, `:all`
|
@@ -609,7 +609,7 @@ Creates a single form with fields for each `filter` and a single radio input fie
|
|
609
609
|
|
610
610
|
The form is submitted by an AJAX POST action, or, in some advanced circumstances (see Dynamic Columns below) as a regular POST or even GET.
|
611
611
|
|
612
|
-
Initialize the datatable in your controller or view, `@datatable = PostsDatatable.new`, and render its filters anywhere with `<%= render_datatable_filters(@datatable) %>`.
|
612
|
+
Initialize the datatable in your controller or view, `@datatable = PostsDatatable.new(self)`, and render its filters anywhere with `<%= render_datatable_filters(@datatable) %>`.
|
613
613
|
|
614
614
|
### scope
|
615
615
|
|
@@ -865,7 +865,7 @@ If you just want to render a datatable and nothing else, there is a quick way to
|
|
865
865
|
```ruby
|
866
866
|
class PostsController < ApplicationController
|
867
867
|
def index
|
868
|
-
render_datatable_index PostsDatatable.new
|
868
|
+
render_datatable_index PostsDatatable.new(self)
|
869
869
|
end
|
870
870
|
end
|
871
871
|
```
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512" width="24" height="24"><path fill="#007bff" d="M41 288h238c21.4 0 32.1 25.9 17 41L177 448c-9.4 9.4-24.6 9.4-33.9 0L24 329c-15.1-15.1-4.4-41 17-41z"/></svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512" width="24" height="24"><path fill="#007bff" d="M279 224H41c-21.4 0-32.1-25.9-17-41L143 64c9.4-9.4 24.6-9.4 33.9 0l119 119c15.2 15.1 4.5 41-16.9 41z"/></svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512" width="24" height="24"><path fill='#ddd' d="M41 288h238c21.4 0 32.1 25.9 17 41L177 448c-9.4 9.4-24.6 9.4-33.9 0L24 329c-15.1-15.1-4.4-41 17-41zm255-105L177 64c-9.4-9.4-24.6-9.4-33.9 0L24 183c-15.1 15.1-4.4 41 17 41h238c21.4 0 32.1-25.9 17-41z"/></svg>
|
data/app/assets/javascripts/dataTables/buttons/{buttons.bootstrap.js → buttons.bootstrap4.js}
RENAMED
@@ -5,7 +5,7 @@
|
|
5
5
|
(function( factory ){
|
6
6
|
if ( typeof define === 'function' && define.amd ) {
|
7
7
|
// AMD
|
8
|
-
define( ['jquery', 'datatables.net-
|
8
|
+
define( ['jquery', 'datatables.net-bs4', 'datatables.net-buttons'], function ( $ ) {
|
9
9
|
return factory( $, window, document );
|
10
10
|
} );
|
11
11
|
}
|
@@ -17,7 +17,7 @@
|
|
17
17
|
}
|
18
18
|
|
19
19
|
if ( ! $ || ! $.fn.dataTable ) {
|
20
|
-
$ = require('datatables.net-
|
20
|
+
$ = require('datatables.net-bs4')(root, $).$;
|
21
21
|
}
|
22
22
|
|
23
23
|
if ( ! $.fn.dataTable.Buttons ) {
|
@@ -35,36 +35,28 @@
|
|
35
35
|
'use strict';
|
36
36
|
var DataTable = $.fn.dataTable;
|
37
37
|
|
38
|
-
|
39
38
|
$.extend( true, DataTable.Buttons.defaults, {
|
40
39
|
dom: {
|
41
40
|
container: {
|
42
41
|
className: 'dt-buttons btn-group'
|
43
42
|
},
|
44
43
|
button: {
|
45
|
-
className: 'btn btn-
|
44
|
+
className: 'btn btn-secondary'
|
46
45
|
},
|
47
46
|
collection: {
|
48
|
-
tag: '
|
47
|
+
tag: 'div',
|
49
48
|
className: 'dt-button-collection dropdown-menu',
|
50
49
|
button: {
|
51
|
-
tag: '
|
52
|
-
className: 'dt-button',
|
50
|
+
tag: 'a',
|
51
|
+
className: 'dt-button dropdown-item',
|
53
52
|
active: 'active',
|
54
53
|
disabled: 'disabled'
|
55
|
-
},
|
56
|
-
buttonLiner: {
|
57
|
-
tag: 'a',
|
58
|
-
className: ''
|
59
54
|
}
|
60
55
|
}
|
61
56
|
}
|
62
57
|
} );
|
63
58
|
|
64
|
-
DataTable.ext.buttons.collection.
|
65
|
-
return dt.i18n('buttons.collection', 'Collection <span class="caret"/>');
|
66
|
-
};
|
67
|
-
|
59
|
+
DataTable.ext.buttons.collection.className += ' dropdown-toggle';
|
68
60
|
|
69
61
|
return DataTable.Buttons;
|
70
62
|
}));
|
@@ -0,0 +1,184 @@
|
|
1
|
+
/*! DataTables Bootstrap 3 integration
|
2
|
+
* ©2011-2015 SpryMedia Ltd - datatables.net/license
|
3
|
+
*/
|
4
|
+
|
5
|
+
/**
|
6
|
+
* DataTables integration for Bootstrap 3. This requires Bootstrap 3 and
|
7
|
+
* DataTables 1.10 or newer.
|
8
|
+
*
|
9
|
+
* This file sets the defaults and adds options to DataTables to style its
|
10
|
+
* controls using Bootstrap. See http://datatables.net/manual/styling/bootstrap
|
11
|
+
* for further information.
|
12
|
+
*/
|
13
|
+
(function( factory ){
|
14
|
+
if ( typeof define === 'function' && define.amd ) {
|
15
|
+
// AMD
|
16
|
+
define( ['jquery', 'datatables.net'], function ( $ ) {
|
17
|
+
return factory( $, window, document );
|
18
|
+
} );
|
19
|
+
}
|
20
|
+
else if ( typeof exports === 'object' ) {
|
21
|
+
// CommonJS
|
22
|
+
module.exports = function (root, $) {
|
23
|
+
if ( ! root ) {
|
24
|
+
root = window;
|
25
|
+
}
|
26
|
+
|
27
|
+
if ( ! $ || ! $.fn.dataTable ) {
|
28
|
+
// Require DataTables, which attaches to jQuery, including
|
29
|
+
// jQuery if needed and have a $ property so we can access the
|
30
|
+
// jQuery object that is used
|
31
|
+
$ = require('datatables.net')(root, $).$;
|
32
|
+
}
|
33
|
+
|
34
|
+
return factory( $, root, root.document );
|
35
|
+
};
|
36
|
+
}
|
37
|
+
else {
|
38
|
+
// Browser
|
39
|
+
factory( jQuery, window, document );
|
40
|
+
}
|
41
|
+
}(function( $, window, document, undefined ) {
|
42
|
+
'use strict';
|
43
|
+
var DataTable = $.fn.dataTable;
|
44
|
+
|
45
|
+
|
46
|
+
/* Set the defaults for DataTables initialisation */
|
47
|
+
$.extend( true, DataTable.defaults, {
|
48
|
+
dom:
|
49
|
+
"<'row'<'col-sm-12 col-md-6'l><'col-sm-12 col-md-6'f>>" +
|
50
|
+
"<'row'<'col-sm-12'tr>>" +
|
51
|
+
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
|
52
|
+
renderer: 'bootstrap'
|
53
|
+
} );
|
54
|
+
|
55
|
+
|
56
|
+
/* Default class modification */
|
57
|
+
$.extend( DataTable.ext.classes, {
|
58
|
+
sWrapper: "dataTables_wrapper container-fluid dt-bootstrap4",
|
59
|
+
sFilterInput: "form-control form-control-sm",
|
60
|
+
sLengthSelect: "form-control form-control-sm",
|
61
|
+
sProcessing: "dataTables_processing card",
|
62
|
+
sPageButton: "paginate_button page-item"
|
63
|
+
} );
|
64
|
+
|
65
|
+
|
66
|
+
/* Bootstrap paging button renderer */
|
67
|
+
DataTable.ext.renderer.pageButton.bootstrap = function ( settings, host, idx, buttons, page, pages ) {
|
68
|
+
var api = new DataTable.Api( settings );
|
69
|
+
var classes = settings.oClasses;
|
70
|
+
var lang = settings.oLanguage.oPaginate;
|
71
|
+
var aria = settings.oLanguage.oAria.paginate || {};
|
72
|
+
var btnDisplay, btnClass, counter=0;
|
73
|
+
|
74
|
+
var attach = function( container, buttons ) {
|
75
|
+
var i, ien, node, button;
|
76
|
+
var clickHandler = function ( e ) {
|
77
|
+
e.preventDefault();
|
78
|
+
if ( !$(e.currentTarget).hasClass('disabled') && api.page() != e.data.action ) {
|
79
|
+
api.page( e.data.action ).draw( 'page' );
|
80
|
+
}
|
81
|
+
};
|
82
|
+
|
83
|
+
for ( i=0, ien=buttons.length ; i<ien ; i++ ) {
|
84
|
+
button = buttons[i];
|
85
|
+
|
86
|
+
if ( $.isArray( button ) ) {
|
87
|
+
attach( container, button );
|
88
|
+
}
|
89
|
+
else {
|
90
|
+
btnDisplay = '';
|
91
|
+
btnClass = '';
|
92
|
+
|
93
|
+
switch ( button ) {
|
94
|
+
case 'ellipsis':
|
95
|
+
btnDisplay = '…';
|
96
|
+
btnClass = 'disabled';
|
97
|
+
break;
|
98
|
+
|
99
|
+
case 'first':
|
100
|
+
btnDisplay = lang.sFirst;
|
101
|
+
btnClass = button + (page > 0 ?
|
102
|
+
'' : ' disabled');
|
103
|
+
break;
|
104
|
+
|
105
|
+
case 'previous':
|
106
|
+
btnDisplay = lang.sPrevious;
|
107
|
+
btnClass = button + (page > 0 ?
|
108
|
+
'' : ' disabled');
|
109
|
+
break;
|
110
|
+
|
111
|
+
case 'next':
|
112
|
+
btnDisplay = lang.sNext;
|
113
|
+
btnClass = button + (page < pages-1 ?
|
114
|
+
'' : ' disabled');
|
115
|
+
break;
|
116
|
+
|
117
|
+
case 'last':
|
118
|
+
btnDisplay = lang.sLast;
|
119
|
+
btnClass = button + (page < pages-1 ?
|
120
|
+
'' : ' disabled');
|
121
|
+
break;
|
122
|
+
|
123
|
+
default:
|
124
|
+
btnDisplay = button + 1;
|
125
|
+
btnClass = page === button ?
|
126
|
+
'active' : '';
|
127
|
+
break;
|
128
|
+
}
|
129
|
+
|
130
|
+
if ( btnDisplay ) {
|
131
|
+
node = $('<li>', {
|
132
|
+
'class': classes.sPageButton+' '+btnClass,
|
133
|
+
'id': idx === 0 && typeof button === 'string' ?
|
134
|
+
settings.sTableId +'_'+ button :
|
135
|
+
null
|
136
|
+
} )
|
137
|
+
.append( $('<a>', {
|
138
|
+
'href': '#',
|
139
|
+
'aria-controls': settings.sTableId,
|
140
|
+
'aria-label': aria[ button ],
|
141
|
+
'data-dt-idx': counter,
|
142
|
+
'tabindex': settings.iTabIndex,
|
143
|
+
'class': 'page-link'
|
144
|
+
} )
|
145
|
+
.html( btnDisplay )
|
146
|
+
)
|
147
|
+
.appendTo( container );
|
148
|
+
|
149
|
+
settings.oApi._fnBindAction(
|
150
|
+
node, {action: button}, clickHandler
|
151
|
+
);
|
152
|
+
|
153
|
+
counter++;
|
154
|
+
}
|
155
|
+
}
|
156
|
+
}
|
157
|
+
};
|
158
|
+
|
159
|
+
// IE9 throws an 'unknown error' if document.activeElement is used
|
160
|
+
// inside an iframe or frame.
|
161
|
+
var activeEl;
|
162
|
+
|
163
|
+
try {
|
164
|
+
// Because this approach is destroying and recreating the paging
|
165
|
+
// elements, focus is lost on the select button which is bad for
|
166
|
+
// accessibility. So we want to restore focus once the draw has
|
167
|
+
// completed
|
168
|
+
activeEl = $(host).find(document.activeElement).data('dt-idx');
|
169
|
+
}
|
170
|
+
catch (e) {}
|
171
|
+
|
172
|
+
attach(
|
173
|
+
$(host).empty().html('<ul class="pagination"/>').children('ul'),
|
174
|
+
buttons
|
175
|
+
);
|
176
|
+
|
177
|
+
if ( activeEl !== undefined ) {
|
178
|
+
$(host).find( '[data-dt-idx='+activeEl+']' ).focus();
|
179
|
+
}
|
180
|
+
};
|
181
|
+
|
182
|
+
|
183
|
+
return DataTable;
|
184
|
+
}));
|
@@ -1,11 +1,11 @@
|
|
1
|
-
/*! Responsive 2.2.
|
1
|
+
/*! Responsive 2.2.1
|
2
2
|
* 2014-2017 SpryMedia Ltd - datatables.net/license
|
3
3
|
*/
|
4
4
|
|
5
5
|
/**
|
6
6
|
* @summary Responsive
|
7
7
|
* @description Responsive tables plug-in for DataTables
|
8
|
-
* @version 2.2.
|
8
|
+
* @version 2.2.1
|
9
9
|
* @file dataTables.responsive.js
|
10
10
|
* @author SpryMedia Ltd (www.sprymedia.co.uk)
|
11
11
|
* @contact www.sprymedia.co.uk/contact
|
@@ -97,8 +97,8 @@ var DataTable = $.fn.dataTable;
|
|
97
97
|
*/
|
98
98
|
var Responsive = function ( settings, opts ) {
|
99
99
|
// Sanity check that we are using DataTables 1.10 or newer
|
100
|
-
if ( ! DataTable.versionCheck || ! DataTable.versionCheck( '1.10.
|
101
|
-
throw 'DataTables Responsive requires DataTables 1.10.
|
100
|
+
if ( ! DataTable.versionCheck || ! DataTable.versionCheck( '1.10.10' ) ) {
|
101
|
+
throw 'DataTables Responsive requires DataTables 1.10.10 or newer';
|
102
102
|
}
|
103
103
|
|
104
104
|
this.s = {
|
@@ -208,10 +208,12 @@ $.extend( Responsive.prototype, {
|
|
208
208
|
|
209
209
|
// DataTables will trigger this event on every column it shows and
|
210
210
|
// hides individually
|
211
|
-
dt.on( 'column-visibility.dtr', function (e, ctx, col, vis) {
|
212
|
-
|
213
|
-
|
214
|
-
|
211
|
+
dt.on( 'column-visibility.dtr', function (e, ctx, col, vis, recalc) {
|
212
|
+
if ( recalc ) {
|
213
|
+
that._classLogic();
|
214
|
+
that._resizeAuto();
|
215
|
+
that._resize();
|
216
|
+
}
|
215
217
|
} );
|
216
218
|
|
217
219
|
// Redraw the details box on each draw which will happen if the data
|
@@ -247,6 +249,9 @@ $.extend( Responsive.prototype, {
|
|
247
249
|
} );
|
248
250
|
|
249
251
|
dt.one( 'draw.dtr', function () {
|
252
|
+
that._resizeAuto();
|
253
|
+
that._resize();
|
254
|
+
|
250
255
|
dt.rows( rowIds ).every( function () {
|
251
256
|
that._detailsDisplay( this, false );
|
252
257
|
} );
|
@@ -762,8 +767,13 @@ $.extend( Responsive.prototype, {
|
|
762
767
|
$( dt.table().node() ).toggleClass( 'collapsed', collapsedClass );
|
763
768
|
|
764
769
|
var changed = false;
|
770
|
+
var visible = 0;
|
765
771
|
|
766
772
|
dt.columns().eq(0).each( function ( colIdx, i ) {
|
773
|
+
if ( columnsVis[i] === true ) {
|
774
|
+
visible++;
|
775
|
+
}
|
776
|
+
|
767
777
|
if ( columnsVis[i] !== oldVis[i] ) {
|
768
778
|
changed = true;
|
769
779
|
that._setColumnVis( colIdx, columnsVis[i] );
|
@@ -778,7 +788,7 @@ $.extend( Responsive.prototype, {
|
|
778
788
|
|
779
789
|
// If no records, update the "No records" display element
|
780
790
|
if ( dt.page.info().recordsDisplay === 0 ) {
|
781
|
-
|
791
|
+
$('td', dt.table().body()).eq(0).attr('colspan', visible);
|
782
792
|
}
|
783
793
|
}
|
784
794
|
},
|
@@ -832,7 +842,8 @@ $.extend( Responsive.prototype, {
|
|
832
842
|
} )
|
833
843
|
.to$()
|
834
844
|
.clone( false )
|
835
|
-
.css( 'display', 'table-cell' )
|
845
|
+
.css( 'display', 'table-cell' )
|
846
|
+
.css( 'min-width', 0 );
|
836
847
|
|
837
848
|
// Body rows - we don't need to take account of DataTables' column
|
838
849
|
// visibility since we implement our own here (hence the `display` set)
|
@@ -1312,6 +1323,14 @@ Api.register( 'responsive.hasHidden()', function () {
|
|
1312
1323
|
false;
|
1313
1324
|
} );
|
1314
1325
|
|
1326
|
+
Api.registerPlural( 'columns().responsiveHidden()', 'column().responsiveHidden()', function () {
|
1327
|
+
return this.iterator( 'column', function ( settings, column ) {
|
1328
|
+
return settings._responsive ?
|
1329
|
+
settings._responsive.s.current[ column ] :
|
1330
|
+
false;
|
1331
|
+
}, 1 );
|
1332
|
+
} );
|
1333
|
+
|
1315
1334
|
|
1316
1335
|
/**
|
1317
1336
|
* Version information
|
@@ -1319,7 +1338,7 @@ Api.register( 'responsive.hasHidden()', function () {
|
|
1319
1338
|
* @name Responsive.version
|
1320
1339
|
* @static
|
1321
1340
|
*/
|
1322
|
-
Responsive.version = '2.2.
|
1341
|
+
Responsive.version = '2.2.1';
|
1323
1342
|
|
1324
1343
|
|
1325
1344
|
$.fn.dataTable.Responsive = Responsive;
|
@@ -1,11 +1,11 @@
|
|
1
|
-
/*! Bootstrap integration for DataTables' Responsive
|
2
|
-
* ©
|
1
|
+
/*! Bootstrap 4 integration for DataTables' Responsive
|
2
|
+
* ©2016 SpryMedia Ltd - datatables.net/license
|
3
3
|
*/
|
4
4
|
|
5
5
|
(function( factory ){
|
6
6
|
if ( typeof define === 'function' && define.amd ) {
|
7
7
|
// AMD
|
8
|
-
define( ['jquery', 'datatables.net-
|
8
|
+
define( ['jquery', 'datatables.net-bs4', 'datatables.net-responsive'], function ( $ ) {
|
9
9
|
return factory( $, window, document );
|
10
10
|
} );
|
11
11
|
}
|
@@ -17,7 +17,7 @@
|
|
17
17
|
}
|
18
18
|
|
19
19
|
if ( ! $ || ! $.fn.dataTable ) {
|
20
|
-
$ = require('datatables.net-
|
20
|
+
$ = require('datatables.net-bs4')(root, $).$;
|
21
21
|
}
|
22
22
|
|
23
23
|
if ( ! $.fn.dataTable.Responsive ) {
|
@@ -61,11 +61,11 @@ _display.modal = function ( options ) {
|
|
61
61
|
if ( options && options.header ) {
|
62
62
|
var header = _modal.find('div.modal-header');
|
63
63
|
var button = header.find('button').detach();
|
64
|
-
|
64
|
+
|
65
65
|
header
|
66
66
|
.empty()
|
67
67
|
.append( '<h4 class="modal-title">'+options.header( row )+'</h4>' )
|
68
|
-
.
|
68
|
+
.append( button );
|
69
69
|
}
|
70
70
|
|
71
71
|
_modal.find( 'div.modal-body' )
|