Socket
Socket
Sign inDemoInstall

datatables.net-select

Package Overview
Dependencies
2
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.4.0 to 1.5.0

js/dataTables.select.min.mjs

39

js/dataTables.select.js

@@ -1,24 +0,5 @@

/*! Select for DataTables 1.4.0-dev
/*! Select for DataTables 1.5.0
* 2015-2021 SpryMedia Ltd - datatables.net/license/mit
*/
/**
* @summary Select for DataTables
* @description A collection of API methods, events and buttons for DataTables
* that provides selection options of the items in a DataTable
* @version 1.4.0-dev
* @file dataTables.select.js
* @author SpryMedia Ltd (www.sprymedia.co.uk)
* @contact datatables.net/forums
* @copyright Copyright 2015-2021 SpryMedia Ltd.
*
* This source file is free software, available under the following license:
* MIT license - http://datatables.net/license/mit
*
* This source file is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
*
* For details please refer to: http://www.datatables.net/extensions/select
*/
(function( factory ){

@@ -35,9 +16,18 @@ if ( typeof define === 'function' && define.amd ) {

if ( ! root ) {
// CommonJS environments without a window global must pass a
// root. This will give an error otherwise
root = window;
}
if ( ! $ || ! $.fn.dataTable ) {
$ = require('datatables.net')(root, $).$;
if ( ! $ ) {
$ = typeof window !== 'undefined' ? // jQuery's factory checks for a global window
require('jquery') :
require('jquery')( root );
}
if ( ! $.fn.dataTable ) {
require('datatables.net')(root, $);
}
return factory( $, root, root.document );

@@ -55,6 +45,7 @@ };

// Version information for debugger
DataTable.select = {};
DataTable.select.version = '1.4.0-dev';
DataTable.select.version = '1.5.0';

@@ -1328,3 +1319,3 @@ DataTable.select.init = function ( dt ) {

return DataTable.select;
return DataTable;
}));

@@ -1,41 +0,4 @@

/*!
Copyright 2015-2021 SpryMedia Ltd.
This source file is free software, available under the following license:
MIT license - http://datatables.net/license/mit
This source file is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
For details please refer to: http://www.datatables.net/extensions/select
Select for DataTables 1.4.0-dev
2015-2021 SpryMedia Ltd - datatables.net/license/mit
*/
(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,w){r||(r=window);w&&w.fn.dataTable||(w=require("datatables.net")(r,w).$);return h(w,r,r.document)}:h(jQuery,window,document)})(function(h,r,w,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=
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",
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();
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)),
k._select_lastCell=q)}});h("body").on("click.dtSelect"+D(a.table().node()),function(g){if(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){var f=h.Event("select-blur.dt");u(a,f,[g.target,g]);f.isDefaultPrevented()||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,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,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}: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,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();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,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.4.0-dev";m.select.init=function(a){var b=a.settings()[0];if(!b._select){var c=a.state.loaded(),d=function(t,G,p){if(null!==p&&p.select!==l){a.rows({selected:!0}).any()&&a.rows().deselect();p.select.rows!==l&&a.rows(p.select.rows).select();a.columns({selected:!0}).any()&&a.columns().deselect();p.select.columns!==l&&a.columns(p.select.columns).select();a.cells({selected:!0}).any()&&a.cells().deselect();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();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!==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):!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<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 v=m.Api.register,x=m.Api.registerPlural;v("select()",function(){return this.iterator("table",function(a){m.select.init(new m.Api(a))})});v("select.blurable()",function(a){return a===l?this.context[0]._select.blurable:
this.iterator("table",function(b){b._select.blurable=a})});v("select.toggleable()",function(a){return a===l?this.context[0]._select.toggleable:this.iterator("table",function(b){b._select.toggleable=a})});v("select.info()",function(a){return a===l?this.context[0]._select.info:this.iterator("table",function(b){b._select.info=a})});v("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])})});v("select.style()",
function(a){return a===l?this.context[0]._select.style:this.iterator("table",function(b){b._select||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])})});v("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=!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});v("row().selected()",function(){var a=this.context[0];return a&&this.length&&a.aoData[this[0]]&&a.aoData[this[0]]._select_selected?!0:!1});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,d){u(b,"select",["column",b[d]],!0)});return this});v("column().selected()",function(){var a=this.context[0];return a&&this.length&&a.aoColumns[this[0]]&&a.aoColumns[this[0]]._select_selected?!0:!1});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});v("cell().selected()",function(){var a=this.context[0];return a&&this.length&&(a=a.aoData[this[0][0].row])&&a._selected_cells&&a._selected_cells[this[0][0].column]?!0:!1});
x("rows().deselect()","row().deselect()",function(){var a=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);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)});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,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],!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)},init:function(d){var e=this;d.on("selectItems.dt.DT",function(g,f,k){e.active(k===c)})}}});h(w).on("preInit.dt.dtSelect",function(a,b){"dt"===a.namespace&&m.select.init(new m.Api(b))});return m.select});
/*! Select for DataTables 1.5.0
* 2015-2021 SpryMedia Ltd - datatables.net/license/mit
*/
!function(l){"function"==typeof define&&define.amd?define(["jquery","datatables.net"],function(e){return l(e,window,document)}):"object"==typeof exports?module.exports=function(e,t){return e=e||window,(t=t||("undefined"!=typeof window?require("jquery"):require("jquery")(e))).fn.dataTable||require("datatables.net")(e,t),l(t,e,e.document)}:l(jQuery,window,document)}(function(m,i,e,h){"use strict";var _=m.fn.dataTable;function r(n,e,t){function l(t,l){l<t&&(e=l,l=t,t=e);var e,s=!1;return n.columns(":visible").indexes().filter(function(e){return e===t&&(s=!0),e===l?!(s=!1):s})}function s(t,l){var e,s=n.rows({search:"applied"}).indexes(),c=(s.indexOf(t)>s.indexOf(l)&&(e=l,l=t,t=e),!1);return s.filter(function(e){return e===t&&(c=!0),e===l?!(c=!1):c})}var c,t=n.cells({selected:!0}).any()||t?(c=l(t.column,e.column),s(t.row,e.row)):(c=l(0,e.column),s(0,e.row)),t=n.cells(t,c).flatten();n.cells(e,{selected:!0}).any()?n.cells(t).deselect():n.cells(t).select()}function s(e){var t=e.settings()[0]._select.selector;m(e.table().container()).off("mousedown.dtSelect",t).off("mouseup.dtSelect",t).off("click.dtSelect",t),m("body").off("click.dtSelect"+w(e.table().node()))}function c(o){var a,t=m(o.table().container()),l=o.settings()[0],s=l._select.selector;t.on("mousedown.dtSelect",s,function(e){(e.shiftKey||e.metaKey||e.ctrlKey)&&t.css("-moz-user-select","none").one("selectstart.dtSelect",s,function(){return!1}),i.getSelection&&(a=i.getSelection())}).on("mouseup.dtSelect",s,function(){t.css("-moz-user-select","")}).on("click.dtSelect",s,function(e){var t,l=o.select.items();if(a){var s=i.getSelection();if((!s.anchorNode||m(s.anchorNode).closest("table")[0]===o.table().node())&&s!==a)return}var c,s=o.settings()[0],n=o.settings()[0].oClasses.sWrapper.trim().replace(/ +/g,".");m(e.target).closest("div."+n)[0]==o.table().container()&&(n=o.cell(m(e.target).closest("td, th"))).any()&&(c=m.Event("user-select.dt"),u(o,c,[l,n,e]),c.isDefaultPrevented()||(c=n.index(),"row"===l?(t=c.row,p(e,o,s,"row",t)):"column"===l?(t=n.index().column,p(e,o,s,"column",t)):"cell"===l&&(t=n.index(),p(e,o,s,"cell",t)),s._select_lastCell=c))}),m("body").on("click.dtSelect"+w(o.table().node()),function(e){var t;!l._select.blurable||m(e.target).parents().filter(o.table().container()).length||0===m(e.target).parents("html").length||m(e.target).parents("div.DTE").length||(t=m.Event("select-blur.dt"),u(o,t,[e.target,e]),t.isDefaultPrevented()||f(l,!0))})}function u(e,t,l,s){s&&!e.flatten().length||("string"==typeof t&&(t+=".dt"),l.unshift(e),m(e.table().node()).trigger(t,l))}function n(o){var i=new _.Api(o);o._select_init=!0,o.aoRowCreatedCallback.push({fn:function(e,t,l){var s,c,n=o.aoData[l];for(n._select_selected&&m(e).addClass(o._select.className),s=0,c=o.aoColumns.length;s<c;s++)(o.aoColumns[s]._select_selected||n._selected_cells&&n._selected_cells[s])&&m(n.anCells[s]).addClass(o._select.className)},sName:"select-deferRender"}),i.on("preXhr.dt.dtSelect",function(e,t){var l,s;t===i.settings()[0]&&(l=i.rows({selected:!0}).ids(!0).filter(function(e){return e!==h}),s=i.cells({selected:!0}).eq(0).map(function(e){var t=i.row(e.row).id(!0);return t?{row:t,column:e.column}:h}).filter(function(e){return e!==h}),i.one("draw.dt.dtSelect",function(){i.rows(l).select(),s.any()&&s.each(function(e){i.cells(e.row,e.column).select()})}))}),i.on("draw.dtSelect.dt select.dtSelect.dt deselect.dtSelect.dt info.dt",function(){var s,c,n,o,a,e;(e=(s=i).settings()[0])._select.info&&e.aanFeatures.i&&"api"!==s.select.style()&&(c=s.rows({selected:!0}).flatten().length,n=s.columns({selected:!0}).flatten().length,o=s.cells({selected:!0}).flatten().length,a=function(e,t,l){e.append(m('<span class="select-item"/>').append(s.i18n("select."+t+"s",{_:"%d "+t+"s selected",0:"",1:"1 "+t+" selected"},l)))},m.each(e.aanFeatures.i,function(e,t){t=m(t);var l=m('<span class="select-info"/>'),s=(a(l,"row",c),a(l,"column",n),a(l,"cell",o),t.children("span.select-info"));s.length&&s.remove(),""!==l.text()&&t.append(l)})),i.state.save()}),i.on("destroy.dtSelect",function(){i.rows({selected:!0}).deselect(),s(i),i.off(".dtSelect"),m("body").off(".dtSelect"+w(i.table().node()))})}function d(e,t,l,s){var c,n=e[t+"s"]({search:"applied"}).indexes(),s=m.inArray(s,n),o=m.inArray(l,n);e[t+"s"]({selected:!0}).any()||-1!==s?(o<s&&(c=o,o=s,s=c),n.splice(o+1,n.length),n.splice(0,s)):n.splice(m.inArray(l,n)+1,n.length),e[t](l,{selected:!0}).any()?(n.splice(m.inArray(l,n),1),e[t+"s"](n).deselect()):e[t+"s"](n).select()}function f(e,t){!t&&"single"!==e._select.style||((t=new _.Api(e)).rows({selected:!0}).deselect(),t.columns({selected:!0}).deselect(),t.cells({selected:!0}).deselect())}function p(e,t,l,s,c){var n=t.select.style(),o=t.select.toggleable(),a=t[s](c,{selected:!0}).any();a&&!o||("os"===n?e.ctrlKey||e.metaKey?t[s](c).select(!a):e.shiftKey?"cell"===s?r(t,c,l._select_lastCell||null):d(t,s,c,l._select_lastCell?l._select_lastCell[s]:null):(o=t[s+"s"]({selected:!0}),a&&1===o.flatten().length?t[s](c).deselect():(o.deselect(),t[s](c).select())):"multi+shift"==n&&e.shiftKey?"cell"===s?r(t,c,l._select_lastCell||null):d(t,s,c,l._select_lastCell?l._select_lastCell[s]:null):t[s](c).select(!a))}function w(e){return e.id.replace(/[^a-zA-Z0-9\-\_]/g,"-")}_.select={},_.select.version="1.5.0",_.select.init=function(c){var e,t,l,s,n,o,a,i,r,u,d,f=c.settings()[0];f._select||(e=c.state.loaded(),t=function(e,t,l){if(null!==l&&l.select!==h){if(c.rows({selected:!0}).any()&&c.rows().deselect(),l.select.rows!==h&&c.rows(l.select.rows).select(),c.columns({selected:!0}).any()&&c.columns().deselect(),l.select.columns!==h&&c.columns(l.select.columns).select(),c.cells({selected:!0}).any()&&c.cells().deselect(),l.select.cells!==h)for(var s=0;s<l.select.cells.length;s++)c.cell(l.select.cells[s].row,l.select.cells[s].column).select();c.state.save()}},c.one("init",function(){c.on("stateSaveParams",function(e,t,l){l.select={},l.select.rows=c.rows({selected:!0}).ids(!0).toArray(),l.select.columns=c.columns({selected:!0})[0],l.select.cells=c.cells({selected:!0})[0].map(function(e){return{row:c.row(e.row).id(!0),column:e.column}})}),t(0,0,e),c.on("stateLoaded stateLoadParams",t)}),s=f.oInit.select,l=_.defaults.select,l=s===h?l:s,s="row",i=a=!(o=!(n="api")),r="td, th",d=!(u="selected"),f._select={},!0===l?(n="os",d=!0):"string"==typeof l?(n=l,d=!0):m.isPlainObject(l)&&(l.blurable!==h&&(o=l.blurable),l.toggleable!==h&&(a=l.toggleable),l.info!==h&&(i=l.info),l.items!==h&&(s=l.items),d=(n=l.style!==h?l.style:"os",!0),l.selector!==h&&(r=l.selector),l.className!==h&&(u=l.className)),c.select.selector(r),c.select.items(s),c.select.style(n),c.select.blurable(o),c.select.toggleable(a),c.select.info(i),f._select.className=u,m.fn.dataTable.ext.order["select-checkbox"]=function(t,e){return this.api().column(e,{order:"index"}).nodes().map(function(e){return"row"===t._select.items?m(e).parent().hasClass(t._select.className):"cell"===t._select.items&&m(e).hasClass(t._select.className)})},!d&&m(c.table().node()).hasClass("selectable")&&c.select.style("os"))},m.each([{type:"row",prop:"aoData"},{type:"column",prop:"aoColumns"}],function(e,i){_.ext.selector[i.type].push(function(e,t,l){var s,c=t.selected,n=[];if(!0!==c&&!1!==c)return l;for(var o=0,a=l.length;o<a;o++)s=e[i.prop][l[o]],(!0===c&&!0===s._select_selected||!1===c&&!s._select_selected)&&n.push(l[o]);return n})}),_.ext.selector.cell.push(function(e,t,l){var s,c=t.selected,n=[];if(c===h)return l;for(var o=0,a=l.length;o<a;o++)s=e.aoData[l[o].row],(!0!==c||!s._selected_cells||!0!==s._selected_cells[l[o].column])&&(!1!==c||s._selected_cells&&s._selected_cells[l[o].column])||n.push(l[o]);return n});var t=_.Api.register,l=_.Api.registerPlural;function o(t,l){return function(e){return e.i18n("buttons."+t,l)}}function a(e){e=e._eventNamespace;return"draw.dt.DT"+e+" select.dt.DT"+e+" deselect.dt.DT"+e}t("select()",function(){return this.iterator("table",function(e){_.select.init(new _.Api(e))})}),t("select.blurable()",function(t){return t===h?this.context[0]._select.blurable:this.iterator("table",function(e){e._select.blurable=t})}),t("select.toggleable()",function(t){return t===h?this.context[0]._select.toggleable:this.iterator("table",function(e){e._select.toggleable=t})}),t("select.info()",function(t){return t===h?this.context[0]._select.info:this.iterator("table",function(e){e._select.info=t})}),t("select.items()",function(t){return t===h?this.context[0]._select.items:this.iterator("table",function(e){e._select.items=t,u(new _.Api(e),"selectItems",[t])})}),t("select.style()",function(l){return l===h?this.context[0]._select.style:this.iterator("table",function(e){e._select||_.select.init(new _.Api(e)),e._select_init||n(e),e._select.style=l;var t=new _.Api(e);s(t),"api"!==l&&c(t),u(new _.Api(e),"selectStyle",[l])})}),t("select.selector()",function(t){return t===h?this.context[0]._select.selector:this.iterator("table",function(e){s(new _.Api(e)),e._select.selector=t,"api"!==e._select.style&&c(new _.Api(e))})}),l("rows().select()","row().select()",function(e){var l=this;return!1===e?this.deselect():(this.iterator("row",function(e,t){f(e),e.aoData[t]._select_selected=!0,m(e.aoData[t].nTr).addClass(e._select.className)}),this.iterator("table",function(e,t){u(l,"select",["row",l[t]],!0)}),this)}),t("row().selected()",function(){var e=this.context[0];return!!(e&&this.length&&e.aoData[this[0]]&&e.aoData[this[0]]._select_selected)}),l("columns().select()","column().select()",function(e){var l=this;return!1===e?this.deselect():(this.iterator("column",function(e,t){f(e),e.aoColumns[t]._select_selected=!0;t=new _.Api(e).column(t);m(t.header()).addClass(e._select.className),m(t.footer()).addClass(e._select.className),t.nodes().to$().addClass(e._select.className)}),this.iterator("table",function(e,t){u(l,"select",["column",l[t]],!0)}),this)}),t("column().selected()",function(){var e=this.context[0];return!!(e&&this.length&&e.aoColumns[this[0]]&&e.aoColumns[this[0]]._select_selected)}),l("cells().select()","cell().select()",function(e){var l=this;return!1===e?this.deselect():(this.iterator("cell",function(e,t,l){f(e);t=e.aoData[t];t._selected_cells===h&&(t._selected_cells=[]),t._selected_cells[l]=!0,t.anCells&&m(t.anCells[l]).addClass(e._select.className)}),this.iterator("table",function(e,t){u(l,"select",["cell",l.cells(l[t]).indexes().toArray()],!0)}),this)}),t("cell().selected()",function(){var e=this.context[0];if(e&&this.length){e=e.aoData[this[0][0].row];if(e&&e._selected_cells&&e._selected_cells[this[0][0].column])return!0}return!1}),l("rows().deselect()","row().deselect()",function(){var l=this;return this.iterator("row",function(e,t){e.aoData[t]._select_selected=!1,e._select_lastCell=null,m(e.aoData[t].nTr).removeClass(e._select.className)}),this.iterator("table",function(e,t){u(l,"deselect",["row",l[t]],!0)}),this}),l("columns().deselect()","column().deselect()",function(){var l=this;return this.iterator("column",function(s,e){s.aoColumns[e]._select_selected=!1;var t=new _.Api(s),l=t.column(e);m(l.header()).removeClass(s._select.className),m(l.footer()).removeClass(s._select.className),t.cells(null,e).indexes().each(function(e){var t=s.aoData[e.row],l=t._selected_cells;!t.anCells||l&&l[e.column]||m(t.anCells[e.column]).removeClass(s._select.className)})}),this.iterator("table",function(e,t){u(l,"deselect",["column",l[t]],!0)}),this}),l("cells().deselect()","cell().deselect()",function(){var l=this;return this.iterator("cell",function(e,t,l){t=e.aoData[t];t._selected_cells!==h&&(t._selected_cells[l]=!1),t.anCells&&!e.aoColumns[l]._select_selected&&m(t.anCells[l]).removeClass(e._select.className)}),this.iterator("table",function(e,t){u(l,"deselect",["cell",l[t]],!0)}),this});var b=0;return m.extend(_.ext.buttons,{selected:{text:o("selected","Selected"),className:"buttons-selected",limitTo:["rows","columns","cells"],init:function(l,e,s){var c=this;s._eventNamespace=".select"+b++,l.on(a(s),function(){var e,t;c.enable((e=l,t=s,!(-1===m.inArray("rows",t.limitTo)||!e.rows({selected:!0}).any())||(!(-1===m.inArray("columns",t.limitTo)||!e.columns({selected:!0}).any())||!(-1===m.inArray("cells",t.limitTo)||!e.cells({selected:!0}).any()))))}),this.disable()},destroy:function(e,t,l){e.off(l._eventNamespace)}},selectedSingle:{text:o("selectedSingle","Selected single"),className:"buttons-selected-single",init:function(t,e,l){var s=this;l._eventNamespace=".select"+b++,t.on(a(l),function(){var e=t.rows({selected:!0}).flatten().length+t.columns({selected:!0}).flatten().length+t.cells({selected:!0}).flatten().length;s.enable(1===e)}),this.disable()},destroy:function(e,t,l){e.off(l._eventNamespace)}},selectAll:{text:o("selectAll","Select all"),className:"buttons-select-all",action:function(){var e=this.select.items();this[e+"s"]().select()}},selectNone:{text:o("selectNone","Deselect all"),className:"buttons-select-none",action:function(){f(this.settings()[0],!0)},init:function(t,e,l){var s=this;l._eventNamespace=".select"+b++,t.on(a(l),function(){var e=t.rows({selected:!0}).flatten().length+t.columns({selected:!0}).flatten().length+t.cells({selected:!0}).flatten().length;s.enable(0<e)}),this.disable()},destroy:function(e,t,l){e.off(l._eventNamespace)}}}),m.each(["Row","Column","Cell"],function(e,t){var c=t.toLowerCase();_.ext.buttons["select"+t+"s"]={text:o("select"+t+"s","Select "+c+"s"),className:"buttons-select-"+c+"s",action:function(){this.select.items(c)},init:function(e){var s=this;e.on("selectItems.dt.DT",function(e,t,l){s.active(l===c)})}}}),m(e).on("preInit.dt.dtSelect",function(e,t){"dt"===e.namespace&&_.select.init(new _.Api(t))}),_});

@@ -5,6 +5,8 @@ {

"main": "js/dataTables.select.js",
"module": "js/dataTables.select.mjs",
"types": "./types/types.d.ts",
"version": "1.4.0",
"version": "1.5.0",
"files": [
"js/**/*.js",
"js/**/*.mjs",
"types/**/*.d.ts"

@@ -22,3 +24,3 @@ ],

"dependencies": {
"datatables.net": ">=1.11.3",
"datatables.net": ">=1.12.1",
"jquery": ">=1.7"

@@ -25,0 +27,0 @@ },

@@ -1,195 +0,224 @@

// Type definitions for datatables.net-select 1.2
// Type definitions for DataTables Select
//
// Project: https://datatables.net/extensions/select/, https://datatables.net
// Definitions by: Jared Szechy <https://github.com/szechyjs>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
// Definitions by:
// SpryMedia
// Jared Szechy <https://github.com/szechyjs>
/// <reference types="jquery" />
/// <reference types="datatables.net"/>
declare namespace DataTables {
interface Settings {
/*
* Select extension options
*/
select?: boolean | string | SelectSettings;
}
import DataTables from 'datatables.net';
interface SelectSettings {
/*
* Indicate if the selected items will be removed when clicking outside of the table
*/
blurable?: boolean;
export default DataTables;
/*
* Set the class name that will be applied to selected items
*/
className?: string;
type StyleType = 'api' | 'single' | 'multi' | 'os' | 'multi+shift';
/*
* Enable / disable the display for item selection information in the table summary
*/
info?: boolean;
declare module 'datatables.net' {
interface Config {
/*
* Select extension options
*/
select?: boolean | string | ConfigSelect;
}
/*
* Set which table items to select (rows, columns or cells)
*/
items?: string;
interface Api<T> {
select: ApiSelect<Api<T>>
}
/*
* Set the element selector used for mouse event capture to select items
*/
selector?: string;
interface ApiRowMethods<T> {
/**
* Select a row
*/
select(): Api<T>;
/*
* Set the selection style for end user interaction with the table
*/
style?: "api" | "single" | "multi" | "os" | "multi+shift";
}
/**
* Deselect a row
*/
deselect(): Api<T>;
}
interface Api {
select: {
/**
* Initialise Select for a DataTable after the DataTable has been constructed.
*
* @returns DataTables Api instance
*/
(): Api;
interface ApiRowsMethods<T> {
/**
* Select multiple rows
*/
select(): Api<T>;
/**
* Get the blurable state for the table.
*
* @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.
*/
blurable(): boolean;
/**
* Deselect a row
*/
deselect(): Api<T>;
}
/**
* Set the blurable state for the table's selection options.
*
* @param flag Value to set for the blurable option - true to enable, false to disable.
* @returns DataTables Api instance for chaining
*/
blurable(flag): Api;
interface ApiCellMethods<T> {
/**
* Select cell
*/
select(): Api<T>;
/**
* Get the summary information display state for the table.
*
* @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.
*/
info(): boolean;
/**
* Deselect a cell
*/
deselect(): Api<T>;
}
/**
* Set the information summary display state for the table's selection options.
*
* @param flag Value to set for the information summary display state - true to enable, false to disable.
* @returns DataTables API instance for chaining.
*/
info(flag): Api;
interface ApiCellsMethods<T> {
/**
* Select multiple cells
*/
select(): Api<T>;
/**
* Get the items that will be selected by user interaction (i.e. a click on the table).
*
* @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.
*/
items(): string;
/**
* Deselect cells
*/
deselect(): Api<T>;
}
/**
* Set the item type that will be selected by user interaction.
*
* @param set Items to select - this must be one of row, column or cells.
* @returns DataTables API instance for chaining.
*/
items(set: string): Api;
interface ApiStatic {
/**
* Select static methods
*/
select: {
/**
* Initialise Select (for use on tables which were not in the document
* when they were initialised).
*/
init: <T=any>(api: Api<T>) => void;
/**
* Get the current item selector string applied to the table.
*
* @returns the item selector string being used for the table.
*/
selector(): string;
/**
* Select version
*/
version: string;
}
}
}
/**
* 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.
*
* @param set jQuery selector that will select the cells that can trigger item selection.
*/
selector(set: string): Api;
interface ConfigSelect {
/**
* Indicate if the selected items will be removed when clicking outside of the table
*/
blurable?: boolean;
/**
* Get the current selection style applied to the table
*
* @returns The current selection style, this will be one of "api", "single", "multi" or "os".
*/
style(): string;
/**
* Set the class name that will be applied to selected items
*/
className?: string;
/**
* Set the table's selection style
*
* @param s Selection style to set - this must be one of "api", "single", "multi" or "os".
* @returns DataTables API instance for chaining.
*/
style(s: "api" | "single" | "multi" | "os"): Api;
/**
* Enable / disable the display for item selection information in the table summary
*/
info?: boolean;
/**
* Get the toggle state of Select for the given DataTable.
*
* @returns true if the item can be deselected when clicked on, false if it cannot be.
*/
toggleable(): boolean;
/**
* Set which table items to select (rows, columns or cells)
*/
items?: string;
/**
* Set the toggle state of Select for the DataTable.
*
* @param set true to allow item deselection, false to disallow.
* @returns DataTables API instance for chaining.
*/
toggleable(set): Api;
};
}
/**
* Set the element selector used for mouse event capture to select items
*/
selector?: string;
interface RowMethods {
/**
* Select a row
*/
select(): Api;
/**
* Deselect a row
*/
deselect(): Api;
}
/**
* Set the selection style for end user interaction with the table
*/
style?: StyleType;
}
interface RowsMethods {
/**
* Select multiple rows
*/
select(): Api;
/**
* Deselect a row
*/
deselect(): Api;
}
interface ApiSelect<Api> {
/**
* Initialise Select for a DataTable after the DataTable has been constructed.
*
* @returns DataTables Api instance
*/
(): Api;
interface CellMethods {
/**
* Select cell
*/
select(): Api;
/**
* Get the blurable state for the table.
*
* @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.
*/
blurable(): boolean;
/**
* Deselect a cell
*/
deselect(): Api;
}
/**
* Set the blurable state for the table's selection options.
*
* @param flag Value to set for the blurable option - true to enable, false to disable.
* @returns DataTables Api instance for chaining
*/
blurable(flag): Api;
interface CellsMethods {
/**
* Select multiple cells
*/
select(): Api;
/**
* Get the summary information display state for the table.
*
* @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.
*/
info(): boolean;
/**
* Deselect cells
*/
deselect(): Api;
}
/**
* Set the information summary display state for the table's selection options.
*
* @param flag Value to set for the information summary display state - true to enable, false to disable.
* @returns DataTables API instance for chaining.
*/
info(flag): Api;
/**
* Get the items that will be selected by user interaction (i.e. a click on the table).
*
* @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.
*/
items(): string;
/**
* Set the item type that will be selected by user interaction.
*
* @param set Items to select - this must be one of row, column or cells.
* @returns DataTables API instance for chaining.
*/
items(set: string): Api;
/**
* Get the current item selector string applied to the table.
*
* @returns the item selector string being used for the table.
*/
selector(): string;
/**
* 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.
*
* @param set jQuery selector that will select the cells that can trigger item selection.
*/
selector(set: string): Api;
/**
* Get the current selection style applied to the table
*
* @returns The current selection style, this will be one of "api", "single", "multi" or "os".
*/
style(): string;
/**
* Set the table's selection style
*
* @param s Selection style to set - this must be one of "api", "single", "multi" or "os".
* @returns DataTables API instance for chaining.
*/
style(s: StyleType): Api;
/**
* Get the toggle state of Select for the given DataTable.
*
* @returns true if the item can be deselected when clicked on, false if it cannot be.
*/
toggleable(): boolean;
/**
* Set the toggle state of Select for the DataTable.
*
* @param set true to allow item deselection, false to disallow.
* @returns DataTables API instance for chaining.
*/
toggleable(set): Api;
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc