bootstrap-table-sticky-header.min.js 16 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.19.1
  5. * @homepage https://bootstrap-table.com
  6. * @author wenzhixin <wenzhixin2010@gmail.com> (http://wenzhixin.net.cn/)
  7. * @license MIT
  8. */
  9. !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("jquery")):"function"==typeof define&&define.amd?define(["jquery"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).jQuery)}(this,(function(t){"use strict";function e(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var n=e(t);function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function i(t){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function c(t,e){return(c=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function a(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function f(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=i(t);if(e){var o=i(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return a(this,n)}}function u(t,e,n){return(u="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){var r=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=i(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(n):o.value}})(t,e,n||t)}var s="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function l(t,e){return t(e={exports:{}},e.exports),e.exports}var d=function(t){return t&&t.Math==Math&&t},h=d("object"==typeof globalThis&&globalThis)||d("object"==typeof window&&window)||d("object"==typeof self&&self)||d("object"==typeof s&&s)||function(){return this}()||Function("return this")(),p=function(t){try{return!!t()}catch(t){return!0}},y=!p((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),v={}.propertyIsEnumerable,b=Object.getOwnPropertyDescriptor,g={f:b&&!v.call({1:2},1)?function(t){var e=b(this,t);return!!e&&e.enumerable}:v},m=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},k={}.toString,w=function(t){return k.call(t).slice(8,-1)},O="".split,$=p((function(){return!Object("z").propertyIsEnumerable(0)}))?function(t){return"String"==w(t)?O.call(t,""):Object(t)}:Object,j=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t},S=function(t){return $(j(t))},T=function(t){return"object"==typeof t?null!==t:"function"==typeof t},C=function(t,e){if(!T(t))return t;var n,r;if(e&&"function"==typeof(n=t.toString)&&!T(r=n.call(t)))return r;if("function"==typeof(n=t.valueOf)&&!T(r=n.call(t)))return r;if(!e&&"function"==typeof(n=t.toString)&&!T(r=n.call(t)))return r;throw TypeError("Can't convert object to primitive value")},P={}.hasOwnProperty,_=function(t,e){return P.call(t,e)},E=h.document,H=T(E)&&T(E.createElement),x=function(t){return H?E.createElement(t):{}},A=!y&&!p((function(){return 7!=Object.defineProperty(x("div"),"a",{get:function(){return 7}}).a})),B=Object.getOwnPropertyDescriptor,R={f:y?B:function(t,e){if(t=S(t),e=C(e,!0),A)try{return B(t,e)}catch(t){}if(_(t,e))return m(!g.f.call(t,e),t[e])}},M=function(t){if(!T(t))throw TypeError(String(t)+" is not an object");return t},L=Object.defineProperty,I={f:y?L:function(t,e,n){if(M(t),e=C(e,!0),M(n),A)try{return L(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(t[e]=n.value),t}},q=y?function(t,e,n){return I.f(t,e,m(1,n))}:function(t,e,n){return t[e]=n,t},F=function(t,e){try{q(h,t,e)}catch(n){h[t]=e}return e},N="__core-js_shared__",z=h[N]||F(N,{}),X=Function.toString;"function"!=typeof z.inspectSource&&(z.inspectSource=function(t){return X.call(t)});var Y,D,W,V=z.inspectSource,G=h.WeakMap,K="function"==typeof G&&/native code/.test(V(G)),Q=l((function(t){(t.exports=function(t,e){return z[t]||(z[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.10.1",mode:"global",copyright:"© 2021 Denis Pushkarev (zloirock.ru)"})})),J=0,U=Math.random(),Z=function(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++J+U).toString(36)},tt=Q("keys"),et=function(t){return tt[t]||(tt[t]=Z(t))},nt={},rt=h.WeakMap;if(K){var ot=z.state||(z.state=new rt),it=ot.get,ct=ot.has,at=ot.set;Y=function(t,e){return e.facade=t,at.call(ot,t,e),e},D=function(t){return it.call(ot,t)||{}},W=function(t){return ct.call(ot,t)}}else{var ft=et("state");nt[ft]=!0,Y=function(t,e){return e.facade=t,q(t,ft,e),e},D=function(t){return _(t,ft)?t[ft]:{}},W=function(t){return _(t,ft)}}var ut,st,lt={set:Y,get:D,has:W,enforce:function(t){return W(t)?D(t):Y(t,{})},getterFor:function(t){return function(e){var n;if(!T(e)||(n=D(e)).type!==t)throw TypeError("Incompatible receiver, "+t+" required");return n}}},dt=l((function(t){var e=lt.get,n=lt.enforce,r=String(String).split("String");(t.exports=function(t,e,o,i){var c,a=!!i&&!!i.unsafe,f=!!i&&!!i.enumerable,u=!!i&&!!i.noTargetGet;"function"==typeof o&&("string"!=typeof e||_(o,"name")||q(o,"name",e),(c=n(o)).source||(c.source=r.join("string"==typeof e?e:""))),t!==h?(a?!u&&t[e]&&(f=!0):delete t[e],f?t[e]=o:q(t,e,o)):f?t[e]=o:F(e,o)})(Function.prototype,"toString",(function(){return"function"==typeof this&&e(this).source||V(this)}))})),ht=h,pt=function(t){return"function"==typeof t?t:void 0},yt=function(t,e){return arguments.length<2?pt(ht[t])||pt(h[t]):ht[t]&&ht[t][e]||h[t]&&h[t][e]},vt=Math.ceil,bt=Math.floor,gt=function(t){return isNaN(t=+t)?0:(t>0?bt:vt)(t)},mt=Math.min,kt=function(t){return t>0?mt(gt(t),9007199254740991):0},wt=Math.max,Ot=Math.min,$t=function(t){return function(e,n,r){var o,i=S(e),c=kt(i.length),a=function(t,e){var n=gt(t);return n<0?wt(n+e,0):Ot(n,e)}(r,c);if(t&&n!=n){for(;c>a;)if((o=i[a++])!=o)return!0}else for(;c>a;a++)if((t||a in i)&&i[a]===n)return t||a||0;return!t&&-1}},jt={includes:$t(!0),indexOf:$t(!1)}.indexOf,St=function(t,e){var n,r=S(t),o=0,i=[];for(n in r)!_(nt,n)&&_(r,n)&&i.push(n);for(;e.length>o;)_(r,n=e[o++])&&(~jt(i,n)||i.push(n));return i},Tt=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Ct=Tt.concat("length","prototype"),Pt={f:Object.getOwnPropertyNames||function(t){return St(t,Ct)}},_t={f:Object.getOwnPropertySymbols},Et=yt("Reflect","ownKeys")||function(t){var e=Pt.f(M(t)),n=_t.f;return n?e.concat(n(t)):e},Ht=function(t,e){for(var n=Et(e),r=I.f,o=R.f,i=0;i<n.length;i++){var c=n[i];_(t,c)||r(t,c,o(e,c))}},xt=/#|\.prototype\./,At=function(t,e){var n=Rt[Bt(t)];return n==Lt||n!=Mt&&("function"==typeof e?p(e):!!e)},Bt=At.normalize=function(t){return String(t).replace(xt,".").toLowerCase()},Rt=At.data={},Mt=At.NATIVE="N",Lt=At.POLYFILL="P",It=At,qt=R.f,Ft=function(t,e){var n,r,o,i,c,a=t.target,f=t.global,u=t.stat;if(n=f?h:u?h[a]||F(a,{}):(h[a]||{}).prototype)for(r in e){if(i=e[r],o=t.noTargetGet?(c=qt(n,r))&&c.value:n[r],!It(f?r:a+(u?".":"#")+r,t.forced)&&void 0!==o){if(typeof i==typeof o)continue;Ht(i,o)}(t.sham||o&&o.sham)&&q(i,"sham",!0),dt(n,r,i,t)}},Nt=Array.isArray||function(t){return"Array"==w(t)},zt=function(t){return Object(j(t))},Xt=function(t,e,n){var r=C(e);r in t?I.f(t,r,m(0,n)):t[r]=n},Yt="process"==w(h.process),Dt=yt("navigator","userAgent")||"",Wt=h.process,Vt=Wt&&Wt.versions,Gt=Vt&&Vt.v8;Gt?st=(ut=Gt.split("."))[0]+ut[1]:Dt&&(!(ut=Dt.match(/Edge\/(\d+)/))||ut[1]>=74)&&(ut=Dt.match(/Chrome\/(\d+)/))&&(st=ut[1]);var Kt,Qt=st&&+st,Jt=!!Object.getOwnPropertySymbols&&!p((function(){return!Symbol.sham&&(Yt?38===Qt:Qt>37&&Qt<41)})),Ut=Jt&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,Zt=Q("wks"),te=h.Symbol,ee=Ut?te:te&&te.withoutSetter||Z,ne=function(t){return _(Zt,t)&&(Jt||"string"==typeof Zt[t])||(Jt&&_(te,t)?Zt[t]=te[t]:Zt[t]=ee("Symbol."+t)),Zt[t]},re=ne("species"),oe=function(t,e){var n;return Nt(t)&&("function"!=typeof(n=t.constructor)||n!==Array&&!Nt(n.prototype)?T(n)&&null===(n=n[re])&&(n=void 0):n=void 0),new(void 0===n?Array:n)(0===e?0:e)},ie=ne("species"),ce=ne("isConcatSpreadable"),ae=9007199254740991,fe="Maximum allowed index exceeded",ue=Qt>=51||!p((function(){var t=[];return t[ce]=!1,t.concat()[0]!==t})),se=(Kt="concat",Qt>=51||!p((function(){var t=[];return(t.constructor={})[ie]=function(){return{foo:1}},1!==t[Kt](Boolean).foo}))),le=function(t){if(!T(t))return!1;var e=t[ce];return void 0!==e?!!e:Nt(t)};Ft({target:"Array",proto:!0,forced:!ue||!se},{concat:function(t){var e,n,r,o,i,c=zt(this),a=oe(c,0),f=0;for(e=-1,r=arguments.length;e<r;e++)if(le(i=-1===e?c:arguments[e])){if(f+(o=kt(i.length))>ae)throw TypeError(fe);for(n=0;n<o;n++,f++)n in i&&Xt(a,f,i[n])}else{if(f>=ae)throw TypeError(fe);Xt(a,f++,i)}return a.length=f,a}});var de,he=function(t,e,n){if(function(t){if("function"!=typeof t)throw TypeError(String(t)+" is not a function")}(t),void 0===e)return t;switch(n){case 0:return function(){return t.call(e)};case 1:return function(n){return t.call(e,n)};case 2:return function(n,r){return t.call(e,n,r)};case 3:return function(n,r,o){return t.call(e,n,r,o)}}return function(){return t.apply(e,arguments)}},pe=[].push,ye=function(t){var e=1==t,n=2==t,r=3==t,o=4==t,i=6==t,c=7==t,a=5==t||i;return function(f,u,s,l){for(var d,h,p=zt(f),y=$(p),v=he(u,s,3),b=kt(y.length),g=0,m=l||oe,k=e?m(f,b):n||c?m(f,0):void 0;b>g;g++)if((a||g in y)&&(h=v(d=y[g],g,p),t))if(e)k[g]=h;else if(h)switch(t){case 3:return!0;case 5:return d;case 6:return g;case 2:pe.call(k,d)}else switch(t){case 4:return!1;case 7:pe.call(k,d)}return i?-1:r||o?o:k}},ve={forEach:ye(0),map:ye(1),filter:ye(2),some:ye(3),every:ye(4),find:ye(5),findIndex:ye(6),filterOut:ye(7)},be=Object.keys||function(t){return St(t,Tt)},ge=y?Object.defineProperties:function(t,e){M(t);for(var n,r=be(e),o=r.length,i=0;o>i;)I.f(t,n=r[i++],e[n]);return t},me=yt("document","documentElement"),ke=et("IE_PROTO"),we=function(){},Oe=function(t){return"<script>"+t+"</"+"script>"},$e=function(){try{de=document.domain&&new ActiveXObject("htmlfile")}catch(t){}var t,e;$e=de?function(t){t.write(Oe("")),t.close();var e=t.parentWindow.Object;return t=null,e}(de):((e=x("iframe")).style.display="none",me.appendChild(e),e.src=String("javascript:"),(t=e.contentWindow.document).open(),t.write(Oe("document.F=Object")),t.close(),t.F);for(var n=Tt.length;n--;)delete $e.prototype[Tt[n]];return $e()};nt[ke]=!0;var je=Object.create||function(t,e){var n;return null!==t?(we.prototype=M(t),n=new we,we.prototype=null,n[ke]=t):n=$e(),void 0===e?n:ge(n,e)},Se=ne("unscopables"),Te=Array.prototype;null==Te[Se]&&I.f(Te,Se,{configurable:!0,value:je(null)});var Ce,Pe=ve.find,_e="find",Ee=!0;_e in[]&&Array(1).find((function(){Ee=!1})),Ft({target:"Array",proto:!0,forced:Ee},{find:function(t){return Pe(this,t,arguments.length>1?arguments[1]:void 0)}}),Ce=_e,Te[Se][Ce]=!0;var He=n.default.fn.bootstrapTable.utils;n.default.extend(n.default.fn.bootstrapTable.defaults,{stickyHeader:!1,stickyHeaderOffsetY:0,stickyHeaderOffsetLeft:0,stickyHeaderOffsetRight:0}),n.default.BootstrapTable=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&c(t,e)}(d,t);var e,a,s,l=f(d);function d(){return r(this,d),l.apply(this,arguments)}return e=d,(a=[{key:"initHeader",value:function(){for(var t,e=this,r=arguments.length,o=new Array(r),c=0;c<r;c++)o[c]=arguments[c];if((t=u(i(d.prototype),"initHeader",this)).call.apply(t,[this].concat(o)),this.options.stickyHeader){this.$tableBody.find(".sticky-header-container,.sticky_anchor_begin,.sticky_anchor_end").remove(),this.$el.before('<div class="sticky-header-container"></div>'),this.$el.before('<div class="sticky_anchor_begin"></div>'),this.$el.after('<div class="sticky_anchor_end"></div>'),this.$header.addClass("sticky-header"),this.$stickyContainer=this.$tableBody.find(".sticky-header-container"),this.$stickyBegin=this.$tableBody.find(".sticky_anchor_begin"),this.$stickyEnd=this.$tableBody.find(".sticky_anchor_end"),this.$stickyHeader=this.$header.clone(!0,!0);var a=He.getEventName("resize.sticky-header-table",this.$el.attr("id")),f=He.getEventName("scroll.sticky-header-table",this.$el.attr("id"));n.default(window).off(a).on(a,(function(){return e.renderStickyHeader()})),n.default(window).off(f).on(f,(function(){return e.renderStickyHeader()})),this.$tableBody.off("scroll").on("scroll",(function(){return e.matchPositionX()}))}}},{key:"onColumnSearch",value:function(t){var e=t.currentTarget,n=t.keyCode;u(i(d.prototype),"onColumnSearch",this).call(this,{currentTarget:e,keyCode:n}),this.renderStickyHeader()}},{key:"resetView",value:function(){for(var t,e=this,r=arguments.length,o=new Array(r),c=0;c<r;c++)o[c]=arguments[c];(t=u(i(d.prototype),"resetView",this)).call.apply(t,[this].concat(o)),n.default(".bootstrap-table.fullscreen").off("scroll").on("scroll",(function(){return e.renderStickyHeader()}))}},{key:"getCaret",value:function(){for(var t,e=arguments.length,r=new Array(e),o=0;o<e;o++)r[o]=arguments[o];if((t=u(i(d.prototype),"getCaret",this)).call.apply(t,[this].concat(r)),this.$stickyHeader){var c=this.$stickyHeader.find("th");this.$header.find("th").each((function(t,e){c.eq(t).find(".sortable").attr("class",n.default(e).find(".sortable").attr("class"))}))}}},{key:"horizontalScroll",value:function(){var t=this;u(i(d.prototype),"horizontalScroll",this).call(this),this.$tableBody.on("scroll",(function(){return t.matchPositionX()}))}},{key:"renderStickyHeader",value:function(){var t=this,e=this;this.$stickyHeader=this.$header.clone(!0,!0),this.options.filterControl&&n.default(this.$stickyHeader).off("keyup change mouseup").on("keyup change mouse",(function(t){var r=n.default(t.target),o=r.val(),i=r.parents("th").data("field"),c=e.$header.find('th[data-field="'.concat(i,'"]'));if(r.is("input"))c.find("input").val(o);else if(r.is("select")){var a=c.find("select");a.find("option[selected]").removeAttr("selected"),a.find('option[value="'.concat(o,'"]')).attr("selected",!0)}e.triggerSearch()}));var r=n.default(window).scrollTop(),o=this.$stickyBegin.offset().top-this.options.stickyHeaderOffsetY,i=this.$stickyEnd.offset().top-this.options.stickyHeaderOffsetY-this.$header.height();if(r>o&&r<=i){this.$stickyHeader.find("tr").each((function(e,r){n.default(r).find("th").each((function(r,o){n.default(o).css("min-width",t.$header.find("tr:eq(".concat(e,")")).find("th:eq(".concat(r,")")).css("width"))}))})),this.$stickyContainer.show().addClass("fix-sticky fixed-table-container");var c=this.$tableBody[0].getBoundingClientRect(),a="100%",f=this.options.stickyHeaderOffsetLeft,u=this.options.stickyHeaderOffsetRight;f||(f=c.left),u||(a="".concat(c.width,"px")),this.$el.closest(".bootstrap-table").hasClass("fullscreen")&&(f=0,u=0,a="100%"),this.$stickyContainer.css("top","".concat(this.options.stickyHeaderOffsetY,"px")),this.$stickyContainer.css("left","".concat(f,"px")),this.$stickyContainer.css("right","".concat(u,"px")),this.$stickyContainer.css("width","".concat(a)),this.$stickyTable=n.default("<table/>"),this.$stickyTable.addClass(this.options.classes),this.$stickyContainer.html(this.$stickyTable.append(this.$stickyHeader)),this.matchPositionX()}else this.$stickyContainer.removeClass("fix-sticky").hide()}},{key:"matchPositionX",value:function(){this.$stickyContainer.scrollLeft(this.$tableBody.scrollLeft())}}])&&o(e.prototype,a),s&&o(e,s),d}(n.default.BootstrapTable)}));