7 lines
57 KiB
JavaScript
Raw Normal View History

/**
* @author zhixin wen <wenzhixin2010@gmail.com>
* version: 1.11.0
* https://github.com/wenzhixin/bootstrap-table/
*/
2020-01-02 19:29:55 +08:00
(function(j){var k=null;var m=function(u){var s=arguments,r=true,t=1;u=u.replace(/%s/g,function(){var v=s[t++];if(typeof v==="undefined"){r=false;return""}return v});return r?u:""};var c=function(t,v,u,s){var r="";j.each(t,function(w,x){if(x[v]===s){r=x[u];return false}return true});return r};var i=function(s,t){var r=-1;j.each(s,function(u,v){if(v.field===t){r=u;return false}return true});return r};var l=function(u){var y,x,w,A=0,B=[];for(y=0;y<u[0].length;y++){A+=u[0][y].colspan||1}for(y=0;y<u.length;y++){B[y]=[];for(x=0;x<A;x++){B[y][x]=false}}for(y=0;y<u.length;y++){for(x=0;x<u[y].length;x++){var s=u[y][x],v=s.rowspan||1,t=s.colspan||1,z=j.inArray(false,B[y]);if(t===1){s.fieldIndex=z;if(typeof s.field==="undefined"){s.field=z}}for(w=0;w<v;w++){B[y+w][z]=true}for(w=0;w<t;w++){B[y][z+w]=true}}}};var a=function(){if(k===null){var t=j("<p/>").addClass("fixed-table-scroll-inner"),u=j("<div/>").addClass("fixed-table-scroll-outer"),s,r;u.append(t);j("body").append(u);s=t[0].offsetWidth;u.css("overflow","scroll");r=t[0].offsetWidth;if(s===r){r=u[0].clientWidth}u.remove();k=s-r}return k};var q=function(s,u,t,r){var v=u;if(typeof u==="string"){var w=u.split(".");if(w.length>1){v=window;j.each(w,function(x,y){v=v[y]})}else{v=window[u]}}if(typeof v==="object"){return v}if(typeof v==="function"){return v.apply(s,t)}if(!v&&typeof u==="string"&&m.apply(this,[u].concat(t))){return m.apply(this,[u].concat(t))}return r};var f=function(s,r,w){var x=Object.getOwnPropertyNames(s),u=Object.getOwnPropertyNames(r),v="";if(w){if(x.length!==u.length){return false}}for(var t=0;t<x.length;t++){v=x[t];if(j.inArray(v,u)>-1){if(s[v]!==r[v]){return false}}}return true};var p=function(r){if(typeof r==="string"){return r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/`/g,"&#x60;")}return r};var d=function(s){var r=0;s.children().each(function(){if(r<j(this).outerHeight(true)){r=j(this).outerHeight(true)}});return r};var g=function(t){for(var r in t){var s=r.split(/(?=[A-Z])/).join("-").toLowerCase();if(s!==r){t[s]=t[r];delete t[r]}}return t};var o=function(t,w,s){var u=t;if(typeof w!=="string"||t.hasOwnProperty(w)){return s?p(t[w]):t[w]}var r=w.split(".");for(var v in r){u=u&&u[r[v]]}return s?p(u):u};var b=function(){return !!(navigator.userAgent.indexOf("MSIE ")>0||!!navigator.userAgent.match(/Trident.*rv\:11\./))};var h=function(){if(!Object.keys){Object.keys=(function(){var t=Object.prototype.hasOwnProperty,u=!({toString:null}).propertyIsEnumerable("toString"),s=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],r=s.length;return function(x){if(typeof x!=="object"&&(typeof x!=="function"||x===null)){throw new TypeError("Object.keys called on non-object")}var v=[],y,w;for(y in x){if(t.call(x,y)){v.push(y)}}if(u){for(w=0;w<r;w++){if(t.call(x,s[w])){v.push(s[w])}}}return v}}())}};var e=function(s,r){this.options=r;this.$el=j(s);this.$el_=this.$el.clone();this.timeoutId_=0;this.timeoutFooter_=0;this.init()};e.DEFAULTS={id:undefined,classes:"table table-hover",locale:undefined,height:undefined,undefinedText:"-",sortName:undefined,sortOrder:"asc",sortStable:false,striped:false,columns:[[]],data:[],dataField:"rows",method:"get",url:undefined,ajax:undefined,cache:true,contentType:"application/json",dataType:"json",ajaxOptions:{},queryParams:function(r){return r},queryParamsType:"limit",responseHandler:function(r){return r},pagination:false,onlyInfoPagination:false,sidePagination:"client",totalRows:0,pageNumber:1,pageSize:10,pageList:[10,25,50,100],paginationHAlign:"right",paginationVAlign:"bottom",paginationDetailHAlign:"left",paginationPreText:"&lsaquo;",paginationNextText:"&rsaquo;",search:false,searchOnEnterKey:false,strictSearch:false,searchAlign:"right",selectItemName:"btSelectItem",showHeader:true,showFooter:false,showColumns:false,showSearch:false,showPageGo:false,showPaginationSwitch:false,showRefresh:false,showToggle:false,buttonsAlign:"right",smartDisplay:true,escape:false,firstLoad:true,minimumCountColumns:1,idFiel
};e.prototype.uncheck=function(r){this.check_(false,r)};e.prototype.check_=function(t,r){var s=this.$selectItem.filter(m('[data-index="%s"]',r)).prop("checked",t);this.data[r][this.header.stateField]=t;this.updateSelected();this.trigger(t?"check":"uncheck",this.data[r],s)};e.prototype.checkBy=function(r){this.checkBy_(true,r)};e.prototype.uncheckBy=function(r){this.checkBy_(false,r)};e.prototype.checkBy_=function(s,u){if(!u.hasOwnProperty("field")||!u.hasOwnProperty("values")){return}var r=this,t=[];j.each(this.options.data,function(v,x){if(!x.hasOwnProperty(u.field)){return false}if(j.inArray(x[u.field],u.values)!==-1){var w=r.$selectItem.filter(":enabled").filter(m('[data-index="%s"]',v)).prop("checked",s);x[r.header.stateField]=s;t.push(x);r.trigger(s?"check":"uncheck",x,w)}});this.updateSelected();this.trigger(s?"check-some":"uncheck-some",t)};e.prototype.destroy=function(){this.$el.insertBefore(this.$container);j(this.options.toolbar).insertBefore(this.$el);this.$container.next().remove();this.$container.remove();this.$el.html(this.$el_.html()).css("margin-top","0").attr("class",this.$el_.attr("class")||"")};e.prototype.showLoading=function(){this.$tableLoading.show()};e.prototype.hideLoading=function(){this.$tableLoading.hide()};e.prototype.togglePagination=function(){this.options.pagination=!this.options.pagination;var r=this.$toolbar.find('button[name="paginationSwitch"] i');if(this.options.pagination){r.attr("class",this.options.iconsPrefix+" "+this.options.icons.paginationSwitchDown)}else{r.attr("class",this.options.iconsPrefix+" "+this.options.icons.paginationSwitchUp)}this.updatePagination()};e.prototype.refresh=function(r){if(r&&r.url){this.options.pageNumber=1}table.rememberSelecteds={};table.rememberSelectedIds={};this.initServer(r&&r.silent,r&&r.query,r&&r.url);this.trigger("refresh",r)};e.prototype.resetWidth=function(){if(this.options.showHeader&&this.options.height){this.fitHeader()}if(this.options.showFooter){this.fitFooter()}};e.prototype.showColumn=function(r){this.toggleColumn(i(this.columns,r),true,true)};e.prototype.hideColumn=function(r){this.toggleColumn(i(this.columns,r),false,true)};e.prototype.getHiddenColumns=function(){return j.grep(this.columns,function(r){return !r.visible})};e.prototype.getVisibleColumns=function(){return j.grep(this.columns,function(r){return r.visible})};e.prototype.toggleAllColumns=function(r){j.each(this.columns,function(t,u){this.columns[t].visible=r});this.initHeader();this.initSearch();this.initPagination();this.initBody();if(this.options.showColumns){var s=this.$toolbar.find(".keep-open input").prop("disabled",false);if(s.filter(":checked").length<=this.options.minimumCountColumns){s.filter(":checked").prop("disabled",true)}}};e.prototype.showAllColumns=function(){this.toggleAllColumns(true)};e.prototype.hideAllColumns=function(){this.toggleAllColumns(false)};e.prototype.filterBy=function(r){this.filterColumns=j.isEmptyObject(r)?{}:r;this.options.pageNumber=1;this.initSearch();this.updatePagination()};e.prototype.scrollTo=function(r){if(typeof r==="string"){r=r==="bottom"?this.$tableBody[0].scrollHeight:0}if(typeof r==="number"){this.$tableBody.scrollTop(r)}if(typeof r==="undefined"){return this.$tableBody.scrollTop()}};e.prototype.getScrollPosition=function(){return this.scrollTo()};e.prototype.selectPage=function(r){if(r>0&&r<=this.options.totalPages){this.options.pageNumber=r;this.updatePagination()}};e.prototype.prevPage=function(){if(this.options.pageNumber>1){this.options.pageNumber--;this.updatePagination()}};e.prototype.nextPage=function(){if(this.options.pageNumber<this.options.totalPages){this.options.pageNumber++;this.updatePagination()}};e.prototype.toggleView=function(){this.options.cardView=!this.options.cardView;this.initHeader();this.initBody();this.trigger("toggle",this.options.cardView)};e.prototype.refreshOptions=function(r){if(f(this.options,r,true)){return}this.options=j.extend(this.options,r);this.trigger("refresh-options",this.options);this.destroy();this.init()};e.prototype.resetSearch=function(s){var r=this.$toolbar.find(".search input"