blob: 1401c938bfbd62d11f59c5db770fa0dc4ad925f1 [file] [log] [blame]
!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery","datatables.net"],(function(t){return e(t,window,document)})):"object"==typeof exports?module.exports=function(t,l){return t||(t=window),l&&l.fn.dataTable||(l=require("datatables.net")(t,l).$),e(l,0,t.document)}:e(jQuery,window,document)}((function(e,t,l,c){"use strict";var n=e.fn.dataTable;function o(t,l){var c=t.settings()[0],n=t.rows({page:"current",search:"applied"});if("single"===t.select.style())throw new Error("Cannot select all rows with selection style 'single'");l?n.select():n.deselect(),e(c._pfSelect.selector,t.table().container()).prop("checked",l),r(t)}function r(t){var l=t.settings()[0],c=t.rows({page:"current",search:"applied"}).flatten().length,n=t.rows({page:"current",search:"applied",selected:!0}).flatten().length,o=e(l._pfSelect.selectAllSelector,t.table().container())[0];o&&(o.checked=c===n),i(t)}function s(t){var l=t.settings()[0];e(l._pfSelect.selector,t.table().container()).prop("checked",!1),t.rows({page:"current",search:"applied",selected:!0}).every((function(c){e(l._pfSelect.selector,t.table().row(c).node()).prop("checked",!0)})),r(t)}function i(t){var l=t.settings()[0],n=t.rows({selected:!0}).flatten().length,o=t.rows().flatten().length;l._pfSelect.results!==c&&0!==l._pfSelect.results.length&&e(l._pfSelect.results).html("<strong>"+n+"</strong> of <strong>"+o+"</strong> selected")}return n.pfSelect={},n.pfSelect.init=function(t){var l=t.settings()[0],n=l.oInit.pfConfig?l.oInit.pfConfig:{},a=l.oInit.select?l.oInit.select:{},f=t.select.style();l._pfSelect={},l._pfSelect.selectAllSelector=n.selectAllSelector!==c?n.selectAllSelector:'th:first-child input[type="checkbox"]',l._pfSelect.selector=a.selector!==c?a.selector:'td:first-child input[type="checkbox"]',l._pfSelect.results=e(".table-view-pf-select-results",n.toolbarSelector),"api"===f?(e(t.table().container()).on("click",l._pfSelect.selectAllSelector,(function(e){e.preventDefault()})),e(t.table().container()).on("click",l._pfSelect.selector,(function(e){e.preventDefault()})),t.table().on("select.dt",(function(){s(t)}))):(e(t.table().container()).on("click",l._pfSelect.selectAllSelector,(function(e){o(t,e.target.checked)})),e(t.table().container()).on("click",l._pfSelect.selector,(function(e){"multi"!==f||"multi+shift"!==f?s(t):r(t)}))),t.table().on("draw.dt",(function(){s(t)})),i(t)},n.Api.register("pfSelect.selectAllRows()",(function(e){return this.iterator("table",(function(t){o(new n.Api(t),e)}))})),e(l).on("preInit.dt.dtSelect",(function(e,t){"dt"===e.namespace&&n.pfSelect.init(new n.Api(t))})),n.pfSelect}));