datatables.net-select 1.2.5 → 1.3.1
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.
- package/License.txt +20 -0
- package/js/dataTables.select.js +56 -19
- package/js/dataTables.select.min.js +26 -25
- package/package.json +2 -2
package/License.txt
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright SpryMedia Limited and other contributors
|
|
2
|
+
http://datatables.net
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in
|
|
12
|
+
all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
20
|
+
THE SOFTWARE.
|
package/js/dataTables.select.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
/*! Select for DataTables 1.
|
|
2
|
-
* 2015-
|
|
1
|
+
/*! Select for DataTables 1.3.1
|
|
2
|
+
* 2015-2019 SpryMedia Ltd - datatables.net/license/mit
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @summary Select for DataTables
|
|
7
7
|
* @description A collection of API methods, events and buttons for DataTables
|
|
8
8
|
* that provides selection options of the items in a DataTable
|
|
9
|
-
* @version 1.
|
|
9
|
+
* @version 1.3.1
|
|
10
10
|
* @file dataTables.select.js
|
|
11
11
|
* @author SpryMedia Ltd (www.sprymedia.co.uk)
|
|
12
12
|
* @contact datatables.net/forums
|
|
13
|
-
* @copyright Copyright 2015-
|
|
13
|
+
* @copyright Copyright 2015-2019 SpryMedia Ltd.
|
|
14
14
|
*
|
|
15
15
|
* This source file is free software, available under the following license:
|
|
16
16
|
* MIT license - http://datatables.net/license/mit
|
|
@@ -54,7 +54,7 @@ var DataTable = $.fn.dataTable;
|
|
|
54
54
|
// Version information for debugger
|
|
55
55
|
DataTable.select = {};
|
|
56
56
|
|
|
57
|
-
DataTable.select.version = '1.
|
|
57
|
+
DataTable.select.version = '1.3.1';
|
|
58
58
|
|
|
59
59
|
DataTable.select.init = function ( dt ) {
|
|
60
60
|
var ctx = dt.settings()[0];
|
|
@@ -68,6 +68,7 @@ DataTable.select.init = function ( dt ) {
|
|
|
68
68
|
var items = 'row';
|
|
69
69
|
var style = 'api';
|
|
70
70
|
var blurable = false;
|
|
71
|
+
var toggleable = true;
|
|
71
72
|
var info = true;
|
|
72
73
|
var selector = 'td, th';
|
|
73
74
|
var className = 'selected';
|
|
@@ -88,6 +89,10 @@ DataTable.select.init = function ( dt ) {
|
|
|
88
89
|
if ( opts.blurable !== undefined ) {
|
|
89
90
|
blurable = opts.blurable;
|
|
90
91
|
}
|
|
92
|
+
|
|
93
|
+
if ( opts.toggleable !== undefined ) {
|
|
94
|
+
toggleable = opts.toggleable;
|
|
95
|
+
}
|
|
91
96
|
|
|
92
97
|
if ( opts.info !== undefined ) {
|
|
93
98
|
info = opts.info;
|
|
@@ -101,6 +106,10 @@ DataTable.select.init = function ( dt ) {
|
|
|
101
106
|
style = opts.style;
|
|
102
107
|
setStyle = true;
|
|
103
108
|
}
|
|
109
|
+
else {
|
|
110
|
+
style = 'os';
|
|
111
|
+
setStyle = true;
|
|
112
|
+
}
|
|
104
113
|
|
|
105
114
|
if ( opts.selector !== undefined ) {
|
|
106
115
|
selector = opts.selector;
|
|
@@ -115,6 +124,7 @@ DataTable.select.init = function ( dt ) {
|
|
|
115
124
|
dt.select.items( items );
|
|
116
125
|
dt.select.style( style );
|
|
117
126
|
dt.select.blurable( blurable );
|
|
127
|
+
dt.select.toggleable( toggleable );
|
|
118
128
|
dt.select.info( info );
|
|
119
129
|
ctx._select.className = className;
|
|
120
130
|
|
|
@@ -176,15 +186,17 @@ The `_select` object contains the following properties:
|
|
|
176
186
|
|
|
177
187
|
```
|
|
178
188
|
{
|
|
179
|
-
items:string
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
style:string
|
|
183
|
-
|
|
184
|
-
blurable:boolean
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
189
|
+
items:string - Can be `rows`, `columns` or `cells`. Defines what item
|
|
190
|
+
will be selected if the user is allowed to activate row
|
|
191
|
+
selection using the mouse.
|
|
192
|
+
style:string - Can be `none`, `single`, `multi` or `os`. Defines the
|
|
193
|
+
interaction style when selecting items
|
|
194
|
+
blurable:boolean - If row selection can be cleared by clicking outside of
|
|
195
|
+
the table
|
|
196
|
+
toggleable:boolean - If row selection can be cancelled by repeated clicking
|
|
197
|
+
on the row
|
|
198
|
+
info:boolean - If the selection summary should be shown in the table
|
|
199
|
+
information elements
|
|
188
200
|
}
|
|
189
201
|
```
|
|
190
202
|
|
|
@@ -310,7 +322,7 @@ function disableMouseSelection( dt )
|
|
|
310
322
|
.off( 'mouseup.dtSelect', selector )
|
|
311
323
|
.off( 'click.dtSelect', selector );
|
|
312
324
|
|
|
313
|
-
$('body').off( 'click.dtSelect' + dt.table().node()
|
|
325
|
+
$('body').off( 'click.dtSelect' + _safeId(dt.table().node()) );
|
|
314
326
|
}
|
|
315
327
|
|
|
316
328
|
/**
|
|
@@ -324,6 +336,7 @@ function enableMouseSelection ( dt )
|
|
|
324
336
|
var container = $( dt.table().container() );
|
|
325
337
|
var ctx = dt.settings()[0];
|
|
326
338
|
var selector = ctx._select.selector;
|
|
339
|
+
var matchSelection;
|
|
327
340
|
|
|
328
341
|
container
|
|
329
342
|
.on( 'mousedown.dtSelect', selector, function(e) {
|
|
@@ -336,6 +349,10 @@ function enableMouseSelection ( dt )
|
|
|
336
349
|
return false;
|
|
337
350
|
} );
|
|
338
351
|
}
|
|
352
|
+
|
|
353
|
+
if ( window.getSelection ) {
|
|
354
|
+
matchSelection = window.getSelection();
|
|
355
|
+
}
|
|
339
356
|
} )
|
|
340
357
|
.on( 'mouseup.dtSelect', selector, function() {
|
|
341
358
|
// Allow text selection to occur again, Mozilla style (tested in FF
|
|
@@ -348,22 +365,23 @@ function enableMouseSelection ( dt )
|
|
|
348
365
|
|
|
349
366
|
// If text was selected (click and drag), then we shouldn't change
|
|
350
367
|
// the row's selected state
|
|
351
|
-
if (
|
|
368
|
+
if ( matchSelection ) {
|
|
352
369
|
var selection = window.getSelection();
|
|
353
370
|
|
|
354
371
|
// If the element that contains the selection is not in the table, we can ignore it
|
|
355
372
|
// This can happen if the developer selects text from the click event
|
|
356
373
|
if ( ! selection.anchorNode || $(selection.anchorNode).closest('table')[0] === dt.table().node() ) {
|
|
357
|
-
if (
|
|
374
|
+
if ( selection !== matchSelection ) {
|
|
358
375
|
return;
|
|
359
376
|
}
|
|
360
377
|
}
|
|
361
378
|
}
|
|
362
379
|
|
|
363
380
|
var ctx = dt.settings()[0];
|
|
381
|
+
var wrapperClass = $.trim(dt.settings()[0].oClasses.sWrapper).replace(/ +/g, '.');
|
|
364
382
|
|
|
365
383
|
// Ignore clicks inside a sub-table
|
|
366
|
-
if ( $(e.target).closest('div.
|
|
384
|
+
if ( $(e.target).closest('div.'+wrapperClass)[0] != dt.table().container() ) {
|
|
367
385
|
return;
|
|
368
386
|
}
|
|
369
387
|
|
|
@@ -400,7 +418,7 @@ function enableMouseSelection ( dt )
|
|
|
400
418
|
} );
|
|
401
419
|
|
|
402
420
|
// Blurable
|
|
403
|
-
$('body').on( 'click.dtSelect' + dt.table().node()
|
|
421
|
+
$('body').on( 'click.dtSelect' + _safeId(dt.table().node()), function ( e ) {
|
|
404
422
|
if ( ctx._select.blurable ) {
|
|
405
423
|
// If the click was inside the DataTables container, don't blur
|
|
406
424
|
if ( $(e.target).parents().filter( dt.table().container() ).length ) {
|
|
@@ -660,7 +678,12 @@ function clear( ctx, force )
|
|
|
660
678
|
function typeSelect ( e, dt, ctx, type, idx )
|
|
661
679
|
{
|
|
662
680
|
var style = dt.select.style();
|
|
681
|
+
var toggleable = dt.select.toggleable();
|
|
663
682
|
var isSelected = dt[type]( idx, { selected: true } ).any();
|
|
683
|
+
|
|
684
|
+
if ( isSelected && ! toggleable ) {
|
|
685
|
+
return;
|
|
686
|
+
}
|
|
664
687
|
|
|
665
688
|
if ( style === 'os' ) {
|
|
666
689
|
if ( e.ctrlKey || e.metaKey ) {
|
|
@@ -712,6 +735,10 @@ function typeSelect ( e, dt, ctx, type, idx )
|
|
|
712
735
|
}
|
|
713
736
|
}
|
|
714
737
|
|
|
738
|
+
function _safeId( node ) {
|
|
739
|
+
return node.id.replace(/[^a-zA-Z0-9\-\_]/g, '-');
|
|
740
|
+
}
|
|
741
|
+
|
|
715
742
|
|
|
716
743
|
|
|
717
744
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
@@ -799,6 +826,16 @@ apiRegister( 'select.blurable()', function ( flag ) {
|
|
|
799
826
|
} );
|
|
800
827
|
} );
|
|
801
828
|
|
|
829
|
+
apiRegister( 'select.toggleable()', function ( flag ) {
|
|
830
|
+
if ( flag === undefined ) {
|
|
831
|
+
return this.context[0]._select.toggleable;
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
return this.iterator( 'table', function ( ctx ) {
|
|
835
|
+
ctx._select.toggleable = flag;
|
|
836
|
+
} );
|
|
837
|
+
} );
|
|
838
|
+
|
|
802
839
|
apiRegister( 'select.info()', function ( flag ) {
|
|
803
840
|
if ( info === undefined ) {
|
|
804
841
|
return this.context[0]._select.info;
|
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
Select for DataTables 1.
|
|
3
|
-
2015-
|
|
2
|
+
Select for DataTables 1.3.1
|
|
3
|
+
2015-2019 SpryMedia Ltd - datatables.net/license/mit
|
|
4
4
|
*/
|
|
5
|
-
(function(e){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(
|
|
6
|
-
function(b,c){var d=a.rows({search:"applied"}).indexes();if(d.indexOf(b)>d.indexOf(c))var f=c,c=b,b=f;var e=!1;return d.filter(function(a){a===b&&(e=!0);return a===c?(e=!1,!0):e})};!a.cells({selected:!0}).any()&&!b?(d=d(0,c.column),b=f(0,c.row)):(d=d(b.column,c.column),b=f(b.row,c.row));b=a.cells(b,d).flatten();a.cells(c,{selected:!0}).any()?a.cells(b).deselect():a.cells(b).select()}function
|
|
7
|
-
c).off("click.dtSelect",c);e("body").off("click.dtSelect"+a.table().node()
|
|
8
|
-
e(d.anchorNode).closest("table")[0]===a.table().node())&&
|
|
9
|
-
a.table().node()
|
|
10
|
-
f=a.cells({selected:!0}).flatten().length,l=function(b,c,d){b.append(e('<span class="select-item"/>').append(a.i18n("select."+c+"s",{_:"%d "+c+"s selected","0":"",1:"1 "+c+" selected"},d)))};e.each(c.aanFeatures.i,function(c,a){var a=e(a),g=e('<span class="select-info"/>');l(g,"row",b);l(g,"column",d);l(g,"cell",f);var h=a.children("span.select-info");h.length&&h.remove();""!==g.text()&&a.append(g)})}}function
|
|
11
|
-
f);if(!a[c+"s"]({selected:!0}).any()&&-1===d)f.splice(e.inArray(b,f)+1,f.length);else{if(d>l)var g=l,l=d,d=g;f.splice(l+1,f.length);f.splice(0,d)}a[c](b,{selected:!0}).any()?(f.splice(e.inArray(b,f),1),a[c+"s"](f).deselect()):a[c+"s"](f).select()}function
|
|
12
|
-
e?a.ctrlKey||a.metaKey?c[d](f).select(!
|
|
13
|
-
a._eventNamespace;return"draw.dt.DT"+a+" select.dt.DT"+a+" deselect.dt.DT"+a}var g=e.fn.dataTable;g.select={};g.select.version="1.
|
|
14
|
-
b.selector!==h&&(
|
|
15
|
-
e.each([{type:"row",prop:"aoData"},{type:"column",prop:"aoColumns"}],function(a,c){g.ext.selector[c.type].push(function(b,a,f){var a=a.selected,e,g=[];if(!0!==a&&!1!==a)return f;for(var
|
|
16
|
-
!1===c&&(!d._selected_cells||!d._selected_cells[b[e].column]))&&f.push(b[e]);return f});var
|
|
17
|
-
function(a){return a===h?this.context[0]._select.
|
|
18
|
-
a._selected_cells[b])&&e(a.anCells[b]).addClass(c._select.className)},sName:"select-deferRender"});b.on("preXhr.dt.dtSelect",function(){var
|
|
19
|
-
function(){
|
|
20
|
-
|
|
21
|
-
function(
|
|
22
|
-
function(a,b)
|
|
23
|
-
|
|
24
|
-
["cell",a[b]],!0)});return this});var
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
g.ext.buttons["select"+c+"s"]={text:
|
|
5
|
+
(function(e){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(i){return e(i,window,document)}):"object"===typeof exports?module.exports=function(i,j){i||(i=window);if(!j||!j.fn.dataTable)j=require("datatables.net")(i,j).$;return e(j,i,i.document)}:e(jQuery,window,document)})(function(e,i,j,h){function u(a,c,b){var d;d=function(b,c){if(b>c)var d=c,c=b,b=d;var f=!1;return a.columns(":visible").indexes().filter(function(a){a===b&&(f=!0);return a===c?(f=!1,!0):f})};var f=
|
|
6
|
+
function(b,c){var d=a.rows({search:"applied"}).indexes();if(d.indexOf(b)>d.indexOf(c))var f=c,c=b,b=f;var e=!1;return d.filter(function(a){a===b&&(e=!0);return a===c?(e=!1,!0):e})};!a.cells({selected:!0}).any()&&!b?(d=d(0,c.column),b=f(0,c.row)):(d=d(b.column,c.column),b=f(b.row,c.row));b=a.cells(b,d).flatten();a.cells(c,{selected:!0}).any()?a.cells(b).deselect():a.cells(b).select()}function q(a){var c=a.settings()[0]._select.selector;e(a.table().container()).off("mousedown.dtSelect",c).off("mouseup.dtSelect",
|
|
7
|
+
c).off("click.dtSelect",c);e("body").off("click.dtSelect"+x(a.table().node()))}function y(a){var c=e(a.table().container()),b=a.settings()[0],d=b._select.selector,f;c.on("mousedown.dtSelect",d,function(b){if(b.shiftKey||b.metaKey||b.ctrlKey)c.css("-moz-user-select","none").one("selectstart.dtSelect",d,function(){return!1});i.getSelection&&(f=i.getSelection())}).on("mouseup.dtSelect",d,function(){c.css("-moz-user-select","")}).on("click.dtSelect",d,function(b){var c=a.select.items();if(f){var d=i.getSelection();
|
|
8
|
+
if((!d.anchorNode||e(d.anchorNode).closest("table")[0]===a.table().node())&&d!==f)return}var d=a.settings()[0],g=e.trim(a.settings()[0].oClasses.sWrapper).replace(/ +/g,".");if(e(b.target).closest("div."+g)[0]==a.table().container()&&(g=a.cell(e(b.target).closest("td, th")),g.any())){var h=e.Event("user-select.dt");k(a,h,[c,g,b]);h.isDefaultPrevented()||(h=g.index(),"row"===c?(c=h.row,r(b,a,d,"row",c)):"column"===c?(c=g.index().column,r(b,a,d,"column",c)):"cell"===c&&(c=g.index(),r(b,a,d,"cell",c)),
|
|
9
|
+
d._select_lastCell=h)}});e("body").on("click.dtSelect"+x(a.table().node()),function(c){b._select.blurable&&!e(c.target).parents().filter(a.table().container()).length&&(0!==e(c.target).parents("html").length&&!e(c.target).parents("div.DTE").length)&&o(b,!0)})}function k(a,c,b,d){if(!d||a.flatten().length)"string"===typeof c&&(c+=".dt"),b.unshift(a),e(a.table().node()).trigger(c,b)}function z(a){var c=a.settings()[0];if(c._select.info&&c.aanFeatures.i&&"api"!==a.select.style()){var b=a.rows({selected:!0}).flatten().length,
|
|
10
|
+
d=a.columns({selected:!0}).flatten().length,f=a.cells({selected:!0}).flatten().length,l=function(b,c,d){b.append(e('<span class="select-item"/>').append(a.i18n("select."+c+"s",{_:"%d "+c+"s selected","0":"",1:"1 "+c+" selected"},d)))};e.each(c.aanFeatures.i,function(c,a){var a=e(a),g=e('<span class="select-info"/>');l(g,"row",b);l(g,"column",d);l(g,"cell",f);var h=a.children("span.select-info");h.length&&h.remove();""!==g.text()&&a.append(g)})}}function A(a,c,b,d){var f=a[c+"s"]({search:"applied"}).indexes(),
|
|
11
|
+
d=e.inArray(d,f),l=e.inArray(b,f);if(!a[c+"s"]({selected:!0}).any()&&-1===d)f.splice(e.inArray(b,f)+1,f.length);else{if(d>l)var g=l,l=d,d=g;f.splice(l+1,f.length);f.splice(0,d)}a[c](b,{selected:!0}).any()?(f.splice(e.inArray(b,f),1),a[c+"s"](f).deselect()):a[c+"s"](f).select()}function o(a,c){if(c||"single"===a._select.style){var b=new g.Api(a);b.rows({selected:!0}).deselect();b.columns({selected:!0}).deselect();b.cells({selected:!0}).deselect()}}function r(a,c,b,d,f){var e=c.select.style(),g=c.select.toggleable(),
|
|
12
|
+
h=c[d](f,{selected:!0}).any();if(!h||g)"os"===e?a.ctrlKey||a.metaKey?c[d](f).select(!h):a.shiftKey?"cell"===d?u(c,f,b._select_lastCell||null):A(c,d,f,b._select_lastCell?b._select_lastCell[d]:null):(a=c[d+"s"]({selected:!0}),h&&1===a.flatten().length?c[d](f).deselect():(a.deselect(),c[d](f).select())):"multi+shift"==e?a.shiftKey?"cell"===d?u(c,f,b._select_lastCell||null):A(c,d,f,b._select_lastCell?b._select_lastCell[d]:null):c[d](f).select(!h):c[d](f).select(!h)}function x(a){return a.id.replace(/[^a-zA-Z0-9\-\_]/g,
|
|
13
|
+
"-")}function p(a,c){return function(b){return b.i18n("buttons."+a,c)}}function s(a){a=a._eventNamespace;return"draw.dt.DT"+a+" select.dt.DT"+a+" deselect.dt.DT"+a}var g=e.fn.dataTable;g.select={};g.select.version="1.3.1";g.select.init=function(a){var c=a.settings()[0],b=c.oInit.select,d=g.defaults.select,b=b===h?d:b,d="row",f="api",l=!1,v=!0,w=!0,i="td, th",k="selected",j=!1;c._select={};if(!0===b)f="os",j=!0;else if("string"===typeof b)f=b,j=!0;else if(e.isPlainObject(b)&&(b.blurable!==h&&(l=b.blurable),
|
|
14
|
+
b.toggleable!==h&&(v=b.toggleable),b.info!==h&&(w=b.info),b.items!==h&&(d=b.items),f=b.style!==h?b.style:"os",j=!0,b.selector!==h&&(i=b.selector),b.className!==h))k=b.className;a.select.selector(i);a.select.items(d);a.select.style(f);a.select.blurable(l);a.select.toggleable(v);a.select.info(w);c._select.className=k;e.fn.dataTable.ext.order["select-checkbox"]=function(b,c){return this.api().column(c,{order:"index"}).nodes().map(function(c){return"row"===b._select.items?e(c).parent().hasClass(b._select.className):
|
|
15
|
+
"cell"===b._select.items?e(c).hasClass(b._select.className):!1})};!j&&e(a.table().node()).hasClass("selectable")&&a.select.style("os")};e.each([{type:"row",prop:"aoData"},{type:"column",prop:"aoColumns"}],function(a,c){g.ext.selector[c.type].push(function(b,a,f){var a=a.selected,e,g=[];if(!0!==a&&!1!==a)return f;for(var h=0,i=f.length;h<i;h++)e=b[c.prop][f[h]],(!0===a&&!0===e._select_selected||!1===a&&!e._select_selected)&&g.push(f[h]);return g})});g.ext.selector.cell.push(function(a,c,b){var c=c.selected,
|
|
16
|
+
d,f=[];if(c===h)return b;for(var e=0,g=b.length;e<g;e++)d=a.aoData[b[e].row],(!0===c&&d._selected_cells&&!0===d._selected_cells[b[e].column]||!1===c&&(!d._selected_cells||!d._selected_cells[b[e].column]))&&f.push(b[e]);return f});var m=g.Api.register,n=g.Api.registerPlural;m("select()",function(){return this.iterator("table",function(a){g.select.init(new g.Api(a))})});m("select.blurable()",function(a){return a===h?this.context[0]._select.blurable:this.iterator("table",function(c){c._select.blurable=
|
|
17
|
+
a})});m("select.toggleable()",function(a){return a===h?this.context[0]._select.toggleable:this.iterator("table",function(c){c._select.toggleable=a})});m("select.info()",function(a){return z===h?this.context[0]._select.info:this.iterator("table",function(c){c._select.info=a})});m("select.items()",function(a){return a===h?this.context[0]._select.items:this.iterator("table",function(c){c._select.items=a;k(new g.Api(c),"selectItems",[a])})});m("select.style()",function(a){return a===h?this.context[0]._select.style:
|
|
18
|
+
this.iterator("table",function(c){c._select.style=a;if(!c._select_init){var b=new g.Api(c);c.aoRowCreatedCallback.push({fn:function(b,a,d){a=c.aoData[d];a._select_selected&&e(b).addClass(c._select.className);b=0;for(d=c.aoColumns.length;b<d;b++)(c.aoColumns[b]._select_selected||a._selected_cells&&a._selected_cells[b])&&e(a.anCells[b]).addClass(c._select.className)},sName:"select-deferRender"});b.on("preXhr.dt.dtSelect",function(){var a=b.rows({selected:!0}).ids(!0).filter(function(b){return b!==h}),
|
|
19
|
+
c=b.cells({selected:!0}).eq(0).map(function(a){var c=b.row(a.row).id(!0);return c?{row:c,column:a.column}:h}).filter(function(b){return b!==h});b.one("draw.dt.dtSelect",function(){b.rows(a).select();c.any()&&c.each(function(a){b.cells(a.row,a.column).select()})})});b.on("draw.dtSelect.dt select.dtSelect.dt deselect.dtSelect.dt info.dt",function(){z(b)});b.on("destroy.dtSelect",function(){q(b);b.off(".dtSelect")})}var d=new g.Api(c);q(d);"api"!==a&&y(d);k(new g.Api(c),"selectStyle",[a])})});m("select.selector()",
|
|
20
|
+
function(a){return a===h?this.context[0]._select.selector:this.iterator("table",function(c){q(new g.Api(c));c._select.selector=a;"api"!==c._select.style&&y(new g.Api(c))})});n("rows().select()","row().select()",function(a){var c=this;if(!1===a)return this.deselect();this.iterator("row",function(b,a){o(b);b.aoData[a]._select_selected=!0;e(b.aoData[a].nTr).addClass(b._select.className)});this.iterator("table",function(b,a){k(c,"select",["row",c[a]],!0)});return this});n("columns().select()","column().select()",
|
|
21
|
+
function(a){var c=this;if(!1===a)return this.deselect();this.iterator("column",function(b,a){o(b);b.aoColumns[a]._select_selected=!0;var c=(new g.Api(b)).column(a);e(c.header()).addClass(b._select.className);e(c.footer()).addClass(b._select.className);c.nodes().to$().addClass(b._select.className)});this.iterator("table",function(b,a){k(c,"select",["column",c[a]],!0)});return this});n("cells().select()","cell().select()",function(a){var c=this;if(!1===a)return this.deselect();this.iterator("cell",
|
|
22
|
+
function(b,a,c){o(b);a=b.aoData[a];a._selected_cells===h&&(a._selected_cells=[]);a._selected_cells[c]=!0;a.anCells&&e(a.anCells[c]).addClass(b._select.className)});this.iterator("table",function(a,d){k(c,"select",["cell",c[d]],!0)});return this});n("rows().deselect()","row().deselect()",function(){var a=this;this.iterator("row",function(a,b){a.aoData[b]._select_selected=!1;e(a.aoData[b].nTr).removeClass(a._select.className)});this.iterator("table",function(c,b){k(a,"deselect",["row",a[b]],!0)});return this});
|
|
23
|
+
n("columns().deselect()","column().deselect()",function(){var a=this;this.iterator("column",function(a,b){a.aoColumns[b]._select_selected=!1;var d=new g.Api(a),f=d.column(b);e(f.header()).removeClass(a._select.className);e(f.footer()).removeClass(a._select.className);d.cells(null,b).indexes().each(function(b){var d=a.aoData[b.row],f=d._selected_cells;d.anCells&&(!f||!f[b.column])&&e(d.anCells[b.column]).removeClass(a._select.className)})});this.iterator("table",function(c,b){k(a,"deselect",["column",
|
|
24
|
+
a[b]],!0)});return this});n("cells().deselect()","cell().deselect()",function(){var a=this;this.iterator("cell",function(a,b,d){b=a.aoData[b];b._selected_cells[d]=!1;b.anCells&&!a.aoColumns[d]._select_selected&&e(b.anCells[d]).removeClass(a._select.className)});this.iterator("table",function(c,b){k(a,"deselect",["cell",a[b]],!0)});return this});var t=0;e.extend(g.ext.buttons,{selected:{text:p("selected","Selected"),className:"buttons-selected",limitTo:["rows","columns","cells"],init:function(a,c,
|
|
25
|
+
b){var d=this;b._eventNamespace=".select"+t++;a.on(s(b),function(){d.enable(-1!==e.inArray("rows",b.limitTo)&&a.rows({selected:!0}).any()||-1!==e.inArray("columns",b.limitTo)&&a.columns({selected:!0}).any()||-1!==e.inArray("cells",b.limitTo)&&a.cells({selected:!0}).any()?!0:!1)});this.disable()},destroy:function(a,c,b){a.off(b._eventNamespace)}},selectedSingle:{text:p("selectedSingle","Selected single"),className:"buttons-selected-single",init:function(a,c,b){var d=this;b._eventNamespace=".select"+
|
|
26
|
+
t++;a.on(s(b),function(){var b=a.rows({selected:!0}).flatten().length+a.columns({selected:!0}).flatten().length+a.cells({selected:!0}).flatten().length;d.enable(1===b)});this.disable()},destroy:function(a,c,b){a.off(b._eventNamespace)}},selectAll:{text:p("selectAll","Select all"),className:"buttons-select-all",action:function(){this[this.select.items()+"s"]().select()}},selectNone:{text:p("selectNone","Deselect all"),className:"buttons-select-none",action:function(){o(this.settings()[0],!0)},init:function(a,
|
|
27
|
+
c,b){var d=this;b._eventNamespace=".select"+t++;a.on(s(b),function(){var b=a.rows({selected:!0}).flatten().length+a.columns({selected:!0}).flatten().length+a.cells({selected:!0}).flatten().length;d.enable(0<b)});this.disable()},destroy:function(a,c,b){a.off(b._eventNamespace)}}});e.each(["Row","Column","Cell"],function(a,c){var b=c.toLowerCase();g.ext.buttons["select"+c+"s"]={text:p("select"+c+"s","Select "+b+"s"),className:"buttons-select-"+b+"s",action:function(){this.select.items(b)},init:function(a){var c=
|
|
28
|
+
this;a.on("selectItems.dt.DT",function(a,d,e){c.active(e===b)})}}});e(j).on("preInit.dt.dtSelect",function(a,c){"dt"===a.namespace&&g.select.init(new g.Api(c))});return g.select});
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "datatables.net-select",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Select for DataTables ",
|
|
5
5
|
"files": [
|
|
6
6
|
"js/**/*.js"
|
|
7
7
|
],
|
|
8
|
-
"main": "
|
|
8
|
+
"main": "js/dataTables.select.js",
|
|
9
9
|
"keywords": [
|
|
10
10
|
"select",
|
|
11
11
|
"selection",
|