bnbweb/back/assets/js/dataTables.buttons.min.js

4 lines
16 KiB
JavaScript
Raw Permalink Normal View History

2022-11-14 15:49:28 +00:00
/*! Buttons for DataTables 1.1.2
* ©2015 SpryMedia Ltd - datatables.net/license
*/
!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";var e=a.fn.dataTable,f=0,g=0,h=e.ext.buttons,i=function(b,c){c===!0&&(c={}),a.isArray(c)&&(c={buttons:c}),this.c=a.extend(!0,{},i.defaults,c),c.buttons&&(this.c.buttons=c.buttons),this.s={dt:new e.Api(b),buttons:[],subButtons:[],listenKeys:"",namespace:"dtb"+f++},this.dom={container:a("<"+this.c.dom.container.tag+"/>").addClass(this.c.dom.container.className)},this._constructor()};a.extend(i.prototype,{action:function(a,b){var c=this._indexToButton(a).conf;this.s.dt;return b===d?c.action:(c.action=b,this)},active:function(a,b){var c=this._indexToButton(a),e=this.c.dom.button.active;return b===d?c.node.hasClass(e):(c.node.toggleClass(e,b===d?!0:b),this)},add:function(a,b){if("string"==typeof a&&-1!==a.indexOf("-")){var c=a.split("-");this.c.buttons[1*c[0]].buttons.splice(1*c[1],0,b)}else this.c.buttons.splice(1*a,0,b);return this.dom.container.empty(),this._buildButtons(this.c.buttons),this},container:function(){return this.dom.container},disable:function(a){var b=this._indexToButton(a);return b.node.addClass(this.c.dom.button.disabled),this},destroy:function(){a("body").off("keyup."+this.s.namespace);var b,c,d,e,f=this.s.buttons,g=this.s.subButtons;for(b=0,c=f.length;c>b;b++)for(this.removePrep(b),d=0,e=g[b].length;e>d;d++)this.removePrep(b+"-"+d);this.removeCommit(),this.dom.container.remove();var h=this.s.dt.settings()[0];for(b=0,c=h.length;c>b;b++)if(h.inst===this){h.splice(b,1);break}return this},enable:function(a,b){if(b===!1)return this.disable(a);var c=this._indexToButton(a);return c.node.removeClass(this.c.dom.button.disabled),this},name:function(){return this.c.name},node:function(a){var b=this._indexToButton(a);return b.node},removeCommit:function(){var a,b,c,d=this.s.buttons,e=this.s.subButtons;for(a=d.length-1;a>=0;a--)null===d[a]&&(d.splice(a,1),e.splice(a,1),this.c.buttons.splice(a,1));for(a=0,b=e.length;b>a;a++)for(c=e[a].length-1;c>=0;c--)null===e[a][c]&&(e[a].splice(c,1),this.c.buttons[a].buttons.splice(c,1));return this},removePrep:function(a){var b,c=this.s.dt;if("number"==typeof a||-1===a.indexOf("-"))b=this.s.buttons[1*a],b.conf.destroy&&b.conf.destroy.call(c.button(a),c,b,b.conf),b.node.remove(),this._removeKey(b.conf),this.s.buttons[1*a]=null;else{var d=a.split("-");b=this.s.subButtons[1*d[0]][1*d[1]],b.conf.destroy&&b.conf.destroy.call(c.button(a),c,b,b.conf),b.node.remove(),this._removeKey(b.conf),this.s.subButtons[1*d[0]][1*d[1]]=null}return this},text:function(a,b){var c=this._indexToButton(a),e=this.c.dom.collection.buttonLiner,f="string"==typeof a&&-1!==a.indexOf("-")&&e&&e.tag?e.tag:this.c.dom.buttonLiner.tag,g=this.s.dt,h=function(a){return"function"==typeof a?a(g,c.node,c.conf):a};return b===d?h(c.conf.text):(c.conf.text=b,f?c.node.children(f).html(h(b)):c.node.html(h(b)),this)},toIndex:function(a){var b,c,d,e,f=this.s.buttons,g=this.s.subButtons;for(b=0,c=f.length;c>b;b++)if(f[b].node[0]===a)return b+"";for(b=0,c=g.length;c>b;b++)for(d=0,e=g[b].length;e>d;d++)if(g[b][d].node[0]===a)return b+"-"+d},_constructor:function(){var b=this,d=this.s.dt,e=d.settings()[0];e._buttons||(e._buttons=[]),e._buttons.push({inst:this,name:this.c.name}),this._buildButtons(this.c.buttons),d.on("destroy",function(){b.destroy()}),a("body").on("keyup."+this.s.namespace,function(a){if(!c.activeElement||c.activeElement===c.body){var d=String.fromCharCode(a.keyCode).toLowerCase();-1!==b.s.listenKeys.toLowerCase().indexOf(d)&&b._keypress(d,a)}})},_addKey:function(b){b.key&&(this.s.listenKeys+=a.isPlainObject(b.key)?b.key.key:b.key)},_buildButtons:function(b,c,e){var f=this.s.dt,g=0;c||(c=this.dom.container,this.s.buttons=[],this.s.subButtons=[]);for(var h=0,i=b.length;i>h;h++){var j=this._resolveExtends(b[h]);if(j)if(a.isArray(j))this._buildButtons(j,c,e);else{var k=this._buildButton(j