bootstrap-table-pipeline.min.js 7.3 KB

12345678910
  1. /**
  2. * bootstrap-table - An extended table to integration with some of the most widely used CSS frameworks. (Supports Bootstrap, Semantic UI, Bulma, Material Design, Foundation)
  3. *
  4. * @version v1.23.0
  5. * @homepage https://bootstrap-table.com
  6. * @author wenzhixin <wenzhixin2010@gmail.com> (http://wenzhixin.net.cn/)
  7. * @license MIT
  8. */
  9. !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("core-js/modules/es.array.concat.js"),require("core-js/modules/es.array.slice.js"),require("core-js/modules/es.object.assign.js"),require("core-js/modules/es.parse-int.js"),require("jquery")):"function"==typeof define&&define.amd?define(["core-js/modules/es.array.concat.js","core-js/modules/es.array.slice.js","core-js/modules/es.object.assign.js","core-js/modules/es.parse-int.js","jquery"],t):t(null,null,null,null,(e="undefined"!=typeof globalThis?globalThis:e||self).jQuery)}(this,(function(e,t,i,r,n){"use strict";function o(e,t,i){return t=l(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,u()?Reflect.construct(t,i||[],l(e).constructor):t.apply(e,i))}function s(e,t,i){return t&&function(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,d(r.key),r)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function a(e,t,i){return(t=d(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function c(){return c="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,i){var r=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=l(e)););return e}(e,t);if(r){var n=Object.getOwnPropertyDescriptor(r,t);return n.get?n.get.call(arguments.length<3?e:i):n.value}},c.apply(null,arguments)}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}function u(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(u=function(){return!!e})()}function p(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,r)}return i}function f(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?p(Object(i),!0).forEach((function(t){a(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):p(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}function d(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var r=i.call(e,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}var y=n.fn.bootstrapTable.utils;Object.assign(n.fn.bootstrapTable.defaults,{usePipeline:!1,pipelineSize:1e3,onCachedDataHit:function(e){return!1},onCachedDataReset:function(e){return!1}}),Object.assign(n.fn.bootstrapTable.events,{"cached-data-hit.bs.table":"onCachedDataHit","cached-data-reset.bs.table":"onCachedDataReset"}),n.BootstrapTable=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),o(this,t,arguments)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&h(e,t)}(t,e),s(t,[{key:"init",value:function(){var e;this.options.usePipeline&&this.initPipeline();for(var i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];(e=c(l(t.prototype),"init",this)).call.apply(e,[this].concat(r))}},{key:"initPipeline",value:function(){this.cacheRequestJSON={},this.cacheWindows=[],this.currWindow=0,this.resetCache=!0}},{key:"onSearch",value:function(){var e;this.options.usePipeline&&(this.resetCache=!0);for(var i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];(e=c(l(t.prototype),"onSearch",this)).call.apply(e,[this].concat(r))}},{key:"onSort",value:function(){var e;this.options.usePipeline&&(this.resetCache=!0);for(var i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];(e=c(l(t.prototype),"onSort",this)).call.apply(e,[this].concat(r))}},{key:"onPageListChange",value:function(e){var i=n(e.currentTarget),r=parseInt(i.text(),10);this.options.pipelineSize=this.calculatePipelineSize(this.options.pipelineSize,r),this.resetCache=!0,c(l(t.prototype),"onPageListChange",this).call(this,e)}},{key:"calculatePipelineSize",value:function(e,t){return 0===t?0:Math.ceil(e/t)*t}},{key:"setCacheWindows",value:function(){this.cacheWindows=[];for(var e=0;e<=this.options.totalRows/this.options.pipelineSize;e++){var t=e*this.options.pipelineSize;this.cacheWindows[e]={lower:t,upper:t+this.options.pipelineSize-1}}}},{key:"setCurrWindow",value:function(e){this.currWindow=0;for(var t=0;t<this.cacheWindows.length;t++)if(this.cacheWindows[t].lower<=e&&e<=this.cacheWindows[t].upper){this.currWindow=t;break}}},{key:"drawFromCache",value:function(e,t){var i=y.extend(!0,{},this.cacheRequestJSON),r=e-this.cacheWindows[this.currWindow].lower,n=r+t;return i.rows=i.rows.slice(r,n),i}},{key:"initServer",value:function(e,i,r){var n=this;if(!this.options.usePipeline)return c(l(t.prototype),"initServer",this).call(this,e,i,r);var o=!0,s={};if("limit"===this.options.queryParamsType&&this.options.pagination&&"server"===this.options.sidePagination)if(s.offset=this.options.pageSize===this.options.formatAllRows()?0:this.options.pageSize*(this.options.pageNumber-1),s.limit=this.options.pageSize,this.cacheWindows.length){var a=this.cacheWindows[this.currWindow];this.resetCache||s.offset<a.lower||s.offset>a.upper?(o=!0,this.setCurrWindow(s.offset),s.drawOffset=s.offset,s.offset=this.cacheWindows[this.currWindow].lower):o=!1}else o=!0,s.drawOffset=s.offset;if(this.resetCache&&(o=!0,this.resetCache=!1),o&&(s.drawLimit=s.limit,s.limit=this.options.pipelineSize),!o){var u=this.drawFromCache(s.offset,s.limit);return this.load(u),this.trigger("load-success",u),void this.trigger("cached-data-hit",u)}return this.pipelineResponseHandler||(this.pipelineResponseHandler=this.options.responseHandler,this.options.responseHandler=function(e,t){var i=y.calculateObjectValue(n.options,n.pipelineResponseHandler,[e,t],e);return n.cacheRequestJSON=y.extend(!0,{},i),n.options.totalRows=i[n.options.totalField],n.setCacheWindows(),i=n.drawFromCache(s.drawOffset,s.drawLimit),n.trigger("cached-data-reset",i),i}),c(l(t.prototype),"initServer",this).call(this,e,f(f({},i),s),r)}},{key:"destroy",value:function(){var e;this.options.responseHandler=this.pipelineResponseHandler,this.pipelineResponseHandler=null;for(var i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];(e=c(l(t.prototype),"destroy",this)).call.apply(e,[this].concat(r))}}])}(n.BootstrapTable)}));