11 lines
19 KiB
JavaScript
11 lines
19 KiB
JavaScript
/**
|
|
* bootstrap-table - An extended table to integration with some of the most widely used CSS frameworks. (Supports Bootstrap, Semantic UI, Bulma, Material Design, Foundation)
|
|
*
|
|
* @version v1.23.1
|
|
* @homepage https://bootstrap-table.com
|
|
* @author wenzhixin <wenzhixin2010@gmail.com> (http://wenzhixin.net.cn/)
|
|
* @license MIT
|
|
*/
|
|
|
|
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?o(require("core-js/modules/es.array.concat.js"),require("core-js/modules/es.array.filter.js"),require("core-js/modules/es.array.find.js"),require("core-js/modules/es.array.includes.js"),require("core-js/modules/es.array.join.js"),require("core-js/modules/es.array.map.js"),require("core-js/modules/es.date.to-json.js"),require("core-js/modules/es.object.assign.js"),require("core-js/modules/es.object.entries.js"),require("core-js/modules/es.object.keys.js"),require("core-js/modules/es.object.to-string.js"),require("core-js/modules/es.regexp.exec.js"),require("core-js/modules/es.regexp.to-string.js"),require("core-js/modules/es.string.includes.js"),require("core-js/modules/es.string.replace.js"),require("core-js/modules/es.string.search.js"),require("core-js/modules/web.dom-collections.for-each.js"),require("jquery")):"function"==typeof define&&define.amd?define(["core-js/modules/es.array.concat.js","core-js/modules/es.array.filter.js","core-js/modules/es.array.find.js","core-js/modules/es.array.includes.js","core-js/modules/es.array.join.js","core-js/modules/es.array.map.js","core-js/modules/es.date.to-json.js","core-js/modules/es.object.assign.js","core-js/modules/es.object.entries.js","core-js/modules/es.object.keys.js","core-js/modules/es.object.to-string.js","core-js/modules/es.regexp.exec.js","core-js/modules/es.regexp.to-string.js","core-js/modules/es.string.includes.js","core-js/modules/es.string.replace.js","core-js/modules/es.string.search.js","core-js/modules/web.dom-collections.for-each.js","jquery"],o):o(null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,(e="undefined"!=typeof globalThis?globalThis:e||self).jQuery)}(this,(function(e,o,t,i,r,s,n,a,l,c,u,p,h,d,f,m,k,g){"use strict";function b(e,o){(null==o||o>e.length)&&(o=e.length);for(var t=0,i=Array(o);t<o;t++)i[t]=e[t];return i}function y(e,o,t){return o=S(o),function(e,o){if(o&&("object"==typeof o||"function"==typeof o))return o;if(void 0!==o)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,w()?Reflect.construct(o,t||[],S(e).constructor):o.apply(e,t))}function C(e,o,t){return o&&function(e,o){for(var t=0;t<o.length;t++){var i=o[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,N(i.key),i)}}(e.prototype,o),Object.defineProperty(e,"prototype",{writable:!1}),e}function v(e,o){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=P(e))||o){t&&(e=t);var i=0,r=function(){};return{s:r,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,n=!0,a=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return n=e.done,e},e:function(e){a=!0,s=e},f:function(){try{n||null==t.return||t.return()}finally{if(a)throw s}}}}function j(){return j="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,o,t){var i=function(e,o){for(;!{}.hasOwnProperty.call(e,o)&&null!==(e=S(e)););return e}(e,o);if(i){var r=Object.getOwnPropertyDescriptor(i,o);return r.get?r.get.call(arguments.length<3?e:t):r.value}},j.apply(null,arguments)}function S(e){return S=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},S(e)}function w(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(w=function(){return!!e})()}function I(e,o){return I=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,o){return e.__proto__=o,e},I(e,o)}function O(e,o){return function(e){if(Array.isArray(e))return e}(e)||function(e,o){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var i,r,s,n,a=[],l=!0,c=!1;try{if(s=(t=t.call(e)).next,0===o);else for(;!(l=(i=s.call(t)).done)&&(a.push(i.value),a.length!==o);l=!0);}catch(e){c=!0,r=e}finally{try{if(!l&&null!=t.return&&(n=t.return(),Object(n)!==n))return}finally{if(c)throw r}}return a}}(e,o)||P(e,o)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function N(e){var o=function(e,o){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var i=t.call(e,o);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof o?o:o+""}function P(e,o){if(e){if("string"==typeof e)return b(e,o);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?b(e,o):void 0}}var T=g.fn.bootstrapTable.utils,_={cookieIds:{sortOrder:"bs.table.sortOrder",sortName:"bs.table.sortName",sortPriority:"bs.table.sortPriority",pageNumber:"bs.table.pageNumber",pageList:"bs.table.pageList",hiddenColumns:"bs.table.hiddenColumns",cardView:"bs.table.cardView",customView:"bs.table.customView",searchText:"bs.table.searchText",reorderColumns:"bs.table.reorderColumns",filterControl:"bs.table.filterControl",filterBy:"bs.table.filterBy"},getCurrentHeader:function(e){return e.options.height?e.$tableHeader:e.$header},getCurrentSearchControls:function(e){return e.options.height?"table select, table input":"select, input"},isCookieSupportedByBrowser:function(){return navigator.cookieEnabled},isCookieEnabled:function(e,o){return e.options.cookiesEnabled.includes(o)},setCookie:function(e,o,t){if(e.options.cookie&&_.isCookieEnabled(e,o))return e._storage.setItem("".concat(e.options.cookieIdTable,".").concat(o),t)},getCookie:function(e,o){return o&&_.isCookieEnabled(e,o)?e._storage.getItem("".concat(e.options.cookieIdTable,".").concat(o)):null},deleteCookie:function(e,o){return e._storage.removeItem("".concat(e.options.cookieIdTable,".").concat(o))},calculateExpiration:function(e){var o=e.replace(/[0-9]*/,"");switch(e=e.replace(/[A-Za-z]{1,2}/,""),o.toLowerCase()){case"s":e=+e;break;case"mi":e*=60;break;case"h":e=60*e*60;break;case"d":e=24*e*60*60;break;case"m":e=30*e*24*60*60;break;case"y":e=365*e*24*60*60;break;default:e=void 0}if(!e)return"";var t=new Date;return t.setTime(t.getTime()+1e3*e),t.toGMTString()},initCookieFilters:function(e){setTimeout((function(){var o=JSON.parse(_.getCookie(e,_.cookieIds.filterControl));if(!e._filterControlValuesLoaded&&o){var t={},i=_.getCurrentHeader(e),r=_.getCurrentSearchControls(e),s=i;e.options.filterControlContainer&&(s=g("".concat(e.options.filterControlContainer))),s.find(r).each((function(){var i=g(this).closest("[data-field]").data("field");!function(o,i){i.forEach((function(i){var r=o.value.toString(),s=i.text;if(""!==s&&("radio"!==o.type||r===s))if("INPUT"===o.tagName&&"radio"===o.type&&r===s)o.checked=!0,t[i.field]=s;else if("INPUT"===o.tagName)o.value=s,t[i.field]=s;else if("SELECT"===o.tagName&&e.options.filterControlContainer)o.value=s,t[i.field]=s;else if(""!==s&&"SELECT"===o.tagName){t[i.field]=s;var n,a=v(o);try{for(a.s();!(n=a.n()).done;){var l=n.value;if(l.value===s)return void(l.selected=!0)}}catch(e){a.e(e)}finally{a.f()}var c=document.createElement("option");c.value=s,c.text=s,o.add(c,o[1]),o.selectedIndex=1}}))}(this,o.filter((function(e){return e.field===i})))})),e.initColumnSearch(t),e._filterControlValuesLoaded=!0,e.initServer()}}),250)}};Object.assign(g.fn.bootstrapTable.defaults,{cookie:!1,cookieExpire:"2h",cookiePath:null,cookieDomain:null,cookieSecure:null,cookieSameSite:"Lax",cookieIdTable:"",cookiesEnabled:["bs.table.sortOrder","bs.table.sortName","bs.table.sortPriority","bs.table.pageNumber","bs.table.pageList","bs.table.hiddenColumns","bs.table.searchText","bs.table.filterControl","bs.table.filterBy","bs.table.reorderColumns","bs.table.cardView","bs.table.customView"],cookieStorage:"cookieStorage",cookieCustomStorageGet:null,cookieCustomStorageSet:null,cookieCustomStorageDelete:null,_filterControls:[],_filterControlValuesLoaded:!1,_storage:{setItem:void 0,getItem:void 0,removeItem:void 0}}),g.fn.bootstrapTable.methods.push("getCookies"),g.fn.bootstrapTable.methods.push("deleteCookie"),Object.assign(g.fn.bootstrapTable.utils,{setCookie:_.setCookie,getCookie:_.getCookie}),g.BootstrapTable=function(e){function o(){return function(e,o){if(!(e instanceof o))throw new TypeError("Cannot call a class as a function")}(this,o),y(this,o,arguments)}return function(e,o){if("function"!=typeof o&&null!==o)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(o&&o.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),o&&I(e,o)}(o,e),C(o,[{key:"init",value:function(){if(this.options.cookie){if("cookieStorage"===this.options.cookieStorage&&!_.isCookieSupportedByBrowser())throw new Error("Cookies are not enabled in this browser.");this.configureStorage();var e=_.getCookie(this,_.cookieIds.filterBy);if("boolean"==typeof e&&!e)throw new Error("The cookie value of filterBy must be a json!");var t={};try{t=JSON.parse(e)}catch(e){throw new Error("Could not parse the json of the filterBy cookie!")}if(this.filterColumns=t||{},this._filterControls=[],this._filterControlValuesLoaded=!1,this.options.cookiesEnabled="string"==typeof this.options.cookiesEnabled?this.options.cookiesEnabled.replace("[","").replace("]","").replace(/'/g,"").replace(/ /g,"").split(","):this.options.cookiesEnabled,this.options.filterControl){var i=this;this.$el.on("column-search.bs.table",(function(e,o,t){for(var r=!0,s=0;s<i._filterControls.length;s++)if(i._filterControls[s].field===o){i._filterControls[s].text=t,r=!1;break}r&&i._filterControls.push({field:o,text:t}),_.setCookie(i,_.cookieIds.filterControl,JSON.stringify(i._filterControls))})).on("created-controls.bs.table",_.initCookieFilters(i))}}j(S(o.prototype),"init",this).call(this)}},{key:"initServer",value:function(){var e;if(this.options.cookie&&this.options.filterControl&&!this._filterControlValuesLoaded&&JSON.parse(_.getCookie(this,_.cookieIds.filterControl)))return;for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];(e=j(S(o.prototype),"initServer",this)).call.apply(e,[this].concat(i))}},{key:"initTable",value:function(){for(var e,t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];(e=j(S(o.prototype),"initTable",this)).call.apply(e,[this].concat(i)),this.initCookie()}},{key:"onSort",value:function(){for(var e,t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];(e=j(S(o.prototype),"onSort",this)).call.apply(e,[this].concat(i)),this.options.cookie&&(void 0===this.options.sortName||void 0===this.options.sortOrder?(_.deleteCookie(this,_.cookieIds.sortName),_.deleteCookie(this,_.cookieIds.sortOrder)):(this.options.sortPriority=null,_.deleteCookie(this,_.cookieIds.sortPriority),_.setCookie(this,_.cookieIds.sortOrder,this.options.sortOrder),_.setCookie(this,_.cookieIds.sortName,this.options.sortName)))}},{key:"onMultipleSort",value:function(){for(var e,t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];(e=j(S(o.prototype),"onMultipleSort",this)).call.apply(e,[this].concat(i)),this.options.cookie&&(void 0===this.options.sortPriority?_.deleteCookie(this,_.cookieIds.sortPriority):(this.options.sortName=void 0,this.options.sortOrder=void 0,_.deleteCookie(this,_.cookieIds.sortName),_.deleteCookie(this,_.cookieIds.sortOrder),_.setCookie(this,_.cookieIds.sortPriority,JSON.stringify(this.options.sortPriority))))}},{key:"onPageNumber",value:function(){for(var e,t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];(e=j(S(o.prototype),"onPageNumber",this)).call.apply(e,[this].concat(i)),this.options.cookie&&_.setCookie(this,_.cookieIds.pageNumber,this.options.pageNumber)}},{key:"onPageListChange",value:function(){for(var e,t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];(e=j(S(o.prototype),"onPageListChange",this)).call.apply(e,[this].concat(i)),this.options.cookie&&(_.setCookie(this,_.cookieIds.pageList,this.options.pageSize===this.options.formatAllRows()?"all":this.options.pageSize),_.setCookie(this,_.cookieIds.pageNumber,this.options.pageNumber))}},{key:"onPagePre",value:function(){for(var e,t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];(e=j(S(o.prototype),"onPagePre",this)).call.apply(e,[this].concat(i)),this.options.cookie&&_.setCookie(this,_.cookieIds.pageNumber,this.options.pageNumber)}},{key:"onPageNext",value:function(){for(var e,t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];(e=j(S(o.prototype),"onPageNext",this)).call.apply(e,[this].concat(i)),this.options.cookie&&_.setCookie(this,_.cookieIds.pageNumber,this.options.pageNumber)}},{key:"_toggleColumn",value:function(){for(var e,t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];(e=j(S(o.prototype),"_toggleColumn",this)).call.apply(e,[this].concat(i)),this.options.cookie&&_.setCookie(this,_.cookieIds.hiddenColumns,JSON.stringify(this.getHiddenColumns().map((function(e){return e.field}))))}},{key:"_toggleAllColumns",value:function(){for(var e,t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];(e=j(S(o.prototype),"_toggleAllColumns",this)).call.apply(e,[this].concat(i)),this.options.cookie&&_.setCookie(this,_.cookieIds.hiddenColumns,JSON.stringify(this.getHiddenColumns().map((function(e){return e.field}))))}},{key:"toggleView",value:function(){j(S(o.prototype),"toggleView",this).call(this),_.setCookie(this,_.cookieIds.cardView,this.options.cardView)}},{key:"toggleCustomView",value:function(){j(S(o.prototype),"toggleCustomView",this).call(this),_.setCookie(this,_.cookieIds.customView,this.customViewDefaultView)}},{key:"selectPage",value:function(e){j(S(o.prototype),"selectPage",this).call(this,e),this.options.cookie&&_.setCookie(this,_.cookieIds.pageNumber,e)}},{key:"onSearch",value:function(e){j(S(o.prototype),"onSearch",this).call(this,e,!(arguments.length>1)||arguments[1]),this.options.cookie&&(this.options.search&&_.setCookie(this,_.cookieIds.searchText,this.searchText),_.setCookie(this,_.cookieIds.pageNumber,this.options.pageNumber))}},{key:"initHeader",value:function(){var e;this.options.reorderableColumns&&this.options.cookie&&(this.columnsSortOrder=JSON.parse(_.getCookie(this,_.cookieIds.reorderColumns)));for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];(e=j(S(o.prototype),"initHeader",this)).call.apply(e,[this].concat(i))}},{key:"persistReorderColumnsState",value:function(e){_.setCookie(e,_.cookieIds.reorderColumns,JSON.stringify(e.columnsSortOrder))}},{key:"filterBy",value:function(){for(var e,t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];(e=j(S(o.prototype),"filterBy",this)).call.apply(e,[this].concat(i)),this.options.cookie&&_.setCookie(this,_.cookieIds.filterBy,JSON.stringify(this.filterColumns))}},{key:"initCookie",value:function(){if(this.options.cookie){if(""===this.options.cookieIdTable||""===this.options.cookieExpire)return console.error("Configuration error. Please review the cookieIdTable and the cookieExpire property. If the properties are correct, then this browser does not support cookies."),void(this.options.cookie=!1);var e=_.getCookie(this,_.cookieIds.sortOrder),o=_.getCookie(this,_.cookieIds.sortName),t=_.getCookie(this,_.cookieIds.sortPriority),i=_.getCookie(this,_.cookieIds.pageNumber),r=_.getCookie(this,_.cookieIds.pageList),s=_.getCookie(this,_.cookieIds.searchText),n=_.getCookie(this,_.cookieIds.cardView),a=_.getCookie(this,_.cookieIds.customView),l=_.getCookie(this,_.cookieIds.hiddenColumns),c={};try{c=JSON.parse(l)}catch(e){throw new Error("Could not parse the json of the hidden columns cookie!",l)}try{t=JSON.parse(t)}catch(e){throw new Error("Could not parse the json of the sortPriority cookie!",t)}if(t?(this.options.sortOrder=void 0,this.options.sortName=void 0):(this.options.sortOrder=e||this.options.sortOrder,this.options.sortName=o||this.options.sortName),this.options.sortPriority=t||this.options.sortPriority,(this.options.sortOrder||this.options.sortName)&&(this.options.sortPriority=null),this.options.pageNumber=i?+i:this.options.pageNumber,this.options.pageSize=r?"all"===r?this.options.formatAllRows():+r:this.options.pageSize,_.isCookieEnabled(this,_.cookieIds.searchText)&&""===this.options.searchText&&(this.options.searchText=s||""),null!==n&&(this.options.cardView="true"===n&&n),this.customViewDefaultView="true"===a,c){var u,p=v(this.columns);try{for(p.s();!(u=p.n()).done;){var h=u.value;h.switchable&&(h.visible=this.isSelectionColumn(h)||!c.includes(h.field))}}catch(e){p.e(e)}finally{p.f()}}}}},{key:"getCookies",value:function(){for(var e={},o=0,t=Object.entries(_.cookieIds);o<t.length;o++){var i=O(t[o],2),r=i[0],s=i[1];e[r]=_.getCookie(this,s),"columns"!==r&&"hiddenColumns"!==r&&"sortPriority"!==r||(e[r]=JSON.parse(e[r]))}return e}},{key:"deleteCookie",value:function(e){e&&this.options.cookie&&_.deleteCookie(this,_.cookieIds[e])}},{key:"configureStorage",value:function(){var e=this;switch(this._storage={},this.options.cookieStorage){case"cookieStorage":this._storage.setItem=function(o,t){document.cookie=[o,"=",encodeURIComponent(t),"; expires=".concat(_.calculateExpiration(e.options.cookieExpire)),e.options.cookiePath?"; path=".concat(e.options.cookiePath):"",e.options.cookieDomain?"; domain=".concat(e.options.cookieDomain):"",e.options.cookieSecure?"; secure":"",";SameSite=".concat(e.options.cookieSameSite)].join("")},this._storage.getItem=function(e){var o="; ".concat(document.cookie).split("; ".concat(e,"="));return 2===o.length?decodeURIComponent(o.pop().split(";").shift()):null},this._storage.removeItem=function(o){document.cookie=[encodeURIComponent(o),"=","; expires=Thu, 01 Jan 1970 00:00:00 GMT",e.options.cookiePath?"; path=".concat(e.options.cookiePath):"",e.options.cookieDomain?"; domain=".concat(e.options.cookieDomain):"",";SameSite=".concat(e.options.cookieSameSite)].join("")};break;case"localStorage":this._storage.setItem=function(e,o){localStorage.setItem(e,o)},this._storage.getItem=function(e){return localStorage.getItem(e)},this._storage.removeItem=function(e){localStorage.removeItem(e)};break;case"sessionStorage":this._storage.setItem=function(e,o){sessionStorage.setItem(e,o)},this._storage.getItem=function(e){return sessionStorage.getItem(e)},this._storage.removeItem=function(e){sessionStorage.removeItem(e)};break;case"customStorage":if(!this.options.cookieCustomStorageSet||!this.options.cookieCustomStorageGet||!this.options.cookieCustomStorageDelete)throw new Error("The following options must be set while using the customStorage: cookieCustomStorageSet, cookieCustomStorageGet and cookieCustomStorageDelete");this._storage.setItem=function(o,t){T.calculateObjectValue(e.options,e.options.cookieCustomStorageSet,[o,t],"")},this._storage.getItem=function(o){return T.calculateObjectValue(e.options,e.options.cookieCustomStorageGet,[o],"")},this._storage.removeItem=function(o){T.calculateObjectValue(e.options,e.options.cookieCustomStorageDelete,[o],"")};break;default:throw new Error("Storage method not supported.")}}}])}(g.BootstrapTable)}));
|