12345678 |
- /*
- * bootstrap-table - v1.7.0 - 2015-04-01
- * https://github.com/wenzhixin/bootstrap-table
- * Copyright (c) 2015 zhixin wen
- * Licensed MIT License
- */
- !function(a){"use strict";var b=37,c=null,d=function(a){var b=arguments,c=!0,d=1;return a=a.replace(/%s/g,function(){var a=b[d++];return"undefined"==typeof a?(c=!1,""):a}),c?a:""},e=function(b,c,d,e){var f="";return a.each(b,function(a,b){return b[c]===e?(f=b[d],!1):!0}),f},f=function(b,c){var d=-1;return a.each(b,function(a,b){return b.field===c?(d=a,!1):!0}),d},g=function(){if(null===c){var b,d,e=a("<p/>").addClass("fixed-table-scroll-inner"),f=a("<div/>").addClass("fixed-table-scroll-outer");f.append(e),a("body").append(f),b=e[0].offsetWidth,f.css("overflow","scroll"),d=e[0].offsetWidth,b===d&&(d=f[0].clientWidth),f.remove(),c=b-d}return c},h=function(b,c,d,e){if("string"==typeof c){var f=c.split(".");f.length>1?(c=window,a.each(f,function(a,b){c=c[b]})):c=window[c]}return"object"==typeof c?c:"function"==typeof c?c.apply(b,d):e},i=function(a){return"string"==typeof a?a.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"):a},j=function(b,c){this.options=c,this.$el=a(b),this.$el_=this.$el.clone(),this.timeoutId_=0,this.timeoutFooter_=0,this.init()};j.DEFAULTS={classes:"table table-hover",height:void 0,undefinedText:"-",sortName:void 0,sortOrder:"asc",striped:!1,columns:[],data:[],method:"get",url:void 0,cache:!0,contentType:"application/json",dataType:"json",ajaxOptions:{},queryParams:function(a){return a},queryParamsType:"limit",responseHandler:function(a){return a},pagination:!1,sidePagination:"client",totalRows:0,pageNumber:1,pageSize:10,pageList:[10,25,50,100],paginationHAlign:"right",paginationVAlign:"bottom",paginationDetailHAlign:"left",search:!1,searchAlign:"right",selectItemName:"btSelectItem",showHeader:!0,showFooter:!1,showColumns:!1,showPaginationSwitch:!1,showRefresh:!1,showToggle:!1,buttonsAlign:"right",smartDisplay:!0,minimumCountColumns:1,idField:void 0,uniqueId:void 0,cardView:!1,trimOnSearch:!0,clickToSelect:!1,singleSelect:!1,toolbar:void 0,toolbarAlign:"left",checkboxHeader:!0,sortable:!0,maintainSelected:!1,searchTimeOut:500,keyEvents:!1,searchText:"",iconSize:void 0,iconsPrefix:"glyphicon",icons:{paginationSwitchDown:"glyphicon-collapse-down icon-chevron-down",paginationSwitchUp:"glyphicon-collapse-up icon-chevron-up",refresh:"glyphicon-refresh icon-refresh",toggle:"glyphicon-list-alt icon-list-alt",columns:"glyphicon-th icon-th"},rowStyle:function(){return{}},rowAttributes:function(){return{}},onAll:function(){return!1},onClickRow:function(){return!1},onDblClickRow:function(){return!1},onSort:function(){return!1},onCheck:function(){return!1},onUncheck:function(){return!1},onCheckAll:function(){return!1},onUncheckAll:function(){return!1},onLoadSuccess:function(){return!1},onLoadError:function(){return!1},onColumnSwitch:function(){return!1},onColumnSearch:function(){return!1},onPageChange:function(){return!1},onSearch:function(){return!1},onPreBody:function(){return!1},onPostBody:function(){return!1},onPostHeader:function(){return!1}},j.LOCALES=[],j.LOCALES["en-US"]={formatLoadingMessage:function(){return"Loading, please wait..."},formatRecordsPerPage:function(a){return d("%s records per page",a)},formatShowingRows:function(a,b,c){return d("Showing %s to %s of %s rows",a,b,c)},formatSearch:function(){return"Search"},formatNoMatches:function(){return"No matching records found"},formatPaginationSwitch:function(){return"Hide/Show pagination"},formatRefresh:function(){return"Refresh"},formatToggle:function(){return"Toggle"},formatColumns:function(){return"Columns"},formatAllRows:function(){return"All"}},a.extend(j.DEFAULTS,j.LOCALES["en-US"]),j.COLUMN_DEFAULTS={radio:!1,checkbox:!1,checkboxEnabled:!0,field:void 0,title:void 0,"class":void 0,align:void 0,halign:void 0,falign:void 0,valign:void 0,width:void 0,sortable:!1,order:"asc",visible:!0,switchable:!0,clickToSelect:!0,formatter:void 0,footerFormatter:void 0,events:void 0,sorter:void 0,cellStyle:void 0,searchable:!0,cardVisible:!0,filterControl:void 0},j.EVENTS={"all.bs.table":"onAll","click-row.bs.table":"onClickRow","dbl-click-row.bs.table":"onDblClickRow","sort.bs.table":"onSort","check.bs.table":"onCheck","uncheck.bs.table":"onUncheck","check-all.bs.table":"onCheckAll","uncheck-all.bs.table":"onUncheckAll","load-success.bs.table":"onLoadSuccess","load-error.bs.table":"onLoadError","column-switch.bs.table":"onColumnSwitch","column-search.bs.table":"onColumnSearch","page-change.bs.table":"onPageChange","search.bs.table":"onSearch","pre-body.bs.table":"onPreBody","post-body.bs.table":"onPostBody","post-header.bs.table":"onPostHeader"},j.prototype.init=function(){this.initContainer(),this.initTable(),this.initHeader(),this.initData(),this.initFooter(),this.initToolbar(),this.initPagination(),this.initBody(),this.initServer(),this.initKeyEvents()},j.prototype.initContainer=function(){this.$container=a(['<div class="bootstrap-table">','<div class="fixed-table-toolbar"></div>',"top"===this.options.paginationVAlign||"both"===this.options.paginationVAlign?'<div class="fixed-table-pagination" style="clear: both;"></div>':"",'<div class="fixed-table-container">','<div class="fixed-table-header"><table></table></div>','<div class="fixed-table-body">','<div class="fixed-table-loading">',this.options.formatLoadingMessage(),"</div>","</div>",'<div class="fixed-table-footer"><table><tr></tr></table></div>',"bottom"===this.options.paginationVAlign||"both"===this.options.paginationVAlign?'<div class="fixed-table-pagination"></div>':"","</div>","</div>"].join("")),this.$container.insertAfter(this.$el),this.$container.find(".fixed-table-body").append(this.$el),this.$container.after('<div class="clearfix"></div>'),this.$loading=this.$container.find(".fixed-table-loading"),this.$el.addClass(this.options.classes),this.options.striped&&this.$el.addClass("table-striped")},j.prototype.initTable=function(){var b=this,c=[],d=[];this.$header=this.$el.find("thead"),this.$header.length||(this.$header=a("<thead></thead>").appendTo(this.$el)),this.$header.find("tr").length||this.$header.append("<tr></tr>"),this.$header.find("th").each(function(){var b=a.extend({},{title:a(this).html(),"class":a(this).attr("class")},a(this).data());c.push(b)}),this.options.columns=a.extend(!0,[],c,this.options.columns),a.each(this.options.columns,function(c,d){b.options.columns[c]=a.extend({},j.COLUMN_DEFAULTS,{field:c},d)}),this.options.data.length||(this.$el.find("tbody tr").each(function(){var c={};c._id=a(this).attr("id"),c._class=a(this).attr("class"),a(this).find("td").each(function(d){var e=b.options.columns[d].field;c[e]=a(this).html(),c["_"+e+"_id"]=a(this).attr("id"),c["_"+e+"_class"]=a(this).attr("class"),c["_"+e+"_data"]=a(this).data()}),d.push(c)}),this.options.data=d)},j.prototype.initHeader=function(){var c=this,e=[],f=[],g=!1,h=0;this.header={fields:[],styles:[],classes:[],formatters:[],events:[],sorters:[],cellStyles:[],clickToSelects:[],searchables:[]},a.each(this.options.columns,function(a,b){var h="",i="",j="",k="",l=d(' class="%s"',b["class"]),m=(c.options.sortOrder||b.order,"px"),n="hidden";if(b.visible&&(!c.options.cardView||b.cardVisible)){if(void 0!==b.width&&"string"==typeof b.width&&(b.width.indexOf("%")>-1&&(m="%"),b.width=b.width.replace("%","").replace("px","")),i=d("text-align: %s; ",b.halign?b.halign:b.align),j=d("text-align: %s; ",b.align),k=d("vertical-align: %s; ",b.valign),k+=d("width: %s"+m+"; ",b.checkbox||b.radio?36:b.width),e.push(b),c.header.fields.push(b.field),c.header.styles.push(j+k),c.header.classes.push(l),c.header.formatters.push(b.formatter),c.header.events.push(b.events),c.header.sorters.push(b.sorter),c.header.cellStyles.push(b.cellStyle),c.header.clickToSelects.push(b.clickToSelect),c.header.searchables.push(b.searchable),f.push("<th",b.checkbox||b.radio?d(' class="bs-checkbox %s"',b["class"]||""):l,d(' style="%s"',i+k),">"),f.push(d('<div class="th-inner %s">',c.options.sortable&&b.sortable?"sortable":"")),h=b.title,c.options.sortName===b.field&&c.options.sortable&&b.sortable&&(h+=c.getCaretHtml()),b.checkbox&&(!c.options.singleSelect&&c.options.checkboxHeader&&(h='<input name="btSelectAll" type="checkbox" />'),c.header.stateField=b.field),b.radio&&(h="",c.header.stateField=b.field,c.options.singleSelect=!0),f.push(h),f.push("</div>"),f.push('<div class="fht-cell"></div>'),f.push('<div style="margin: 0px 2px 2px 2px;" class="filterControl">'),b.filterControl&&b.searchable&&(g=!0,n="visible"),void 0!==b.filterControl)switch(b.filterControl.toLowerCase()){case"input":f.push(d('<input type="text" class="form-control" style="width: 100%; visibility: %s">',n));break;case"select":f.push(d('<select class="%s form-control" style="width: 100%; visibility: %s"></select>',b.field,n))}else f.push('<div style="height: 34px;"></div>');f.push("</div>"),f.push("</th>")}}),this.$header.find("tr").html(f.join("")),this.$header.find("th").each(function(b){a(this).data(e[b])}),this.$container.off("click",".th-inner").on("click",".th-inner",function(b){c.options.sortable&&a(this).parent().data().sortable&&c.onSort(b)}),!this.options.showHeader||this.options.cardView?(this.$header.hide(),this.$container.find(".fixed-table-header").hide(),this.$loading.css("top",0)):(this.$header.show(),this.$container.find(".fixed-table-header").show(),this.$loading.css("top",b+"px")),this.$selectAll=this.$header.find('[name="btSelectAll"]'),this.$container.off("click",'[name="btSelectAll"]').on("click",'[name="btSelectAll"]',function(){var b=a(this).prop("checked");c[b?"checkAll":"uncheckAll"]()}),g?(this.$header.off("keyup","input").on("keyup","input",function(a){clearTimeout(h),h=setTimeout(function(){c.onColumnSearch(a)},c.options.searchTimeOut)}),this.$header.off("change","select").on("change","select",function(a){clearTimeout(h),h=setTimeout(function(){c.onColumnSearch(a)},c.options.searchTimeOut)})):this.$header.find(".filterControl").hide()},j.prototype.initFooter=function(){this.$footer=this.$container.find(".fixed-table-footer"),!this.options.showFooter||this.options.cardView?this.$footer.hide():this.$footer.show()},j.prototype.initData=function(a,b){this.data="append"===b?this.data.concat(a):"prepend"===b?[].concat(a).concat(this.data):a||this.options.data,this.options.data=this.data,"server"!==this.options.sidePagination&&this.initSort()},j.prototype.initSort=function(){var b=this,c=this.options.sortName,d="desc"===this.options.sortOrder?-1:1,e=a.inArray(this.options.sortName,this.header.fields);-1!==e&&this.data.sort(function(f,g){var i=f[c],j=g[c],k=h(b.header,b.header.sorters[e],[i,j]);return void 0!==k?d*k:void 0!==k?d*k:((void 0===i||null===i)&&(i=""),(void 0===j||null===j)&&(j=""),a.isNumeric(i)&&a.isNumeric(j)?(i=parseFloat(i),j=parseFloat(j),j>i?-1*d:d):i===j?0:("string"!=typeof i&&(i=i.toString()),-1===i.localeCompare(j)?-1*d:d))})},j.prototype.onSort=function(b){var c=a(b.currentTarget).parent(),d=this.$header.find("th").eq(c.index());return this.$header.add(this.$header_).find("span.order").remove(),this.options.sortName===c.data("field")?this.options.sortOrder="asc"===this.options.sortOrder?"desc":"asc":(this.options.sortName=c.data("field"),this.options.sortOrder="asc"===c.data("order")?"desc":"asc"),this.trigger("sort",this.options.sortName,this.options.sortOrder),c.add(d).data("order",this.options.sortOrder).find(".th-inner").append(this.getCaretHtml()),"server"===this.options.sidePagination?void this.initServer():(this.initSort(),void this.initBody())},j.prototype.initToolbar=function(){var b,c,e=this,f=[],g=0,i=0;this.$toolbar=this.$container.find(".fixed-table-toolbar").html(""),"string"==typeof this.options.toolbar&&a(d('<div class="bars pull-%s"></div>',this.options.toolbarAlign)).appendTo(this.$toolbar).append(a(this.options.toolbar)),f=[d('<div class="columns columns-%s btn-group pull-%s">',this.options.buttonsAlign,this.options.buttonsAlign)],"string"==typeof this.options.icons&&(this.options.icons=h(null,this.options.icons)),this.options.showPaginationSwitch&&f.push(d('<button class="btn btn-default" type="button" name="paginationSwitch" title="%s">',this.options.formatPaginationSwitch()),d('<i class="%s %s"></i>',this.options.iconsPrefix,this.options.icons.paginationSwitchDown),"</button>"),this.options.showRefresh&&f.push(d('<button class="btn btn-default'+(void 0===this.options.iconSize?"":" btn-"+this.options.iconSize)+'" type="button" name="refresh" title="%s">',this.options.formatRefresh()),d('<i class="%s %s"></i>',this.options.iconsPrefix,this.options.icons.refresh),"</button>"),this.options.showToggle&&f.push(d('<button class="btn btn-default'+(void 0===this.options.iconSize?"":" btn-"+this.options.iconSize)+'" type="button" name="toggle" title="%s">',this.options.formatToggle()),d('<i class="%s %s"></i>',this.options.iconsPrefix,this.options.icons.toggle),"</button>"),this.options.showColumns&&(f.push(d('<div class="keep-open btn-group" title="%s">',this.options.formatColumns()),'<button type="button" class="btn btn-default'+(void 0==this.options.iconSize?"":" btn-"+this.options.iconSize)+' dropdown-toggle" data-toggle="dropdown">',d('<i class="%s %s"></i>',this.options.iconsPrefix,this.options.icons.columns),' <span class="caret"></span>',"</button>",'<ul class="dropdown-menu" role="menu">'),a.each(this.options.columns,function(a,b){if(!(b.radio||b.checkbox||e.options.cardView&&!b.cardVisible)){var c=b.visible?' checked="checked"':"";b.switchable&&(f.push(d('<li><label><input type="checkbox" data-field="%s" value="%s"%s> %s</label></li>',b.field,a,c,b.title)),i++)}}),f.push("</ul>","</div>")),f.push("</div>"),(this.showToolbar||f.length>2)&&this.$toolbar.append(f.join("")),this.options.showPaginationSwitch&&this.$toolbar.find('button[name="paginationSwitch"]').off("click").on("click",a.proxy(this.togglePagination,this)),this.options.showRefresh&&this.$toolbar.find('button[name="refresh"]').off("click").on("click",a.proxy(this.refresh,this)),this.options.showToggle&&this.$toolbar.find('button[name="toggle"]').off("click").on("click",function(){e.toggleView()}),this.options.showColumns&&(b=this.$toolbar.find(".keep-open"),i<=this.options.minimumCountColumns&&b.find("input").prop("disabled",!0),b.find("li").off("click").on("click",function(a){a.stopImmediatePropagation()}),b.find("input").off("click").on("click",function(){var b=a(this);e.toggleColumn(b.val(),b.prop("checked"),!1),e.trigger("column-switch",a(this).data("field"),b.prop("checked"))})),this.options.search&&(f=[],f.push('<div class="pull-'+this.options.searchAlign+' search">',d('<input class="form-control'+(void 0===this.options.iconSize?"":" input-"+this.options.iconSize)+'" type="text" placeholder="%s">',this.options.formatSearch()),"</div>"),this.$toolbar.append(f.join("")),c=this.$toolbar.find(".search input"),c.off("keyup").on("keyup",function(a){clearTimeout(g),g=setTimeout(function(){e.onSearch(a)},e.options.searchTimeOut)}),""!==this.options.searchText&&(c.val(this.options.searchText),clearTimeout(g),g=setTimeout(function(){c.trigger("keyup")},e.options.searchTimeOut)))},j.prototype.onSearch=function(b){var c=a.trim(a(b.currentTarget).val());this.options.trimOnSearch&&a(b.currentTarget).val()!==c&&a(b.currentTarget).val(c),c!==this.searchText&&(this.searchText=c,this.options.pageNumber=1,this.initSearch(),this.updatePagination(),this.trigger("search",c))},j.prototype.onColumnSearch=function(b){var c=a.trim(a(b.currentTarget).val()),d=a(b.currentTarget).parent().parent().data("field");a.isEmptyObject(this.filterColumnsPartial)&&(this.filterColumnsPartial={}),c?this.filterColumnsPartial[d]=c:delete this.filterColumnsPartial[d],this.options.pageNumber=1,this.initSearch(),this.updatePagination()},j.prototype.initSearch=function(){var b=this;if("server"!==this.options.sidePagination){var c=this.searchText&&this.searchText.toLowerCase(),d=a.isEmptyObject(this.filterColumns)?null:this.filterColumns,e=a.isEmptyObject(this.filterColumnsPartial)?null:this.filterColumnsPartial;this.data=d?a.grep(this.options.data,function(a){for(var b in d)if(a[b]!==d[b])return!1;return!0}):this.options.data,this.data=e?a.grep(this.data,function(c,d){for(var f in e){var g=e[f].toLowerCase(),i=c[f];if(i=h(b.header,b.header.formatters[a.inArray(f,b.header.fields)],[i,c,d],i),-1===a.inArray(f,b.header.fields)||"string"!=typeof i&&"number"!=typeof i||-1===(i+"").toLowerCase().indexOf(g))return!1}return!0}):this.data,this.data=c?a.grep(this.data,function(d,e){for(var f in d){f=a.isNumeric(f)?parseInt(f,10):f;var g=d[f];g=h(b.header,b.header.formatters[a.inArray(f,b.header.fields)],[g,d,e],g);var i=a.inArray(f,b.header.fields);if(-1!==i&&b.header.searchables[i]&&("string"==typeof g||"number"==typeof g)&&-1!==(g+"").toLowerCase().indexOf(c))return!0}return!1}):this.data}},j.prototype.initPagination=function(){if(this.$pagination=this.$container.find(".fixed-table-pagination"),!this.options.pagination)return void this.$pagination.hide();this.$pagination.show();var b,c,e,f,g,h,i,j,k,l=this,m=[],n=!1,o=this.getData();if("server"!==this.options.sidePagination&&(this.options.totalRows=o.length),this.totalPages=0,this.options.totalRows){if(this.options.pageSize===this.options.formatAllRows())this.options.pageSize=this.options.totalRows,n=!0;else if(this.options.pageSize===this.options.totalRows){var p="string"==typeof this.options.pageList?this.options.pageList.replace("[","").replace("]","").replace(/ /g,"").toLowerCase().split(","):this.options.pageList;p.indexOf(this.options.formatAllRows().toLowerCase())>-1&&(n=!0)}this.totalPages=~~((this.options.totalRows-1)/this.options.pageSize)+1,this.options.totalPages=this.totalPages}this.totalPages>0&&this.options.pageNumber>this.totalPages&&(this.options.pageNumber=this.totalPages),this.pageFrom=(this.options.pageNumber-1)*this.options.pageSize+1,this.pageTo=this.options.pageNumber*this.options.pageSize,this.pageTo>this.options.totalRows&&(this.pageTo=this.options.totalRows),m.push('<div class="pull-'+this.options.paginationDetailHAlign+' pagination-detail">','<span class="pagination-info">',this.options.formatShowingRows(this.pageFrom,this.pageTo,this.options.totalRows),"</span>"),m.push('<span class="page-list">');var q=[d('<span class="btn-group %s">',"top"===this.options.paginationVAlign||"both"===this.options.paginationVAlign?"dropdown":"dropup"),'<button type="button" class="btn btn-default '+(void 0===this.options.iconSize?"":" btn-"+this.options.iconSize)+' dropdown-toggle" data-toggle="dropdown">','<span class="page-size">',n?this.options.formatAllRows():this.options.pageSize,"</span>",' <span class="caret"></span>',"</button>",'<ul class="dropdown-menu" role="menu">'],r=this.options.pageList;if("string"==typeof this.options.pageList){var s=this.options.pageList.replace("[","").replace("]","").replace(/ /g,"").split(",");r=[],a.each(s,function(a,b){r.push(b.toUpperCase()===l.options.formatAllRows().toUpperCase()?l.options.formatAllRows():+b)})}for(a.each(r,function(a,b){if(!l.options.smartDisplay||0===a||r[a-1]<=l.options.totalRows){var c;c=n?b===l.options.formatAllRows()?' class="active"':"":b===l.options.pageSize?' class="active"':"",q.push(d('<li%s><a href="javascript:void(0)">%s</a></li>',c,b))}}),q.push("</ul></span>"),m.push(this.options.formatRecordsPerPage(q.join(""))),m.push("</span>"),m.push("</div>",'<div class="pull-'+this.options.paginationHAlign+'">','<ul class="pagination'+(void 0===this.options.iconSize?"":" pagination-"+this.options.iconSize)+'">','<li class="page-first"><a href="javascript:void(0)"><<</a></li>','<li class="page-pre"><a href="javascript:void(0)"><</a></li>'),this.totalPages<5?(c=1,e=this.totalPages):(c=this.options.pageNumber-2,e=c+4,1>c&&(c=1,e=5),e>this.totalPages&&(e=this.totalPages,c=e-4)),b=c;e>=b;b++)m.push('<li class="page-number'+(b===this.options.pageNumber?" active":"")+'">','<a href="javascript:void(0)">',b,"</a>","</li>");m.push('<li class="page-next"><a href="javascript:void(0)">></a></li>','<li class="page-last"><a href="javascript:void(0)">>></a></li>',"</ul>","</div>"),this.$pagination.html(m.join("")),f=this.$pagination.find(".page-list a"),g=this.$pagination.find(".page-first"),h=this.$pagination.find(".page-pre"),i=this.$pagination.find(".page-next"),j=this.$pagination.find(".page-last"),k=this.$pagination.find(".page-number"),this.options.pageNumber<=1&&(g.addClass("disabled"),h.addClass("disabled")),this.options.pageNumber>=this.totalPages&&(i.addClass("disabled"),j.addClass("disabled")),this.options.smartDisplay&&(this.totalPages<=1&&this.$pagination.find("div.pagination").hide(),(r.length<2||this.options.totalRows<=r[0])&&this.$pagination.find("span.page-list").hide(),this.$pagination[this.getData().length?"show":"hide"]()),n&&(this.options.pageSize=this.options.formatAllRows()),f.off("click").on("click",a.proxy(this.onPageListChange,this)),g.off("click").on("click",a.proxy(this.onPageFirst,this)),h.off("click").on("click",a.proxy(this.onPagePre,this)),i.off("click").on("click",a.proxy(this.onPageNext,this)),j.off("click").on("click",a.proxy(this.onPageLast,this)),k.off("click").on("click",a.proxy(this.onPageNumber,this))},j.prototype.updatePagination=function(b){b&&a(b.currentTarget).hasClass("disabled")||(this.options.maintainSelected||this.resetRows(),this.initPagination(),"server"===this.options.sidePagination?this.initServer():this.initBody(),this.trigger("page-change",this.options.pageNumber,this.options.pageSize))},j.prototype.onPageListChange=function(b){var c=a(b.currentTarget);c.parent().addClass("active").siblings().removeClass("active"),this.options.pageSize=c.text().toUpperCase()===this.options.formatAllRows().toUpperCase()?this.options.formatAllRows():+c.text(),this.$toolbar.find(".page-size").text(this.options.pageSize),this.updatePagination(b)},j.prototype.onPageFirst=function(a){this.options.pageNumber=1,this.updatePagination(a)},j.prototype.onPagePre=function(a){this.options.pageNumber--,this.updatePagination(a)},j.prototype.onPageNext=function(a){this.options.pageNumber++,this.updatePagination(a)},j.prototype.onPageLast=function(a){this.options.pageNumber=this.totalPages,this.updatePagination(a)},j.prototype.onPageNumber=function(b){this.options.pageNumber!==+a(b.currentTarget).text()&&(this.options.pageNumber=+a(b.currentTarget).text(),this.updatePagination(b))},j.prototype.initBody=function(b){var c=this,g=[],j=this.getData();this.trigger("pre-body",j),this.$body=this.$el.find("tbody"),this.$body.length||(this.$body=a("<tbody></tbody>").appendTo(this.$el)),this.options.pagination&&"server"!==this.options.sidePagination||(this.pageFrom=1,this.pageTo=j.length);for(var k=this.pageFrom-1;k<this.pageTo;k++){var l,m=j[k],n={},o=[],p={},q=[];if(n=h(this.options,this.options.rowStyle,[m,k],n),n&&n.css)for(l in n.css)o.push(l+": "+n.css[l]);if(p=h(this.options,this.options.rowAttributes,[m,k],p))for(l in p)q.push(d('%s="%s"',l,i(p[l])));g.push("<tr",d(" %s",q.join(" ")),d(' id="%s"',a.isArray(m)?void 0:m._id),d(' class="%s"',n.classes||(a.isArray(m)?void 0:m._class)),d(' data-index="%s"',k),d(' data-unique-id="%s"',m[this.options.uniqueId]),">"),this.options.cardView&&g.push(d('<td colspan="%s">',this.header.fields.length)),a.each(this.header.fields,function(b,i){var j="",l=m[i],p="",q={},r="",s=c.header.classes[b],t="",u=c.options.columns[f(c.options.columns,i)];if(n=d('style="%s"',o.concat(c.header.styles[b]).join("; ")),l=h(c.header,c.header.formatters[b],[l,m,k],l),m["_"+i+"_id"]&&(r=d(' id="%s"',m["_"+i+"_id"])),m["_"+i+"_class"]&&(s=d(' class="%s"',m["_"+i+"_class"])),q=h(c.header,c.header.cellStyles[b],[l,m,k],q),q.classes&&(s=d(' class="%s"',q.classes)),q.css){var v=[];for(var w in q.css)v.push(w+": "+q.css[w]);n=d('style="%s"',v.concat(c.header.styles[b]).join("; "))}if(m["_"+i+"_data"]&&!a.isEmptyObject(m["_"+i+"_data"])&&a.each(m["_"+i+"_data"],function(a,b){"index"!==a&&(t+=d(' data-%s="%s"',a,b))}),u.checkbox||u.radio)p=u.checkbox?"checkbox":p,p=u.radio?"radio":p,j=[c.options.cardView?'<div class="card-view">':'<td class="bs-checkbox">',"<input"+d(' data-index="%s"',k)+d(' name="%s"',c.options.selectItemName)+d(' type="%s"',p)+d(' value="%s"',m[c.options.idField])+d(' checked="%s"',l===!0||l&&l.checked?"checked":void 0)+d(' disabled="%s"',!u.checkboxEnabled||l&&l.disabled?"disabled":void 0)+" />",c.options.cardView?"</div>":"</td>"].join("");else{if(l="undefined"==typeof l||null===l?c.options.undefinedText:l,j=c.options.cardView?['<div class="card-view">',c.options.showHeader?d('<span class="title" %s>%s</span>',n,e(c.options.columns,"field","title",i)):"",d('<span class="value">%s</span>',l),"</div>"].join(""):[d("<td%s %s %s %s>",r,s,n,t),l,"</td>"].join(""),void 0!==u.filterControl&&"select"===u.filterControl.toLowerCase()&&u.searchable){var x,y=a("."+u.field),z=0,A=!1;if(void 0!==y)if(x=y.get(0).options,0===x.length)y.append(a("<option></option>").attr("value","").text("")),y.append(a("<option></option>").attr("value",l).text(l));else{for(;z<x.length;z++)if(x[z].value===l){A=!0;break}A||y.append(a("<option></option>").attr("value",l).text(l))}}c.options.cardView&&c.options.smartDisplay&&""===l&&(j="")}g.push(j)}),this.options.cardView&&g.push("</td>"),g.push("</tr>")}g.length||g.push('<tr class="no-records-found">',d('<td colspan="%s">%s</td>',this.header.fields.length,this.options.formatNoMatches()),"</tr>"),this.$body.html(g.join("")),b||this.scrollTo(0),this.$body.find("> tr > td").off("click").on("click",function(){var b=a(this).parent();c.trigger("click-row",c.data[b.data("index")],b),c.options.clickToSelect&&c.header.clickToSelects[b.children().index(a(this))]&&b.find(d('[name="%s"]',c.options.selectItemName))[0].click()}),this.$body.find("tr").off("dblclick").on("dblclick",function(){c.trigger("dbl-click-row",c.data[a(this).data("index")],a(this))}),this.$selectItem=this.$body.find(d('[name="%s"]',this.options.selectItemName)),this.$selectItem.off("click").on("click",function(b){b.stopImmediatePropagation();var d=a(this).prop("checked"),e=c.data[a(this).data("index")];e[c.header.stateField]=d,c.trigger(d?"check":"uncheck",e),c.options.singleSelect&&(c.$selectItem.not(this).each(function(){c.data[a(this).data("index")][c.header.stateField]=!1}),c.$selectItem.filter(":checked").not(this).prop("checked",!1)),c.updateSelected()}),a.each(this.header.events,function(b,d){if(d){"string"==typeof d&&(d=h(null,d));for(var e in d)c.$body.find("tr").each(function(){var f=a(this),g=f.find(c.options.cardView?".card-view":"td").eq(b),h=e.indexOf(" "),i=e.substring(0,h),j=e.substring(h+1),k=d[e];g.find(j).off(i).on(i,function(a){var d=f.data("index"),e=c.data[d],g=e[c.header.fields[b]];k.apply(this,[a,g,e,d])})})}}),this.updateSelected(),this.resetView(),this.trigger("post-body")},j.prototype.initServer=function(b,c){var d=this,e={},f={pageSize:this.options.pageSize===this.options.formatAllRows()?this.options.totalRows:this.options.pageSize,pageNumber:this.options.pageNumber,searchText:this.searchText,sortName:this.options.sortName,sortOrder:this.options.sortOrder};this.options.url&&("limit"===this.options.queryParamsType&&(f={search:f.searchText,sort:f.sortName,order:f.sortOrder},this.options.pagination&&(f.limit=this.options.pageSize===this.options.formatAllRows()?this.options.totalRows:this.options.pageSize,f.offset=this.options.pageSize===this.options.formatAllRows()?0:this.options.pageSize*(this.options.pageNumber-1))),a.isEmptyObject(this.filterColumnsPartial)||(f.filter=JSON.stringify(this.filterColumnsPartial,null)),e=h(this.options,this.options.queryParams,[f],e),a.extend(e,c||{}),e!==!1&&(b||this.$loading.show(),a.ajax(a.extend({},h(null,this.options.ajaxOptions),{type:this.options.method,url:this.options.url,data:"application/json"===this.options.contentType&&"post"===this.options.method?JSON.stringify(e):e,cache:this.options.cache,contentType:this.options.contentType,dataType:this.options.dataType,success:function(a){a=h(d.options,d.options.responseHandler,[a],a),d.load(a),d.trigger("load-success",a)},error:function(a){d.trigger("load-error",a.status)},complete:function(){b||d.$loading.hide()}}))))},j.prototype.initKeyEvents=function(){if(this.options.keyEvents){var b=this;a(document).off("keypress").on("keypress",function(a){var c=b.$toolbar.find(".search input"),d=b.$toolbar.find('button[name="refresh"]'),e=b.$toolbar.find('button[name="toggle"]'),f=b.$toolbar.find('button[name="paginationSwitch"]');switch(a.keyCode){case 115:case 83:if(!b.options.search)return;return document.activeElement===c.get(0)?!0:(c.focus(),!1);case 114:case 82:if(!b.options.showRefresh)return;return document.activeElement===c.get(0)?!0:(d.click(),!1);case 116:case 84:if(!b.options.showToggle)return;return document.activeElement===c.get(0)?!0:(e.click(),!1);case 112:case 80:if(!b.options.showPaginationSwitch)return;return document.activeElement===c.get(0)?!0:(f.click(),!1)}})}},j.prototype.getCaretHtml=function(){return['<span class="order'+("desc"===this.options.sortOrder?"":" dropup")+'">','<span class="caret" style="margin: 10px 5px;"></span>',"</span>"].join("")},j.prototype.updateSelected=function(){var b=this.$selectItem.filter(":enabled").length===this.$selectItem.filter(":enabled").filter(":checked").length;this.$selectAll.add(this.$selectAll_).prop("checked",b),this.$selectItem.each(function(){a(this).parents("tr")[a(this).prop("checked")?"addClass":"removeClass"]("selected")})},j.prototype.updateRows=function(b){var c=this;this.$selectItem.each(function(){c.data[a(this).data("index")][c.header.stateField]=b})},j.prototype.resetRows=function(){var b=this;a.each(this.data,function(a,c){b.$selectAll.prop("checked",!1),b.$selectItem.prop("checked",!1),c[b.header.stateField]=!1})},j.prototype.trigger=function(b){var c=Array.prototype.slice.call(arguments,1);b+=".bs.table",this.options[j.EVENTS[b]].apply(this.options,c),this.$el.trigger(a.Event(b),c),this.options.onAll(b,c),this.$el.trigger(a.Event("all.bs.table"),[b,c])},j.prototype.resetHeader=function(){this.$el.css("margin-top",-this.$header.height()),clearTimeout(this.timeoutId_),this.timeoutId_=setTimeout(a.proxy(this.fitHeader,this),this.$el.is(":hidden")?100:0)},j.prototype.fitHeader=function(){var b,c,d,e=this;return e.$el.is(":hidden")?void(e.timeoutFooter_=setTimeout(a.proxy(e.fitHeader,e),100)):(b=e.$container.find(".fixed-table-header"),c=e.$container.find(".fixed-table-body"),d=e.$el.width()>c.width()?g():0,e.$header_=e.$header.clone(!0,!0),e.$selectAll_=e.$header_.find('[name="btSelectAll"]'),b.css({"margin-right":d}).find("table").css("width",e.$el.css("width")).html("").attr("class",e.$el.attr("class")).append(e.$header_),e.$header.find("th").each(function(b){e.$header_.find("th").eq(b).data(a(this).data())}),e.$body.find("tr:first-child:not(.no-records-found) > *").each(function(b){e.$header_.find("div.fht-cell").eq(b).width(a(this).innerWidth())}),c.off("scroll").on("scroll",function(){b.scrollLeft(a(this).scrollLeft())}),void e.trigger("post-header"))},j.prototype.resetFooter=function(){var b=this,c=b.getData(),e=[];this.options.showFooter&&!this.options.cardView&&(a.each(this.options.columns,function(a,f){var g="",i="",j=d(' class="%s"',f["class"]);f.visible&&(!b.options.cardView||f.cardVisible)&&(g=d("text-align: %s; ",f.falign?f.falign:f.align),i=d("vertical-align: %s; ",f.valign),e.push("<td",j,d(' style="%s"',g+i),">"),e.push(h(f,f.footerFormatter,[c]," ")||" "),e.push("</td>"))}),this.$footer.find("tr").html(e.join("")),clearTimeout(this.timeoutFooter_),this.timeoutFooter_=setTimeout(a.proxy(this.fitFooter,this),this.$el.is(":hidden")?100:0))},j.prototype.fitFooter=function(){var b,c,d,e;return clearTimeout(this.timeoutFooter_),this.$el.is(":hidden")?void(this.timeoutFooter_=setTimeout(a.proxy(this.fitFooter,this),100)):(b=this.$container.find(".fixed-table-body"),d=this.$el.css("width"),e=d>b.width()?g():0,this.$footer.css({"margin-right":e}).find("table").css("width",d).attr("class",this.$el.attr("class")),c=this.$footer.find("td"),void b.find("tbody tr:first-child:not(.no-records-found) > td").each(function(b){c.eq(b).outerWidth(a(this).outerWidth())}))},j.prototype.toggleColumn=function(a,b,c){if(-1!==a&&(this.options.columns[a].visible=b,this.initHeader(),this.initSearch(),this.initPagination(),this.initBody(),this.options.showColumns)){var e=this.$toolbar.find(".keep-open input").prop("disabled",!1);
- c&&e.filter(d('[value="%s"]',a)).prop("checked",b),e.filter(":checked").length<=this.options.minimumCountColumns&&e.filter(":checked").prop("disabled",!0)}},j.prototype.toggleRow=function(b,c,e){-1!==b&&a(this.$body[0]).children().filter(d(c?'[value="%s"]':'[data-index="%s"]',b))[e?"show":"hide"]()},j.prototype.resetView=function(a){var c=this,d=0,e=c.$container.find(".fixed-table-container");if(a&&a.height&&(this.options.height=a.height),this.$selectAll.prop("checked",this.$selectItem.length>0&&this.$selectItem.length===this.$selectItem.filter(":checked").length),this.options.height){var f=+this.$toolbar.children().outerHeight(!0),g=+this.$pagination.children().outerHeight(!0),h=this.options.height-f-g;e.css("height",h+"px")}return this.options.cardView?(c.$el.css("margin-top","0"),void e.css("padding-bottom","0")):(this.options.showHeader&&this.options.height?(this.$container.find(".fixed-table-header").show(),this.resetHeader(),d+=b):(this.$container.find(".fixed-table-header").hide(),this.trigger("post-header")),this.options.showFooter&&(this.resetFooter(),this.options.height&&(d+=b)),void e.css("padding-bottom",d+"px"))},j.prototype.getData=function(){return!this.searchText&&a.isEmptyObject(this.filterColumns)&&a.isEmptyObject(this.filterColumnsPartial)?this.options.data:this.data},j.prototype.load=function(b){var c=!1;"server"===this.options.sidePagination?(this.options.totalRows=b.total,c=b.fixedScroll,b=b.rows):a.isArray(b)||(c=b.fixedScroll,b=b.data),this.initData(b),this.initSearch(),this.initPagination(),this.initBody(c)},j.prototype.append=function(a){this.initData(a,"append"),this.initSearch(),this.initPagination(),this.initBody(!0)},j.prototype.prepend=function(a){this.initData(a,"prepend"),this.initSearch(),this.initPagination(),this.initBody(!0)},j.prototype.remove=function(b){var c,d,e=this.options.data.length;if(b.hasOwnProperty("field")&&b.hasOwnProperty("values")){for(c=e-1;c>=0;c--)d=this.options.data[c],d.hasOwnProperty(b.field)&&-1!==a.inArray(d[b.field],b.values)&&this.options.data.splice(c,1);e!==this.options.data.length&&(this.initSearch(),this.initPagination(),this.initBody(!0))}},j.prototype.insertRow=function(a){a.hasOwnProperty("index")&&a.hasOwnProperty("row")&&(this.data.splice(a.index,0,a.row),this.initSearch(),this.initPagination(),this.initBody(!0))},j.prototype.updateRow=function(b){b.hasOwnProperty("index")&&b.hasOwnProperty("row")&&(a.extend(this.data[b.index],b.row),this.initBody(!0))},j.prototype.showRow=function(a){a.hasOwnProperty("index")&&this.toggleRow(a.index,void 0===a.isIdField?!1:!0,!0)},j.prototype.hideRow=function(a){a.hasOwnProperty("index")&&this.toggleRow(a.index,void 0===a.isIdField?!1:!0,!1)},j.prototype.getRowsHidden=function(b){var c=a(this.$body[0]).children().filter(":hidden"),d=0;if(b)for(;d<c.length;d++)a(c[d]).show();return c},j.prototype.mergeCells=function(b){var c,d,e=b.index,f=a.inArray(b.field,this.header.fields),g=b.rowspan||1,h=b.colspan||1,i=this.$body.find("tr"),j=i.eq(e).find("td").eq(f);if(!(0>e||0>f||e>=this.data.length)){for(c=e;e+g>c;c++)for(d=f;f+h>d;d++)i.eq(c).find("td").eq(d).hide();j.attr("rowspan",g).attr("colspan",h).show()}},j.prototype.getOptions=function(){return this.options},j.prototype.getSelections=function(){var b=this;return a.grep(this.data,function(a){return a[b.header.stateField]})},j.prototype.checkAll=function(){this.checkAll_(!0)},j.prototype.uncheckAll=function(){this.checkAll_(!1)},j.prototype.checkAll_=function(a){var b;a||(b=this.getSelections()),this.$selectItem.filter(":enabled").prop("checked",a),this.updateRows(a),this.updateSelected(),a&&(b=this.getSelections()),this.trigger(a?"check-all":"uncheck-all",b)},j.prototype.check=function(a){this.check_(!0,a)},j.prototype.uncheck=function(a){this.check_(!1,a)},j.prototype.check_=function(a,b){this.$selectItem.filter(d('[data-index="%s"]',b)).prop("checked",a),this.data[b][this.header.stateField]=a,this.updateSelected(),this.trigger(a?"check":"uncheck",this.data[b])},j.prototype.checkBy=function(a){this.checkBy_(!0,a)},j.prototype.uncheckBy=function(a){this.checkBy_(!1,a)},j.prototype.checkBy_=function(b,c){if(c.hasOwnProperty("field")&&c.hasOwnProperty("values")){var e=this;a.each(this.options.data,function(f,g){return g.hasOwnProperty(c.field)?void(-1!==a.inArray(g[c.field],c.values)&&(e.$selectItem.filter(d('[data-index="%s"]',f)).prop("checked",b),g[e.header.stateField]=b,e.trigger(b?"check":"uncheck",g))):!1}),this.updateSelected()}},j.prototype.destroy=function(){this.$el.insertBefore(this.$container),a(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")||"")},j.prototype.showLoading=function(){this.$loading.show()},j.prototype.hideLoading=function(){this.$loading.hide()},j.prototype.togglePagination=function(){this.options.pagination=!this.options.pagination;var a=this.$toolbar.find('button[name="paginationSwitch"] i');this.options.pagination?a.attr("class",this.options.iconsPrefix+" "+this.options.icons.paginationSwitchDown):a.attr("class",this.options.iconsPrefix+" "+this.options.icons.paginationSwitchUp),this.updatePagination()},j.prototype.refresh=function(a){a&&a.url&&(this.options.url=a.url,this.options.pageNumber=1),this.initServer(a&&a.silent,a&&a.query)},j.prototype.showColumn=function(a){this.toggleColumn(f(this.options.columns,a),!0,!0)},j.prototype.hideColumn=function(a){this.toggleColumn(f(this.options.columns,a),!1,!0)},j.prototype.filterBy=function(b){this.filterColumns=a.isEmptyObject(b)?{}:b,this.options.pageNumber=1,this.initSearch(),this.updatePagination()},j.prototype.scrollTo=function(a){var b=this.$container.find(".fixed-table-body");"string"==typeof a&&(a="bottom"===a?b[0].scrollHeight:0),"number"==typeof a&&b.scrollTop(a)},j.prototype.selectPage=function(a){a>0&&a<=this.options.totalPages&&(this.options.pageNumber=a,this.updatePagination())},j.prototype.prevPage=function(){this.options.pageNumber>1&&(this.options.pageNumber--,this.updatePagination())},j.prototype.nextPage=function(){this.options.pageNumber<this.options.totalPages&&(this.options.pageNumber++,this.updatePagination())},j.prototype.toggleView=function(){this.options.cardView=!this.options.cardView,this.initHeader(),this.initBody()};var k=["getOptions","getSelections","getData","load","append","prepend","remove","insertRow","updateRow","showRow","hideRow","getRowsHidden","mergeCells","checkAll","uncheckAll","check","uncheck","checkBy","uncheckBy","refresh","resetView","destroy","showLoading","hideLoading","showColumn","hideColumn","filterBy","scrollTo","selectPage","prevPage","nextPage","togglePagination","toggleView"];a.fn.bootstrapTable=function(b,c){var d;return this.each(function(){var e=a(this),f=e.data("bootstrap.table"),g=a.extend({},j.DEFAULTS,e.data(),"object"==typeof b&&b);if("string"==typeof b){if(a.inArray(b,k)<0)throw"Unknown method: "+b;if(!f)return;d=f[b](c),"destroy"===b&&e.removeData("bootstrap.table")}f||e.data("bootstrap.table",f=new j(this,g))}),"undefined"==typeof d?this:d},a.fn.bootstrapTable.Constructor=j,a.fn.bootstrapTable.defaults=j.DEFAULTS,a.fn.bootstrapTable.columnDefaults=j.COLUMN_DEFAULTS,a.fn.bootstrapTable.locales=j.LOCALES,a.fn.bootstrapTable.methods=k,a(function(){a('[data-toggle="table"]').bootstrapTable()})}(jQuery);
|