datatables.net-select 2.0.0 → 2.0.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.
@@ -1,4 +1,4 @@
1
- /*! Select for DataTables 2.0.0
1
+ /*! Select for DataTables 2.0.1
2
2
  * © SpryMedia Ltd - datatables.net/license/mit
3
3
  */
4
4
 
@@ -52,7 +52,7 @@ var DataTable = $.fn.dataTable;
52
52
  // Version information for debugger
53
53
  DataTable.select = {};
54
54
 
55
- DataTable.select.version = '2.0.0';
55
+ DataTable.select.version = '2.0.1';
56
56
 
57
57
  DataTable.select.init = function (dt) {
58
58
  var ctx = dt.settings()[0];
@@ -667,7 +667,9 @@ function init(ctx) {
667
667
 
668
668
  // Row
669
669
  if (d._select_selected) {
670
- $(row).addClass(ctx._select.className);
670
+ $(row)
671
+ .addClass(ctx._select.className)
672
+ .find('input.dt-select-checkbox').prop('checked', true);
671
673
  }
672
674
 
673
675
  // Cells and columns - if separated out, we would need to do two
@@ -677,7 +679,7 @@ function init(ctx) {
677
679
  ctx.aoColumns[i]._select_selected ||
678
680
  (d._selected_cells && d._selected_cells[i])
679
681
  ) {
680
- $(d.anCells[i]).addClass(ctx._select.className);
682
+ $(d.anCells[i]).addClass(ctx._select.className)
681
683
  }
682
684
  }
683
685
  }
@@ -1100,12 +1102,23 @@ apiRegisterPlural('rows().select()', 'row().select()', function (select) {
1100
1102
  for (var i=0 ; i<dtColumns.length ; i++) {
1101
1103
  var col = dtColumns[i];
1102
1104
 
1105
+ // Regenerate the column type if not present
1106
+ if (col.sType === null) {
1107
+ api.columns().types()
1108
+ }
1109
+
1103
1110
  if (col.sType === 'select-checkbox') {
1111
+ var cells = dtData.anCells;
1112
+
1104
1113
  // Make sure the checkbox shows the right state
1105
- $('input.dt-select-checkbox', dtData.anCells[i]).prop('checked', true);
1114
+ if (cells && cells[i]) {
1115
+ $('input.dt-select-checkbox', cells[i]).prop('checked', true);
1116
+ }
1106
1117
 
1107
- // Invalidate the sort data for this column
1108
- dtData._aSortData[i] = null;
1118
+ // Invalidate the sort data for this column, if not already done
1119
+ if (dtData._aSortData !== null) {
1120
+ dtData._aSortData[i] = null;
1121
+ }
1109
1122
  }
1110
1123
  }
1111
1124
  });
@@ -1223,12 +1236,23 @@ apiRegisterPlural('rows().deselect()', 'row().deselect()', function () {
1223
1236
  for (var i=0 ; i<dtColumns.length ; i++) {
1224
1237
  var col = dtColumns[i];
1225
1238
 
1239
+ // Regenerate the column type if not present
1240
+ if (col.sType === null) {
1241
+ api.columns().types()
1242
+ }
1243
+
1226
1244
  if (col.sType === 'select-checkbox') {
1245
+ var cells = dtData.anCells;
1246
+
1227
1247
  // Make sure the checkbox shows the right state
1228
- $('input.dt-select-checkbox', dtData.anCells[i]).prop('checked', false);
1248
+ if (cells && cells[i]) {
1249
+ $('input.dt-select-checkbox', dtData.anCells[i]).prop('checked', false);
1250
+ }
1229
1251
 
1230
- // Invalidate the sort data for this column
1231
- dtData._aSortData[i] = null;
1252
+ // Invalidate the sort data for this column, if not already done
1253
+ if (dtData._aSortData !== null) {
1254
+ dtData._aSortData[i] = null;
1255
+ }
1232
1256
  }
1233
1257
  }
1234
1258
  });
@@ -1,4 +1,4 @@
1
- /*! Select for DataTables 2.0.0
1
+ /*! Select for DataTables 2.0.1
2
2
  * © SpryMedia Ltd - datatables.net/license/mit
3
3
  */
4
- !function(l){var s,c;"function"==typeof define&&define.amd?define(["jquery","datatables.net"],function(e){return l(e,window,document)}):"object"==typeof exports?(s=require("jquery"),c=function(e,t){t.fn.dataTable||require("datatables.net")(e,t)},"undefined"==typeof window?module.exports=function(e,t){return e=e||window,t=t||s(e),c(e,t),l(t,e,e.document)}:(c(window,s),module.exports=l(s,window,window.document))):l(jQuery,window,document)}(function(m,i,e){"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"+v(e.table().node()))}function n(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.table().container();m(e.target).closest("div.dt-container")[0]==n&&(n=o.cell(m(e.target).closest("td, th"))).any()&&(c=m.Event("user-select.dt"),d(o,c,[l,n,e]),c.isDefaultPrevented()||(c=n.index(),"row"===l?(t=c.row,h(e,o,s,"row",t)):"column"===l?(t=n.index().column,h(e,o,s,"column",t)):"cell"===l&&(t=n.index(),h(e,o,s,"cell",t)),s._select_lastCell=c))}),m("body").on("click.dtSelect"+v(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"),d(o,t,[e.target,e]),t.isDefaultPrevented())||f(l,!0)})}function d(e,t,l,s){s&&!e.flatten().length||("string"==typeof t&&(t+=".dt"),l.unshift(e),m(e.table().node()).trigger(t,l))}function a(s,e){var t,l,c,n,o;"api"!==s.select.style()&&!1!==s.select.info()&&(o=s.rows({selected:!0}).flatten().length,t=s.columns({selected:!0}).flatten().length,l=s.cells({selected:!0}).flatten().length,c=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)))},e=m(e),c(n=m('<span class="select-info"/>'),"row",o),c(n,"column",t),c(n,"cell",l),(o=e.children("span.select-info")).length&&o.remove(),""!==n.text())&&e.append(n)}function p(o){o.columns(".dt-select").every(function(){var n,e=this.header();m("input",e).length||(n=m("<input>").attr({class:"dt-select-checkbox",type:"checkbox","aria-label":o.i18n("select.aria.headerCheckbox")||"Select all rows"}).appendTo(e).on("change",function(){this.checked?o.rows({search:"applied"}).select():o.rows({selected:!0}).deselect()}).on("click",function(e){e.stopPropagation()}),o.on("draw select deselect",function(e,t,l){var s,c;"row"!==l&&l||(l=o.rows({selected:!0}).count(),s=o.rows({search:"applied",selected:!0}).count(),c=o.rows({search:"applied"}).count(),s&&s<=l&&s===c?n.prop("checked",!0).prop("indeterminate",!1):0===s&&0===l?n.prop("checked",!1).prop("indeterminate",!1):n.prop("checked",!1).prop("indeterminate",!0))}))})}function u(e,t,l,s){var c,n=e[t+"s"]({search:"applied"}).indexes(),s=n.indexOf(s),o=n.indexOf(l);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(n.indexOf(l)+1,n.length),e[t](l,{selected:!0}).any()?(n.splice(n.indexOf(l),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 h(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):u(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):u(t,s,c,l._select_lastCell?l._select_lastCell[s]:null):t[s](c).select(!a))}function v(e){return e.id.replace(/[^a-zA-Z0-9\-\_]/g,"-")}_.select={},_.select.version="2.0.0",_.select.init=function(c){var e,t,l,s,n,o,a,i,r,d,u,f,h=c.settings()[0];if(!_.versionCheck("2"))throw"Warning: Select requires DataTables 2 or newer";h._select||(e=c.state.loaded(),t=function(e,t,l){if(null!==l&&void 0!==l.select){if(c.rows({selected:!0}).any()&&c.rows().deselect(),void 0!==l.select.rows&&c.rows(l.select.rows).select(),c.columns({selected:!0}).any()&&c.columns().deselect(),void 0!==l.select.columns&&c.columns(l.select.columns).select(),c.cells({selected:!0}).any()&&c.cells().deselect(),void 0!==l.select.cells)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.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}})}).on("stateLoadParams",t).one("init",function(){t(0,0,e)}),s=h.oInit.select,l=_.defaults.select,l=void 0===s?l:s,s="row",r="td, th",d="selected",f=!(u=i=a=!(o=!(n="api"))),h._select={infoEls:[]},!0===l?(n="os",f=!0):"string"==typeof l?(n=l,f=!0):m.isPlainObject(l)&&(void 0!==l.blurable&&(o=l.blurable),void 0!==l.toggleable&&(a=l.toggleable),void 0!==l.info&&(i=l.info),void 0!==l.items&&(s=l.items),f=(n=void 0!==l.style?l.style:"os",!0),void 0!==l.selector&&(r=l.selector),void 0!==l.className&&(d=l.className),void 0!==l.headerCheckbox)&&(u=l.headerCheckbox),c.select.selector(r),c.select.items(s),c.select.style(n),c.select.blurable(o),c.select.toggleable(a),c.select.info(i),h._select.className=d,!f&&m(c.table().node()).hasClass("selectable")&&c.select.style("os"),u&&(p(c),c.on("init",function(){p(c)})))},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(void 0===c)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 w(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 void 0===t?this.context[0]._select.blurable:this.iterator("table",function(e){e._select.blurable=t})}),t("select.toggleable()",function(t){return void 0===t?this.context[0]._select.toggleable:this.iterator("table",function(e){e._select.toggleable=t})}),t("select.info()",function(t){return void 0===t?this.context[0]._select.info:this.iterator("table",function(e){e._select.info=t})}),t("select.items()",function(t){return void 0===t?this.context[0]._select.items:this.iterator("table",function(e){e._select.items=t,d(new _.Api(e),"selectItems",[t])})}),t("select.style()",function(l){return void 0===l?this.context[0]._select.style:this.iterator("table",function(e){e._select||_.select.init(new _.Api(e)),e._select_init||(o=e,c=new _.Api(o),o._select_init=!0,o.aoRowCreatedCallback.push(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)}),c.on("preXhr.dt.dtSelect",function(e,t){var l,s;t===c.settings()[0]&&(l=c.rows({selected:!0}).ids(!0).filter(function(e){return void 0!==e}),s=c.cells({selected:!0}).eq(0).map(function(e){var t=c.row(e.row).id(!0);return t?{row:t,column:e.column}:void 0}).filter(function(e){return void 0!==e}),c.one("draw.dt.dtSelect",function(){c.rows(l).select(),s.any()&&s.each(function(e){c.cells(e.row,e.column).select()})}))}),c.on("info.dt",function(e,t,l){t._select.infoEls.includes(l)||t._select.infoEls.push(l),a(c,l)}),c.on("select.dtSelect.dt deselect.dtSelect.dt",function(){o._select.infoEls.forEach(function(e){a(c,e)}),c.state.save()}),c.on("destroy.dtSelect",function(){m(c.rows({selected:!0}).nodes()).removeClass(c.settings()[0]._select.className),s(c),c.off(".dtSelect"),m("body").off(".dtSelect"+v(c.table().node()))})),e._select.style=l;var o,c,t=new _.Api(e);s(t),"api"!==l&&n(t),d(new _.Api(e),"selectStyle",[l])})}),t("select.selector()",function(t){return void 0===t?this.context[0]._select.selector:this.iterator("table",function(e){s(new _.Api(e)),e._select.selector=t,"api"!==e._select.style&&n(new _.Api(e))})}),t("select.last()",function(e){var t=this.context[0];return e?(t._select_lastCell=e,this):t._select_lastCell}),l("rows().select()","row().select()",function(e){var l=this;return!1===e?this.deselect():(this.iterator("row",function(e,t){f(e);var l=e.aoData[t],s=e.aoColumns;m(l.nTr).addClass(e._select.className),l._select_selected=!0;for(var c=0;c<s.length;c++)"select-checkbox"===s[c].sType&&(m("input.dt-select-checkbox",l.anCells[c]).prop("checked",!0),l._aSortData[c]=null)}),this.iterator("table",function(e,t){d(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){d(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];void 0===t._selected_cells&&(t._selected_cells=[]),t._selected_cells[l]=!0,t.anCells&&m(t.anCells[l]).addClass(e._select.className)}),this.iterator("table",function(e,t){d(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){var l=e.aoData[t],s=e.aoColumns;m(l.nTr).removeClass(e._select.className),l._select_selected=!1,e._select_lastCell=null;for(var c=0;c<s.length;c++)"select-checkbox"===s[c].sType&&(m("input.dt-select-checkbox",l.anCells[c]).prop("checked",!1),l._aSortData[c]=null)}),this.iterator("table",function(e,t){d(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){d(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];void 0!==t._selected_cells&&(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){d(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(w(s),function(){var e,t;c.enable((e=l,!(-1===(t=s).limitTo.indexOf("rows")||!e.rows({selected:!0}).any())||!(-1===t.limitTo.indexOf("columns")||!e.columns({selected:!0}).any())||!(-1===t.limitTo.indexOf("cells")||!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(w(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(e,t,l,s){var c=this.select.items(),n=s.selectorModifier;(n?("function"==typeof n&&(n=n.call(t,e,t,l,s)),this[c+"s"](n)):this[c+"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(w(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)}},showSelected:{text:o("showSelected","Show only selected"),className:"buttons-show-selected",action:function(e,t){var s;t.search.fixed("dt-select")?(t.search.fixed("dt-select",null),this.active(!1)):(s=t.settings()[0].aoData,t.search.fixed("dt-select",function(e,t,l){return s[l]._select_selected}),this.active(!0)),t.draw()}}}),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)})}}}),_.type("select-checkbox",{className:"dt-select",detect:function(e){return"select-checkbox"===e&&e},order:{pre:function(e){return"X"===e?-1:0}}}),m.extend(!0,_.defaults.oLanguage,{select:{aria:{rowCheckbox:"Select row"}}}),_.render.select=function(e,t){var n=e?_.util.get(e):null,o=t?_.util.get(t):null;return function(e,t,l,s){var c=s.settings.aoData[s.row]._select_selected,s=s.settings.oLanguage.select.aria.rowCheckbox;return"display"===t?m("<input>").attr({"aria-label":s,class:"dt-select-checkbox",name:o?o(l):null,type:"checkbox",value:n?n(l):null,checked:c})[0]:"type"===t?"select-checkbox":"filter"!==t&&c?"X":""}},_.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)})},m.fn.DataTable.select=_.select,m(e).on("preInit.dt.dtSelect",function(e,t){"dt"===e.namespace&&_.select.init(new _.Api(t))}),_});
4
+ !function(l){var s,c;"function"==typeof define&&define.amd?define(["jquery","datatables.net"],function(e){return l(e,window,document)}):"object"==typeof exports?(s=require("jquery"),c=function(e,t){t.fn.dataTable||require("datatables.net")(e,t)},"undefined"==typeof window?module.exports=function(e,t){return e=e||window,t=t||s(e),c(e,t),l(t,e,e.document)}:(c(window,s),module.exports=l(s,window,window.document))):l(jQuery,window,document)}(function(m,i,e){"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"+v(e.table().node()))}function n(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.table().container();m(e.target).closest("div.dt-container")[0]==n&&(n=o.cell(m(e.target).closest("td, th"))).any()&&(c=m.Event("user-select.dt"),d(o,c,[l,n,e]),c.isDefaultPrevented()||(c=n.index(),"row"===l?(t=c.row,h(e,o,s,"row",t)):"column"===l?(t=n.index().column,h(e,o,s,"column",t)):"cell"===l&&(t=n.index(),h(e,o,s,"cell",t)),s._select_lastCell=c))}),m("body").on("click.dtSelect"+v(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"),d(o,t,[e.target,e]),t.isDefaultPrevented())||f(l,!0)})}function d(e,t,l,s){s&&!e.flatten().length||("string"==typeof t&&(t+=".dt"),l.unshift(e),m(e.table().node()).trigger(t,l))}function a(s,e){var t,l,c,n,o;"api"!==s.select.style()&&!1!==s.select.info()&&(o=s.rows({selected:!0}).flatten().length,t=s.columns({selected:!0}).flatten().length,l=s.cells({selected:!0}).flatten().length,c=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)))},e=m(e),c(n=m('<span class="select-info"/>'),"row",o),c(n,"column",t),c(n,"cell",l),(o=e.children("span.select-info")).length&&o.remove(),""!==n.text())&&e.append(n)}function p(o){o.columns(".dt-select").every(function(){var n,e=this.header();m("input",e).length||(n=m("<input>").attr({class:"dt-select-checkbox",type:"checkbox","aria-label":o.i18n("select.aria.headerCheckbox")||"Select all rows"}).appendTo(e).on("change",function(){this.checked?o.rows({search:"applied"}).select():o.rows({selected:!0}).deselect()}).on("click",function(e){e.stopPropagation()}),o.on("draw select deselect",function(e,t,l){var s,c;"row"!==l&&l||(l=o.rows({selected:!0}).count(),s=o.rows({search:"applied",selected:!0}).count(),c=o.rows({search:"applied"}).count(),s&&s<=l&&s===c?n.prop("checked",!0).prop("indeterminate",!1):0===s&&0===l?n.prop("checked",!1).prop("indeterminate",!1):n.prop("checked",!1).prop("indeterminate",!0))}))})}function u(e,t,l,s){var c,n=e[t+"s"]({search:"applied"}).indexes(),s=n.indexOf(s),o=n.indexOf(l);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(n.indexOf(l)+1,n.length),e[t](l,{selected:!0}).any()?(n.splice(n.indexOf(l),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 h(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):u(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):u(t,s,c,l._select_lastCell?l._select_lastCell[s]:null):t[s](c).select(!a))}function v(e){return e.id.replace(/[^a-zA-Z0-9\-\_]/g,"-")}_.select={},_.select.version="2.0.1",_.select.init=function(c){var e,t,l,s,n,o,a,i,r,d,u,f,h=c.settings()[0];if(!_.versionCheck("2"))throw"Warning: Select requires DataTables 2 or newer";h._select||(e=c.state.loaded(),t=function(e,t,l){if(null!==l&&void 0!==l.select){if(c.rows({selected:!0}).any()&&c.rows().deselect(),void 0!==l.select.rows&&c.rows(l.select.rows).select(),c.columns({selected:!0}).any()&&c.columns().deselect(),void 0!==l.select.columns&&c.columns(l.select.columns).select(),c.cells({selected:!0}).any()&&c.cells().deselect(),void 0!==l.select.cells)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.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}})}).on("stateLoadParams",t).one("init",function(){t(0,0,e)}),s=h.oInit.select,l=_.defaults.select,l=void 0===s?l:s,s="row",r="td, th",d="selected",f=!(u=i=a=!(o=!(n="api"))),h._select={infoEls:[]},!0===l?(n="os",f=!0):"string"==typeof l?(n=l,f=!0):m.isPlainObject(l)&&(void 0!==l.blurable&&(o=l.blurable),void 0!==l.toggleable&&(a=l.toggleable),void 0!==l.info&&(i=l.info),void 0!==l.items&&(s=l.items),f=(n=void 0!==l.style?l.style:"os",!0),void 0!==l.selector&&(r=l.selector),void 0!==l.className&&(d=l.className),void 0!==l.headerCheckbox)&&(u=l.headerCheckbox),c.select.selector(r),c.select.items(s),c.select.style(n),c.select.blurable(o),c.select.toggleable(a),c.select.info(i),h._select.className=d,!f&&m(c.table().node()).hasClass("selectable")&&c.select.style("os"),u&&(p(c),c.on("init",function(){p(c)})))},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(void 0===c)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 w(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 void 0===t?this.context[0]._select.blurable:this.iterator("table",function(e){e._select.blurable=t})}),t("select.toggleable()",function(t){return void 0===t?this.context[0]._select.toggleable:this.iterator("table",function(e){e._select.toggleable=t})}),t("select.info()",function(t){return void 0===t?this.context[0]._select.info:this.iterator("table",function(e){e._select.info=t})}),t("select.items()",function(t){return void 0===t?this.context[0]._select.items:this.iterator("table",function(e){e._select.items=t,d(new _.Api(e),"selectItems",[t])})}),t("select.style()",function(l){return void 0===l?this.context[0]._select.style:this.iterator("table",function(e){e._select||_.select.init(new _.Api(e)),e._select_init||(o=e,c=new _.Api(o),o._select_init=!0,o.aoRowCreatedCallback.push(function(e,t,l){var s,c,n=o.aoData[l];for(n._select_selected&&m(e).addClass(o._select.className).find("input.dt-select-checkbox").prop("checked",!0),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)}),c.on("preXhr.dt.dtSelect",function(e,t){var l,s;t===c.settings()[0]&&(l=c.rows({selected:!0}).ids(!0).filter(function(e){return void 0!==e}),s=c.cells({selected:!0}).eq(0).map(function(e){var t=c.row(e.row).id(!0);return t?{row:t,column:e.column}:void 0}).filter(function(e){return void 0!==e}),c.one("draw.dt.dtSelect",function(){c.rows(l).select(),s.any()&&s.each(function(e){c.cells(e.row,e.column).select()})}))}),c.on("info.dt",function(e,t,l){t._select.infoEls.includes(l)||t._select.infoEls.push(l),a(c,l)}),c.on("select.dtSelect.dt deselect.dtSelect.dt",function(){o._select.infoEls.forEach(function(e){a(c,e)}),c.state.save()}),c.on("destroy.dtSelect",function(){m(c.rows({selected:!0}).nodes()).removeClass(c.settings()[0]._select.className),s(c),c.off(".dtSelect"),m("body").off(".dtSelect"+v(c.table().node()))})),e._select.style=l;var o,c,t=new _.Api(e);s(t),"api"!==l&&n(t),d(new _.Api(e),"selectStyle",[l])})}),t("select.selector()",function(t){return void 0===t?this.context[0]._select.selector:this.iterator("table",function(e){s(new _.Api(e)),e._select.selector=t,"api"!==e._select.style&&n(new _.Api(e))})}),t("select.last()",function(e){var t=this.context[0];return e?(t._select_lastCell=e,this):t._select_lastCell}),l("rows().select()","row().select()",function(e){var o=this;return!1===e?this.deselect():(this.iterator("row",function(e,t){f(e);var l=e.aoData[t],s=e.aoColumns;m(l.nTr).addClass(e._select.className),l._select_selected=!0;for(var c=0;c<s.length;c++){var n=s[c];null===n.sType&&o.columns().types(),"select-checkbox"===n.sType&&((n=l.anCells)&&n[c]&&m("input.dt-select-checkbox",n[c]).prop("checked",!0),null!==l._aSortData)&&(l._aSortData[c]=null)}}),this.iterator("table",function(e,t){d(o,"select",["row",o[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){d(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];void 0===t._selected_cells&&(t._selected_cells=[]),t._selected_cells[l]=!0,t.anCells&&m(t.anCells[l]).addClass(e._select.className)}),this.iterator("table",function(e,t){d(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 o=this;return this.iterator("row",function(e,t){var l=e.aoData[t],s=e.aoColumns;m(l.nTr).removeClass(e._select.className),l._select_selected=!1,e._select_lastCell=null;for(var c=0;c<s.length;c++){var n=s[c];null===n.sType&&o.columns().types(),"select-checkbox"===n.sType&&((n=l.anCells)&&n[c]&&m("input.dt-select-checkbox",l.anCells[c]).prop("checked",!1),null!==l._aSortData)&&(l._aSortData[c]=null)}}),this.iterator("table",function(e,t){d(o,"deselect",["row",o[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){d(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];void 0!==t._selected_cells&&(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){d(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(w(s),function(){var e,t;c.enable((e=l,!(-1===(t=s).limitTo.indexOf("rows")||!e.rows({selected:!0}).any())||!(-1===t.limitTo.indexOf("columns")||!e.columns({selected:!0}).any())||!(-1===t.limitTo.indexOf("cells")||!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(w(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(e,t,l,s){var c=this.select.items(),n=s.selectorModifier;(n?("function"==typeof n&&(n=n.call(t,e,t,l,s)),this[c+"s"](n)):this[c+"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(w(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)}},showSelected:{text:o("showSelected","Show only selected"),className:"buttons-show-selected",action:function(e,t){var s;t.search.fixed("dt-select")?(t.search.fixed("dt-select",null),this.active(!1)):(s=t.settings()[0].aoData,t.search.fixed("dt-select",function(e,t,l){return s[l]._select_selected}),this.active(!0)),t.draw()}}}),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)})}}}),_.type("select-checkbox",{className:"dt-select",detect:function(e){return"select-checkbox"===e&&e},order:{pre:function(e){return"X"===e?-1:0}}}),m.extend(!0,_.defaults.oLanguage,{select:{aria:{rowCheckbox:"Select row"}}}),_.render.select=function(e,t){var n=e?_.util.get(e):null,o=t?_.util.get(t):null;return function(e,t,l,s){var c=s.settings.aoData[s.row]._select_selected,s=s.settings.oLanguage.select.aria.rowCheckbox;return"display"===t?m("<input>").attr({"aria-label":s,class:"dt-select-checkbox",name:o?o(l):null,type:"checkbox",value:n?n(l):null,checked:c})[0]:"type"===t?"select-checkbox":"filter"!==t&&c?"X":""}},_.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)})},m.fn.DataTable.select=_.select,m(e).on("preInit.dt.dtSelect",function(e,t){"dt"===e.namespace&&_.select.init(new _.Api(t))}),_});
@@ -1,4 +1,4 @@
1
- /*! Select for DataTables 2.0.0
1
+ /*! Select for DataTables 2.0.1
2
2
  * © SpryMedia Ltd - datatables.net/license/mit
3
3
  */
4
- import jQuery from"jquery";import DataTable from"datatables.net";let $=jQuery;function cellRange(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 disableMouseSelection(e){var t=e.settings()[0]._select.selector;$(e.table().container()).off("mousedown.dtSelect",t).off("mouseup.dtSelect",t).off("click.dtSelect",t),$("body").off("click.dtSelect"+_safeId(e.table().node()))}function enableMouseSelection(a){var o,t=$(a.table().container()),l=a.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}),window.getSelection&&(o=window.getSelection())}).on("mouseup.dtSelect",s,function(){t.css("-moz-user-select","")}).on("click.dtSelect",s,function(e){var t,l=a.select.items();if(o){var s=window.getSelection();if((!s.anchorNode||$(s.anchorNode).closest("table")[0]===a.table().node())&&s!==o)return}var c,s=a.settings()[0],n=a.table().container();$(e.target).closest("div.dt-container")[0]==n&&(n=a.cell($(e.target).closest("td, th"))).any()&&(c=$.Event("user-select.dt"),eventTrigger(a,c,[l,n,e]),c.isDefaultPrevented()||(c=n.index(),"row"===l?(t=c.row,typeSelect(e,a,s,"row",t)):"column"===l?(t=n.index().column,typeSelect(e,a,s,"column",t)):"cell"===l&&(t=n.index(),typeSelect(e,a,s,"cell",t)),s._select_lastCell=c))}),$("body").on("click.dtSelect"+_safeId(a.table().node()),function(e){var t;!l._select.blurable||$(e.target).parents().filter(a.table().container()).length||0===$(e.target).parents("html").length||$(e.target).parents("div.DTE").length||(t=$.Event("select-blur.dt"),eventTrigger(a,t,[e.target,e]),t.isDefaultPrevented())||clear(l,!0)})}function eventTrigger(e,t,l,s){s&&!e.flatten().length||("string"==typeof t&&(t+=".dt"),l.unshift(e),$(e.table().node()).trigger(t,l))}function info(s,e){var t,l,c,n,a;"api"!==s.select.style()&&!1!==s.select.info()&&(a=s.rows({selected:!0}).flatten().length,t=s.columns({selected:!0}).flatten().length,l=s.cells({selected:!0}).flatten().length,c=function(e,t,l){e.append($('<span class="select-item"/>').append(s.i18n("select."+t+"s",{_:"%d "+t+"s selected",0:"",1:"1 "+t+" selected"},l)))},e=$(e),c(n=$('<span class="select-info"/>'),"row",a),c(n,"column",t),c(n,"cell",l),(a=e.children("span.select-info")).length&&a.remove(),""!==n.text())&&e.append(n)}function initCheckboxHeader(a){a.columns(".dt-select").every(function(){var n,e=this.header();$("input",e).length||(n=$("<input>").attr({class:"dt-select-checkbox",type:"checkbox","aria-label":a.i18n("select.aria.headerCheckbox")||"Select all rows"}).appendTo(e).on("change",function(){this.checked?a.rows({search:"applied"}).select():a.rows({selected:!0}).deselect()}).on("click",function(e){e.stopPropagation()}),a.on("draw select deselect",function(e,t,l){var s,c;"row"!==l&&l||(l=a.rows({selected:!0}).count(),s=a.rows({search:"applied",selected:!0}).count(),c=a.rows({search:"applied"}).count(),s&&s<=l&&s===c?n.prop("checked",!0).prop("indeterminate",!1):0===s&&0===l?n.prop("checked",!1).prop("indeterminate",!1):n.prop("checked",!1).prop("indeterminate",!0))}))})}function init(a){var c=new DataTable.Api(a);a._select_init=!0,a.aoRowCreatedCallback.push(function(e,t,l){var s,c,n=a.aoData[l];for(n._select_selected&&$(e).addClass(a._select.className),s=0,c=a.aoColumns.length;s<c;s++)(a.aoColumns[s]._select_selected||n._selected_cells&&n._selected_cells[s])&&$(n.anCells[s]).addClass(a._select.className)}),c.on("preXhr.dt.dtSelect",function(e,t){var l,s;t===c.settings()[0]&&(l=c.rows({selected:!0}).ids(!0).filter(function(e){return void 0!==e}),s=c.cells({selected:!0}).eq(0).map(function(e){var t=c.row(e.row).id(!0);return t?{row:t,column:e.column}:void 0}).filter(function(e){return void 0!==e}),c.one("draw.dt.dtSelect",function(){c.rows(l).select(),s.any()&&s.each(function(e){c.cells(e.row,e.column).select()})}))}),c.on("info.dt",function(e,t,l){t._select.infoEls.includes(l)||t._select.infoEls.push(l),info(c,l)}),c.on("select.dtSelect.dt deselect.dtSelect.dt",function(){a._select.infoEls.forEach(function(e){info(c,e)}),c.state.save()}),c.on("destroy.dtSelect",function(){$(c.rows({selected:!0}).nodes()).removeClass(c.settings()[0]._select.className),disableMouseSelection(c),c.off(".dtSelect"),$("body").off(".dtSelect"+_safeId(c.table().node()))})}function rowColumnRange(e,t,l,s){var c,n=e[t+"s"]({search:"applied"}).indexes(),s=n.indexOf(s),a=n.indexOf(l);e[t+"s"]({selected:!0}).any()||-1!==s?(a<s&&(c=a,a=s,s=c),n.splice(a+1,n.length),n.splice(0,s)):n.splice(n.indexOf(l)+1,n.length),e[t](l,{selected:!0}).any()?(n.splice(n.indexOf(l),1),e[t+"s"](n).deselect()):e[t+"s"](n).select()}function clear(e,t){!t&&"single"!==e._select.style||((t=new DataTable.Api(e)).rows({selected:!0}).deselect(),t.columns({selected:!0}).deselect(),t.cells({selected:!0}).deselect())}function typeSelect(e,t,l,s,c){var n=t.select.style(),a=t.select.toggleable(),o=t[s](c,{selected:!0}).any();o&&!a||("os"===n?e.ctrlKey||e.metaKey?t[s](c).select(!o):e.shiftKey?"cell"===s?cellRange(t,c,l._select_lastCell||null):rowColumnRange(t,s,c,l._select_lastCell?l._select_lastCell[s]:null):(a=t[s+"s"]({selected:!0}),o&&1===a.flatten().length?t[s](c).deselect():(a.deselect(),t[s](c).select())):"multi+shift"==n&&e.shiftKey?"cell"===s?cellRange(t,c,l._select_lastCell||null):rowColumnRange(t,s,c,l._select_lastCell?l._select_lastCell[s]:null):t[s](c).select(!o))}function _safeId(e){return e.id.replace(/[^a-zA-Z0-9\-\_]/g,"-")}DataTable.select={},DataTable.select.version="2.0.0",DataTable.select.init=function(c){var e,t,l,s,n,a,o,i,r,d,u,f,h=c.settings()[0];if(!DataTable.versionCheck("2"))throw"Warning: Select requires DataTables 2 or newer";h._select||(e=c.state.loaded(),t=function(e,t,l){if(null!==l&&void 0!==l.select){if(c.rows({selected:!0}).any()&&c.rows().deselect(),void 0!==l.select.rows&&c.rows(l.select.rows).select(),c.columns({selected:!0}).any()&&c.columns().deselect(),void 0!==l.select.columns&&c.columns(l.select.columns).select(),c.cells({selected:!0}).any()&&c.cells().deselect(),void 0!==l.select.cells)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.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}})}).on("stateLoadParams",t).one("init",function(){t(0,0,e)}),s=h.oInit.select,l=DataTable.defaults.select,l=void 0===s?l:s,s="row",r="td, th",d="selected",f=!(u=i=o=!(a=!(n="api"))),h._select={infoEls:[]},!0===l?(n="os",f=!0):"string"==typeof l?(n=l,f=!0):$.isPlainObject(l)&&(void 0!==l.blurable&&(a=l.blurable),void 0!==l.toggleable&&(o=l.toggleable),void 0!==l.info&&(i=l.info),void 0!==l.items&&(s=l.items),f=(n=void 0!==l.style?l.style:"os",!0),void 0!==l.selector&&(r=l.selector),void 0!==l.className&&(d=l.className),void 0!==l.headerCheckbox)&&(u=l.headerCheckbox),c.select.selector(r),c.select.items(s),c.select.style(n),c.select.blurable(a),c.select.toggleable(o),c.select.info(i),h._select.className=d,!f&&$(c.table().node()).hasClass("selectable")&&c.select.style("os"),u&&(initCheckboxHeader(c),c.on("init",function(){initCheckboxHeader(c)})))},$.each([{type:"row",prop:"aoData"},{type:"column",prop:"aoColumns"}],function(e,i){DataTable.ext.selector[i.type].push(function(e,t,l){var s,c=t.selected,n=[];if(!0!==c&&!1!==c)return l;for(var a=0,o=l.length;a<o;a++)(s=e[i.prop][l[a]])&&(!0===c&&!0===s._select_selected||!1===c&&!s._select_selected)&&n.push(l[a]);return n})}),DataTable.ext.selector.cell.push(function(e,t,l){var s,c=t.selected,n=[];if(void 0===c)return l;for(var a=0,o=l.length;a<o;a++)(s=e.aoData[l[a].row])&&(!0===c&&s._selected_cells&&!0===s._selected_cells[l[a].column]||!1===c&&(!s._selected_cells||!s._selected_cells[l[a].column]))&&n.push(l[a]);return n});var apiRegister=DataTable.Api.register,apiRegisterPlural=DataTable.Api.registerPlural;function i18n(t,l){return function(e){return e.i18n("buttons."+t,l)}}function namespacedEvents(e){e=e._eventNamespace;return"draw.dt.DT"+e+" select.dt.DT"+e+" deselect.dt.DT"+e}function enabled(e,t){return!(-1===t.limitTo.indexOf("rows")||!e.rows({selected:!0}).any())||!(-1===t.limitTo.indexOf("columns")||!e.columns({selected:!0}).any())||!(-1===t.limitTo.indexOf("cells")||!e.cells({selected:!0}).any())}apiRegister("select()",function(){return this.iterator("table",function(e){DataTable.select.init(new DataTable.Api(e))})}),apiRegister("select.blurable()",function(t){return void 0===t?this.context[0]._select.blurable:this.iterator("table",function(e){e._select.blurable=t})}),apiRegister("select.toggleable()",function(t){return void 0===t?this.context[0]._select.toggleable:this.iterator("table",function(e){e._select.toggleable=t})}),apiRegister("select.info()",function(t){return void 0===t?this.context[0]._select.info:this.iterator("table",function(e){e._select.info=t})}),apiRegister("select.items()",function(t){return void 0===t?this.context[0]._select.items:this.iterator("table",function(e){e._select.items=t,eventTrigger(new DataTable.Api(e),"selectItems",[t])})}),apiRegister("select.style()",function(l){return void 0===l?this.context[0]._select.style:this.iterator("table",function(e){e._select||DataTable.select.init(new DataTable.Api(e)),e._select_init||init(e),e._select.style=l;var t=new DataTable.Api(e);disableMouseSelection(t),"api"!==l&&enableMouseSelection(t),eventTrigger(new DataTable.Api(e),"selectStyle",[l])})}),apiRegister("select.selector()",function(t){return void 0===t?this.context[0]._select.selector:this.iterator("table",function(e){disableMouseSelection(new DataTable.Api(e)),e._select.selector=t,"api"!==e._select.style&&enableMouseSelection(new DataTable.Api(e))})}),apiRegister("select.last()",function(e){var t=this.context[0];return e?(t._select_lastCell=e,this):t._select_lastCell}),apiRegisterPlural("rows().select()","row().select()",function(e){var l=this;return!1===e?this.deselect():(this.iterator("row",function(e,t){clear(e);var l=e.aoData[t],s=e.aoColumns;$(l.nTr).addClass(e._select.className),l._select_selected=!0;for(var c=0;c<s.length;c++)"select-checkbox"===s[c].sType&&($("input.dt-select-checkbox",l.anCells[c]).prop("checked",!0),l._aSortData[c]=null)}),this.iterator("table",function(e,t){eventTrigger(l,"select",["row",l[t]],!0)}),this)}),apiRegister("row().selected()",function(){var e=this.context[0];return!!(e&&this.length&&e.aoData[this[0]]&&e.aoData[this[0]]._select_selected)}),apiRegisterPlural("columns().select()","column().select()",function(e){var l=this;return!1===e?this.deselect():(this.iterator("column",function(e,t){clear(e),e.aoColumns[t]._select_selected=!0;t=new DataTable.Api(e).column(t);$(t.header()).addClass(e._select.className),$(t.footer()).addClass(e._select.className),t.nodes().to$().addClass(e._select.className)}),this.iterator("table",function(e,t){eventTrigger(l,"select",["column",l[t]],!0)}),this)}),apiRegister("column().selected()",function(){var e=this.context[0];return!!(e&&this.length&&e.aoColumns[this[0]]&&e.aoColumns[this[0]]._select_selected)}),apiRegisterPlural("cells().select()","cell().select()",function(e){var l=this;return!1===e?this.deselect():(this.iterator("cell",function(e,t,l){clear(e);t=e.aoData[t];void 0===t._selected_cells&&(t._selected_cells=[]),t._selected_cells[l]=!0,t.anCells&&$(t.anCells[l]).addClass(e._select.className)}),this.iterator("table",function(e,t){eventTrigger(l,"select",["cell",l.cells(l[t]).indexes().toArray()],!0)}),this)}),apiRegister("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}),apiRegisterPlural("rows().deselect()","row().deselect()",function(){var l=this;return this.iterator("row",function(e,t){var l=e.aoData[t],s=e.aoColumns;$(l.nTr).removeClass(e._select.className),l._select_selected=!1,e._select_lastCell=null;for(var c=0;c<s.length;c++)"select-checkbox"===s[c].sType&&($("input.dt-select-checkbox",l.anCells[c]).prop("checked",!1),l._aSortData[c]=null)}),this.iterator("table",function(e,t){eventTrigger(l,"deselect",["row",l[t]],!0)}),this}),apiRegisterPlural("columns().deselect()","column().deselect()",function(){var l=this;return this.iterator("column",function(s,e){s.aoColumns[e]._select_selected=!1;var t=new DataTable.Api(s),l=t.column(e);$(l.header()).removeClass(s._select.className),$(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]||$(t.anCells[e.column]).removeClass(s._select.className)})}),this.iterator("table",function(e,t){eventTrigger(l,"deselect",["column",l[t]],!0)}),this}),apiRegisterPlural("cells().deselect()","cell().deselect()",function(){var l=this;return this.iterator("cell",function(e,t,l){t=e.aoData[t];void 0!==t._selected_cells&&(t._selected_cells[l]=!1),t.anCells&&!e.aoColumns[l]._select_selected&&$(t.anCells[l]).removeClass(e._select.className)}),this.iterator("table",function(e,t){eventTrigger(l,"deselect",["cell",l[t]],!0)}),this});var _buttonNamespace=0;$.extend(DataTable.ext.buttons,{selected:{text:i18n("selected","Selected"),className:"buttons-selected",limitTo:["rows","columns","cells"],init:function(e,t,l){var s=this;l._eventNamespace=".select"+_buttonNamespace++,e.on(namespacedEvents(l),function(){s.enable(enabled(e,l))}),this.disable()},destroy:function(e,t,l){e.off(l._eventNamespace)}},selectedSingle:{text:i18n("selectedSingle","Selected single"),className:"buttons-selected-single",init:function(t,e,l){var s=this;l._eventNamespace=".select"+_buttonNamespace++,t.on(namespacedEvents(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:i18n("selectAll","Select all"),className:"buttons-select-all",action:function(e,t,l,s){var c=this.select.items(),n=s.selectorModifier;(n?("function"==typeof n&&(n=n.call(t,e,t,l,s)),this[c+"s"](n)):this[c+"s"]()).select()}},selectNone:{text:i18n("selectNone","Deselect all"),className:"buttons-select-none",action:function(){clear(this.settings()[0],!0)},init:function(t,e,l){var s=this;l._eventNamespace=".select"+_buttonNamespace++,t.on(namespacedEvents(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)}},showSelected:{text:i18n("showSelected","Show only selected"),className:"buttons-show-selected",action:function(e,t){var s;t.search.fixed("dt-select")?(t.search.fixed("dt-select",null),this.active(!1)):(s=t.settings()[0].aoData,t.search.fixed("dt-select",function(e,t,l){return s[l]._select_selected}),this.active(!0)),t.draw()}}}),$.each(["Row","Column","Cell"],function(e,t){var c=t.toLowerCase();DataTable.ext.buttons["select"+t+"s"]={text:i18n("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)})}}}),DataTable.type("select-checkbox",{className:"dt-select",detect:function(e){return"select-checkbox"===e&&e},order:{pre:function(e){return"X"===e?-1:0}}}),$.extend(!0,DataTable.defaults.oLanguage,{select:{aria:{rowCheckbox:"Select row"}}}),DataTable.render.select=function(e,t){var n=e?DataTable.util.get(e):null,a=t?DataTable.util.get(t):null;return function(e,t,l,s){var c=s.settings.aoData[s.row]._select_selected,s=s.settings.oLanguage.select.aria.rowCheckbox;return"display"===t?$("<input>").attr({"aria-label":s,class:"dt-select-checkbox",name:a?a(l):null,type:"checkbox",value:n?n(l):null,checked:c})[0]:"type"===t?"select-checkbox":"filter"!==t&&c?"X":""}},DataTable.ext.order["select-checkbox"]=function(t,e){return this.api().column(e,{order:"index"}).nodes().map(function(e){return"row"===t._select.items?$(e).parent().hasClass(t._select.className):"cell"===t._select.items&&$(e).hasClass(t._select.className)})},$.fn.DataTable.select=DataTable.select,$(document).on("preInit.dt.dtSelect",function(e,t){"dt"===e.namespace&&DataTable.select.init(new DataTable.Api(t))});export default DataTable;
4
+ import jQuery from"jquery";import DataTable from"datatables.net";let $=jQuery;function cellRange(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 disableMouseSelection(e){var t=e.settings()[0]._select.selector;$(e.table().container()).off("mousedown.dtSelect",t).off("mouseup.dtSelect",t).off("click.dtSelect",t),$("body").off("click.dtSelect"+_safeId(e.table().node()))}function enableMouseSelection(a){var o,t=$(a.table().container()),l=a.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}),window.getSelection&&(o=window.getSelection())}).on("mouseup.dtSelect",s,function(){t.css("-moz-user-select","")}).on("click.dtSelect",s,function(e){var t,l=a.select.items();if(o){var s=window.getSelection();if((!s.anchorNode||$(s.anchorNode).closest("table")[0]===a.table().node())&&s!==o)return}var c,s=a.settings()[0],n=a.table().container();$(e.target).closest("div.dt-container")[0]==n&&(n=a.cell($(e.target).closest("td, th"))).any()&&(c=$.Event("user-select.dt"),eventTrigger(a,c,[l,n,e]),c.isDefaultPrevented()||(c=n.index(),"row"===l?(t=c.row,typeSelect(e,a,s,"row",t)):"column"===l?(t=n.index().column,typeSelect(e,a,s,"column",t)):"cell"===l&&(t=n.index(),typeSelect(e,a,s,"cell",t)),s._select_lastCell=c))}),$("body").on("click.dtSelect"+_safeId(a.table().node()),function(e){var t;!l._select.blurable||$(e.target).parents().filter(a.table().container()).length||0===$(e.target).parents("html").length||$(e.target).parents("div.DTE").length||(t=$.Event("select-blur.dt"),eventTrigger(a,t,[e.target,e]),t.isDefaultPrevented())||clear(l,!0)})}function eventTrigger(e,t,l,s){s&&!e.flatten().length||("string"==typeof t&&(t+=".dt"),l.unshift(e),$(e.table().node()).trigger(t,l))}function info(s,e){var t,l,c,n,a;"api"!==s.select.style()&&!1!==s.select.info()&&(a=s.rows({selected:!0}).flatten().length,t=s.columns({selected:!0}).flatten().length,l=s.cells({selected:!0}).flatten().length,c=function(e,t,l){e.append($('<span class="select-item"/>').append(s.i18n("select."+t+"s",{_:"%d "+t+"s selected",0:"",1:"1 "+t+" selected"},l)))},e=$(e),c(n=$('<span class="select-info"/>'),"row",a),c(n,"column",t),c(n,"cell",l),(a=e.children("span.select-info")).length&&a.remove(),""!==n.text())&&e.append(n)}function initCheckboxHeader(a){a.columns(".dt-select").every(function(){var n,e=this.header();$("input",e).length||(n=$("<input>").attr({class:"dt-select-checkbox",type:"checkbox","aria-label":a.i18n("select.aria.headerCheckbox")||"Select all rows"}).appendTo(e).on("change",function(){this.checked?a.rows({search:"applied"}).select():a.rows({selected:!0}).deselect()}).on("click",function(e){e.stopPropagation()}),a.on("draw select deselect",function(e,t,l){var s,c;"row"!==l&&l||(l=a.rows({selected:!0}).count(),s=a.rows({search:"applied",selected:!0}).count(),c=a.rows({search:"applied"}).count(),s&&s<=l&&s===c?n.prop("checked",!0).prop("indeterminate",!1):0===s&&0===l?n.prop("checked",!1).prop("indeterminate",!1):n.prop("checked",!1).prop("indeterminate",!0))}))})}function init(a){var c=new DataTable.Api(a);a._select_init=!0,a.aoRowCreatedCallback.push(function(e,t,l){var s,c,n=a.aoData[l];for(n._select_selected&&$(e).addClass(a._select.className).find("input.dt-select-checkbox").prop("checked",!0),s=0,c=a.aoColumns.length;s<c;s++)(a.aoColumns[s]._select_selected||n._selected_cells&&n._selected_cells[s])&&$(n.anCells[s]).addClass(a._select.className)}),c.on("preXhr.dt.dtSelect",function(e,t){var l,s;t===c.settings()[0]&&(l=c.rows({selected:!0}).ids(!0).filter(function(e){return void 0!==e}),s=c.cells({selected:!0}).eq(0).map(function(e){var t=c.row(e.row).id(!0);return t?{row:t,column:e.column}:void 0}).filter(function(e){return void 0!==e}),c.one("draw.dt.dtSelect",function(){c.rows(l).select(),s.any()&&s.each(function(e){c.cells(e.row,e.column).select()})}))}),c.on("info.dt",function(e,t,l){t._select.infoEls.includes(l)||t._select.infoEls.push(l),info(c,l)}),c.on("select.dtSelect.dt deselect.dtSelect.dt",function(){a._select.infoEls.forEach(function(e){info(c,e)}),c.state.save()}),c.on("destroy.dtSelect",function(){$(c.rows({selected:!0}).nodes()).removeClass(c.settings()[0]._select.className),disableMouseSelection(c),c.off(".dtSelect"),$("body").off(".dtSelect"+_safeId(c.table().node()))})}function rowColumnRange(e,t,l,s){var c,n=e[t+"s"]({search:"applied"}).indexes(),s=n.indexOf(s),a=n.indexOf(l);e[t+"s"]({selected:!0}).any()||-1!==s?(a<s&&(c=a,a=s,s=c),n.splice(a+1,n.length),n.splice(0,s)):n.splice(n.indexOf(l)+1,n.length),e[t](l,{selected:!0}).any()?(n.splice(n.indexOf(l),1),e[t+"s"](n).deselect()):e[t+"s"](n).select()}function clear(e,t){!t&&"single"!==e._select.style||((t=new DataTable.Api(e)).rows({selected:!0}).deselect(),t.columns({selected:!0}).deselect(),t.cells({selected:!0}).deselect())}function typeSelect(e,t,l,s,c){var n=t.select.style(),a=t.select.toggleable(),o=t[s](c,{selected:!0}).any();o&&!a||("os"===n?e.ctrlKey||e.metaKey?t[s](c).select(!o):e.shiftKey?"cell"===s?cellRange(t,c,l._select_lastCell||null):rowColumnRange(t,s,c,l._select_lastCell?l._select_lastCell[s]:null):(a=t[s+"s"]({selected:!0}),o&&1===a.flatten().length?t[s](c).deselect():(a.deselect(),t[s](c).select())):"multi+shift"==n&&e.shiftKey?"cell"===s?cellRange(t,c,l._select_lastCell||null):rowColumnRange(t,s,c,l._select_lastCell?l._select_lastCell[s]:null):t[s](c).select(!o))}function _safeId(e){return e.id.replace(/[^a-zA-Z0-9\-\_]/g,"-")}DataTable.select={},DataTable.select.version="2.0.1",DataTable.select.init=function(c){var e,t,l,s,n,a,o,i,r,d,u,f,h=c.settings()[0];if(!DataTable.versionCheck("2"))throw"Warning: Select requires DataTables 2 or newer";h._select||(e=c.state.loaded(),t=function(e,t,l){if(null!==l&&void 0!==l.select){if(c.rows({selected:!0}).any()&&c.rows().deselect(),void 0!==l.select.rows&&c.rows(l.select.rows).select(),c.columns({selected:!0}).any()&&c.columns().deselect(),void 0!==l.select.columns&&c.columns(l.select.columns).select(),c.cells({selected:!0}).any()&&c.cells().deselect(),void 0!==l.select.cells)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.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}})}).on("stateLoadParams",t).one("init",function(){t(0,0,e)}),s=h.oInit.select,l=DataTable.defaults.select,l=void 0===s?l:s,s="row",r="td, th",d="selected",f=!(u=i=o=!(a=!(n="api"))),h._select={infoEls:[]},!0===l?(n="os",f=!0):"string"==typeof l?(n=l,f=!0):$.isPlainObject(l)&&(void 0!==l.blurable&&(a=l.blurable),void 0!==l.toggleable&&(o=l.toggleable),void 0!==l.info&&(i=l.info),void 0!==l.items&&(s=l.items),f=(n=void 0!==l.style?l.style:"os",!0),void 0!==l.selector&&(r=l.selector),void 0!==l.className&&(d=l.className),void 0!==l.headerCheckbox)&&(u=l.headerCheckbox),c.select.selector(r),c.select.items(s),c.select.style(n),c.select.blurable(a),c.select.toggleable(o),c.select.info(i),h._select.className=d,!f&&$(c.table().node()).hasClass("selectable")&&c.select.style("os"),u&&(initCheckboxHeader(c),c.on("init",function(){initCheckboxHeader(c)})))},$.each([{type:"row",prop:"aoData"},{type:"column",prop:"aoColumns"}],function(e,i){DataTable.ext.selector[i.type].push(function(e,t,l){var s,c=t.selected,n=[];if(!0!==c&&!1!==c)return l;for(var a=0,o=l.length;a<o;a++)(s=e[i.prop][l[a]])&&(!0===c&&!0===s._select_selected||!1===c&&!s._select_selected)&&n.push(l[a]);return n})}),DataTable.ext.selector.cell.push(function(e,t,l){var s,c=t.selected,n=[];if(void 0===c)return l;for(var a=0,o=l.length;a<o;a++)(s=e.aoData[l[a].row])&&(!0===c&&s._selected_cells&&!0===s._selected_cells[l[a].column]||!1===c&&(!s._selected_cells||!s._selected_cells[l[a].column]))&&n.push(l[a]);return n});var apiRegister=DataTable.Api.register,apiRegisterPlural=DataTable.Api.registerPlural;function i18n(t,l){return function(e){return e.i18n("buttons."+t,l)}}function namespacedEvents(e){e=e._eventNamespace;return"draw.dt.DT"+e+" select.dt.DT"+e+" deselect.dt.DT"+e}function enabled(e,t){return!(-1===t.limitTo.indexOf("rows")||!e.rows({selected:!0}).any())||!(-1===t.limitTo.indexOf("columns")||!e.columns({selected:!0}).any())||!(-1===t.limitTo.indexOf("cells")||!e.cells({selected:!0}).any())}apiRegister("select()",function(){return this.iterator("table",function(e){DataTable.select.init(new DataTable.Api(e))})}),apiRegister("select.blurable()",function(t){return void 0===t?this.context[0]._select.blurable:this.iterator("table",function(e){e._select.blurable=t})}),apiRegister("select.toggleable()",function(t){return void 0===t?this.context[0]._select.toggleable:this.iterator("table",function(e){e._select.toggleable=t})}),apiRegister("select.info()",function(t){return void 0===t?this.context[0]._select.info:this.iterator("table",function(e){e._select.info=t})}),apiRegister("select.items()",function(t){return void 0===t?this.context[0]._select.items:this.iterator("table",function(e){e._select.items=t,eventTrigger(new DataTable.Api(e),"selectItems",[t])})}),apiRegister("select.style()",function(l){return void 0===l?this.context[0]._select.style:this.iterator("table",function(e){e._select||DataTable.select.init(new DataTable.Api(e)),e._select_init||init(e),e._select.style=l;var t=new DataTable.Api(e);disableMouseSelection(t),"api"!==l&&enableMouseSelection(t),eventTrigger(new DataTable.Api(e),"selectStyle",[l])})}),apiRegister("select.selector()",function(t){return void 0===t?this.context[0]._select.selector:this.iterator("table",function(e){disableMouseSelection(new DataTable.Api(e)),e._select.selector=t,"api"!==e._select.style&&enableMouseSelection(new DataTable.Api(e))})}),apiRegister("select.last()",function(e){var t=this.context[0];return e?(t._select_lastCell=e,this):t._select_lastCell}),apiRegisterPlural("rows().select()","row().select()",function(e){var a=this;return!1===e?this.deselect():(this.iterator("row",function(e,t){clear(e);var l=e.aoData[t],s=e.aoColumns;$(l.nTr).addClass(e._select.className),l._select_selected=!0;for(var c=0;c<s.length;c++){var n=s[c];null===n.sType&&a.columns().types(),"select-checkbox"===n.sType&&((n=l.anCells)&&n[c]&&$("input.dt-select-checkbox",n[c]).prop("checked",!0),null!==l._aSortData)&&(l._aSortData[c]=null)}}),this.iterator("table",function(e,t){eventTrigger(a,"select",["row",a[t]],!0)}),this)}),apiRegister("row().selected()",function(){var e=this.context[0];return!!(e&&this.length&&e.aoData[this[0]]&&e.aoData[this[0]]._select_selected)}),apiRegisterPlural("columns().select()","column().select()",function(e){var l=this;return!1===e?this.deselect():(this.iterator("column",function(e,t){clear(e),e.aoColumns[t]._select_selected=!0;t=new DataTable.Api(e).column(t);$(t.header()).addClass(e._select.className),$(t.footer()).addClass(e._select.className),t.nodes().to$().addClass(e._select.className)}),this.iterator("table",function(e,t){eventTrigger(l,"select",["column",l[t]],!0)}),this)}),apiRegister("column().selected()",function(){var e=this.context[0];return!!(e&&this.length&&e.aoColumns[this[0]]&&e.aoColumns[this[0]]._select_selected)}),apiRegisterPlural("cells().select()","cell().select()",function(e){var l=this;return!1===e?this.deselect():(this.iterator("cell",function(e,t,l){clear(e);t=e.aoData[t];void 0===t._selected_cells&&(t._selected_cells=[]),t._selected_cells[l]=!0,t.anCells&&$(t.anCells[l]).addClass(e._select.className)}),this.iterator("table",function(e,t){eventTrigger(l,"select",["cell",l.cells(l[t]).indexes().toArray()],!0)}),this)}),apiRegister("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}),apiRegisterPlural("rows().deselect()","row().deselect()",function(){var a=this;return this.iterator("row",function(e,t){var l=e.aoData[t],s=e.aoColumns;$(l.nTr).removeClass(e._select.className),l._select_selected=!1,e._select_lastCell=null;for(var c=0;c<s.length;c++){var n=s[c];null===n.sType&&a.columns().types(),"select-checkbox"===n.sType&&((n=l.anCells)&&n[c]&&$("input.dt-select-checkbox",l.anCells[c]).prop("checked",!1),null!==l._aSortData)&&(l._aSortData[c]=null)}}),this.iterator("table",function(e,t){eventTrigger(a,"deselect",["row",a[t]],!0)}),this}),apiRegisterPlural("columns().deselect()","column().deselect()",function(){var l=this;return this.iterator("column",function(s,e){s.aoColumns[e]._select_selected=!1;var t=new DataTable.Api(s),l=t.column(e);$(l.header()).removeClass(s._select.className),$(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]||$(t.anCells[e.column]).removeClass(s._select.className)})}),this.iterator("table",function(e,t){eventTrigger(l,"deselect",["column",l[t]],!0)}),this}),apiRegisterPlural("cells().deselect()","cell().deselect()",function(){var l=this;return this.iterator("cell",function(e,t,l){t=e.aoData[t];void 0!==t._selected_cells&&(t._selected_cells[l]=!1),t.anCells&&!e.aoColumns[l]._select_selected&&$(t.anCells[l]).removeClass(e._select.className)}),this.iterator("table",function(e,t){eventTrigger(l,"deselect",["cell",l[t]],!0)}),this});var _buttonNamespace=0;$.extend(DataTable.ext.buttons,{selected:{text:i18n("selected","Selected"),className:"buttons-selected",limitTo:["rows","columns","cells"],init:function(e,t,l){var s=this;l._eventNamespace=".select"+_buttonNamespace++,e.on(namespacedEvents(l),function(){s.enable(enabled(e,l))}),this.disable()},destroy:function(e,t,l){e.off(l._eventNamespace)}},selectedSingle:{text:i18n("selectedSingle","Selected single"),className:"buttons-selected-single",init:function(t,e,l){var s=this;l._eventNamespace=".select"+_buttonNamespace++,t.on(namespacedEvents(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:i18n("selectAll","Select all"),className:"buttons-select-all",action:function(e,t,l,s){var c=this.select.items(),n=s.selectorModifier;(n?("function"==typeof n&&(n=n.call(t,e,t,l,s)),this[c+"s"](n)):this[c+"s"]()).select()}},selectNone:{text:i18n("selectNone","Deselect all"),className:"buttons-select-none",action:function(){clear(this.settings()[0],!0)},init:function(t,e,l){var s=this;l._eventNamespace=".select"+_buttonNamespace++,t.on(namespacedEvents(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)}},showSelected:{text:i18n("showSelected","Show only selected"),className:"buttons-show-selected",action:function(e,t){var s;t.search.fixed("dt-select")?(t.search.fixed("dt-select",null),this.active(!1)):(s=t.settings()[0].aoData,t.search.fixed("dt-select",function(e,t,l){return s[l]._select_selected}),this.active(!0)),t.draw()}}}),$.each(["Row","Column","Cell"],function(e,t){var c=t.toLowerCase();DataTable.ext.buttons["select"+t+"s"]={text:i18n("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)})}}}),DataTable.type("select-checkbox",{className:"dt-select",detect:function(e){return"select-checkbox"===e&&e},order:{pre:function(e){return"X"===e?-1:0}}}),$.extend(!0,DataTable.defaults.oLanguage,{select:{aria:{rowCheckbox:"Select row"}}}),DataTable.render.select=function(e,t){var n=e?DataTable.util.get(e):null,a=t?DataTable.util.get(t):null;return function(e,t,l,s){var c=s.settings.aoData[s.row]._select_selected,s=s.settings.oLanguage.select.aria.rowCheckbox;return"display"===t?$("<input>").attr({"aria-label":s,class:"dt-select-checkbox",name:a?a(l):null,type:"checkbox",value:n?n(l):null,checked:c})[0]:"type"===t?"select-checkbox":"filter"!==t&&c?"X":""}},DataTable.ext.order["select-checkbox"]=function(t,e){return this.api().column(e,{order:"index"}).nodes().map(function(e){return"row"===t._select.items?$(e).parent().hasClass(t._select.className):"cell"===t._select.items&&$(e).hasClass(t._select.className)})},$.fn.DataTable.select=DataTable.select,$(document).on("preInit.dt.dtSelect",function(e,t){"dt"===e.namespace&&DataTable.select.init(new DataTable.Api(t))});export default DataTable;
@@ -1,4 +1,4 @@
1
- /*! Select for DataTables 2.0.0
1
+ /*! Select for DataTables 2.0.1
2
2
  * © SpryMedia Ltd - datatables.net/license/mit
3
3
  */
4
4
 
@@ -12,7 +12,7 @@ let $ = jQuery;
12
12
  // Version information for debugger
13
13
  DataTable.select = {};
14
14
 
15
- DataTable.select.version = '2.0.0';
15
+ DataTable.select.version = '2.0.1';
16
16
 
17
17
  DataTable.select.init = function (dt) {
18
18
  var ctx = dt.settings()[0];
@@ -627,7 +627,9 @@ function init(ctx) {
627
627
 
628
628
  // Row
629
629
  if (d._select_selected) {
630
- $(row).addClass(ctx._select.className);
630
+ $(row)
631
+ .addClass(ctx._select.className)
632
+ .find('input.dt-select-checkbox').prop('checked', true);
631
633
  }
632
634
 
633
635
  // Cells and columns - if separated out, we would need to do two
@@ -637,7 +639,7 @@ function init(ctx) {
637
639
  ctx.aoColumns[i]._select_selected ||
638
640
  (d._selected_cells && d._selected_cells[i])
639
641
  ) {
640
- $(d.anCells[i]).addClass(ctx._select.className);
642
+ $(d.anCells[i]).addClass(ctx._select.className)
641
643
  }
642
644
  }
643
645
  }
@@ -1060,12 +1062,23 @@ apiRegisterPlural('rows().select()', 'row().select()', function (select) {
1060
1062
  for (var i=0 ; i<dtColumns.length ; i++) {
1061
1063
  var col = dtColumns[i];
1062
1064
 
1065
+ // Regenerate the column type if not present
1066
+ if (col.sType === null) {
1067
+ api.columns().types()
1068
+ }
1069
+
1063
1070
  if (col.sType === 'select-checkbox') {
1071
+ var cells = dtData.anCells;
1072
+
1064
1073
  // Make sure the checkbox shows the right state
1065
- $('input.dt-select-checkbox', dtData.anCells[i]).prop('checked', true);
1074
+ if (cells && cells[i]) {
1075
+ $('input.dt-select-checkbox', cells[i]).prop('checked', true);
1076
+ }
1066
1077
 
1067
- // Invalidate the sort data for this column
1068
- dtData._aSortData[i] = null;
1078
+ // Invalidate the sort data for this column, if not already done
1079
+ if (dtData._aSortData !== null) {
1080
+ dtData._aSortData[i] = null;
1081
+ }
1069
1082
  }
1070
1083
  }
1071
1084
  });
@@ -1183,12 +1196,23 @@ apiRegisterPlural('rows().deselect()', 'row().deselect()', function () {
1183
1196
  for (var i=0 ; i<dtColumns.length ; i++) {
1184
1197
  var col = dtColumns[i];
1185
1198
 
1199
+ // Regenerate the column type if not present
1200
+ if (col.sType === null) {
1201
+ api.columns().types()
1202
+ }
1203
+
1186
1204
  if (col.sType === 'select-checkbox') {
1205
+ var cells = dtData.anCells;
1206
+
1187
1207
  // Make sure the checkbox shows the right state
1188
- $('input.dt-select-checkbox', dtData.anCells[i]).prop('checked', false);
1208
+ if (cells && cells[i]) {
1209
+ $('input.dt-select-checkbox', dtData.anCells[i]).prop('checked', false);
1210
+ }
1189
1211
 
1190
- // Invalidate the sort data for this column
1191
- dtData._aSortData[i] = null;
1212
+ // Invalidate the sort data for this column, if not already done
1213
+ if (dtData._aSortData !== null) {
1214
+ dtData._aSortData[i] = null;
1215
+ }
1192
1216
  }
1193
1217
  }
1194
1218
  });
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "main": "js/dataTables.select.js",
5
5
  "module": "js/dataTables.select.mjs",
6
6
  "types": "./types/types.d.ts",
7
- "version": "2.0.0",
7
+ "version": "2.0.1",
8
8
  "files": [
9
9
  "js/**/*.js",
10
10
  "js/**/*.mjs",
@@ -20,7 +20,7 @@
20
20
  "sort"
21
21
  ],
22
22
  "dependencies": {
23
- "datatables.net": ">=2.0.0",
23
+ "datatables.net": "^2",
24
24
  "jquery": ">=1.7"
25
25
  },
26
26
  "moduleType": [