4 lines
11 KiB
JavaScript
4 lines
11 KiB
JavaScript
|
/*! Select for DataTables 1.1.2
|
||
|
* 2015-2016 SpryMedia Ltd - datatables.net/license/mit
|
||
|
*/
|
||
|
!function(a){"function"==typeof define&&define.amd?define(["jquery","datatables.net"],function(b){return a(b,window,document)}):"object"==typeof exports?module.exports=function(b,c){return b||(b=window),c&&c.fn.dataTable||(c=require("datatables.net")(b,c).$),a(c,b,b.document)}:a(jQuery,window,document)}(function(a,b,c,d){"use strict";function e(a,b,c){var d,e,f,g=function(b,c){if(b>c){var d=c;c=b,b=d}var e=!1;return a.columns(":visible").indexes().filter(function(a){return a===b&&(e=!0),a===c?(e=!1,!0):e})},h=function(b,c){var d=a.rows({search:"applied"}).indexes();if(d.indexOf(b)>d.indexOf(c)){var e=c;c=b,b=e}var f=!1;return d.filter(function(a){return a===b&&(f=!0),a===c?(f=!1,!0):f})};a.cells({selected:!0}).any()||c?(e=g(c.column,b.column),f=h(c.row,b.row)):(e=g(0,b.column),f=h(0,b.row)),d=a.cells(f,e).flatten(),a.cells(b,{selected:!0}).any()?a.cells(d).deselect():a.cells(d).select()}function f(b){var c=b.settings()[0],d=c._select.selector;a(b.table().body()).off("mousedown.dtSelect",d).off("mouseup.dtSelect",d).off("click.dtSelect",d),a("body").off("click.dtSelect")}function g(c){var d=a(c.table().body()),e=c.settings()[0],f=e._select.selector;d.on("mousedown.dtSelect",f,function(a){a.shiftKey&&d.css("-moz-user-select","none").one("selectstart.dtSelect",f,function(){return!1})}).on("mouseup.dtSelect",f,function(a){d.css("-moz-user-select","")}).on("click.dtSelect",f,function(d){var e,f=c.select.items();if(!b.getSelection||!b.getSelection().toString()){var g=c.settings()[0];if(a(d.target).closest("div.dataTables_wrapper")[0]==c.table().container()){var h=a(d.target).closest("td, th"),i=c.cell(h).index();c.cell(h).any()&&("row"===f?(e=i.row,m(d,c,g,"row",e)):"column"===f?(e=c.cell(h).index().column,m(d,c,g,"column",e)):"cell"===f&&(e=c.cell(h).index(),m(d,c,g,"cell",e)),g._select_lastCell=i)}}}),a("body").on("click.dtSelect",function(b){if(e._select.blurable){if(a(b.target).parents().filter(c.table().container()).length)return;if(a(b.target).parents("div.DTE").length)return;l(e,!0)}})}function h(b,c,d,e){e&&!b.flatten().length||(d.unshift(b),a(b.table().node()).triggerHandler(c+".dt",d))}function i(b){var c=b.settings()[0];if(c._select.info&&c.aanFeatures.i){var d=a('<span class="select-info"/>'),e=function(c,e){d.append(a('<span class="select-item"/>').append(b.i18n("select."+c+"s",{_:"%d "+c+"s selected",0:"",1:"1 "+c+" selected"},e)))};e("row",b.rows({selected:!0}).flatten().length),e("column",b.columns({selected:!0}).flatten().length),e("cell",b.cells({selected:!0}).flatten().length),a.each(c.aanFeatures.i,function(b,c){c=a(c);var e=c.children("span.select-info");e.length&&e.remove(),""!==d.text()&&c.append(d)})}}function j(b){var c=new o.Api(b);b.aoRowCreatedCallback.push({fn:function(c,d,e){var f,g,h=b.aoData[e];for(h._select_selected&&a(c).addClass(b._select.className),f=0,g=b.aoColumns.length;g>f;f++)(b.aoColumns[f]._select_selected||h._selected_cells&&h._selected_cells[f])&&a(h.anCells[f]).addClass(b._select.className)},sName:"select-deferRender"}),c.on("preXhr.dt.dtSelect",function(){var a=c.rows({selected:!0}).ids(!0).filter(function(a){return a!==d}),b=c.cells({selected:!0}).eq(0).map(function(a){var b=c.row(a.row).id(!0);return b?{row:b,column:a.column}:d}).filter(function(a){return a!==d});c.one("draw.dt.dtSelect",function(){c.rows(a).select(),b.any()&&b.each(function(a){c.cells(a.row,a.column).select()})})}),c.on("draw.dtSelect.dt select.dtSelect.dt deselect.dtSelect.dt",function(){i(c)}),c.on("destroy.dtSelect",function(){f(c),c.off(".dtSelect")})}function k(b,c,d,e){var f=b[c+"s"]({search:"applied"}).indexes(),g=a.inArray(e,f),h=a.inArray(d,f);if(b[c+"s"]({selected:!0}).any()||-1!==g){if(g>h){var i=h;h=g,g=i}f.splice(h+1,f.length),f.splice(0,g)}else f.splice(a.inArray(d,f)+1,f.length);b[c](d,{selected:!0}).any()?(f.splice(a.inArray(d,f),1),b[c+"s"](f).deselect()):b[c+"s"](f).select()}function l(a,b){if(b||"single"===a._select.style){var c=new o.Api(a);c.rows({selected:!0}).deselect(),c.columns({selected:!0}).deselect(),c.cells({selected:!0}).deselect()}}function m(a,b,c,d,f){var g=b.select.style(),h=b
|