datatables.net-select 1.3.3 → 1.3.4
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 +3 -1
- package/Readme.md +7 -2
- package/js/dataTables.select.js +57 -6
- package/js/dataTables.select.min.js +37 -25
- package/package.json +26 -17
- package/types/types.d.ts +195 -0
package/License.txt
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
1
3
|
Copyright SpryMedia Limited and other contributors
|
|
2
4
|
http://datatables.net
|
|
3
5
|
|
|
@@ -17,4 +19,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
17
19
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
20
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
21
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
20
|
-
THE SOFTWARE.
|
|
22
|
+
THE SOFTWARE.
|
package/Readme.md
CHANGED
|
@@ -17,11 +17,17 @@ For inclusion of this library using a standard `<script>` tag, rather than using
|
|
|
17
17
|
npm install datatables.net-select
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
+
ES3 Syntax
|
|
20
21
|
```
|
|
21
22
|
var $ = require( 'jquery' );
|
|
22
23
|
require( 'datatables.net-select' )( window, $ );
|
|
23
24
|
```
|
|
24
25
|
|
|
26
|
+
ES6 Syntax
|
|
27
|
+
```
|
|
28
|
+
import 'datatables.net-select'
|
|
29
|
+
```
|
|
30
|
+
|
|
25
31
|
### bower
|
|
26
32
|
|
|
27
33
|
```
|
|
@@ -32,8 +38,7 @@ bower install --save datatables.net-select
|
|
|
32
38
|
|
|
33
39
|
## Documentation
|
|
34
40
|
|
|
35
|
-
Full documentation
|
|
36
|
-
|
|
41
|
+
Full documentation and examples for Select can be found [on the website](https://datatables.net/extensions/select).
|
|
37
42
|
|
|
38
43
|
## Bug / Support
|
|
39
44
|
|
package/js/dataTables.select.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! Select for DataTables 1.3.
|
|
1
|
+
/*! Select for DataTables 1.3.4-dev
|
|
2
2
|
* 2015-2021 SpryMedia Ltd - datatables.net/license/mit
|
|
3
3
|
*/
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@
|
|
|
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.3.
|
|
9
|
+
* @version 1.3.4-dev
|
|
10
10
|
* @file dataTables.select.js
|
|
11
11
|
* @author SpryMedia Ltd (www.sprymedia.co.uk)
|
|
12
12
|
* @contact datatables.net/forums
|
|
@@ -54,10 +54,52 @@ var DataTable = $.fn.dataTable;
|
|
|
54
54
|
// Version information for debugger
|
|
55
55
|
DataTable.select = {};
|
|
56
56
|
|
|
57
|
-
DataTable.select.version = '1.3.
|
|
57
|
+
DataTable.select.version = '1.3.4-dev';
|
|
58
58
|
|
|
59
59
|
DataTable.select.init = function ( dt ) {
|
|
60
60
|
var ctx = dt.settings()[0];
|
|
61
|
+
|
|
62
|
+
if (ctx._select) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
var savedSelected = dt.state.loaded();
|
|
67
|
+
|
|
68
|
+
var selectAndSave = function(e, settings, data) {
|
|
69
|
+
if(data === null || data.select === undefined) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
dt.rows().deselect();
|
|
73
|
+
dt.columns().deselect();
|
|
74
|
+
dt.cells().deselect();
|
|
75
|
+
if (data.select.rows !== undefined) {
|
|
76
|
+
dt.rows(data.select.rows).select();
|
|
77
|
+
}
|
|
78
|
+
if (data.select.columns !== undefined) {
|
|
79
|
+
dt.columns(data.select.columns).select();
|
|
80
|
+
}
|
|
81
|
+
if (data.select.cells !== undefined) {
|
|
82
|
+
for(var i = 0; i < data.select.cells.length; i++) {
|
|
83
|
+
dt.cell(data.select.cells[i].row, data.select.cells[i].column).select();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
dt.state.save();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
dt.one('init', function() {
|
|
90
|
+
dt.on('stateSaveParams', function(e, settings, data) {
|
|
91
|
+
data.select = {};
|
|
92
|
+
data.select.rows = dt.rows({selected:true}).ids(true).toArray();
|
|
93
|
+
data.select.columns = dt.columns({selected:true})[0];
|
|
94
|
+
data.select.cells = dt.cells({selected:true})[0].map(function(coords) {
|
|
95
|
+
return {row: dt.row(coords.row).id(true), column: coords.column}
|
|
96
|
+
});
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
selectAndSave(undefined, undefined, savedSelected)
|
|
100
|
+
dt.on('stateLoaded stateLoadParams', selectAndSave)
|
|
101
|
+
})
|
|
102
|
+
|
|
61
103
|
var init = ctx.oInit.select;
|
|
62
104
|
var defaults = DataTable.defaults.select;
|
|
63
105
|
var opts = init === undefined ?
|
|
@@ -529,6 +571,7 @@ function info ( api )
|
|
|
529
571
|
*/
|
|
530
572
|
function init ( ctx ) {
|
|
531
573
|
var api = new DataTable.Api( ctx );
|
|
574
|
+
ctx._select_init = true;
|
|
532
575
|
|
|
533
576
|
// Row callback so that classes can be added to rows and cells if the item
|
|
534
577
|
// was selected before the element was created. This will happen with the
|
|
@@ -597,6 +640,7 @@ function init ( ctx ) {
|
|
|
597
640
|
// Update the table information element with selected item summary
|
|
598
641
|
api.on( 'draw.dtSelect.dt select.dtSelect.dt deselect.dtSelect.dt info.dt', function () {
|
|
599
642
|
info( api );
|
|
643
|
+
api.state.save();
|
|
600
644
|
} );
|
|
601
645
|
|
|
602
646
|
// Clean up and release
|
|
@@ -605,6 +649,7 @@ function init ( ctx ) {
|
|
|
605
649
|
|
|
606
650
|
disableMouseSelection( api );
|
|
607
651
|
api.off( '.dtSelect' );
|
|
652
|
+
$('body').off('.dtSelect' + _safeId(api.table().node()));
|
|
608
653
|
} );
|
|
609
654
|
}
|
|
610
655
|
|
|
@@ -873,12 +918,16 @@ apiRegister( 'select.style()', function ( style ) {
|
|
|
873
918
|
}
|
|
874
919
|
|
|
875
920
|
return this.iterator( 'table', function ( ctx ) {
|
|
876
|
-
ctx._select
|
|
921
|
+
if ( ! ctx._select ) {
|
|
922
|
+
DataTable.select.init( new DataTable.Api(ctx) );
|
|
923
|
+
}
|
|
877
924
|
|
|
878
925
|
if ( ! ctx._select_init ) {
|
|
879
|
-
init(
|
|
926
|
+
init(ctx);
|
|
880
927
|
}
|
|
881
928
|
|
|
929
|
+
ctx._select.style = style;
|
|
930
|
+
|
|
882
931
|
// Add / remove mouse event handlers. They aren't required when only
|
|
883
932
|
// API selection is available
|
|
884
933
|
var dt = new DataTable.Api( ctx );
|
|
@@ -1043,7 +1092,9 @@ apiRegisterPlural( 'cells().deselect()', 'cell().deselect()', function () {
|
|
|
1043
1092
|
this.iterator( 'cell', function ( ctx, rowIdx, colIdx ) {
|
|
1044
1093
|
var data = ctx.aoData[ rowIdx ];
|
|
1045
1094
|
|
|
1046
|
-
data._selected_cells
|
|
1095
|
+
if(data._selected_cells !== undefined) {
|
|
1096
|
+
data._selected_cells[ colIdx ] = false;
|
|
1097
|
+
}
|
|
1047
1098
|
|
|
1048
1099
|
// Remove class only if the cells exist, and the cell is not column
|
|
1049
1100
|
// selected, in which case the class should remain (since it is selected
|
|
@@ -1,28 +1,40 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
|
|
2
|
+
Copyright 2015-2021 SpryMedia Ltd.
|
|
3
|
+
|
|
4
|
+
This source file is free software, available under the following license:
|
|
5
|
+
MIT license - http://datatables.net/license/mit
|
|
6
|
+
|
|
7
|
+
This source file is distributed in the hope that it will be useful, but
|
|
8
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
9
|
+
or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
|
|
10
|
+
|
|
11
|
+
For details please refer to: http://www.datatables.net/extensions/select
|
|
12
|
+
Select for DataTables 1.3.4-dev
|
|
3
13
|
2015-2021 SpryMedia Ltd - datatables.net/license/mit
|
|
4
14
|
*/
|
|
5
|
-
(function(
|
|
6
|
-
function(
|
|
7
|
-
|
|
8
|
-
if((!
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
a.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
!
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
h
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
this.iterator("table",function(c,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
c
|
|
27
|
-
|
|
28
|
-
|
|
15
|
+
(function(h){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(r){return h(r,window,document)}):"object"===typeof exports?module.exports=function(r,v){r||(r=window);v&&v.fn.dataTable||(v=require("datatables.net")(r,v).$);return h(v,r,r.document)}:h(jQuery,window,document)})(function(h,r,v,l){function I(a,b,c){var d=function(g,f){if(g>f){var k=f;f=g;g=k}var n=!1;return a.columns(":visible").indexes().filter(function(q){q===g&&(n=!0);return q===f?(n=!1,!0):n})};var e=
|
|
16
|
+
function(g,f){var k=a.rows({search:"applied"}).indexes();if(k.indexOf(g)>k.indexOf(f)){var n=f;f=g;g=n}var q=!1;return k.filter(function(y){y===g&&(q=!0);return y===f?(q=!1,!0):q})};a.cells({selected:!0}).any()||c?(d=d(c.column,b.column),c=e(c.row,b.row)):(d=d(0,b.column),c=e(0,b.row));c=a.cells(c,d).flatten();a.cells(b,{selected:!0}).any()?a.cells(c).deselect():a.cells(c).select()}function C(a){var b=a.settings()[0]._select.selector;h(a.table().container()).off("mousedown.dtSelect",b).off("mouseup.dtSelect",
|
|
17
|
+
b).off("click.dtSelect",b);h("body").off("click.dtSelect"+D(a.table().node()))}function J(a){var b=h(a.table().container()),c=a.settings()[0],d=c._select.selector,e;b.on("mousedown.dtSelect",d,function(g){if(g.shiftKey||g.metaKey||g.ctrlKey)b.css("-moz-user-select","none").one("selectstart.dtSelect",d,function(){return!1});r.getSelection&&(e=r.getSelection())}).on("mouseup.dtSelect",d,function(){b.css("-moz-user-select","")}).on("click.dtSelect",d,function(g){var f=a.select.items();if(e){var k=r.getSelection();
|
|
18
|
+
if((!k.anchorNode||h(k.anchorNode).closest("table")[0]===a.table().node())&&k!==e)return}k=a.settings()[0];var n=a.settings()[0].oClasses.sWrapper.trim().replace(/ +/g,".");if(h(g.target).closest("div."+n)[0]==a.table().container()&&(n=a.cell(h(g.target).closest("td, th")),n.any())){var q=h.Event("user-select.dt");u(a,q,[f,n,g]);q.isDefaultPrevented()||(q=n.index(),"row"===f?(f=q.row,E(g,a,k,"row",f)):"column"===f?(f=n.index().column,E(g,a,k,"column",f)):"cell"===f&&(f=n.index(),E(g,a,k,"cell",f)),
|
|
19
|
+
k._select_lastCell=q)}});h("body").on("click.dtSelect"+D(a.table().node()),function(g){!c._select.blurable||h(g.target).parents().filter(a.table().container()).length||0===h(g.target).parents("html").length||h(g.target).parents("div.DTE").length||z(c,!0)})}function u(a,b,c,d){if(!d||a.flatten().length)"string"===typeof b&&(b+=".dt"),c.unshift(a),h(a.table().node()).trigger(b,c)}function N(a){var b=a.settings()[0];if(b._select.info&&b.aanFeatures.i&&"api"!==a.select.style()){var c=a.rows({selected:!0}).flatten().length,
|
|
20
|
+
d=a.columns({selected:!0}).flatten().length,e=a.cells({selected:!0}).flatten().length,g=function(f,k,n){f.append(h('<span class="select-item"/>').append(a.i18n("select."+k+"s",{_:"%d "+k+"s selected",0:"",1:"1 "+k+" selected"},n)))};h.each(b.aanFeatures.i,function(f,k){k=h(k);f=h('<span class="select-info"/>');g(f,"row",c);g(f,"column",d);g(f,"cell",e);var n=k.children("span.select-info");n.length&&n.remove();""!==f.text()&&k.append(f)})}}function O(a){var b=new m.Api(a);a._select_init=!0;a.aoRowCreatedCallback.push({fn:function(c,
|
|
21
|
+
d,e){d=a.aoData[e];d._select_selected&&h(c).addClass(a._select.className);c=0;for(e=a.aoColumns.length;c<e;c++)(a.aoColumns[c]._select_selected||d._selected_cells&&d._selected_cells[c])&&h(d.anCells[c]).addClass(a._select.className)},sName:"select-deferRender"});b.on("preXhr.dt.dtSelect",function(c,d){if(d===b.settings()[0]){var e=b.rows({selected:!0}).ids(!0).filter(function(f){return f!==l}),g=b.cells({selected:!0}).eq(0).map(function(f){var k=b.row(f.row).id(!0);return k?{row:k,column:f.column}:
|
|
22
|
+
l}).filter(function(f){return f!==l});b.one("draw.dt.dtSelect",function(){b.rows(e).select();g.any()&&g.each(function(f){b.cells(f.row,f.column).select()})})}});b.on("draw.dtSelect.dt select.dtSelect.dt deselect.dtSelect.dt info.dt",function(){N(b);b.state.save()});b.on("destroy.dtSelect",function(){b.rows({selected:!0}).deselect();C(b);b.off(".dtSelect");h("body").off(".dtSelect"+D(b.table().node()))})}function K(a,b,c,d){var e=a[b+"s"]({search:"applied"}).indexes();d=h.inArray(d,e);var g=h.inArray(c,
|
|
23
|
+
e);if(a[b+"s"]({selected:!0}).any()||-1!==d){if(d>g){var f=g;g=d;d=f}e.splice(g+1,e.length);e.splice(0,d)}else e.splice(h.inArray(c,e)+1,e.length);a[b](c,{selected:!0}).any()?(e.splice(h.inArray(c,e),1),a[b+"s"](e).deselect()):a[b+"s"](e).select()}function z(a,b){if(b||"single"===a._select.style)a=new m.Api(a),a.rows({selected:!0}).deselect(),a.columns({selected:!0}).deselect(),a.cells({selected:!0}).deselect()}function E(a,b,c,d,e){var g=b.select.style(),f=b.select.toggleable(),k=b[d](e,{selected:!0}).any();
|
|
24
|
+
if(!k||f)"os"===g?a.ctrlKey||a.metaKey?b[d](e).select(!k):a.shiftKey?"cell"===d?I(b,e,c._select_lastCell||null):K(b,d,e,c._select_lastCell?c._select_lastCell[d]:null):(a=b[d+"s"]({selected:!0}),k&&1===a.flatten().length?b[d](e).deselect():(a.deselect(),b[d](e).select())):"multi+shift"==g?a.shiftKey?"cell"===d?I(b,e,c._select_lastCell||null):K(b,d,e,c._select_lastCell?c._select_lastCell[d]:null):b[d](e).select(!k):b[d](e).select(!k)}function D(a){return a.id.replace(/[^a-zA-Z0-9\-_]/g,"-")}function A(a,
|
|
25
|
+
b){return function(c){return c.i18n("buttons."+a,b)}}function F(a){a=a._eventNamespace;return"draw.dt.DT"+a+" select.dt.DT"+a+" deselect.dt.DT"+a}function P(a,b){return-1!==h.inArray("rows",b.limitTo)&&a.rows({selected:!0}).any()||-1!==h.inArray("columns",b.limitTo)&&a.columns({selected:!0}).any()||-1!==h.inArray("cells",b.limitTo)&&a.cells({selected:!0}).any()?!0:!1}var m=h.fn.dataTable;m.select={};m.select.version="1.3.4-dev";m.select.init=function(a){var b=a.settings()[0];if(!b._select){var c=
|
|
26
|
+
a.state.loaded(),d=function(t,G,p){if(null!==p&&p.select!==l){a.rows().deselect();a.columns().deselect();a.cells().deselect();p.select.rows!==l&&a.rows(p.select.rows).select();p.select.columns!==l&&a.columns(p.select.columns).select();if(p.select.cells!==l)for(t=0;t<p.select.cells.length;t++)a.cell(p.select.cells[t].row,p.select.cells[t].column).select();a.state.save()}};a.one("init",function(){a.on("stateSaveParams",function(t,G,p){p.select={};p.select.rows=a.rows({selected:!0}).ids(!0).toArray();
|
|
27
|
+
p.select.columns=a.columns({selected:!0})[0];p.select.cells=a.cells({selected:!0})[0].map(function(L){return{row:a.row(L.row).id(!0),column:L.column}})});d(l,l,c);a.on("stateLoaded stateLoadParams",d)});var e=b.oInit.select,g=m.defaults.select;e=e===l?g:e;g="row";var f="api",k=!1,n=!0,q=!0,y="td, th",M="selected",B=!1;b._select={};!0===e?(f="os",B=!0):"string"===typeof e?(f=e,B=!0):h.isPlainObject(e)&&(e.blurable!==l&&(k=e.blurable),e.toggleable!==l&&(n=e.toggleable),e.info!==l&&(q=e.info),e.items!==
|
|
28
|
+
l&&(g=e.items),f=e.style!==l?e.style:"os",B=!0,e.selector!==l&&(y=e.selector),e.className!==l&&(M=e.className));a.select.selector(y);a.select.items(g);a.select.style(f);a.select.blurable(k);a.select.toggleable(n);a.select.info(q);b._select.className=M;h.fn.dataTable.ext.order["select-checkbox"]=function(t,G){return this.api().column(G,{order:"index"}).nodes().map(function(p){return"row"===t._select.items?h(p).parent().hasClass(t._select.className):"cell"===t._select.items?h(p).hasClass(t._select.className):
|
|
29
|
+
!1})};!B&&h(a.table().node()).hasClass("selectable")&&a.select.style("os")}};h.each([{type:"row",prop:"aoData"},{type:"column",prop:"aoColumns"}],function(a,b){m.ext.selector[b.type].push(function(c,d,e){d=d.selected;var g=[];if(!0!==d&&!1!==d)return e;for(var f=0,k=e.length;f<k;f++){var n=c[b.prop][e[f]];(!0===d&&!0===n._select_selected||!1===d&&!n._select_selected)&&g.push(e[f])}return g})});m.ext.selector.cell.push(function(a,b,c){b=b.selected;var d=[];if(b===l)return c;for(var e=0,g=c.length;e<
|
|
30
|
+
g;e++){var f=a.aoData[c[e].row];(!0===b&&f._selected_cells&&!0===f._selected_cells[c[e].column]||!(!1!==b||f._selected_cells&&f._selected_cells[c[e].column]))&&d.push(c[e])}return d});var w=m.Api.register,x=m.Api.registerPlural;w("select()",function(){return this.iterator("table",function(a){m.select.init(new m.Api(a))})});w("select.blurable()",function(a){return a===l?this.context[0]._select.blurable:this.iterator("table",function(b){b._select.blurable=a})});w("select.toggleable()",function(a){return a===
|
|
31
|
+
l?this.context[0]._select.toggleable:this.iterator("table",function(b){b._select.toggleable=a})});w("select.info()",function(a){return a===l?this.context[0]._select.info:this.iterator("table",function(b){b._select.info=a})});w("select.items()",function(a){return a===l?this.context[0]._select.items:this.iterator("table",function(b){b._select.items=a;u(new m.Api(b),"selectItems",[a])})});w("select.style()",function(a){return a===l?this.context[0]._select.style:this.iterator("table",function(b){b._select||
|
|
32
|
+
m.select.init(new m.Api(b));b._select_init||O(b);b._select.style=a;var c=new m.Api(b);C(c);"api"!==a&&J(c);u(new m.Api(b),"selectStyle",[a])})});w("select.selector()",function(a){return a===l?this.context[0]._select.selector:this.iterator("table",function(b){C(new m.Api(b));b._select.selector=a;"api"!==b._select.style&&J(new m.Api(b))})});x("rows().select()","row().select()",function(a){var b=this;if(!1===a)return this.deselect();this.iterator("row",function(c,d){z(c);c.aoData[d]._select_selected=
|
|
33
|
+
!0;h(c.aoData[d].nTr).addClass(c._select.className)});this.iterator("table",function(c,d){u(b,"select",["row",b[d]],!0)});return this});x("columns().select()","column().select()",function(a){var b=this;if(!1===a)return this.deselect();this.iterator("column",function(c,d){z(c);c.aoColumns[d]._select_selected=!0;d=(new m.Api(c)).column(d);h(d.header()).addClass(c._select.className);h(d.footer()).addClass(c._select.className);d.nodes().to$().addClass(c._select.className)});this.iterator("table",function(c,
|
|
34
|
+
d){u(b,"select",["column",b[d]],!0)});return this});x("cells().select()","cell().select()",function(a){var b=this;if(!1===a)return this.deselect();this.iterator("cell",function(c,d,e){z(c);d=c.aoData[d];d._selected_cells===l&&(d._selected_cells=[]);d._selected_cells[e]=!0;d.anCells&&h(d.anCells[e]).addClass(c._select.className)});this.iterator("table",function(c,d){u(b,"select",["cell",b.cells(b[d]).indexes().toArray()],!0)});return this});x("rows().deselect()","row().deselect()",function(){var a=
|
|
35
|
+
this;this.iterator("row",function(b,c){b.aoData[c]._select_selected=!1;b._select_lastCell=null;h(b.aoData[c].nTr).removeClass(b._select.className)});this.iterator("table",function(b,c){u(a,"deselect",["row",a[c]],!0)});return this});x("columns().deselect()","column().deselect()",function(){var a=this;this.iterator("column",function(b,c){b.aoColumns[c]._select_selected=!1;var d=new m.Api(b),e=d.column(c);h(e.header()).removeClass(b._select.className);h(e.footer()).removeClass(b._select.className);
|
|
36
|
+
d.cells(null,c).indexes().each(function(g){var f=b.aoData[g.row],k=f._selected_cells;!f.anCells||k&&k[g.column]||h(f.anCells[g.column]).removeClass(b._select.className)})});this.iterator("table",function(b,c){u(a,"deselect",["column",a[c]],!0)});return this});x("cells().deselect()","cell().deselect()",function(){var a=this;this.iterator("cell",function(b,c,d){c=b.aoData[c];c._selected_cells!==l&&(c._selected_cells[d]=!1);c.anCells&&!b.aoColumns[d]._select_selected&&h(c.anCells[d]).removeClass(b._select.className)});
|
|
37
|
+
this.iterator("table",function(b,c){u(a,"deselect",["cell",a[c]],!0)});return this});var H=0;h.extend(m.ext.buttons,{selected:{text:A("selected","Selected"),className:"buttons-selected",limitTo:["rows","columns","cells"],init:function(a,b,c){var d=this;c._eventNamespace=".select"+H++;a.on(F(c),function(){d.enable(P(a,c))});this.disable()},destroy:function(a,b,c){a.off(c._eventNamespace)}},selectedSingle:{text:A("selectedSingle","Selected single"),className:"buttons-selected-single",init:function(a,
|
|
38
|
+
b,c){var d=this;c._eventNamespace=".select"+H++;a.on(F(c),function(){var e=a.rows({selected:!0}).flatten().length+a.columns({selected:!0}).flatten().length+a.cells({selected:!0}).flatten().length;d.enable(1===e)});this.disable()},destroy:function(a,b,c){a.off(c._eventNamespace)}},selectAll:{text:A("selectAll","Select all"),className:"buttons-select-all",action:function(){this[this.select.items()+"s"]().select()}},selectNone:{text:A("selectNone","Deselect all"),className:"buttons-select-none",action:function(){z(this.settings()[0],
|
|
39
|
+
!0)},init:function(a,b,c){var d=this;c._eventNamespace=".select"+H++;a.on(F(c),function(){var e=a.rows({selected:!0}).flatten().length+a.columns({selected:!0}).flatten().length+a.cells({selected:!0}).flatten().length;d.enable(0<e)});this.disable()},destroy:function(a,b,c){a.off(c._eventNamespace)}}});h.each(["Row","Column","Cell"],function(a,b){var c=b.toLowerCase();m.ext.buttons["select"+b+"s"]={text:A("select"+b+"s","Select "+c+"s"),className:"buttons-select-"+c+"s",action:function(){this.select.items(c)},
|
|
40
|
+
init:function(d){var e=this;d.on("selectItems.dt.DT",function(g,f,k){e.active(k===c)})}}});h(v).on("preInit.dt.dtSelect",function(a,b){"dt"===a.namespace&&m.select.init(new m.Api(b))});return m.select});
|
package/package.json
CHANGED
|
@@ -1,36 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "datatables.net-select",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
3
|
+
"description": "Select for DataTables",
|
|
4
|
+
"main": "js/dataTables.select.js",
|
|
5
|
+
"types": "./types/types.d.ts",
|
|
6
|
+
"version": "1.3.4",
|
|
5
7
|
"files": [
|
|
6
|
-
"js/**/*.js"
|
|
8
|
+
"js/**/*.js",
|
|
9
|
+
"types/**/*.d.ts"
|
|
7
10
|
],
|
|
8
|
-
"main": "js/dataTables.select.js",
|
|
9
|
-
"type": "types.d.ts",
|
|
10
11
|
"keywords": [
|
|
11
12
|
"select",
|
|
12
13
|
"selection",
|
|
13
|
-
"
|
|
14
|
+
"Datatables",
|
|
14
15
|
"jQuery",
|
|
15
16
|
"table",
|
|
16
|
-
"
|
|
17
|
+
"filter",
|
|
18
|
+
"sort"
|
|
19
|
+
],
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"datatables.net": ">=1.11.3",
|
|
22
|
+
"jquery": ">=1.7"
|
|
23
|
+
},
|
|
24
|
+
"moduleType": [
|
|
25
|
+
"globals",
|
|
26
|
+
"amd",
|
|
27
|
+
"node"
|
|
28
|
+
],
|
|
29
|
+
"ignore": [
|
|
30
|
+
"composer.json",
|
|
31
|
+
"datatables.json",
|
|
32
|
+
"package.json"
|
|
17
33
|
],
|
|
18
|
-
"homepage": "https://datatables.net",
|
|
19
|
-
"bugs": "https://datatables.net/forums",
|
|
20
|
-
"license": "MIT",
|
|
21
34
|
"author": {
|
|
22
35
|
"name": "SpryMedia Ltd",
|
|
23
36
|
"url": "http://datatables.net"
|
|
24
37
|
},
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
},
|
|
38
|
+
"homepage": "https://datatables.net",
|
|
39
|
+
"bugs": "https://datatables.net/forums",
|
|
40
|
+
"license": "MIT",
|
|
29
41
|
"repository": {
|
|
30
42
|
"type": "git",
|
|
31
43
|
"url": "https://github.com/DataTables/Dist-DataTables-Select.git"
|
|
32
|
-
},
|
|
33
|
-
"devDependencies": {
|
|
34
|
-
"@types/jquery": "^3.5.1"
|
|
35
44
|
}
|
|
36
45
|
}
|
package/types/types.d.ts
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
// Type definitions for datatables.net-select 1.2
|
|
2
|
+
// Project: https://datatables.net/extensions/select/, https://datatables.net
|
|
3
|
+
// Definitions by: Jared Szechy <https://github.com/szechyjs>
|
|
4
|
+
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
5
|
+
// TypeScript Version: 2.4
|
|
6
|
+
|
|
7
|
+
/// <reference types="jquery" />
|
|
8
|
+
/// <reference types="datatables.net"/>
|
|
9
|
+
|
|
10
|
+
declare namespace DataTables {
|
|
11
|
+
interface Settings {
|
|
12
|
+
/*
|
|
13
|
+
* Select extension options
|
|
14
|
+
*/
|
|
15
|
+
select?: boolean | string | SelectSettings;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface SelectSettings {
|
|
19
|
+
/*
|
|
20
|
+
* Indicate if the selected items will be removed when clicking outside of the table
|
|
21
|
+
*/
|
|
22
|
+
blurable?: boolean;
|
|
23
|
+
|
|
24
|
+
/*
|
|
25
|
+
* Set the class name that will be applied to selected items
|
|
26
|
+
*/
|
|
27
|
+
className?: string;
|
|
28
|
+
|
|
29
|
+
/*
|
|
30
|
+
* Enable / disable the display for item selection information in the table summary
|
|
31
|
+
*/
|
|
32
|
+
info?: boolean;
|
|
33
|
+
|
|
34
|
+
/*
|
|
35
|
+
* Set which table items to select (rows, columns or cells)
|
|
36
|
+
*/
|
|
37
|
+
items?: string;
|
|
38
|
+
|
|
39
|
+
/*
|
|
40
|
+
* Set the element selector used for mouse event capture to select items
|
|
41
|
+
*/
|
|
42
|
+
selector?: string;
|
|
43
|
+
|
|
44
|
+
/*
|
|
45
|
+
* Set the selection style for end user interaction with the table
|
|
46
|
+
*/
|
|
47
|
+
style?: "api" | "single" | "multi" | "os" | "multi+shift";
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
interface Api {
|
|
51
|
+
select: {
|
|
52
|
+
/**
|
|
53
|
+
* Initialise Select for a DataTable after the DataTable has been constructed.
|
|
54
|
+
*
|
|
55
|
+
* @returns DataTables Api instance
|
|
56
|
+
*/
|
|
57
|
+
(): Api;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Get the blurable state for the table.
|
|
61
|
+
*
|
|
62
|
+
* @returns Current state - true if blurable, false otherwise. Note that if multiple tables are defined in the API's context, only the blurable state of the first table will be returned.
|
|
63
|
+
*/
|
|
64
|
+
blurable(): boolean;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Set the blurable state for the table's selection options.
|
|
68
|
+
*
|
|
69
|
+
* @param flag Value to set for the blurable option - true to enable, false to disable.
|
|
70
|
+
* @returns DataTables Api instance for chaining
|
|
71
|
+
*/
|
|
72
|
+
blurable(flag): Api;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Get the summary information display state for the table.
|
|
76
|
+
*
|
|
77
|
+
* @returns Current state - true if information summary shown, false otherwise. Note that if multiple tables are defined in the API's context, only the information state of the first table will be returned.
|
|
78
|
+
*/
|
|
79
|
+
info(): boolean;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Set the information summary display state for the table's selection options.
|
|
83
|
+
*
|
|
84
|
+
* @param flag Value to set for the information summary display state - true to enable, false to disable.
|
|
85
|
+
* @returns DataTables API instance for chaining.
|
|
86
|
+
*/
|
|
87
|
+
info(flag): Api;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Get the items that will be selected by user interaction (i.e. a click on the table).
|
|
91
|
+
*
|
|
92
|
+
* @returns The current item that will be selected when the user interacts with Select's event listeners - this will be the value row, column or cell.
|
|
93
|
+
*/
|
|
94
|
+
items(): string;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Set the item type that will be selected by user interaction.
|
|
98
|
+
*
|
|
99
|
+
* @param set Items to select - this must be one of row, column or cells.
|
|
100
|
+
* @returns DataTables API instance for chaining.
|
|
101
|
+
*/
|
|
102
|
+
items(set: string): Api;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Get the current item selector string applied to the table.
|
|
106
|
+
*
|
|
107
|
+
* @returns the item selector string being used for the table.
|
|
108
|
+
*/
|
|
109
|
+
selector(): string;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Set the table's item selector string. Note that any old selectors will be automatically removed if this is used as a selector to ensure that there are no memory leaks in unattached event listeners.
|
|
113
|
+
*
|
|
114
|
+
* @param set jQuery selector that will select the cells that can trigger item selection.
|
|
115
|
+
*/
|
|
116
|
+
selector(set: string): Api;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Get the current selection style applied to the table
|
|
120
|
+
*
|
|
121
|
+
* @returns The current selection style, this will be one of "api", "single", "multi" or "os".
|
|
122
|
+
*/
|
|
123
|
+
style(): string;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Set the table's selection style
|
|
127
|
+
*
|
|
128
|
+
* @param s Selection style to set - this must be one of "api", "single", "multi" or "os".
|
|
129
|
+
* @returns DataTables API instance for chaining.
|
|
130
|
+
*/
|
|
131
|
+
style(s: "api" | "single" | "multi" | "os"): Api;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Get the toggle state of Select for the given DataTable.
|
|
135
|
+
*
|
|
136
|
+
* @returns true if the item can be deselected when clicked on, false if it cannot be.
|
|
137
|
+
*/
|
|
138
|
+
toggleable(): boolean;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Set the toggle state of Select for the DataTable.
|
|
142
|
+
*
|
|
143
|
+
* @param set true to allow item deselection, false to disallow.
|
|
144
|
+
* @returns DataTables API instance for chaining.
|
|
145
|
+
*/
|
|
146
|
+
toggleable(set): Api;
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
interface RowMethods {
|
|
151
|
+
/**
|
|
152
|
+
* Select a row
|
|
153
|
+
*/
|
|
154
|
+
select(): Api;
|
|
155
|
+
/**
|
|
156
|
+
* Deselect a row
|
|
157
|
+
*/
|
|
158
|
+
deselect(): Api;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
interface RowsMethods {
|
|
162
|
+
/**
|
|
163
|
+
* Select multiple rows
|
|
164
|
+
*/
|
|
165
|
+
select(): Api;
|
|
166
|
+
/**
|
|
167
|
+
* Deselect a row
|
|
168
|
+
*/
|
|
169
|
+
deselect(): Api;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
interface CellMethods {
|
|
173
|
+
/**
|
|
174
|
+
* Select cell
|
|
175
|
+
*/
|
|
176
|
+
select(): Api;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Deselect a cell
|
|
180
|
+
*/
|
|
181
|
+
deselect(): Api;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
interface CellsMethods {
|
|
185
|
+
/**
|
|
186
|
+
* Select multiple cells
|
|
187
|
+
*/
|
|
188
|
+
select(): Api;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Deselect cells
|
|
192
|
+
*/
|
|
193
|
+
deselect(): Api;
|
|
194
|
+
}
|
|
195
|
+
}
|