bootstrap-table-rails 1.8.2 → 1.8.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +68 -29
  3. data/bootstrap-table-rails-1.8.2.gem +0 -0
  4. data/lib/bootstrap-table-rails/version.rb +1 -1
  5. data/vendor/assets/javascripts/bootstrap-table-all.js +5177 -9
  6. data/vendor/assets/javascripts/bootstrap-table-locale-all.js +1500 -6
  7. data/vendor/assets/javascripts/bootstrap-table.js +2506 -8
  8. data/vendor/assets/javascripts/extensions/bootstrap-table-angular.js +105 -7
  9. data/vendor/assets/javascripts/extensions/bootstrap-table-cookie.js +318 -7
  10. data/vendor/assets/javascripts/extensions/bootstrap-table-editable.js +107 -7
  11. data/vendor/assets/javascripts/extensions/bootstrap-table-export.js +103 -7
  12. data/vendor/assets/javascripts/extensions/bootstrap-table-filter-control.js +458 -7
  13. data/vendor/assets/javascripts/extensions/bootstrap-table-filter.js +67 -7
  14. data/vendor/assets/javascripts/extensions/bootstrap-table-flat-json.js +62 -7
  15. data/vendor/assets/javascripts/extensions/bootstrap-table-group-by.js +228 -0
  16. data/vendor/assets/javascripts/extensions/bootstrap-table-key-events.js +80 -7
  17. data/vendor/assets/javascripts/extensions/bootstrap-table-mobile.js +142 -7
  18. data/vendor/assets/javascripts/extensions/bootstrap-table-multiple-sort.js +378 -7
  19. data/vendor/assets/javascripts/extensions/bootstrap-table-natural-sorting.js +47 -7
  20. data/vendor/assets/javascripts/extensions/bootstrap-table-reorder-columns.js +130 -7
  21. data/vendor/assets/javascripts/extensions/bootstrap-table-reorder-rows.js +115 -7
  22. data/vendor/assets/javascripts/extensions/bootstrap-table-resizable.js +74 -7
  23. data/vendor/assets/javascripts/extensions/bootstrap-table-toolbar.js +245 -7
  24. data/vendor/assets/javascripts/locale/bootstrap-table-ar-SA.js +40 -0
  25. data/vendor/assets/javascripts/locale/bootstrap-table-ca-ES.js +43 -0
  26. data/vendor/assets/javascripts/locale/bootstrap-table-cs-CZ.js +44 -0
  27. data/vendor/assets/javascripts/locale/bootstrap-table-da-DK.js +37 -0
  28. data/vendor/assets/javascripts/locale/bootstrap-table-de-DE.js +37 -0
  29. data/vendor/assets/javascripts/locale/bootstrap-table-el-GR.js +28 -0
  30. data/vendor/assets/javascripts/locale/bootstrap-table-en-US.js +43 -0
  31. data/vendor/assets/javascripts/locale/bootstrap-table-es-AR.js +31 -0
  32. data/vendor/assets/javascripts/locale/bootstrap-table-es-CR.js +40 -0
  33. data/vendor/assets/javascripts/locale/bootstrap-table-es-ES.js +43 -0
  34. data/vendor/assets/javascripts/locale/bootstrap-table-es-MX.js +32 -0
  35. data/vendor/assets/javascripts/locale/bootstrap-table-es-NI.js +40 -0
  36. data/vendor/assets/javascripts/locale/bootstrap-table-es-SP.js +40 -0
  37. data/vendor/assets/javascripts/locale/bootstrap-table-fa-IR.js +43 -0
  38. data/vendor/assets/javascripts/locale/bootstrap-table-fr-BE.js +28 -0
  39. data/vendor/assets/javascripts/locale/bootstrap-table-fr-FR.js +41 -0
  40. data/vendor/assets/javascripts/locale/bootstrap-table-hr-HR.js +44 -0
  41. data/vendor/assets/javascripts/locale/bootstrap-table-hu-HU.js +43 -0
  42. data/vendor/assets/javascripts/locale/bootstrap-table-it-IT.js +37 -0
  43. data/vendor/assets/javascripts/locale/bootstrap-table-ja-JP.js +40 -0
  44. data/vendor/assets/javascripts/locale/bootstrap-table-ka-GE.js +40 -0
  45. data/vendor/assets/javascripts/locale/bootstrap-table-ko-KR.js +37 -0
  46. data/vendor/assets/javascripts/locale/bootstrap-table-ms-MY.js +40 -0
  47. data/vendor/assets/javascripts/locale/bootstrap-table-nb-NO.js +37 -0
  48. data/vendor/assets/javascripts/locale/bootstrap-table-nl-NL.js +28 -0
  49. data/vendor/assets/javascripts/locale/bootstrap-table-pl-PL.js +37 -0
  50. data/vendor/assets/javascripts/locale/bootstrap-table-pt-BR.js +41 -0
  51. data/vendor/assets/javascripts/locale/bootstrap-table-pt-PT.js +28 -0
  52. data/vendor/assets/javascripts/locale/bootstrap-table-ro-RO.js +43 -0
  53. data/vendor/assets/javascripts/locale/bootstrap-table-ru-RU.js +36 -0
  54. data/vendor/assets/javascripts/locale/bootstrap-table-sk-SK.js +37 -0
  55. data/vendor/assets/javascripts/locale/bootstrap-table-sv-SE.js +37 -0
  56. data/vendor/assets/javascripts/locale/bootstrap-table-th-TH.js +37 -0
  57. data/vendor/assets/javascripts/locale/bootstrap-table-tr-TR.js +41 -0
  58. data/vendor/assets/javascripts/locale/bootstrap-table-uk-UA.js +37 -0
  59. data/vendor/assets/javascripts/locale/bootstrap-table-ur-PK.js +37 -0
  60. data/vendor/assets/javascripts/locale/bootstrap-table-vi-VN.js +28 -0
  61. data/vendor/assets/javascripts/locale/bootstrap-table-zh-CN.js +40 -0
  62. data/vendor/assets/javascripts/locale/bootstrap-table-zh-TW.js +40 -0
  63. data/vendor/assets/stylesheets/bootstrap-table.css +297 -1
  64. data/vendor/assets/stylesheets/extensions/bootstrap-table-group-by.css +53 -0
  65. metadata +44 -2
@@ -1,8 +1,2506 @@
1
- /*
2
- * bootstrap-table - v1.8.1 - 2015-05-29
3
- * https://github.com/wenzhixin/bootstrap-table
4
- * Copyright (c) 2015 zhixin wen
5
- * Licensed MIT License
6
- */
7
- !function(a){"use strict";var b=37,c=null,d="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByUDbMAAAAZ0lEQVQ4y2NgGLKgquEuFxBPAGI2ahhWCsS/gDibUoO0gPgxEP8H4ttArEyuQYxAPBdqEAxPBImTY5gjEL9DM+wTENuQahAvEO9DMwiGdwAxOymGJQLxTyD+jgWDxCMZRsEoGAVoAADeemwtPcZI2wAAAABJRU5ErkJggg==",e="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAQAAADYWf5HAAAAkElEQVQoz7XQMQ5AQBCF4dWQSJxC5wwax1Cq1e7BAdxD5SL+Tq/QCM1oNiJidwox0355mXnG/DrEtIQ6azioNZQxI0ykPhTQIwhCR+BmBYtlK7kLJYwWCcJA9M4qdrZrd8pPjZWPtOqdRQy320YSV17OatFC4euts6z39GYMKRPCTKY9UnPQ6P+GtMRfGtPnBCiqhAeJPmkqAAAAAElFTkSuQmCC",f="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByUDbMAAAAZUlEQVQ4y2NgGAWjYBSggaqGu5FA/BOIv2PBIPFEUgxjB+IdQPwfC94HxLykus4GiD+hGfQOiB3J8SojEE9EM2wuSJzcsFMG4ttQgx4DsRalkZENxL+AuJQaMcsGxBOAmGvopk8AVz1sLZgg0bsAAAAASUVORK5CYII= ",g=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:""},h=function(b,c,d,e){var f="";return a.each(b,function(a,b){return b[c]===e?(f=b[d],!1):!0}),f},i=function(b,c){var d=-1;return a.each(b,function(a,b){return b.field===c?(d=a,!1):!0}),d},j=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},k=function(b,c,d,e){var f=c;if("string"==typeof c){var h=c.split(".");h.length>1?(f=window,a.each(h,function(a,b){f=f[b]})):f=window[c]}return"object"==typeof f?f:"function"==typeof f?f.apply(b,d):!f&&"string"==typeof c&&g.apply(this,[c].concat(d))?g.apply(this,[c].concat(d)):e},l=function(a){return"string"==typeof a?a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;"):a},m=function(b){var c=0;return b.children().each(function(){c<a(this).outerHeight(!0)&&(c=a(this).outerHeight(!0))}),c},n=function(a){for(var b in a){var c=b.split(/(?=[A-Z])/).join("-").toLowerCase();c!==b&&(a[c]=a[b],delete a[b])}return a},o=function(b,c){this.options=c,this.$el=a(b),this.$el_=this.$el.clone(),this.timeoutId_=0,this.timeoutFooter_=0,this.init()};o.DEFAULTS={classes:"table table-hover",height:void 0,undefinedText:"-",sortName:void 0,sortOrder:"asc",striped:!1,columns:[],data:[],method:"get",url:void 0,ajax: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",paginationFirstText:"&laquo;",paginationPreText:"&lsaquo;",paginationNextText:"&rsaquo;",paginationLastText:"&raquo;",search:!1,searchAlign:"right",selectItemName:"btSelectItem",showHeader:!0,showFooter:!1,showColumns:!1,showPaginationtable:!1,showRefresh:!1,showToggle:!1,buttonsAlign:"right",smartDisplay:!0,minimumCountColumns:1,idField:void 0,uniqueId:void 0,cardView:!1,detailView:!1,detailFormatter:function(){return""},trimOnSearch:!0,clickToSelect:!1,singleSelect:!1,toolbar:void 0,toolbarAlign:"left",checkboxHeader:!0,sortable:!0,maintainSelected:!1,searchTimeOut:500,searchText:"",iconSize:void 0,iconsPrefix:"glyphicon",icons:{paginationtableDown:"glyphicon-collapse-down icon-chevron-down",paginationtableUp:"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},onClickCell:function(){return!1},onDblClickCell: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},onCheckSome:function(){return!1},onUncheckSome:function(){return!1},onLoadSuccess:function(){return!1},onLoadError:function(){return!1},onColumntable:function(){return!1},onPageChange:function(){return!1},onSearch:function(){return!1},onToggle:function(){return!1},onPreBody:function(){return!1},onPostBody:function(){return!1},onPostHeader:function(){return!1},onExpandRow:function(){return!1},onCollapseRow:function(){return!1}},o.LOCALES=[],o.LOCALES["en-US"]={formatLoadingMessage:function(){return"Loading, please wait..."},formatRecordsPerPage:function(a){return g("%s records per page",a)},formatShowingRows:function(a,b,c){return g("Showing %s to %s of %s rows",a,b,c)},formatSearch:function(){return"Search"},formatNoMatches:function(){return"No matching records found"},formatPaginationtable:function(){return"Hide/Show pagination"},formatRefresh:function(){return"Refresh"},formatToggle:function(){return"Toggle"},formatColumns:function(){return"Columns"},formatAllRows:function(){return"All"}},a.extend(o.DEFAULTS,o.LOCALES["en-US"]),o.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,tableable:!0,clickToSelect:!0,formatter:void 0,footerFormatter:void 0,events:void 0,sorter:void 0,sortName:void 0,cellStyle:void 0,searchable:!0,cardVisible:!0},o.EVENTS={"all.bs.table":"onAll","click-cell.bs.table":"onClickCell","dbl-click-cell.bs.table":"onDblClickCell","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","check-some.bs.table":"onCheckSome","uncheck-some.bs.table":"onUncheckSome","load-success.bs.table":"onLoadSuccess","load-error.bs.table":"onLoadError","column-table.bs.table":"onColumntable","page-change.bs.table":"onPageChange","search.bs.table":"onSearch","toggle.bs.table":"onToggle","pre-body.bs.table":"onPreBody","post-body.bs.table":"onPostBody","post-header.bs.table":"onPostHeader","expand-row.bs.table":"onExpandRow","collapse-row.bs.table":"onCollapseRow"},o.prototype.init=function(){this.initContainer(),this.initTable(),this.initHeader(),this.initData(),this.initFooter(),this.initToolbar(),this.initPagination(),this.initBody(),this.initServer()},o.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.$tableContainer=this.$container.find(".fixed-table-container"),this.$tableHeader=this.$container.find(".fixed-table-header"),this.$tableBody=this.$container.find(".fixed-table-body"),this.$tableLoading=this.$container.find(".fixed-table-loading"),this.$tableFooter=this.$container.find(".fixed-table-footer"),this.$toolbar=this.$container.find(".fixed-table-toolbar"),this.$pagination=this.$container.find(".fixed-table-pagination"),this.$tableBody.append(this.$el),this.$container.after('<div class="clearfix"></div>'),this.$el.addClass(this.options.classes),this.options.striped&&this.$el.addClass("table-striped"),-1!==a.inArray("table-no-bordered",this.options.classes.split(" "))&&this.$tableContainer.addClass("table-no-bordered")},o.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({},o.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"),c._data=n(a(this).data()),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+"_rowspan"]=a(this).attr("rowspan"),c["_"+e+"_data"]=n(a(this).data())}),d.push(c)}),this.options.data=d)},o.prototype.initHeader=function(){var c=this,d=[],e=[];this.header={fields:[],styles:[],classes:[],formatters:[],events:[],sorters:[],sortNames:[],cellStyles:[],clickToSelects:[],searchables:[]},!this.options.cardView&&this.options.detailView&&(e.push('<th class="detail"><div class="fht-cell"></div></th>'),d.push({})),a.each(this.options.columns,function(a,b){var f="",h="",i="",j="",k=g(' class="%s"',b["class"]),l=(c.options.sortOrder||b.order,"px"),m=b.width;return b.visible?void((!c.options.cardView||b.cardVisible)&&(void 0===b.width||c.options.cardView||"string"==typeof b.width&&-1!==b.width.indexOf("%")&&(l="%"),b.width&&"string"==typeof b.width&&(m=b.width.replace("%","").replace("px","")),h=g("text-align: %s; ",b.halign?b.halign:b.align),i=g("text-align: %s; ",b.align),j=g("vertical-align: %s; ",b.valign),j+=g("width: %s%s; ",b.checkbox||b.radio?36:m,l),d.push(b),c.header.fields.push(b.field),c.header.styles.push(i+j),c.header.classes.push(k),c.header.formatters.push(b.formatter),c.header.events.push(b.events),c.header.sorters.push(b.sorter),c.header.sortNames.push(b.sortName),c.header.cellStyles.push(b.cellStyle),c.header.clickToSelects.push(b.clickToSelect),c.header.searchables.push(b.searchable),e.push("<th",b.checkbox||b.radio?g(' class="bs-checkbox %s"',b["class"]||""):k,g(' style="%s"',h+j),">"),e.push(g('<div class="th-inner %s">',c.options.sortable&&b.sortable?"sortable":"")),f=b.title,b.checkbox&&(!c.options.singleSelect&&c.options.checkboxHeader&&(f='<input name="btSelectAll" type="checkbox" />'),c.header.stateField=b.field),b.radio&&(f="",c.header.stateField=b.field,c.options.singleSelect=!0),e.push(f),e.push("</div>"),e.push('<div class="fht-cell"></div>'),e.push("</div>"),e.push("</th>"))):void(b.field===c.options.sortName&&c.header.fields.push(b.field))}),this.$header.find("tr").html(e.join("")),this.$header.find("th").each(function(b){a(this).data(d[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.$tableHeader.hide(),this.$tableLoading.css("top",0)):(this.$header.show(),this.$tableHeader.show(),this.$tableLoading.css("top",b+"px"),this.getCaretHtml()),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"]()})},o.prototype.initFooter=function(){!this.options.showFooter||this.options.cardView?this.$tableFooter.hide():this.$tableFooter.show()},o.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="append"===b?this.options.data.concat(a):"prepend"===b?[].concat(a).concat(this.options.data):this.data,"server"!==this.options.sidePagination&&this.initSort()},o.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){b.header.sortNames[e]&&(c=b.header.sortNames[e]);var h=f[c],i=g[c],j=k(b.header,b.header.sorters[e],[h,i]);return void 0!==j?d*j:((void 0===h||null===h)&&(h=""),(void 0===i||null===i)&&(i=""),a.isNumeric(h)&&a.isNumeric(i)?(h=parseFloat(h),i=parseFloat(i),i>h?-1*d:d):h===i?0:("string"!=typeof h&&(h=h.toString()),-1===h.localeCompare(i)?-1*d:d))})},o.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),this.getCaretHtml(),"server"===this.options.sidePagination?void this.initServer():(this.initSort(),void this.initBody())},o.prototype.initToolbar=function(){var b,c,d=this,e=[],f=0,h=0;this.$toolbar.html(""),"string"==typeof this.options.toolbar&&a(g('<div class="bars pull-%s"></div>',this.options.toolbarAlign)).appendTo(this.$toolbar).append(a(this.options.toolbar)),e=[g('<div class="columns columns-%s btn-group pull-%s">',this.options.buttonsAlign,this.options.buttonsAlign)],"string"==typeof this.options.icons&&(this.options.icons=k(null,this.options.icons)),this.options.showPaginationtable&&e.push(g('<button class="btn btn-default" type="button" name="paginationtable" title="%s">',this.options.formatPaginationtable()),g('<i class="%s %s"></i>',this.options.iconsPrefix,this.options.icons.paginationtableDown),"</button>"),this.options.showRefresh&&e.push(g('<button class="btn btn-default'+(void 0===this.options.iconSize?"":" btn-"+this.options.iconSize)+'" type="button" name="refresh" title="%s">',this.options.formatRefresh()),g('<i class="%s %s"></i>',this.options.iconsPrefix,this.options.icons.refresh),"</button>"),this.options.showToggle&&e.push(g('<button class="btn btn-default'+(void 0===this.options.iconSize?"":" btn-"+this.options.iconSize)+'" type="button" name="toggle" title="%s">',this.options.formatToggle()),g('<i class="%s %s"></i>',this.options.iconsPrefix,this.options.icons.toggle),"</button>"),this.options.showColumns&&(e.push(g('<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">',g('<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||d.options.cardView&&!b.cardVisible)){var c=b.visible?' checked="checked"':"";b.tableable&&(e.push(g('<li><label><input type="checkbox" data-field="%s" value="%s"%s> %s</label></li>',b.field,a,c,b.title)),h++)}}),e.push("</ul>","</div>")),e.push("</div>"),(this.showToolbar||e.length>2)&&this.$toolbar.append(e.join("")),this.options.showPaginationtable&&this.$toolbar.find('button[name="paginationtable"]').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(){d.toggleView()}),this.options.showColumns&&(b=this.$toolbar.find(".keep-open"),h<=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);d.toggleColumn(i(d.options.columns,a(this).data("field")),b.prop("checked"),!1),d.trigger("column-table",a(this).data("field"),b.prop("checked"))})),this.options.search&&(e=[],e.push('<div class="pull-'+this.options.searchAlign+' search">',g('<input class="form-control'+(void 0===this.options.iconSize?"":" input-"+this.options.iconSize)+'" type="text" placeholder="%s">',this.options.formatSearch()),"</div>"),this.$toolbar.append(e.join("")),c=this.$toolbar.find(".search input"),c.off("keyup drop").on("keyup drop",function(a){clearTimeout(f),f=setTimeout(function(){d.onSearch(a)},d.options.searchTimeOut)}),""!==this.options.searchText&&(c.val(this.options.searchText),clearTimeout(f),f=setTimeout(function(){c.trigger("keyup")},d.options.searchTimeOut)))},o.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))},o.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;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=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],h=b.options.columns[i(b.options.columns,f)],j=a.inArray(f,b.header.fields);g=k(h,b.header.formatters[j],[g,d,e],g);var l=a.inArray(f,b.header.fields);if(-1!==l&&b.header.searchables[l]&&("string"==typeof g||"number"==typeof g)&&-1!==(g+"").toLowerCase().indexOf(c))return!0}return!1}):this.data}},o.prototype.initPagination=function(){if(!this.options.pagination)return void this.$pagination.hide();this.$pagination.show();var b,c,d,e,f,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=[g('<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(g('<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+' pagination">','<ul class="pagination'+(void 0===this.options.iconSize?"":" pagination-"+this.options.iconSize)+'">','<li class="page-first"><a href="javascript:void(0)">'+this.options.paginationFirstText+"</a></li>",'<li class="page-pre"><a href="javascript:void(0)">'+this.options.paginationPreText+"</a></li>"),this.totalPages<5?(c=1,d=this.totalPages):(c=this.options.pageNumber-2,d=c+4,1>c&&(c=1,d=5),d>this.totalPages&&(d=this.totalPages,c=d-4)),b=c;d>=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)">'+this.options.paginationNextText+"</a></li>",'<li class="page-last"><a href="javascript:void(0)">'+this.options.paginationLastText+"</a></li>","</ul>","</div>"),this.$pagination.html(m.join("")),e=this.$pagination.find(".page-list a"),f=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&&(f.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()),e.off("click").on("click",a.proxy(this.onPageListChange,this)),f.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))},o.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))},o.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)},o.prototype.onPageFirst=function(a){this.options.pageNumber=1,this.updatePagination(a)},o.prototype.onPagePre=function(a){this.options.pageNumber--,this.updatePagination(a)},o.prototype.onPageNext=function(a){this.options.pageNumber++,this.updatePagination(a)},o.prototype.onPageLast=function(a){this.options.pageNumber=this.totalPages,this.updatePagination(a)},o.prototype.onPageNumber=function(b){this.options.pageNumber!==+a(b.currentTarget).text()&&(this.options.pageNumber=+a(b.currentTarget).text(),this.updatePagination(b))},o.prototype.initBody=function(b){var c=this,d=[],e=this.getData();this.trigger("pre-body",e),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=e.length);for(var f=this.pageFrom-1;f<this.pageTo;f++){var j,m=e[f],n={},o=[],p="",q={},r=[];if(n=k(this.options,this.options.rowStyle,[m,f],n),n&&n.css)for(j in n.css)o.push(j+": "+n.css[j]);if(q=k(this.options,this.options.rowAttributes,[m,f],q))for(j in q)r.push(g('%s="%s"',j,l(q[j])));m._data&&!a.isEmptyObject(m._data)&&a.each(m._data,function(a,b){"index"!==a&&(p+=g(' data-%s="%s"',a,b))}),d.push("<tr",g(" %s",r.join(" ")),g(' id="%s"',a.isArray(m)?void 0:m._id),g(' class="%s"',n.classes||(a.isArray(m)?void 0:m._class)),g(' data-index="%s"',f),g(' data-uniqueid="%s"',m[this.options.uniqueId]),g("%s",p),">"),this.options.cardView&&d.push(g('<td colspan="%s">',this.header.fields.length)),!this.options.cardView&&this.options.detailView&&d.push("<td>",'<a class="detail-icon" href="javascript:">','<i class="glyphicon glyphicon-plus icon-plus"></i>',"</a>","</td>"),a.each(this.header.fields,function(b,e){var j="",l=m[e],p="",q={},r="",s=c.header.classes[b],t="",u="",v=c.options.columns[i(c.options.columns,e)];if(n=g('style="%s"',o.concat(c.header.styles[b]).join("; ")),l=k(v,c.header.formatters[b],[l,m,f],l),m["_"+e+"_id"]&&(r=g(' id="%s"',m["_"+e+"_id"])),m["_"+e+"_class"]&&(s=g(' class="%s"',m["_"+e+"_class"])),m["_"+e+"_rowspan"]&&(u=g(' rowspan="%s"',m["_"+e+"_rowspan"])),q=k(c.header,c.header.cellStyles[b],[l,m,f],q),q.classes&&(s=g(' class="%s"',q.classes)),q.css){var w=[];for(var x in q.css)w.push(x+": "+q.css[x]);n=g('style="%s"',w.concat(c.header.styles[b]).join("; "))}m["_"+e+"_data"]&&!a.isEmptyObject(m["_"+e+"_data"])&&a.each(m["_"+e+"_data"],function(a,b){"index"!==a&&(t+=g(' data-%s="%s"',a,b))}),v.checkbox||v.radio?(p=v.checkbox?"checkbox":p,p=v.radio?"radio":p,j=[c.options.cardView?'<div class="card-view">':'<td class="bs-checkbox">',"<input"+g(' data-index="%s"',f)+g(' name="%s"',c.options.selectItemName)+g(' type="%s"',p)+g(' value="%s"',m[c.options.idField])+g(' checked="%s"',l===!0||l&&l.checked?"checked":void 0)+g(' disabled="%s"',!v.checkboxEnabled||l&&l.disabled?"disabled":void 0)+" />",c.options.cardView?"</div>":"</td>"].join(""),m[c.header.stateField]=l===!0||l&&l.checked):(l="undefined"==typeof l||null===l?c.options.undefinedText:l,j=c.options.cardView?['<div class="card-view">',c.options.showHeader?g('<span class="title" %s>%s</span>',n,h(c.options.columns,"field","title",e)):"",g('<span class="value">%s</span>',l),"</div>"].join(""):[g("<td%s %s %s %s %s>",r,s,n,t,u),l,"</td>"].join(""),c.options.cardView&&c.options.smartDisplay&&""===l&&(j="")),d.push(j)}),this.options.cardView&&d.push("</td>"),d.push("</tr>")}d.length||d.push('<tr class="no-records-found">',g('<td colspan="%s">%s</td>',this.$header.find("th").length,this.options.formatNoMatches()),"</tr>"),this.$body.html(d.join("")),b||this.scrollTo(0),this.$body.find("> tr > td").off("click").on("click",function(){var b=a(this),d=b.parent(),e=c.data[d.data("index")],f=b[0].cellIndex,h=c.$header.find("th:eq("+f+")"),i=h.data("field"),j=e[i];c.trigger("click-cell",i,j,e,b),c.trigger("click-row",e,d),c.options.clickToSelect&&c.header.clickToSelects[d.children().index(a(this))]&&d.find(g('[name="%s"]',c.options.selectItemName))[0].click()}),this.$body.find("> tr > td").off("dblclick").on("dblclick",function(){var b=a(this),d=b.parent(),e=c.data[d.data("index")],f=b[0].cellIndex,g=c.$header.find("th:eq("+f+")"),h=g.data("field"),i=e[h];c.trigger("dbl-click-cell",h,i,e,b),c.trigger("dbl-click-row",e,d)}),this.$body.find("> tr > td > .detail-icon").off("click").on("click",function(){var b=a(this),d=b.parent().parent(),e=d.data("index"),f=c.options.data[e];d.next().is("tr.detail-view")?(b.find("i").attr("class","glyphicon glyphicon-plus icon-plus"),d.next().remove(),c.trigger("collapse-row",e,f)):(b.find("i").attr("class","glyphicon glyphicon-minus icon-minus"),d.after(g('<tr class="detail-view"><td colspan="%s">%s</td></tr>',d.find("td").length,k(c.options,c.options.detailFormatter,[e,f],""))),c.trigger("expand-row",e,f,d.next().find("td"))),c.resetView()}),this.$selectItem=this.$body.find(g('[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.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(),c.trigger(d?"check":"uncheck",e)}),a.each(this.header.events,function(b,d){if(d){"string"==typeof d&&(d=k(null,d)),!c.options.cardView&&c.options.detailView&&(b+=1);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")},o.prototype.initServer=function(b,c){var d,e=this,f={},g={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||this.options.ajax)&&("limit"===this.options.queryParamsType&&(g={search:g.searchText,sort:g.sortName,order:g.sortOrder},this.options.pagination&&(g.limit=this.options.pageSize===this.options.formatAllRows()?this.options.totalRows:this.options.pageSize,g.offset=this.options.pageSize===this.options.formatAllRows()?0:this.options.pageSize*(this.options.pageNumber-1))),a.isEmptyObject(this.filterColumnsPartial)||(g.filter=JSON.stringify(this.filterColumnsPartial,null)),f=k(this.options,this.options.queryParams,[g],f),a.extend(f,c||{}),f!==!1&&(b||this.$tableLoading.show(),d=a.extend({},k(null,this.options.ajaxOptions),{type:this.options.method,url:this.options.url,data:"application/json"===this.options.contentType&&"post"===this.options.method?JSON.stringify(f):f,cache:this.options.cache,contentType:this.options.contentType,dataType:this.options.dataType,success:function(a){a=k(e.options,e.options.responseHandler,[a],a),e.load(a),e.trigger("load-success",a)},error:function(a){e.trigger("load-error",a.status)},complete:function(){b||e.$tableLoading.hide()}}),this.options.ajax?k(this,this.options.ajax,[d],null):a.ajax(d)))},o.prototype.getCaretHtml=function(){var b=this;a.each(this.$header.find("th"),function(c,g){a(g).data("field")===b.options.sortName?a(g).find(".sortable").css("background-image","url("+("desc"===b.options.sortOrder?f:d)+")"):a(g).find(".sortable").css("background-image","url("+e+")")})},o.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")})},o.prototype.updateRows=function(){var b=this;this.$selectItem.each(function(){b.data[a(this).data("index")][b.header.stateField]=a(this).prop("checked")})},o.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})},o.prototype.trigger=function(b){var c=Array.prototype.slice.call(arguments,1);b+=".bs.table",this.options[o.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])},o.prototype.resetHeader=function(){clearTimeout(this.timeoutId_),this.timeoutId_=setTimeout(a.proxy(this.fitHeader,this),this.$el.is(":hidden")?100:0)},o.prototype.fitHeader=function(){var b,c,d=this;return d.$el.is(":hidden")?void(d.timeoutFooter_=setTimeout(a.proxy(d.fitHeader,d),100)):(b=this.$tableBody.get(0),c=b.scrollWidth>b.clientWidth&&b.scrollHeight>b.clientHeight+this.$header.height()?j():0,this.$el.css("margin-top",-this.$header.height()),this.$header_=this.$header.clone(!0,!0),this.$selectAll_=this.$header_.find('[name="btSelectAll"]'),this.$tableHeader.css({"margin-right":c}).find("table").css("width",this.$el.css("width")).html("").attr("class",this.$el.attr("class")).append(this.$header_),this.$header.find("th").each(function(b){d.$header_.find("th").eq(b).data(a(this).data())}),this.$body.find("tr:first-child:not(.no-records-found) > *").each(function(b){d.$header_.find("div.fht-cell").eq(b).width(a(this).innerWidth())
8
- }),this.$tableBody.off("scroll").on("scroll",function(){d.$tableHeader.scrollLeft(a(this).scrollLeft())}),void d.trigger("post-header"))},o.prototype.resetFooter=function(){var b=this,c=b.getData(),d=[];this.options.showFooter&&!this.options.cardView&&(!this.options.cardView&&this.options.detailView&&d.push("<td></td>"),a.each(this.options.columns,function(a,e){var f="",h="",i=g(' class="%s"',e["class"]);e.visible&&(!b.options.cardView||e.cardVisible)&&(f=g("text-align: %s; ",e.falign?e.falign:e.align),h=g("vertical-align: %s; ",e.valign),d.push("<td",i,g(' style="%s"',f+h),">"),d.push(k(e,e.footerFormatter,[c],"&nbsp;")||"&nbsp;"),d.push("</td>"))}),this.$tableFooter.find("tr").html(d.join("")),clearTimeout(this.timeoutFooter_),this.timeoutFooter_=setTimeout(a.proxy(this.fitFooter,this),this.$el.is(":hidden")?100:0))},o.prototype.fitFooter=function(){var b,c,d;return clearTimeout(this.timeoutFooter_),this.$el.is(":hidden")?void(this.timeoutFooter_=setTimeout(a.proxy(this.fitFooter,this),100)):(c=this.$el.css("width"),d=c>this.$tableBody.width()?j():0,this.$tableFooter.css({"margin-right":d}).find("table").css("width",c).attr("class",this.$el.attr("class")),b=this.$tableFooter.find("td"),void this.$tableBody.find("tbody tr:first-child:not(.no-records-found) > td").each(function(c){b.eq(c).outerWidth(a(this).outerWidth())}))},o.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 d=this.$toolbar.find(".keep-open input").prop("disabled",!1);c&&d.filter(g('[value="%s"]',a)).prop("checked",b),d.filter(":checked").length<=this.options.minimumCountColumns&&d.filter(":checked").prop("disabled",!0)}},o.prototype.toggleRow=function(b,c,d){-1!==b&&a(this.$body[0]).children().filter(g(c?'[data-uniqueid="%s"]':'[data-index="%s"]',b))[d?"show":"hide"]()},o.prototype.resetView=function(a){var c=0;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 d=m(this.$toolbar),e=m(this.$pagination),f=this.options.height-d-e;this.$tableContainer.css("height",f+"px")}return this.options.cardView?(this.$el.css("margin-top","0"),void this.$tableContainer.css("padding-bottom","0")):(this.options.showHeader&&this.options.height?(this.$tableHeader.show(),this.resetHeader(),c+=b):(this.$tableHeader.hide(),this.trigger("post-header")),this.options.showFooter&&(this.resetFooter(),this.options.height&&(c+=b)),this.getCaretHtml(),void this.$tableContainer.css("padding-bottom",c+"px"))},o.prototype.getData=function(b){return!this.searchText&&a.isEmptyObject(this.filterColumns)&&a.isEmptyObject(this.filterColumnsPartial)?b?this.options.data.slice(this.pageFrom-1,this.pageTo):this.options.data:b?this.data.slice(this.pageFrom-1,this.pageTo):this.data},o.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)},o.prototype.append=function(a){this.initData(a,"append"),this.initSearch(),this.initPagination(),this.initBody(!0)},o.prototype.prepend=function(a){this.initData(a,"prepend"),this.initSearch(),this.initPagination(),this.initBody(!0)},o.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))}},o.prototype.removeAll=function(){this.options.data.length>0&&(this.options.data.splice(0,this.options.data.length),this.initSearch(),this.initPagination(),this.initBody(!0))},o.prototype.removeByUniqueId=function(a){var b,c,d=this.options.uniqueId,e=this.options.data.length;for(b=e-1;b>=0;b--)c=this.options.data[b],c.hasOwnProperty(d)&&("string"==typeof c[d]?a=a.toString():"number"==typeof c[d]&&(Number(c[d])===c[d]&&c[d]%1===0?a=parseInt(a):c[d]===Number(c[d])&&0!==c[d]&&(a=parseFloat(a))),c[d]===a&&this.options.data.splice(b,1));e!==this.options.data.length&&(this.initSearch(),this.initPagination(),this.initBody(!0))},o.prototype.insertRow=function(a){a.hasOwnProperty("index")&&a.hasOwnProperty("row")&&(this.data.splice(a.index,0,a.row),this.initSearch(),this.initPagination(),this.initSort(),this.initBody(!0))},o.prototype.updateRow=function(b){b.hasOwnProperty("index")&&b.hasOwnProperty("row")&&(a.extend(this.data[b.index],b.row),this.initSort(),this.initBody(!0))},o.prototype.showRow=function(a){a.hasOwnProperty("index")&&this.toggleRow(a.index,void 0===a.isIdField?!1:!0,!0)},o.prototype.hideRow=function(a){a.hasOwnProperty("index")&&this.toggleRow(a.index,void 0===a.isIdField?!1:!0,!1)},o.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},o.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(!this.options.cardView&&this.options.detailView&&(f+=1),j=i.eq(e).find("td").eq(f),!(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()}},o.prototype.updateCell=function(a){a.hasOwnProperty("rowIndex")&&a.hasOwnProperty("fieldName")&&a.hasOwnProperty("fieldValue")&&(this.data[a.rowIndex][a.fieldName]=a.fieldValue,this.initSort(),this.initBody(!0))},o.prototype.getOptions=function(){return this.options},o.prototype.getSelections=function(){var b=this;return a.grep(this.data,function(a){return a[b.header.stateField]})},o.prototype.getAllSelections=function(){var b=this;return a.grep(this.options.data,function(a){return a[b.header.stateField]})},o.prototype.checkAll=function(){this.checkAll_(!0)},o.prototype.uncheckAll=function(){this.checkAll_(!1)},o.prototype.checkAll_=function(a){var b;a||(b=this.getSelections()),this.$selectItem.filter(":enabled").prop("checked",a),this.updateRows(),this.updateSelected(),a&&(b=this.getSelections()),this.trigger(a?"check-all":"uncheck-all",b)},o.prototype.check=function(a){this.check_(!0,a)},o.prototype.uncheck=function(a){this.check_(!1,a)},o.prototype.check_=function(a,b){this.$selectItem.filter(g('[data-index="%s"]',b)).prop("checked",a),this.data[b][this.header.stateField]=a,this.updateSelected(),this.trigger(a?"check":"uncheck",this.data[b])},o.prototype.checkBy=function(a){this.checkBy_(!0,a)},o.prototype.uncheckBy=function(a){this.checkBy_(!1,a)},o.prototype.checkBy_=function(b,c){if(c.hasOwnProperty("field")&&c.hasOwnProperty("values")){var d=this,e=[];a.each(this.options.data,function(f,h){return h.hasOwnProperty(c.field)?void(-1!==a.inArray(h[c.field],c.values)&&(d.$selectItem.filter(g('[data-index="%s"]',f)).prop("checked",b),h[d.header.stateField]=b,e.push(h),d.trigger(b?"check":"uncheck",h))):!1}),this.updateSelected(),this.trigger(b?"check-some":"uncheck-some",e)}},o.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")||"")},o.prototype.showLoading=function(){this.$tableLoading.show()},o.prototype.hideLoading=function(){this.$tableLoading.hide()},o.prototype.togglePagination=function(){this.options.pagination=!this.options.pagination;var a=this.$toolbar.find('button[name="paginationtable"] i');this.options.pagination?a.attr("class",this.options.iconsPrefix+" "+this.options.icons.paginationtableDown):a.attr("class",this.options.iconsPrefix+" "+this.options.icons.paginationtableUp),this.updatePagination()},o.prototype.refresh=function(a){a&&a.url&&(this.options.url=a.url,this.options.pageNumber=1),this.initServer(a&&a.silent,a&&a.query)},o.prototype.resetWidth=function(){this.options.showHeader&&this.options.height&&this.fitHeader(),this.options.showFooter&&this.fitFooter()},o.prototype.showColumn=function(a){this.toggleColumn(i(this.options.columns,a),!0,!0)},o.prototype.hideColumn=function(a){this.toggleColumn(i(this.options.columns,a),!1,!0)},o.prototype.filterBy=function(b){this.filterColumns=a.isEmptyObject(b)?{}:b,this.options.pageNumber=1,this.initSearch(),this.updatePagination()},o.prototype.scrollTo=function(a){return"string"==typeof a&&(a="bottom"===a?this.$tableBody[0].scrollHeight:0),"number"==typeof a&&this.$tableBody.scrollTop(a),"undefined"==typeof a?this.$tableBody.scrollTop():void 0},o.prototype.getScrollPosition=function(){return this.scrollTo()},o.prototype.selectPage=function(a){a>0&&a<=this.options.totalPages&&(this.options.pageNumber=a,this.updatePagination())},o.prototype.prevPage=function(){this.options.pageNumber>1&&(this.options.pageNumber--,this.updatePagination())},o.prototype.nextPage=function(){this.options.pageNumber<this.options.totalPages&&(this.options.pageNumber++,this.updatePagination())},o.prototype.toggleView=function(){this.options.cardView=!this.options.cardView,this.initHeader(),this.initBody(),this.trigger("toggle",this.options.cardView)};var p=["getOptions","getSelections","getAllSelections","getData","load","append","prepend","remove","removeAll","insertRow","updateRow","updateCell","removeByUniqueId","showRow","hideRow","getRowsHidden","mergeCells","checkAll","uncheckAll","check","uncheck","checkBy","uncheckBy","refresh","resetView","resetWidth","destroy","showLoading","hideLoading","showColumn","hideColumn","filterBy","scrollTo","getScrollPosition","selectPage","prevPage","nextPage","togglePagination","toggleView"];a.fn.bootstrapTable=function(b){var c,d=Array.prototype.slice.call(arguments,1);return this.each(function(){var e=a(this),f=e.data("bootstrap.table"),g=a.extend({},o.DEFAULTS,e.data(),"object"==typeof b&&b);if("string"==typeof b){if(a.inArray(b,p)<0)throw new Error("Unknown method: "+b);if(!f)return;c=f[b].apply(f,d),"destroy"===b&&e.removeData("bootstrap.table")}f||e.data("bootstrap.table",f=new o(this,g))}),"undefined"==typeof c?this:c},a.fn.bootstrapTable.Constructor=o,a.fn.bootstrapTable.defaults=o.DEFAULTS,a.fn.bootstrapTable.columnDefaults=o.COLUMN_DEFAULTS,a.fn.bootstrapTable.locales=o.LOCALES,a.fn.bootstrapTable.methods=p,a(function(){a('[data-toggle="table"]').bootstrapTable()})}(jQuery);
1
+ /**
2
+ * @author zhixin wen <wenzhixin2010@gmail.com>
3
+ * version: 1.8.1
4
+ * https://github.com/wenzhixin/bootstrap-table/
5
+ */
6
+
7
+ ! function ($) {
8
+ 'use strict';
9
+
10
+ // TOOLS DEFINITION
11
+ // ======================
12
+
13
+ var cachedWidth = null;
14
+
15
+ // it only does '%s', and return '' when arguments are undefined
16
+ var sprintf = function (str) {
17
+ var args = arguments,
18
+ flag = true,
19
+ i = 1;
20
+
21
+ str = str.replace(/%s/g, function () {
22
+ var arg = args[i++];
23
+
24
+ if (typeof arg === 'undefined') {
25
+ flag = false;
26
+ return '';
27
+ }
28
+ return arg;
29
+ });
30
+ return flag ? str : '';
31
+ };
32
+
33
+ var getPropertyFromOther = function (list, from, to, value) {
34
+ var result = '';
35
+ $.each(list, function (i, item) {
36
+ if (item[from] === value) {
37
+ result = item[to];
38
+ return false;
39
+ }
40
+ return true;
41
+ });
42
+ return result;
43
+ };
44
+
45
+ var getFieldIndex = function (columns, field) {
46
+ var index = -1;
47
+
48
+ $.each(columns, function (i, column) {
49
+ if (column.field === field) {
50
+ index = i;
51
+ return false;
52
+ }
53
+ return true;
54
+ });
55
+ return index;
56
+ };
57
+
58
+ // http://jsfiddle.net/wenyi/47nz7ez9/3/
59
+ var setFieldIndex = function (columns) {
60
+ var i, j, k,
61
+ totalCol = 0,
62
+ flag = [];
63
+
64
+ for (i = 0; i < columns[0].length; i++) {
65
+ totalCol += columns[0][i].colspan || 1;
66
+ }
67
+
68
+ for (i = 0; i < columns.length; i++) {
69
+ flag[i] = [];
70
+ for (j = 0; j < totalCol; j++) {
71
+ flag[i][j] = false;
72
+ }
73
+ }
74
+
75
+ for (i = 0; i < columns.length; i++) {
76
+ for (j = 0; j < columns[i].length; j++) {
77
+ var r = columns[i][j],
78
+ rowspan = r.rowspan || 1,
79
+ colspan = r.colspan || 1,
80
+ index = $.inArray(false, flag[i]);
81
+
82
+ if (colspan === 1) {
83
+ r.fieldIndex = index;
84
+ // when field is undefined, use index instead
85
+ if (typeof r.field === 'undefined') {
86
+ r.field = index;
87
+ }
88
+ }
89
+
90
+ for (k = 0; k < rowspan; k++) {
91
+ flag[i + k][index] = true;
92
+ }
93
+ for (k = 0; k < colspan; k++) {
94
+ flag[i][index + k] = true;
95
+ }
96
+ }
97
+ }
98
+ }
99
+
100
+ var getScrollBarWidth = function () {
101
+ if (cachedWidth === null) {
102
+ var inner = $('<p/>').addClass('fixed-table-scroll-inner'),
103
+ outer = $('<div/>').addClass('fixed-table-scroll-outer'),
104
+ w1, w2;
105
+
106
+ outer.append(inner);
107
+ $('body').append(outer);
108
+
109
+ w1 = inner[0].offsetWidth;
110
+ outer.css('overflow', 'scroll');
111
+ w2 = inner[0].offsetWidth;
112
+
113
+ if (w1 === w2) {
114
+ w2 = outer[0].clientWidth;
115
+ }
116
+
117
+ outer.remove();
118
+ cachedWidth = w1 - w2;
119
+ }
120
+ return cachedWidth;
121
+ };
122
+
123
+ var calculateObjectValue = function (self, name, args, defaultValue) {
124
+ var func = name;
125
+
126
+ if (typeof name === 'string') {
127
+ // support obj.func1.func2
128
+ var names = name.split('.');
129
+
130
+ if (names.length > 1) {
131
+ func = window;
132
+ $.each(names, function (i, f) {
133
+ func = func[f];
134
+ });
135
+ } else {
136
+ func = window[name];
137
+ }
138
+ }
139
+ if (typeof func === 'object') {
140
+ return func;
141
+ }
142
+ if (typeof func === 'function') {
143
+ return func.apply(self, args);
144
+ }
145
+ if (!func && typeof name === 'string' && sprintf.apply(this, [name].concat(args))) {
146
+ return sprintf.apply(this, [name].concat(args));
147
+ }
148
+ return defaultValue;
149
+ };
150
+
151
+ var compareObjects = function (objectA, objectB, compareLength) {
152
+ // Create arrays of property names
153
+ var objectAProperties = Object.getOwnPropertyNames(objectA),
154
+ objectBProperties = Object.getOwnPropertyNames(objectB),
155
+ propName = '';
156
+
157
+ if (compareLength) {
158
+ // If number of properties is different, objects are not equivalent
159
+ if (objectAProperties.length != objectBProperties.length) {
160
+ return false;
161
+ }
162
+ }
163
+
164
+ for (var i = 0; i < objectAProperties.length; i++) {
165
+ propName = objectAProperties[i];
166
+
167
+ // If the property is not in the object B properties, continue with the next property
168
+ if ($.inArray(propName, objectBProperties) > -1) {
169
+ // If values of same property are not equal, objects are not equivalent
170
+ if (objectA[propName] !== objectB[propName]) {
171
+ return false;
172
+ }
173
+ }
174
+ }
175
+
176
+ // If we made it this far, objects are considered equivalent
177
+ return true;
178
+ };
179
+
180
+ var escapeHTML = function (text) {
181
+ if (typeof text === 'string') {
182
+ return text
183
+ .replace(/&/g, "&amp;")
184
+ .replace(/</g, "&lt;")
185
+ .replace(/>/g, "&gt;")
186
+ .replace(/"/g, "&quot;")
187
+ .replace(/'/g, "&#039;");
188
+ }
189
+ return text;
190
+ };
191
+
192
+ var getRealHeight = function ($el) {
193
+ var height = 0;
194
+ $el.children().each(function () {
195
+ if (height < $(this).outerHeight(true)) {
196
+ height = $(this).outerHeight(true);
197
+ }
198
+ });
199
+ return height;
200
+ };
201
+
202
+ var getRealDataAttr = function (dataAttr) {
203
+ for (var attr in dataAttr) {
204
+ var auxAttr = attr.split(/(?=[A-Z])/).join('-').toLowerCase();
205
+ if (auxAttr !== attr) {
206
+ dataAttr[auxAttr] = dataAttr[attr];
207
+ delete dataAttr[attr];
208
+ }
209
+ }
210
+
211
+ return dataAttr;
212
+ };
213
+
214
+ // BOOTSTRAP TABLE CLASS DEFINITION
215
+ // ======================
216
+
217
+ var BootstrapTable = function (el, options) {
218
+ this.options = options;
219
+ this.$el = $(el);
220
+ this.$el_ = this.$el.clone();
221
+ this.timeoutId_ = 0;
222
+ this.timeoutFooter_ = 0;
223
+
224
+ this.init();
225
+ };
226
+
227
+ BootstrapTable.DEFAULTS = {
228
+ classes: 'table table-hover',
229
+ locale: undefined,
230
+ height: undefined,
231
+ undefinedText: '-',
232
+ sortName: undefined,
233
+ sortOrder: 'asc',
234
+ striped: false,
235
+ columns: [[]],
236
+ data: [],
237
+ method: 'get',
238
+ url: undefined,
239
+ ajax: undefined,
240
+ cache: true,
241
+ contentType: 'application/json',
242
+ dataType: 'json',
243
+ ajaxOptions: {},
244
+ queryParams: function (params) {
245
+ return params;
246
+ },
247
+ queryParamsType: 'limit', // undefined
248
+ responseHandler: function (res) {
249
+ return res;
250
+ },
251
+ pagination: false,
252
+ sidePagination: 'client', // client or server
253
+ totalRows: 0, // server side need to set
254
+ pageNumber: 1,
255
+ pageSize: 10,
256
+ pageList: [10, 25, 50, 100],
257
+ paginationHAlign: 'right', //right, left
258
+ paginationVAlign: 'bottom', //bottom, top, both
259
+ paginationDetailHAlign: 'left', //right, left
260
+ paginationFirstText: '&laquo;',
261
+ paginationPreText: '&lsaquo;',
262
+ paginationNextText: '&rsaquo;',
263
+ paginationLastText: '&raquo;',
264
+ search: false,
265
+ strictSearch: false,
266
+ searchAlign: 'right',
267
+ selectItemName: 'btSelectItem',
268
+ showHeader: true,
269
+ showFooter: false,
270
+ showColumns: false,
271
+ showPaginationSwitch: false,
272
+ showRefresh: false,
273
+ showToggle: false,
274
+ buttonsAlign: 'right',
275
+ smartDisplay: true,
276
+ minimumCountColumns: 1,
277
+ idField: undefined,
278
+ uniqueId: undefined,
279
+ cardView: false,
280
+ detailView: false,
281
+ detailFormatter: function (index, row) {
282
+ return '';
283
+ },
284
+ trimOnSearch: true,
285
+ clickToSelect: false,
286
+ singleSelect: false,
287
+ toolbar: undefined,
288
+ toolbarAlign: 'left',
289
+ checkboxHeader: true,
290
+ sortable: true,
291
+ silentSort: true,
292
+ maintainSelected: false,
293
+ searchTimeOut: 500,
294
+ searchText: '',
295
+ iconSize: undefined,
296
+ iconsPrefix: 'glyphicon', // glyphicon of fa (font awesome)
297
+ icons: {
298
+ paginationSwitchDown: 'glyphicon-collapse-down icon-chevron-down',
299
+ paginationSwitchUp: 'glyphicon-collapse-up icon-chevron-up',
300
+ refresh: 'glyphicon-refresh icon-refresh',
301
+ toggle: 'glyphicon-list-alt icon-list-alt',
302
+ columns: 'glyphicon-th icon-th',
303
+ detailOpen: 'glyphicon-plus icon-plus',
304
+ detailClose: 'glyphicon-minus icon-minus'
305
+ },
306
+
307
+ rowStyle: function (row, index) {
308
+ return {};
309
+ },
310
+
311
+ rowAttributes: function (row, index) {
312
+ return {};
313
+ },
314
+
315
+ onAll: function (name, args) {
316
+ return false;
317
+ },
318
+ onClickCell: function (field, value, row, $element) {
319
+ return false;
320
+ },
321
+ onDblClickCell: function (field, value, row, $element) {
322
+ return false;
323
+ },
324
+ onClickRow: function (item, $element) {
325
+ return false;
326
+ },
327
+ onDblClickRow: function (item, $element) {
328
+ return false;
329
+ },
330
+ onSort: function (name, order) {
331
+ return false;
332
+ },
333
+ onCheck: function (row) {
334
+ return false;
335
+ },
336
+ onUncheck: function (row) {
337
+ return false;
338
+ },
339
+ onCheckAll: function (rows) {
340
+ return false;
341
+ },
342
+ onUncheckAll: function (rows) {
343
+ return false;
344
+ },
345
+ onCheckSome: function (rows) {
346
+ return false;
347
+ },
348
+ onUncheckSome: function (rows) {
349
+ return false;
350
+ },
351
+ onLoadSuccess: function (data) {
352
+ return false;
353
+ },
354
+ onLoadError: function (status) {
355
+ return false;
356
+ },
357
+ onColumnSwitch: function (field, checked) {
358
+ return false;
359
+ },
360
+ onPageChange: function (number, size) {
361
+ return false;
362
+ },
363
+ onSearch: function (text) {
364
+ return false;
365
+ },
366
+ onToggle: function (cardView) {
367
+ return false;
368
+ },
369
+ onPreBody: function (data) {
370
+ return false;
371
+ },
372
+ onPostBody: function () {
373
+ return false;
374
+ },
375
+ onPostHeader: function () {
376
+ return false;
377
+ },
378
+ onExpandRow: function (index, row, $detail) {
379
+ return false;
380
+ },
381
+ onCollapseRow: function (index, row) {
382
+ return false;
383
+ },
384
+ onRefreshOptions: function (options) {
385
+ return false;
386
+ },
387
+ onResetView: function () {
388
+ return false;
389
+ }
390
+ };
391
+
392
+ BootstrapTable.LOCALES = [];
393
+
394
+ BootstrapTable.LOCALES['en-US'] = BootstrapTable.LOCALES['en'] = {
395
+ formatLoadingMessage: function () {
396
+ return 'Loading, please wait...';
397
+ },
398
+ formatRecordsPerPage: function (pageNumber) {
399
+ return sprintf('%s records per page', pageNumber);
400
+ },
401
+ formatShowingRows: function (pageFrom, pageTo, totalRows) {
402
+ return sprintf('Showing %s to %s of %s rows', pageFrom, pageTo, totalRows);
403
+ },
404
+ formatSearch: function () {
405
+ return 'Search';
406
+ },
407
+ formatNoMatches: function () {
408
+ return 'No matching records found';
409
+ },
410
+ formatPaginationSwitch: function () {
411
+ return 'Hide/Show pagination';
412
+ },
413
+ formatRefresh: function () {
414
+ return 'Refresh';
415
+ },
416
+ formatToggle: function () {
417
+ return 'Toggle';
418
+ },
419
+ formatColumns: function () {
420
+ return 'Columns';
421
+ },
422
+ formatAllRows: function () {
423
+ return 'All';
424
+ }
425
+ };
426
+
427
+ $.extend(BootstrapTable.DEFAULTS, BootstrapTable.LOCALES['en-US']);
428
+
429
+ BootstrapTable.COLUMN_DEFAULTS = {
430
+ radio: false,
431
+ checkbox: false,
432
+ checkboxEnabled: true,
433
+ field: undefined,
434
+ title: undefined,
435
+ titleTooltip: undefined,
436
+ 'class': undefined,
437
+ align: undefined, // left, right, center
438
+ halign: undefined, // left, right, center
439
+ falign: undefined, // left, right, center
440
+ valign: undefined, // top, middle, bottom
441
+ width: undefined,
442
+ sortable: false,
443
+ order: 'asc', // asc, desc
444
+ visible: true,
445
+ switchable: true,
446
+ clickToSelect: true,
447
+ formatter: undefined,
448
+ footerFormatter: undefined,
449
+ events: undefined,
450
+ sorter: undefined,
451
+ sortName: undefined,
452
+ cellStyle: undefined,
453
+ searchable: true,
454
+ searchFormatter: true,
455
+ cardVisible: true
456
+ };
457
+
458
+ BootstrapTable.EVENTS = {
459
+ 'all.bs.table': 'onAll',
460
+ 'click-cell.bs.table': 'onClickCell',
461
+ 'dbl-click-cell.bs.table': 'onDblClickCell',
462
+ 'click-row.bs.table': 'onClickRow',
463
+ 'dbl-click-row.bs.table': 'onDblClickRow',
464
+ 'sort.bs.table': 'onSort',
465
+ 'check.bs.table': 'onCheck',
466
+ 'uncheck.bs.table': 'onUncheck',
467
+ 'check-all.bs.table': 'onCheckAll',
468
+ 'uncheck-all.bs.table': 'onUncheckAll',
469
+ 'check-some.bs.table': 'onCheckSome',
470
+ 'uncheck-some.bs.table': 'onUncheckSome',
471
+ 'load-success.bs.table': 'onLoadSuccess',
472
+ 'load-error.bs.table': 'onLoadError',
473
+ 'column-switch.bs.table': 'onColumnSwitch',
474
+ 'page-change.bs.table': 'onPageChange',
475
+ 'search.bs.table': 'onSearch',
476
+ 'toggle.bs.table': 'onToggle',
477
+ 'pre-body.bs.table': 'onPreBody',
478
+ 'post-body.bs.table': 'onPostBody',
479
+ 'post-header.bs.table': 'onPostHeader',
480
+ 'expand-row.bs.table': 'onExpandRow',
481
+ 'collapse-row.bs.table': 'onCollapseRow',
482
+ 'refresh-options.bs.table': 'onRefreshOptions',
483
+ 'reset-view.bs.table': 'onResetView'
484
+ };
485
+
486
+ BootstrapTable.prototype.init = function () {
487
+ this.initLocale();
488
+ this.initContainer();
489
+ this.initTable();
490
+ this.initHeader();
491
+ this.initData();
492
+ this.initFooter();
493
+ this.initToolbar();
494
+ this.initPagination();
495
+ this.initBody();
496
+ this.initServer();
497
+ };
498
+
499
+ BootstrapTable.prototype.initLocale = function () {
500
+ if (this.options.locale) {
501
+ var parts = this.options.locale.split(/-|_/);
502
+ parts[0].toLowerCase();
503
+ parts[1] && parts[1].toUpperCase();
504
+ if ($.fn.bootstrapTable.locales[this.options.locale]) {
505
+ // locale as requested
506
+ $.extend(this.options, $.fn.bootstrapTable.locales[this.options.locale]);
507
+ } else if ($.fn.bootstrapTable.locales[parts.join('-')]) {
508
+ // locale with sep set to - (in case original was specified with _)
509
+ $.extend(this.options, $.fn.bootstrapTable.locales[parts.join('-')]);
510
+ } else if ($.fn.bootstrapTable.locales[parts[0]]) {
511
+ // short locale language code (i.e. 'en')
512
+ $.extend(this.options, $.fn.bootstrapTable.locales[parts[0]]);
513
+ }
514
+ }
515
+ };
516
+
517
+ BootstrapTable.prototype.initContainer = function () {
518
+ this.$container = $([
519
+ '<div class="bootstrap-table">',
520
+ '<div class="fixed-table-toolbar"></div>',
521
+ this.options.paginationVAlign === 'top' || this.options.paginationVAlign === 'both' ?
522
+ '<div class="fixed-table-pagination" style="clear: both;"></div>' :
523
+ '',
524
+ '<div class="fixed-table-container">',
525
+ '<div class="fixed-table-header"><table></table></div>',
526
+ '<div class="fixed-table-body">',
527
+ '<div class="fixed-table-loading">',
528
+ this.options.formatLoadingMessage(),
529
+ '</div>',
530
+ '</div>',
531
+ '<div class="fixed-table-footer"><table><tr></tr></table></div>',
532
+ this.options.paginationVAlign === 'bottom' || this.options.paginationVAlign === 'both' ?
533
+ '<div class="fixed-table-pagination"></div>' :
534
+ '',
535
+ '</div>',
536
+ '</div>'
537
+ ].join(''));
538
+
539
+ this.$container.insertAfter(this.$el);
540
+ this.$tableContainer = this.$container.find('.fixed-table-container');
541
+ this.$tableHeader = this.$container.find('.fixed-table-header');
542
+ this.$tableBody = this.$container.find('.fixed-table-body');
543
+ this.$tableLoading = this.$container.find('.fixed-table-loading');
544
+ this.$tableFooter = this.$container.find('.fixed-table-footer');
545
+ this.$toolbar = this.$container.find('.fixed-table-toolbar');
546
+ this.$pagination = this.$container.find('.fixed-table-pagination');
547
+
548
+ this.$tableBody.append(this.$el);
549
+ this.$container.after('<div class="clearfix"></div>');
550
+
551
+ this.$el.addClass(this.options.classes);
552
+ if (this.options.striped) {
553
+ this.$el.addClass('table-striped');
554
+ }
555
+ if ($.inArray('table-no-bordered', this.options.classes.split(' ')) !== -1) {
556
+ this.$tableContainer.addClass('table-no-bordered');
557
+ }
558
+ };
559
+
560
+ BootstrapTable.prototype.initTable = function () {
561
+ var that = this,
562
+ columns = [],
563
+ data = [];
564
+
565
+ this.$header = this.$el.find('thead');
566
+ if (!this.$header.length) {
567
+ this.$header = $('<thead></thead>').appendTo(this.$el);
568
+ }
569
+ this.$header.find('tr').each(function () {
570
+ var column = [];
571
+
572
+ $(this).find('th').each(function () {
573
+ column.push($.extend({}, {
574
+ title: $(this).html(),
575
+ 'class': $(this).attr('class'),
576
+ titleTooltip: $(this).attr('title'),
577
+ rowspan: $(this).attr('rowspan') ? +$(this).attr('rowspan') : undefined,
578
+ colspan: $(this).attr('colspan') ? +$(this).attr('colspan') : undefined
579
+ }, $(this).data()));
580
+ });
581
+ columns.push(column);
582
+ });
583
+ if (!$.isArray(this.options.columns[0])) {
584
+ this.options.columns = [this.options.columns];
585
+ }
586
+ this.options.columns = $.extend(true, [], columns, this.options.columns);
587
+ this.columns = [];
588
+
589
+ setFieldIndex(this.options.columns);
590
+ $.each(this.options.columns, function (i, columns) {
591
+ $.each(columns, function (j, column) {
592
+ column = $.extend({}, BootstrapTable.COLUMN_DEFAULTS, column);
593
+
594
+ if (typeof column.fieldIndex !== 'undefined') {
595
+ that.columns[column.fieldIndex] = column;
596
+ }
597
+
598
+ that.options.columns[i][j] = column;
599
+ });
600
+ });
601
+
602
+ // if options.data is setting, do not process tbody data
603
+ if (this.options.data.length) {
604
+ return;
605
+ }
606
+
607
+ this.$el.find('tbody tr').each(function () {
608
+ var row = {};
609
+
610
+ // save tr's id, class and data-* attributes
611
+ row._id = $(this).attr('id');
612
+ row._class = $(this).attr('class');
613
+ row._data = getRealDataAttr($(this).data());
614
+
615
+ $(this).find('td').each(function (i) {
616
+ var field = that.columns[i].field;
617
+
618
+ row[field] = $(this).html();
619
+ // save td's id, class and data-* attributes
620
+ row['_' + field + '_id'] = $(this).attr('id');
621
+ row['_' + field + '_class'] = $(this).attr('class');
622
+ row['_' + field + '_rowspan'] = $(this).attr('rowspan');
623
+ row['_' + field + '_title'] = $(this).attr('title');
624
+ row['_' + field + '_data'] = getRealDataAttr($(this).data());
625
+ });
626
+ data.push(row);
627
+ });
628
+ this.options.data = data;
629
+ };
630
+
631
+ BootstrapTable.prototype.initHeader = function () {
632
+ var that = this,
633
+ visibleColumns = {},
634
+ html = [];
635
+
636
+ this.header = {
637
+ fields: [],
638
+ styles: [],
639
+ classes: [],
640
+ formatters: [],
641
+ events: [],
642
+ sorters: [],
643
+ sortNames: [],
644
+ cellStyles: [],
645
+ searchables: []
646
+ };
647
+
648
+ $.each(this.options.columns, function (i, columns) {
649
+ html.push('<tr>');
650
+
651
+ if (i == 0 && !that.options.cardView && that.options.detailView) {
652
+ html.push(sprintf('<th class="detail" rowspan="%s"><div class="fht-cell"></div></th>',
653
+ that.options.columns.length));
654
+ }
655
+
656
+ $.each(columns, function (j, column) {
657
+ var text = '',
658
+ halign = '', // header align style
659
+ align = '', // body align style
660
+ style = '',
661
+ class_ = sprintf(' class="%s"', column['class']),
662
+ order = that.options.sortOrder || column.order,
663
+ unitWidth = 'px',
664
+ width = column.width;
665
+
666
+ if (column.width !== undefined && (!that.options.cardView)) {
667
+ if (typeof column.width === 'string') {
668
+ if (column.width.indexOf('%') !== -1) {
669
+ unitWidth = '%';
670
+ }
671
+ }
672
+ }
673
+ if (column.width && typeof column.width === 'string') {
674
+ width = column.width.replace('%', '').replace('px', '');
675
+ }
676
+
677
+ halign = sprintf('text-align: %s; ', column.halign ? column.halign : column.align);
678
+ align = sprintf('text-align: %s; ', column.align);
679
+ style = sprintf('vertical-align: %s; ', column.valign);
680
+ style += sprintf('width: %s%s; ', column.checkbox || column.radio ? 36 : width, unitWidth);
681
+
682
+ if (typeof column.fieldIndex !== 'undefined') {
683
+ that.header.fields[column.fieldIndex] = column.field;
684
+ that.header.styles[column.fieldIndex] = align + style;
685
+ that.header.classes[column.fieldIndex] = class_;
686
+ that.header.formatters[column.fieldIndex] = column.formatter;
687
+ that.header.events[column.fieldIndex] = column.events;
688
+ that.header.sorters[column.fieldIndex] = column.sorter;
689
+ that.header.sortNames[column.fieldIndex] = column.sortName;
690
+ that.header.cellStyles[column.fieldIndex] = column.cellStyle;
691
+ that.header.searchables[column.fieldIndex] = column.searchable;
692
+
693
+ if (!column.visible) {
694
+ return;
695
+ }
696
+
697
+ if (that.options.cardView && (!column.cardVisible)) {
698
+ return;
699
+ }
700
+
701
+ visibleColumns[column.field] = column;
702
+ }
703
+
704
+ html.push('<th' + sprintf(' title="%s"', column.titleTooltip),
705
+ column.checkbox || column.radio ?
706
+ sprintf(' class="bs-checkbox %s"', column['class'] || '') :
707
+ class_,
708
+ sprintf(' style="%s"', halign + style),
709
+ sprintf(' rowspan="%s"', column.rowspan),
710
+ sprintf(' colspan="%s"', column.colspan),
711
+ sprintf(' data-field="%s"', column.field),
712
+ '>');
713
+
714
+ html.push(sprintf('<div class="th-inner %s">', that.options.sortable && column.sortable ?
715
+ 'sortable both' : ''));
716
+
717
+ text = column.title;
718
+
719
+ if (column.checkbox) {
720
+ if (!that.options.singleSelect && that.options.checkboxHeader) {
721
+ text = '<input name="btSelectAll" type="checkbox" />';
722
+ }
723
+ that.header.stateField = column.field;
724
+ }
725
+ if (column.radio) {
726
+ text = '';
727
+ that.header.stateField = column.field;
728
+ that.options.singleSelect = true;
729
+ }
730
+
731
+ html.push(text);
732
+ html.push('</div>');
733
+ html.push('<div class="fht-cell"></div>');
734
+ html.push('</div>');
735
+ html.push('</th>');
736
+ });
737
+ html.push('</tr>');
738
+ });
739
+
740
+ this.$header.html(html.join(''));
741
+ this.$header.find('th[data-field]').each(function (i) {
742
+ $(this).data(visibleColumns[$(this).data('field')]);
743
+ });
744
+ this.$container.off('click', '.th-inner').on('click', '.th-inner', function (event) {
745
+ if (that.options.sortable && $(this).parent().data().sortable) {
746
+ that.onSort(event);
747
+ }
748
+ });
749
+
750
+ if (!this.options.showHeader || this.options.cardView) {
751
+ this.$header.hide();
752
+ this.$tableHeader.hide();
753
+ this.$tableLoading.css('top', 0);
754
+ } else {
755
+ this.$header.show();
756
+ this.$tableHeader.show();
757
+ this.$tableLoading.css('top', this.$header.outerHeight() + 1);
758
+ // Assign the correct sortable arrow
759
+ this.getCaret();
760
+ }
761
+
762
+ this.$selectAll = this.$header.find('[name="btSelectAll"]');
763
+ this.$container.off('click', '[name="btSelectAll"]')
764
+ .on('click', '[name="btSelectAll"]', function () {
765
+ var checked = $(this).prop('checked');
766
+ that[checked ? 'checkAll' : 'uncheckAll']();
767
+ });
768
+ };
769
+
770
+ BootstrapTable.prototype.initFooter = function () {
771
+ if (!this.options.showFooter || this.options.cardView) {
772
+ this.$tableFooter.hide();
773
+ } else {
774
+ this.$tableFooter.show();
775
+ }
776
+ };
777
+
778
+ /**
779
+ * @param data
780
+ * @param type: append / prepend
781
+ */
782
+ BootstrapTable.prototype.initData = function (data, type) {
783
+ if (type === 'append') {
784
+ this.data = this.data.concat(data);
785
+ } else if (type === 'prepend') {
786
+ this.data = [].concat(data).concat(this.data);
787
+ } else {
788
+ this.data = data || this.options.data;
789
+ }
790
+
791
+ // Fix #839 Records deleted when adding new row on filtered table
792
+ if (type === 'append') {
793
+ this.options.data = this.options.data.concat(data);
794
+ } else if (type === 'prepend') {
795
+ this.options.data = [].concat(data).concat(this.options.data);
796
+ } else {
797
+ this.options.data = this.data;
798
+ }
799
+
800
+ if (this.options.sidePagination === 'server') {
801
+ return;
802
+ }
803
+ this.initSort();
804
+ };
805
+
806
+ BootstrapTable.prototype.initSort = function () {
807
+ var that = this,
808
+ name = this.options.sortName,
809
+ order = this.options.sortOrder === 'desc' ? -1 : 1,
810
+ index = $.inArray(this.options.sortName, this.header.fields);
811
+
812
+ if (index !== -1) {
813
+ this.data.sort(function (a, b) {
814
+ if (that.header.sortNames[index]) {
815
+ name = that.header.sortNames[index];
816
+ }
817
+ var aa = a[name],
818
+ bb = b[name],
819
+ value = calculateObjectValue(that.header, that.header.sorters[index], [aa, bb]);
820
+
821
+ if (value !== undefined) {
822
+ return order * value;
823
+ }
824
+
825
+ // Fix #161: undefined or null string sort bug.
826
+ if (aa === undefined || aa === null) {
827
+ aa = '';
828
+ }
829
+ if (bb === undefined || bb === null) {
830
+ bb = '';
831
+ }
832
+
833
+ // IF both values are numeric, do a numeric comparison
834
+ if ($.isNumeric(aa) && $.isNumeric(bb)) {
835
+ // Convert numerical values form string to float.
836
+ aa = parseFloat(aa);
837
+ bb = parseFloat(bb);
838
+ if (aa < bb) {
839
+ return order * -1;
840
+ }
841
+ return order;
842
+ }
843
+
844
+ if (aa === bb) {
845
+ return 0;
846
+ }
847
+
848
+ // If value is not a string, convert to string
849
+ if (typeof aa !== 'string') {
850
+ aa = aa.toString();
851
+ }
852
+
853
+ if (aa.localeCompare(bb) === -1) {
854
+ return order * -1;
855
+ }
856
+
857
+ return order;
858
+ });
859
+ }
860
+ };
861
+
862
+ BootstrapTable.prototype.onSort = function (event) {
863
+ var $this = $(event.currentTarget).parent(),
864
+ $this_ = this.$header.find('th').eq($this.index());
865
+
866
+ this.$header.add(this.$header_).find('span.order').remove();
867
+
868
+ if (this.options.sortName === $this.data('field')) {
869
+ this.options.sortOrder = this.options.sortOrder === 'asc' ? 'desc' : 'asc';
870
+ } else {
871
+ this.options.sortName = $this.data('field');
872
+ this.options.sortOrder = $this.data('order') === 'asc' ? 'desc' : 'asc';
873
+ }
874
+ this.trigger('sort', this.options.sortName, this.options.sortOrder);
875
+
876
+ $this.add($this_).data('order', this.options.sortOrder);
877
+
878
+ // Assign the correct sortable arrow
879
+ this.getCaret();
880
+
881
+ if (this.options.sidePagination === 'server') {
882
+ this.initServer(this.options.silentSort);
883
+ return;
884
+ }
885
+
886
+ this.initSort();
887
+ this.initBody();
888
+ };
889
+
890
+ BootstrapTable.prototype.initToolbar = function () {
891
+ var that = this,
892
+ html = [],
893
+ timeoutId = 0,
894
+ $keepOpen,
895
+ $search,
896
+ switchableCount = 0;
897
+
898
+ this.$toolbar.html('');
899
+
900
+ if (typeof this.options.toolbar === 'string' || typeof this.options.toolbar === 'object') {
901
+ $(sprintf('<div class="bars pull-%s"></div>', this.options.toolbarAlign))
902
+ .appendTo(this.$toolbar)
903
+ .append($(this.options.toolbar));
904
+ }
905
+
906
+ // showColumns, showToggle, showRefresh
907
+ html = [sprintf('<div class="columns columns-%s btn-group pull-%s">',
908
+ this.options.buttonsAlign, this.options.buttonsAlign)];
909
+
910
+ if (typeof this.options.icons === 'string') {
911
+ this.options.icons = calculateObjectValue(null, this.options.icons);
912
+ }
913
+
914
+ if (this.options.showPaginationSwitch) {
915
+ html.push(sprintf('<button class="btn btn-default" type="button" name="paginationSwitch" title="%s">',
916
+ this.options.formatPaginationSwitch()),
917
+ sprintf('<i class="%s %s"></i>', this.options.iconsPrefix, this.options.icons.paginationSwitchDown),
918
+ '</button>');
919
+ }
920
+
921
+ if (this.options.showRefresh) {
922
+ html.push(sprintf('<button class="btn btn-default' + (this.options.iconSize === undefined ? '' : ' btn-' + this.options.iconSize) + '" type="button" name="refresh" title="%s">',
923
+ this.options.formatRefresh()),
924
+ sprintf('<i class="%s %s"></i>', this.options.iconsPrefix, this.options.icons.refresh),
925
+ '</button>');
926
+ }
927
+
928
+ if (this.options.showToggle) {
929
+ html.push(sprintf('<button class="btn btn-default' + (this.options.iconSize === undefined ? '' : ' btn-' + this.options.iconSize) + '" type="button" name="toggle" title="%s">',
930
+ this.options.formatToggle()),
931
+ sprintf('<i class="%s %s"></i>', this.options.iconsPrefix, this.options.icons.toggle),
932
+ '</button>');
933
+ }
934
+
935
+ if (this.options.showColumns) {
936
+ html.push(sprintf('<div class="keep-open btn-group" title="%s">',
937
+ this.options.formatColumns()),
938
+ '<button type="button" class="btn btn-default' + (this.options.iconSize == undefined ? '' : ' btn-' + this.options.iconSize) + ' dropdown-toggle" data-toggle="dropdown">',
939
+ sprintf('<i class="%s %s"></i>', this.options.iconsPrefix, this.options.icons.columns),
940
+ ' <span class="caret"></span>',
941
+ '</button>',
942
+ '<ul class="dropdown-menu" role="menu">');
943
+
944
+ $.each(this.columns, function (i, column) {
945
+ if (column.radio || column.checkbox) {
946
+ return;
947
+ }
948
+
949
+ if (that.options.cardView && (!column.cardVisible)) {
950
+ return;
951
+ }
952
+
953
+ var checked = column.visible ? ' checked="checked"' : '';
954
+
955
+ if (column.switchable) {
956
+ html.push(sprintf('<li>' +
957
+ '<label><input type="checkbox" data-field="%s" value="%s"%s> %s</label>' +
958
+ '</li>', column.field, i, checked, column.title));
959
+ switchableCount++;
960
+ }
961
+ });
962
+ html.push('</ul>',
963
+ '</div>');
964
+ }
965
+
966
+ html.push('</div>');
967
+
968
+ // Fix #188: this.showToolbar is for extentions
969
+ if (this.showToolbar || html.length > 2) {
970
+ this.$toolbar.append(html.join(''));
971
+ }
972
+
973
+ if (this.options.showPaginationSwitch) {
974
+ this.$toolbar.find('button[name="paginationSwitch"]')
975
+ .off('click').on('click', $.proxy(this.togglePagination, this));
976
+ }
977
+
978
+ if (this.options.showRefresh) {
979
+ this.$toolbar.find('button[name="refresh"]')
980
+ .off('click').on('click', $.proxy(this.refresh, this));
981
+ }
982
+
983
+ if (this.options.showToggle) {
984
+ this.$toolbar.find('button[name="toggle"]')
985
+ .off('click').on('click', function () {
986
+ that.toggleView();
987
+ });
988
+ }
989
+
990
+ if (this.options.showColumns) {
991
+ $keepOpen = this.$toolbar.find('.keep-open');
992
+
993
+ if (switchableCount <= this.options.minimumCountColumns) {
994
+ $keepOpen.find('input').prop('disabled', true);
995
+ }
996
+
997
+ $keepOpen.find('li').off('click').on('click', function (event) {
998
+ event.stopImmediatePropagation();
999
+ });
1000
+ $keepOpen.find('input').off('click').on('click', function () {
1001
+ var $this = $(this);
1002
+
1003
+ that.toggleColumn(getFieldIndex(that.columns,
1004
+ $(this).data('field')), $this.prop('checked'), false);
1005
+ that.trigger('column-switch', $(this).data('field'), $this.prop('checked'));
1006
+ });
1007
+ }
1008
+
1009
+ if (this.options.search) {
1010
+ html = [];
1011
+ html.push(
1012
+ '<div class="pull-' + this.options.searchAlign + ' search">',
1013
+ sprintf('<input class="form-control' + (this.options.iconSize === undefined ? '' : ' input-' + this.options.iconSize) + '" type="text" placeholder="%s">',
1014
+ this.options.formatSearch()),
1015
+ '</div>');
1016
+
1017
+ this.$toolbar.append(html.join(''));
1018
+ $search = this.$toolbar.find('.search input');
1019
+ $search.off('keyup drop').on('keyup drop', function (event) {
1020
+ clearTimeout(timeoutId); // doesn't matter if it's 0
1021
+ timeoutId = setTimeout(function () {
1022
+ that.onSearch(event);
1023
+ }, that.options.searchTimeOut);
1024
+ });
1025
+
1026
+ if (this.options.searchText !== '') {
1027
+ $search.val(this.options.searchText);
1028
+ that.onSearch({currentTarget: $search});
1029
+ }
1030
+ }
1031
+ };
1032
+
1033
+ BootstrapTable.prototype.onSearch = function (event) {
1034
+ var text = $.trim($(event.currentTarget).val());
1035
+
1036
+ // trim search input
1037
+ if (this.options.trimOnSearch && $(event.currentTarget).val() !== text) {
1038
+ $(event.currentTarget).val(text);
1039
+ }
1040
+
1041
+ if (text === this.searchText) {
1042
+ return;
1043
+ }
1044
+ this.searchText = text;
1045
+
1046
+ this.options.pageNumber = 1;
1047
+ this.initSearch();
1048
+ this.updatePagination();
1049
+ this.trigger('search', text);
1050
+ };
1051
+
1052
+ BootstrapTable.prototype.initSearch = function () {
1053
+ var that = this;
1054
+
1055
+ if (this.options.sidePagination !== 'server') {
1056
+ var s = this.searchText && this.searchText.toLowerCase();
1057
+ var f = $.isEmptyObject(this.filterColumns) ? null : this.filterColumns;
1058
+
1059
+ // Check filter
1060
+ this.data = f ? $.grep(this.options.data, function (item, i) {
1061
+ for (var key in f) {
1062
+ if (item[key] !== f[key]) {
1063
+ return false;
1064
+ }
1065
+ }
1066
+ return true;
1067
+ }) : this.options.data;
1068
+
1069
+ this.data = s ? $.grep(this.data, function (item, i) {
1070
+ for (var key in item) {
1071
+ key = $.isNumeric(key) ? parseInt(key, 10) : key;
1072
+ var value = item[key],
1073
+ column = that.columns[getFieldIndex(that.columns, key)],
1074
+ j = $.inArray(key, that.header.fields);
1075
+
1076
+ // Fix #142: search use formated data
1077
+ if (column && column.searchFormatter) {
1078
+ value = calculateObjectValue(column,
1079
+ that.header.formatters[j], [value, item, i], value);
1080
+ }
1081
+
1082
+ var index = $.inArray(key, that.header.fields);
1083
+ if (index !== -1 && that.header.searchables[index] && (typeof value === 'string' || typeof value === 'number')) {
1084
+ if (that.options.strictSearch) {
1085
+ if ((value + '').toLowerCase() === s) {
1086
+ return true;
1087
+ }
1088
+ } else {
1089
+ if ((value + '').toLowerCase().indexOf(s) !== -1) {
1090
+ return true;
1091
+ }
1092
+ }
1093
+ }
1094
+ }
1095
+ return false;
1096
+ }) : this.data;
1097
+ }
1098
+ };
1099
+
1100
+ BootstrapTable.prototype.initPagination = function () {
1101
+ if (!this.options.pagination) {
1102
+ this.$pagination.hide();
1103
+ return;
1104
+ } else {
1105
+ this.$pagination.show();
1106
+ }
1107
+
1108
+ var that = this,
1109
+ html = [],
1110
+ $allSelected = false,
1111
+ i, from, to,
1112
+ $pageList,
1113
+ $first, $pre,
1114
+ $next, $last,
1115
+ $number,
1116
+ data = this.getData();
1117
+
1118
+ if (this.options.sidePagination !== 'server') {
1119
+ this.options.totalRows = data.length;
1120
+ }
1121
+
1122
+ this.totalPages = 0;
1123
+ if (this.options.totalRows) {
1124
+ if (this.options.pageSize === this.options.formatAllRows()) {
1125
+ this.options.pageSize = this.options.totalRows;
1126
+ $allSelected = true;
1127
+ } else if (this.options.pageSize === this.options.totalRows) {
1128
+ // Fix #667 Table with pagination,
1129
+ // multiple pages and a search that matches to one page throws exception
1130
+ var pageLst = typeof this.options.pageList === 'string' ?
1131
+ this.options.pageList.replace('[', '').replace(']', '')
1132
+ .replace(/ /g, '').toLowerCase().split(',') : this.options.pageList;
1133
+ if (pageLst.indexOf(this.options.formatAllRows().toLowerCase()) > -1) {
1134
+ $allSelected = true;
1135
+ }
1136
+ }
1137
+
1138
+ this.totalPages = ~~((this.options.totalRows - 1) / this.options.pageSize) + 1;
1139
+
1140
+ this.options.totalPages = this.totalPages;
1141
+ }
1142
+ if (this.totalPages > 0 && this.options.pageNumber > this.totalPages) {
1143
+ this.options.pageNumber = this.totalPages;
1144
+ }
1145
+
1146
+ this.pageFrom = (this.options.pageNumber - 1) * this.options.pageSize + 1;
1147
+ this.pageTo = this.options.pageNumber * this.options.pageSize;
1148
+ if (this.pageTo > this.options.totalRows) {
1149
+ this.pageTo = this.options.totalRows;
1150
+ }
1151
+
1152
+ html.push(
1153
+ '<div class="pull-' + this.options.paginationDetailHAlign + ' pagination-detail">',
1154
+ '<span class="pagination-info">',
1155
+ this.options.formatShowingRows(this.pageFrom, this.pageTo, this.options.totalRows),
1156
+ '</span>');
1157
+
1158
+ html.push('<span class="page-list">');
1159
+
1160
+ var pageNumber = [
1161
+ sprintf('<span class="btn-group %s">',
1162
+ this.options.paginationVAlign === 'top' || this.options.paginationVAlign === 'both' ?
1163
+ 'dropdown' : 'dropup'),
1164
+ '<button type="button" class="btn btn-default ' +
1165
+ (this.options.iconSize === undefined ? '' : ' btn-' + this.options.iconSize) +
1166
+ ' dropdown-toggle" data-toggle="dropdown">',
1167
+ '<span class="page-size">',
1168
+ $allSelected ? this.options.formatAllRows() : this.options.pageSize,
1169
+ '</span>',
1170
+ ' <span class="caret"></span>',
1171
+ '</button>',
1172
+ '<ul class="dropdown-menu" role="menu">'
1173
+ ],
1174
+ pageList = this.options.pageList;
1175
+
1176
+ if (typeof this.options.pageList === 'string') {
1177
+ var list = this.options.pageList.replace('[', '').replace(']', '')
1178
+ .replace(/ /g, '').split(',');
1179
+
1180
+ pageList = [];
1181
+ $.each(list, function (i, value) {
1182
+ pageList.push(value.toUpperCase() === that.options.formatAllRows().toUpperCase() ?
1183
+ that.options.formatAllRows() : +value);
1184
+ });
1185
+ }
1186
+
1187
+ $.each(pageList, function (i, page) {
1188
+ if (!that.options.smartDisplay || i === 0 || pageList[i - 1] <= that.options.totalRows) {
1189
+ var active;
1190
+ if ($allSelected) {
1191
+ active = page === that.options.formatAllRows() ? ' class="active"' : '';
1192
+ } else {
1193
+ active = page === that.options.pageSize ? ' class="active"' : '';
1194
+ }
1195
+ pageNumber.push(sprintf('<li%s><a href="javascript:void(0)">%s</a></li>', active, page));
1196
+ }
1197
+ });
1198
+ pageNumber.push('</ul></span>');
1199
+
1200
+ html.push(this.options.formatRecordsPerPage(pageNumber.join('')));
1201
+ html.push('</span>');
1202
+
1203
+ html.push('</div>',
1204
+ '<div class="pull-' + this.options.paginationHAlign + ' pagination">',
1205
+ '<ul class="pagination' + (this.options.iconSize === undefined ? '' : ' pagination-' + this.options.iconSize) + '">',
1206
+ '<li class="page-first"><a href="javascript:void(0)">' + this.options.paginationFirstText + '</a></li>',
1207
+ '<li class="page-pre"><a href="javascript:void(0)">' + this.options.paginationPreText + '</a></li>');
1208
+
1209
+ if (this.totalPages < 5) {
1210
+ from = 1;
1211
+ to = this.totalPages;
1212
+ } else {
1213
+ from = this.options.pageNumber - 2;
1214
+ to = from + 4;
1215
+ if (from < 1) {
1216
+ from = 1;
1217
+ to = 5;
1218
+ }
1219
+ if (to > this.totalPages) {
1220
+ to = this.totalPages;
1221
+ from = to - 4;
1222
+ }
1223
+ }
1224
+ for (i = from; i <= to; i++) {
1225
+ html.push('<li class="page-number' + (i === this.options.pageNumber ? ' active' : '') + '">',
1226
+ '<a href="javascript:void(0)">', i, '</a>',
1227
+ '</li>');
1228
+ }
1229
+
1230
+ html.push(
1231
+ '<li class="page-next"><a href="javascript:void(0)">' + this.options.paginationNextText + '</a></li>',
1232
+ '<li class="page-last"><a href="javascript:void(0)">' + this.options.paginationLastText + '</a></li>',
1233
+ '</ul>',
1234
+ '</div>');
1235
+
1236
+ this.$pagination.html(html.join(''));
1237
+
1238
+ $pageList = this.$pagination.find('.page-list a');
1239
+ $first = this.$pagination.find('.page-first');
1240
+ $pre = this.$pagination.find('.page-pre');
1241
+ $next = this.$pagination.find('.page-next');
1242
+ $last = this.$pagination.find('.page-last');
1243
+ $number = this.$pagination.find('.page-number');
1244
+
1245
+ if (this.options.pageNumber <= 1) {
1246
+ $first.addClass('disabled');
1247
+ $pre.addClass('disabled');
1248
+ }
1249
+ if (this.options.pageNumber >= this.totalPages) {
1250
+ $next.addClass('disabled');
1251
+ $last.addClass('disabled');
1252
+ }
1253
+ if (this.options.smartDisplay) {
1254
+ if (this.totalPages <= 1) {
1255
+ this.$pagination.find('div.pagination').hide();
1256
+ }
1257
+ if (pageList.length < 2 || this.options.totalRows <= pageList[0]) {
1258
+ this.$pagination.find('span.page-list').hide();
1259
+ }
1260
+
1261
+ // when data is empty, hide the pagination
1262
+ this.$pagination[this.getData().length ? 'show' : 'hide']();
1263
+ }
1264
+ if ($allSelected) {
1265
+ this.options.pageSize = this.options.formatAllRows();
1266
+ }
1267
+ $pageList.off('click').on('click', $.proxy(this.onPageListChange, this));
1268
+ $first.off('click').on('click', $.proxy(this.onPageFirst, this));
1269
+ $pre.off('click').on('click', $.proxy(this.onPagePre, this));
1270
+ $next.off('click').on('click', $.proxy(this.onPageNext, this));
1271
+ $last.off('click').on('click', $.proxy(this.onPageLast, this));
1272
+ $number.off('click').on('click', $.proxy(this.onPageNumber, this));
1273
+ };
1274
+
1275
+ BootstrapTable.prototype.updatePagination = function (event) {
1276
+ // Fix #171: IE disabled button can be clicked bug.
1277
+ if (event && $(event.currentTarget).hasClass('disabled')) {
1278
+ return;
1279
+ }
1280
+
1281
+ if (!this.options.maintainSelected) {
1282
+ this.resetRows();
1283
+ }
1284
+
1285
+ this.initPagination();
1286
+ if (this.options.sidePagination === 'server') {
1287
+ this.initServer();
1288
+ } else {
1289
+ this.initBody();
1290
+ }
1291
+
1292
+ this.trigger('page-change', this.options.pageNumber, this.options.pageSize);
1293
+ };
1294
+
1295
+ BootstrapTable.prototype.onPageListChange = function (event) {
1296
+ var $this = $(event.currentTarget);
1297
+
1298
+ $this.parent().addClass('active').siblings().removeClass('active');
1299
+ this.options.pageSize = $this.text().toUpperCase() === this.options.formatAllRows().toUpperCase() ?
1300
+ this.options.formatAllRows() : +$this.text();
1301
+ this.$toolbar.find('.page-size').text(this.options.pageSize);
1302
+
1303
+ this.updatePagination(event);
1304
+ };
1305
+
1306
+ BootstrapTable.prototype.onPageFirst = function (event) {
1307
+ this.options.pageNumber = 1;
1308
+ this.updatePagination(event);
1309
+ };
1310
+
1311
+ BootstrapTable.prototype.onPagePre = function (event) {
1312
+ this.options.pageNumber--;
1313
+ this.updatePagination(event);
1314
+ };
1315
+
1316
+ BootstrapTable.prototype.onPageNext = function (event) {
1317
+ this.options.pageNumber++;
1318
+ this.updatePagination(event);
1319
+ };
1320
+
1321
+ BootstrapTable.prototype.onPageLast = function (event) {
1322
+ this.options.pageNumber = this.totalPages;
1323
+ this.updatePagination(event);
1324
+ };
1325
+
1326
+ BootstrapTable.prototype.onPageNumber = function (event) {
1327
+ if (this.options.pageNumber === +$(event.currentTarget).text()) {
1328
+ return;
1329
+ }
1330
+ this.options.pageNumber = +$(event.currentTarget).text();
1331
+ this.updatePagination(event);
1332
+ };
1333
+
1334
+ BootstrapTable.prototype.initBody = function (fixedScroll) {
1335
+ var that = this,
1336
+ html = [],
1337
+ data = this.getData();
1338
+
1339
+ this.trigger('pre-body', data);
1340
+
1341
+ this.$body = this.$el.find('tbody');
1342
+ if (!this.$body.length) {
1343
+ this.$body = $('<tbody></tbody>').appendTo(this.$el);
1344
+ }
1345
+
1346
+ //Fix #389 Bootstrap-table-flatJSON is not working
1347
+
1348
+ if (!this.options.pagination || this.options.sidePagination === 'server') {
1349
+ this.pageFrom = 1;
1350
+ this.pageTo = data.length;
1351
+ }
1352
+
1353
+ for (var i = this.pageFrom - 1; i < this.pageTo; i++) {
1354
+ var key,
1355
+ item = data[i],
1356
+ style = {},
1357
+ csses = [],
1358
+ data_ = '',
1359
+ attributes = {},
1360
+ htmlAttributes = [];
1361
+
1362
+ style = calculateObjectValue(this.options, this.options.rowStyle, [item, i], style);
1363
+
1364
+ if (style && style.css) {
1365
+ for (key in style.css) {
1366
+ csses.push(key + ': ' + style.css[key]);
1367
+ }
1368
+ }
1369
+
1370
+ attributes = calculateObjectValue(this.options,
1371
+ this.options.rowAttributes, [item, i], attributes);
1372
+
1373
+ if (attributes) {
1374
+ for (key in attributes) {
1375
+ htmlAttributes.push(sprintf('%s="%s"', key, escapeHTML(attributes[key])));
1376
+ }
1377
+ }
1378
+
1379
+ if (item._data && !$.isEmptyObject(item._data)) {
1380
+ $.each(item._data, function (k, v) {
1381
+ // ignore data-index
1382
+ if (k === 'index') {
1383
+ return;
1384
+ }
1385
+ data_ += sprintf(' data-%s="%s"', k, v);
1386
+ });
1387
+ }
1388
+
1389
+ html.push('<tr',
1390
+ sprintf(' %s', htmlAttributes.join(' ')),
1391
+ sprintf(' id="%s"', $.isArray(item) ? undefined : item._id),
1392
+ sprintf(' class="%s"', style.classes || ($.isArray(item) ? undefined : item._class)),
1393
+ sprintf(' data-index="%s"', i),
1394
+ sprintf(' data-uniqueid="%s"', item[this.options.uniqueId]),
1395
+ sprintf('%s', data_),
1396
+ '>'
1397
+ );
1398
+
1399
+ if (this.options.cardView) {
1400
+ html.push(sprintf('<td colspan="%s">', this.header.fields.length));
1401
+ }
1402
+
1403
+ if (!this.options.cardView && this.options.detailView) {
1404
+ html.push('<td>',
1405
+ '<a class="detail-icon" href="javascript:">',
1406
+ sprintf('<i class="%s %s"></i>', this.options.iconsPrefix, this.options.icons.detailOpen),
1407
+ '</a>',
1408
+ '</td>');
1409
+ }
1410
+
1411
+ $.each(this.header.fields, function (j, field) {
1412
+ var text = '',
1413
+ value = item[field],
1414
+ type = '',
1415
+ cellStyle = {},
1416
+ id_ = '',
1417
+ class_ = that.header.classes[j],
1418
+ data_ = '',
1419
+ rowspan_ = '',
1420
+ title_ = '',
1421
+ column = that.columns[getFieldIndex(that.columns, field)];
1422
+
1423
+ if (!column.visible) {
1424
+ return;
1425
+ }
1426
+
1427
+ style = sprintf('style="%s"', csses.concat(that.header.styles[j]).join('; '));
1428
+
1429
+ value = calculateObjectValue(column,
1430
+ that.header.formatters[j], [value, item, i], value);
1431
+
1432
+ // handle td's id and class
1433
+ if (item['_' + field + '_id']) {
1434
+ id_ = sprintf(' id="%s"', item['_' + field + '_id']);
1435
+ }
1436
+ if (item['_' + field + '_class']) {
1437
+ class_ = sprintf(' class="%s"', item['_' + field + '_class']);
1438
+ }
1439
+ if (item['_' + field + '_rowspan']) {
1440
+ rowspan_ = sprintf(' rowspan="%s"', item['_' + field + '_rowspan']);
1441
+ }
1442
+ if (item['_' + field + '_title']) {
1443
+ title_ = sprintf(' title="%s"', item['_' + field + '_title']);
1444
+ }
1445
+ cellStyle = calculateObjectValue(that.header,
1446
+ that.header.cellStyles[j], [value, item, i], cellStyle);
1447
+ if (cellStyle.classes) {
1448
+ class_ = sprintf(' class="%s"', cellStyle.classes);
1449
+ }
1450
+ if (cellStyle.css) {
1451
+ var csses_ = [];
1452
+ for (var key in cellStyle.css) {
1453
+ csses_.push(key + ': ' + cellStyle.css[key]);
1454
+ }
1455
+ style = sprintf('style="%s"', csses_.concat(that.header.styles[j]).join('; '));
1456
+ }
1457
+
1458
+ if (item['_' + field + '_data'] && !$.isEmptyObject(item['_' + field + '_data'])) {
1459
+ $.each(item['_' + field + '_data'], function (k, v) {
1460
+ // ignore data-index
1461
+ if (k === 'index') {
1462
+ return;
1463
+ }
1464
+ data_ += sprintf(' data-%s="%s"', k, v);
1465
+ });
1466
+ }
1467
+
1468
+ if (column.checkbox || column.radio) {
1469
+ type = column.checkbox ? 'checkbox' : type;
1470
+ type = column.radio ? 'radio' : type;
1471
+
1472
+ text = [that.options.cardView ?
1473
+ '<div class="card-view">' : '<td class="bs-checkbox">',
1474
+ '<input' +
1475
+ sprintf(' data-index="%s"', i) +
1476
+ sprintf(' name="%s"', that.options.selectItemName) +
1477
+ sprintf(' type="%s"', type) +
1478
+ sprintf(' value="%s"', item[that.options.idField]) +
1479
+ sprintf(' checked="%s"', value === true ||
1480
+ (value && value.checked) ? 'checked' : undefined) +
1481
+ sprintf(' disabled="%s"', !column.checkboxEnabled ||
1482
+ (value && value.disabled) ? 'disabled' : undefined) +
1483
+ ' />',
1484
+ that.options.cardView ? '</div>' : '</td>'
1485
+ ].join('');
1486
+
1487
+ item[that.header.stateField] = value === true || (value && value.checked);
1488
+ } else {
1489
+ value = typeof value === 'undefined' || value === null ?
1490
+ that.options.undefinedText : value;
1491
+
1492
+ text = that.options.cardView ? ['<div class="card-view">',
1493
+ that.options.showHeader ? sprintf('<span class="title" %s>%s</span>', style,
1494
+ getPropertyFromOther(that.columns, 'field', 'title', field)) : '',
1495
+ sprintf('<span class="value">%s</span>', value),
1496
+ '</div>'
1497
+ ].join('') : [sprintf('<td%s %s %s %s %s %s>', id_, class_, style, data_, rowspan_, title_),
1498
+ value,
1499
+ '</td>'
1500
+ ].join('');
1501
+
1502
+ // Hide empty data on Card view when smartDisplay is set to true.
1503
+ if (that.options.cardView && that.options.smartDisplay && value === '') {
1504
+ text = '';
1505
+ }
1506
+ }
1507
+
1508
+ html.push(text);
1509
+ });
1510
+
1511
+ if (this.options.cardView) {
1512
+ html.push('</td>');
1513
+ }
1514
+
1515
+ html.push('</tr>');
1516
+ }
1517
+
1518
+ // show no records
1519
+ if (!html.length) {
1520
+ html.push('<tr class="no-records-found">',
1521
+ sprintf('<td colspan="%s">%s</td>',
1522
+ this.$header.find('th').length, this.options.formatNoMatches()),
1523
+ '</tr>');
1524
+ }
1525
+
1526
+ this.$body.html(html.join(''));
1527
+
1528
+ if (!fixedScroll) {
1529
+ this.scrollTo(0);
1530
+ }
1531
+
1532
+ // click to select by column
1533
+ this.$body.find('> tr[data-index] > td').off('click dblclick').on('click dblclick', function (e) {
1534
+ var $td = $(this),
1535
+ $tr = $td.parent(),
1536
+ item = that.data[$tr.data('index')],
1537
+ index = $td[0].cellIndex,
1538
+ field = that.header.fields[that.options.detailView && !that.options.cardView ? index - 1 : index],
1539
+ colomn = that.columns[getFieldIndex(that.columns, field)],
1540
+ value = item[field];
1541
+
1542
+ if ($td.find('.detail-icon').length) {
1543
+ return;
1544
+ }
1545
+
1546
+ that.trigger(e.type === 'click' ? 'click-cell' : 'dbl-click-cell', field, value, item, $td);
1547
+ that.trigger(e.type === 'click' ? 'click-row' : 'dbl-click-row', item, $tr);
1548
+
1549
+ // if click to select - then trigger the checkbox/radio click
1550
+ if (e.type === 'click' && that.options.clickToSelect && colomn.clickToSelect) {
1551
+ var $selectItem = $tr.find(sprintf('[name="%s"]', that.options.selectItemName));
1552
+ if ($selectItem.length) {
1553
+ $selectItem[0].click(); // #144: .trigger('click') bug
1554
+ }
1555
+ }
1556
+ });
1557
+
1558
+ this.$body.find('> tr[data-index] > td > .detail-icon').off('click').on('click', function () {
1559
+ var $this = $(this),
1560
+ $tr = $this.parent().parent(),
1561
+ index = $tr.data('index'),
1562
+ row = data[index]; // Fix #980 Detail view, when searching, returns wrong row
1563
+
1564
+ // remove and update
1565
+ if ($tr.next().is('tr.detail-view')) {
1566
+ $this.find('i').attr('class', sprintf('%s %s', that.options.iconsPrefix, that.options.icons.detailOpen));
1567
+ $tr.next().remove();
1568
+ that.trigger('collapse-row', index, row);
1569
+ } else {
1570
+ $this.find('i').attr('class', sprintf('%s %s', that.options.iconsPrefix, that.options.icons.detailClose));
1571
+ $tr.after(sprintf('<tr class="detail-view"><td colspan="%s">%s</td></tr>',
1572
+ $tr.find('td').length, calculateObjectValue(that.options,
1573
+ that.options.detailFormatter, [index, row], '')));
1574
+ that.trigger('expand-row', index, row, $tr.next().find('td'));
1575
+ }
1576
+ that.resetView();
1577
+ });
1578
+
1579
+ this.$selectItem = this.$body.find(sprintf('[name="%s"]', this.options.selectItemName));
1580
+ this.$selectItem.off('click').on('click', function (event) {
1581
+ event.stopImmediatePropagation();
1582
+
1583
+ var checked = $(this).prop('checked'),
1584
+ row = that.data[$(this).data('index')];
1585
+
1586
+ row[that.header.stateField] = checked;
1587
+
1588
+ if (that.options.singleSelect) {
1589
+ that.$selectItem.not(this).each(function () {
1590
+ that.data[$(this).data('index')][that.header.stateField] = false;
1591
+ });
1592
+ that.$selectItem.filter(':checked').not(this).prop('checked', false);
1593
+ }
1594
+
1595
+ that.updateSelected();
1596
+ that.trigger(checked ? 'check' : 'uncheck', row);
1597
+ });
1598
+
1599
+ $.each(this.header.events, function (i, events) {
1600
+ if (!events) {
1601
+ return;
1602
+ }
1603
+ // fix bug, if events is defined with namespace
1604
+ if (typeof events === 'string') {
1605
+ events = calculateObjectValue(null, events);
1606
+ }
1607
+
1608
+ var field = that.header.fields[i],
1609
+ fieldIndex = $.inArray(field, that.getVisibleFields());
1610
+
1611
+ if (that.options.detailView && !that.options.cardView) {
1612
+ fieldIndex += 1;
1613
+ }
1614
+
1615
+ for (var key in events) {
1616
+ that.$body.find('tr').each(function () {
1617
+ var $tr = $(this),
1618
+ $td = $tr.find(that.options.cardView ? '.card-view' : 'td').eq(fieldIndex),
1619
+ index = key.indexOf(' '),
1620
+ name = key.substring(0, index),
1621
+ el = key.substring(index + 1),
1622
+ func = events[key];
1623
+
1624
+ $td.find(el).off(name).on(name, function (e) {
1625
+ var index = $tr.data('index'),
1626
+ row = that.data[index],
1627
+ value = row[field];
1628
+
1629
+ func.apply(this, [e, value, row, index]);
1630
+ });
1631
+ });
1632
+ }
1633
+ });
1634
+
1635
+ this.updateSelected();
1636
+ this.resetView();
1637
+
1638
+ this.trigger('post-body');
1639
+ };
1640
+
1641
+ BootstrapTable.prototype.initServer = function (silent, query) {
1642
+ var that = this,
1643
+ data = {},
1644
+ params = {
1645
+ pageSize: this.options.pageSize === this.options.formatAllRows() ?
1646
+ this.options.totalRows : this.options.pageSize,
1647
+ pageNumber: this.options.pageNumber,
1648
+ searchText: this.searchText,
1649
+ sortName: this.options.sortName,
1650
+ sortOrder: this.options.sortOrder
1651
+ },
1652
+ request;
1653
+
1654
+ if (!this.options.url && !this.options.ajax) {
1655
+ return;
1656
+ }
1657
+
1658
+ if (this.options.queryParamsType === 'limit') {
1659
+ params = {
1660
+ search: params.searchText,
1661
+ sort: params.sortName,
1662
+ order: params.sortOrder
1663
+ };
1664
+ if (this.options.pagination) {
1665
+ params.limit = this.options.pageSize === this.options.formatAllRows() ?
1666
+ this.options.totalRows : this.options.pageSize;
1667
+ params.offset = this.options.pageSize === this.options.formatAllRows() ?
1668
+ 0 : this.options.pageSize * (this.options.pageNumber - 1);
1669
+ }
1670
+ }
1671
+
1672
+ if (!($.isEmptyObject(this.filterColumnsPartial))) {
1673
+ params['filter'] = JSON.stringify(this.filterColumnsPartial, null);
1674
+ }
1675
+
1676
+ data = calculateObjectValue(this.options, this.options.queryParams, [params], data);
1677
+
1678
+ $.extend(data, query || {});
1679
+
1680
+ // false to stop request
1681
+ if (data === false) {
1682
+ return;
1683
+ }
1684
+
1685
+ if (!silent) {
1686
+ this.$tableLoading.show();
1687
+ }
1688
+ request = $.extend({}, calculateObjectValue(null, this.options.ajaxOptions), {
1689
+ type: this.options.method,
1690
+ url: this.options.url,
1691
+ data: this.options.contentType === 'application/json' && this.options.method === 'post' ?
1692
+ JSON.stringify(data) : data,
1693
+ cache: this.options.cache,
1694
+ contentType: this.options.contentType,
1695
+ dataType: this.options.dataType,
1696
+ success: function (res) {
1697
+ res = calculateObjectValue(that.options, that.options.responseHandler, [res], res);
1698
+
1699
+ that.load(res);
1700
+ that.trigger('load-success', res);
1701
+ },
1702
+ error: function (res) {
1703
+ that.trigger('load-error', res.status);
1704
+ },
1705
+ complete: function () {
1706
+ if (!silent) {
1707
+ that.$tableLoading.hide();
1708
+ }
1709
+ }
1710
+ });
1711
+
1712
+ if (this.options.ajax) {
1713
+ calculateObjectValue(this, this.options.ajax, [request], null);
1714
+ } else {
1715
+ $.ajax(request);
1716
+ }
1717
+ };
1718
+
1719
+ BootstrapTable.prototype.getCaret = function () {
1720
+ var that = this;
1721
+
1722
+ $.each(this.$header.find('th'), function (i, th) {
1723
+ $(th).find('.sortable').removeClass('desc asc').addClass($(th).data('field') === that.options.sortName ? that.options.sortOrder : 'both');
1724
+ });
1725
+ };
1726
+
1727
+ BootstrapTable.prototype.updateSelected = function () {
1728
+ var checkAll = this.$selectItem.filter(':enabled').length ===
1729
+ this.$selectItem.filter(':enabled').filter(':checked').length;
1730
+
1731
+ this.$selectAll.add(this.$selectAll_).prop('checked', checkAll);
1732
+
1733
+ this.$selectItem.each(function () {
1734
+ $(this).closest('tr')[$(this).prop('checked') ? 'addClass' : 'removeClass']('selected');
1735
+ });
1736
+ };
1737
+
1738
+ BootstrapTable.prototype.updateRows = function () {
1739
+ var that = this;
1740
+
1741
+ this.$selectItem.each(function () {
1742
+ that.data[$(this).data('index')][that.header.stateField] = $(this).prop('checked');
1743
+ });
1744
+ };
1745
+
1746
+ BootstrapTable.prototype.resetRows = function () {
1747
+ var that = this;
1748
+
1749
+ $.each(this.data, function (i, row) {
1750
+ that.$selectAll.prop('checked', false);
1751
+ that.$selectItem.prop('checked', false);
1752
+ if (that.header.stateField) {
1753
+ row[that.header.stateField] = false;
1754
+ }
1755
+ });
1756
+ };
1757
+
1758
+ BootstrapTable.prototype.trigger = function (name) {
1759
+ var args = Array.prototype.slice.call(arguments, 1);
1760
+
1761
+ name += '.bs.table';
1762
+ this.options[BootstrapTable.EVENTS[name]].apply(this.options, args);
1763
+ this.$el.trigger($.Event(name), args);
1764
+
1765
+ this.options.onAll(name, args);
1766
+ this.$el.trigger($.Event('all.bs.table'), [name, args]);
1767
+ };
1768
+
1769
+ BootstrapTable.prototype.resetHeader = function () {
1770
+ // fix #61: the hidden table reset header bug.
1771
+ // fix bug: get $el.css('width') error sometime (height = 500)
1772
+ clearTimeout(this.timeoutId_);
1773
+ this.timeoutId_ = setTimeout($.proxy(this.fitHeader, this), this.$el.is(':hidden') ? 100 : 0);
1774
+ };
1775
+
1776
+ BootstrapTable.prototype.fitHeader = function () {
1777
+ var that = this,
1778
+ fixedBody,
1779
+ scrollWidth;
1780
+
1781
+ if (that.$el.is(':hidden')) {
1782
+ that.timeoutId_ = setTimeout($.proxy(that.fitHeader, that), 100);
1783
+ return;
1784
+ }
1785
+ fixedBody = this.$tableBody.get(0);
1786
+
1787
+ scrollWidth = fixedBody.scrollWidth > fixedBody.clientWidth &&
1788
+ fixedBody.scrollHeight > fixedBody.clientHeight + this.$header.outerHeight() ?
1789
+ getScrollBarWidth() : 0;
1790
+
1791
+ this.$el.css('margin-top', -this.$header.outerHeight());
1792
+ this.$header_ = this.$header.clone(true, true);
1793
+ this.$selectAll_ = this.$header_.find('[name="btSelectAll"]');
1794
+ this.$tableHeader.css({
1795
+ 'margin-right': scrollWidth
1796
+ }).find('table').css('width', this.$el.outerWidth())
1797
+ .html('').attr('class', this.$el.attr('class'))
1798
+ .append(this.$header_);
1799
+
1800
+ // fix bug: $.data() is not working as expected after $.append()
1801
+ this.$header.find('th[data-field]').each(function (i) {
1802
+ that.$header_.find(sprintf('th[data-field="%s"]', $(this).data('field'))).data($(this).data());
1803
+ });
1804
+
1805
+ var visibleFields = this.getVisibleFields();
1806
+
1807
+ this.$body.find('tr:first-child:not(.no-records-found) > *').each(function (i) {
1808
+ var $this = $(this),
1809
+ index = i;
1810
+
1811
+ if (that.options.detailView && !that.options.cardView) {
1812
+ if (i === 0) {
1813
+ that.$header_.find('th.detail').find('.fht-cell').width($this.innerWidth());
1814
+ }
1815
+ index = i - 1;
1816
+ }
1817
+
1818
+ that.$header_.find(sprintf('th[data-field="%s"]', visibleFields[index]))
1819
+ .find('.fht-cell').width($this.innerWidth());
1820
+ });
1821
+ // horizontal scroll event
1822
+ // TODO: it's probably better improving the layout than binding to scroll event
1823
+ this.$tableBody.off('scroll').on('scroll', function () {
1824
+ that.$tableHeader.scrollLeft($(this).scrollLeft());
1825
+
1826
+ if (that.options.showFooter && !that.options.cardView) {
1827
+ that.$tableFooter.scrollLeft($(this).scrollLeft());
1828
+ }
1829
+ });
1830
+ that.trigger('post-header');
1831
+ };
1832
+
1833
+ BootstrapTable.prototype.resetFooter = function () {
1834
+ var that = this,
1835
+ data = that.getData(),
1836
+ html = [];
1837
+
1838
+ if (!this.options.showFooter || this.options.cardView) { //do nothing
1839
+ return;
1840
+ }
1841
+
1842
+ if (!this.options.cardView && this.options.detailView) {
1843
+ html.push('<td><div class="th-inner">&nbsp;</div><div class="fht-cell"></div></td>');
1844
+ }
1845
+
1846
+ $.each(this.columns, function (i, column) {
1847
+ var falign = '', // footer align style
1848
+ style = '',
1849
+ class_ = sprintf(' class="%s"', column['class']);
1850
+
1851
+ if (!column.visible) {
1852
+ return;
1853
+ }
1854
+
1855
+ if (that.options.cardView && (!column.cardVisible)) {
1856
+ return;
1857
+ }
1858
+
1859
+ falign = sprintf('text-align: %s; ', column.falign ? column.falign : column.align);
1860
+ style = sprintf('vertical-align: %s; ', column.valign);
1861
+
1862
+ html.push('<td', class_, sprintf(' style="%s"', falign + style), '>');
1863
+ html.push('<div class="th-inner">');
1864
+
1865
+ html.push(calculateObjectValue(column, column.footerFormatter, [data], '&nbsp;') || '&nbsp;');
1866
+
1867
+ html.push('</div>');
1868
+ html.push('<div class="fht-cell"></div>');
1869
+ html.push('</div>');
1870
+ html.push('</td>');
1871
+ });
1872
+
1873
+ this.$tableFooter.find('tr').html(html.join(''));
1874
+ clearTimeout(this.timeoutFooter_);
1875
+ this.timeoutFooter_ = setTimeout($.proxy(this.fitFooter, this),
1876
+ this.$el.is(':hidden') ? 100 : 0);
1877
+ };
1878
+
1879
+ BootstrapTable.prototype.fitFooter = function () {
1880
+ var that = this,
1881
+ $footerTd,
1882
+ elWidth,
1883
+ scrollWidth;
1884
+
1885
+ clearTimeout(this.timeoutFooter_);
1886
+ if (this.$el.is(':hidden')) {
1887
+ this.timeoutFooter_ = setTimeout($.proxy(this.fitFooter, this), 100);
1888
+ return;
1889
+ }
1890
+
1891
+ elWidth = this.$el.css('width');
1892
+ scrollWidth = elWidth > this.$tableBody.width() ? getScrollBarWidth() : 0;
1893
+
1894
+ this.$tableFooter.css({
1895
+ 'margin-right': scrollWidth
1896
+ }).find('table').css('width', elWidth)
1897
+ .attr('class', this.$el.attr('class'));
1898
+
1899
+ $footerTd = this.$tableFooter.find('td');
1900
+
1901
+ this.$body.find('tr:first-child:not(.no-records-found) > *').each(function (i) {
1902
+ var $this = $(this);
1903
+
1904
+ $footerTd.eq(i).find('.fht-cell').width($this.innerWidth());
1905
+ });
1906
+ };
1907
+
1908
+ BootstrapTable.prototype.toggleColumn = function (index, checked, needUpdate) {
1909
+ if (index === -1) {
1910
+ return;
1911
+ }
1912
+ this.columns[index].visible = checked;
1913
+ this.initHeader();
1914
+ this.initSearch();
1915
+ this.initPagination();
1916
+ this.initBody();
1917
+
1918
+ if (this.options.showColumns) {
1919
+ var $items = this.$toolbar.find('.keep-open input').prop('disabled', false);
1920
+
1921
+ if (needUpdate) {
1922
+ $items.filter(sprintf('[value="%s"]', index)).prop('checked', checked);
1923
+ }
1924
+
1925
+ if ($items.filter(':checked').length <= this.options.minimumCountColumns) {
1926
+ $items.filter(':checked').prop('disabled', true);
1927
+ }
1928
+ }
1929
+ };
1930
+
1931
+ BootstrapTable.prototype.toggleRow = function (index, isIdField, visible) {
1932
+ if (index === -1) {
1933
+ return;
1934
+ }
1935
+
1936
+ $(this.$body[0]).children().filter(sprintf(isIdField ? '[data-uniqueid="%s"]' : '[data-index="%s"]', index))[visible ? 'show' : 'hide']();
1937
+ };
1938
+
1939
+ BootstrapTable.prototype.getVisibleFields = function () {
1940
+ var that = this,
1941
+ visibleFields = [];
1942
+
1943
+ $.each(this.header.fields, function (j, field) {
1944
+ var column = that.columns[getFieldIndex(that.columns, field)];
1945
+
1946
+ if (!column.visible) {
1947
+ return;
1948
+ }
1949
+ visibleFields.push(field);
1950
+ });
1951
+ return visibleFields;
1952
+ };
1953
+
1954
+ // PUBLIC FUNCTION DEFINITION
1955
+ // =======================
1956
+
1957
+ BootstrapTable.prototype.resetView = function (params) {
1958
+ var padding = 0;
1959
+
1960
+ if (params && params.height) {
1961
+ this.options.height = params.height;
1962
+ }
1963
+
1964
+ this.$selectAll.prop('checked', this.$selectItem.length > 0 &&
1965
+ this.$selectItem.length === this.$selectItem.filter(':checked').length);
1966
+
1967
+ if (this.options.height) {
1968
+ var toolbarHeight = getRealHeight(this.$toolbar),
1969
+ paginationHeight = getRealHeight(this.$pagination),
1970
+ height = this.options.height - toolbarHeight - paginationHeight;
1971
+
1972
+ this.$tableContainer.css('height', height + 'px');
1973
+ }
1974
+
1975
+ if (this.options.cardView) {
1976
+ // remove the element css
1977
+ this.$el.css('margin-top', '0');
1978
+ this.$tableContainer.css('padding-bottom', '0');
1979
+ return;
1980
+ }
1981
+
1982
+ if (this.options.showHeader && this.options.height) {
1983
+ this.$tableHeader.show();
1984
+ this.resetHeader();
1985
+ padding += this.$header.outerHeight();
1986
+ } else {
1987
+ this.$tableHeader.hide();
1988
+ this.trigger('post-header');
1989
+ }
1990
+
1991
+ if (this.options.showFooter) {
1992
+ this.resetFooter();
1993
+ if (this.options.height) {
1994
+ padding += this.$tableFooter.outerHeight() + 1;
1995
+ }
1996
+ }
1997
+
1998
+ // Assign the correct sortable arrow
1999
+ this.getCaret();
2000
+ this.$tableContainer.css('padding-bottom', padding + 'px');
2001
+ this.trigger('reset-view');
2002
+ };
2003
+
2004
+ BootstrapTable.prototype.getData = function (useCurrentPage) {
2005
+ return (this.searchText || !$.isEmptyObject(this.filterColumns) || !$.isEmptyObject(this.filterColumnsPartial)) ?
2006
+ (useCurrentPage ? this.data.slice(this.pageFrom - 1, this.pageTo) : this.data) :
2007
+ (useCurrentPage ? this.options.data.slice(this.pageFrom - 1, this.pageTo) : this.options.data);
2008
+ };
2009
+
2010
+ BootstrapTable.prototype.load = function (data) {
2011
+ var fixedScroll = false;
2012
+
2013
+ // #431: support pagination
2014
+ if (this.options.sidePagination === 'server') {
2015
+ this.options.totalRows = data.total;
2016
+ fixedScroll = data.fixedScroll;
2017
+ data = data.rows;
2018
+ } else if (!$.isArray(data)) { // support fixedScroll
2019
+ fixedScroll = data.fixedScroll;
2020
+ data = data.data;
2021
+ }
2022
+
2023
+ this.initData(data);
2024
+ this.initSearch();
2025
+ this.initPagination();
2026
+ this.initBody(fixedScroll);
2027
+ };
2028
+
2029
+ BootstrapTable.prototype.append = function (data) {
2030
+ this.initData(data, 'append');
2031
+ this.initSearch();
2032
+ this.initPagination();
2033
+ this.initBody(true);
2034
+ };
2035
+
2036
+ BootstrapTable.prototype.prepend = function (data) {
2037
+ this.initData(data, 'prepend');
2038
+ this.initSearch();
2039
+ this.initPagination();
2040
+ this.initBody(true);
2041
+ };
2042
+
2043
+ BootstrapTable.prototype.remove = function (params) {
2044
+ var len = this.options.data.length,
2045
+ i, row;
2046
+
2047
+ if (!params.hasOwnProperty('field') || !params.hasOwnProperty('values')) {
2048
+ return;
2049
+ }
2050
+
2051
+ for (i = len - 1; i >= 0; i--) {
2052
+ row = this.options.data[i];
2053
+
2054
+ if (!row.hasOwnProperty(params.field)) {
2055
+ continue;
2056
+ }
2057
+ if ($.inArray(row[params.field], params.values) !== -1) {
2058
+ this.options.data.splice(i, 1);
2059
+ }
2060
+ }
2061
+
2062
+ if (len === this.options.data.length) {
2063
+ return;
2064
+ }
2065
+
2066
+ this.initSearch();
2067
+ this.initPagination();
2068
+ this.initBody(true);
2069
+ };
2070
+
2071
+ BootstrapTable.prototype.removeAll = function () {
2072
+ if (this.options.data.length > 0) {
2073
+ this.options.data.splice(0, this.options.data.length);
2074
+ this.initSearch();
2075
+ this.initPagination();
2076
+ this.initBody(true);
2077
+ }
2078
+ };
2079
+
2080
+ BootstrapTable.prototype.getRowByUniqueId = function (id) {
2081
+ var uniqueId = this.options.uniqueId,
2082
+ len = this.options.data.length,
2083
+ dataRow = null,
2084
+ i, row;
2085
+
2086
+ for (i = len - 1; i >= 0; i--) {
2087
+ row = this.options.data[i];
2088
+
2089
+ if (!row.hasOwnProperty(uniqueId)) {
2090
+ continue;
2091
+ }
2092
+
2093
+ if (typeof row[uniqueId] === 'string') {
2094
+ id = id.toString();
2095
+ } else if (typeof row[uniqueId] === 'number') {
2096
+ if ((Number(row[uniqueId]) === row[uniqueId]) && (row[uniqueId] % 1 === 0)) {
2097
+ id = parseInt(id);
2098
+ } else if ((row[uniqueId] === Number(row[uniqueId])) && (row[uniqueId] !== 0)) {
2099
+ id = parseFloat(id);
2100
+ }
2101
+ }
2102
+
2103
+ if (row[uniqueId] === id) {
2104
+ dataRow = row;
2105
+ break;
2106
+ }
2107
+ }
2108
+
2109
+ return dataRow;
2110
+ };
2111
+
2112
+ BootstrapTable.prototype.removeByUniqueId = function (id) {
2113
+ var len = this.options.data.length,
2114
+ row = this.getRowByUniqueId(id);
2115
+
2116
+ if (row) {
2117
+ this.options.data.splice(this.options.data.indexOf(row), 1);
2118
+ }
2119
+
2120
+ if (len === this.options.data.length) {
2121
+ return;
2122
+ }
2123
+
2124
+ this.initSearch();
2125
+ this.initPagination();
2126
+ this.initBody(true);
2127
+ };
2128
+
2129
+ BootstrapTable.prototype.insertRow = function (params) {
2130
+ if (!params.hasOwnProperty('index') || !params.hasOwnProperty('row')) {
2131
+ return;
2132
+ }
2133
+ this.data.splice(params.index, 0, params.row);
2134
+ this.initSearch();
2135
+ this.initPagination();
2136
+ this.initSort();
2137
+ this.initBody(true);
2138
+ };
2139
+
2140
+ BootstrapTable.prototype.updateRow = function (params) {
2141
+ if (!params.hasOwnProperty('index') || !params.hasOwnProperty('row')) {
2142
+ return;
2143
+ }
2144
+ $.extend(this.data[params.index], params.row);
2145
+ this.initSort();
2146
+ this.initBody(true);
2147
+ };
2148
+
2149
+ BootstrapTable.prototype.showRow = function (params) {
2150
+ if (!params.hasOwnProperty('index')) {
2151
+ return;
2152
+ }
2153
+
2154
+ this.toggleRow(params.index, params.isIdField === undefined ? false : true, true);
2155
+ };
2156
+
2157
+ BootstrapTable.prototype.hideRow = function (params) {
2158
+ if (!params.hasOwnProperty('index')) {
2159
+ return;
2160
+ }
2161
+
2162
+ this.toggleRow(params.index, params.isIdField === undefined ? false : true, false);
2163
+ };
2164
+
2165
+ BootstrapTable.prototype.getRowsHidden = function (show) {
2166
+ var rows = $(this.$body[0]).children().filter(':hidden'),
2167
+ i = 0;
2168
+ if (show) {
2169
+ for (; i < rows.length; i++) {
2170
+ $(rows[i]).show();
2171
+ }
2172
+ }
2173
+ return rows;
2174
+ };
2175
+
2176
+ BootstrapTable.prototype.mergeCells = function (options) {
2177
+ var row = options.index,
2178
+ col = $.inArray(options.field, this.getVisibleFields()),
2179
+ rowspan = options.rowspan || 1,
2180
+ colspan = options.colspan || 1,
2181
+ i, j,
2182
+ $tr = this.$body.find('tr'),
2183
+ $td;
2184
+
2185
+ if (this.options.detailView && !this.options.cardView) {
2186
+ col += 1;
2187
+ }
2188
+
2189
+ $td = $tr.eq(row).find('td').eq(col);
2190
+
2191
+ if (row < 0 || col < 0 || row >= this.data.length) {
2192
+ return;
2193
+ }
2194
+
2195
+ for (i = row; i < row + rowspan; i++) {
2196
+ for (j = col; j < col + colspan; j++) {
2197
+ $tr.eq(i).find('td').eq(j).hide();
2198
+ }
2199
+ }
2200
+
2201
+ $td.attr('rowspan', rowspan).attr('colspan', colspan).show();
2202
+ };
2203
+
2204
+ BootstrapTable.prototype.updateCell = function (params) {
2205
+ if (!params.hasOwnProperty('rowIndex') || !params.hasOwnProperty('fieldName') || !params.hasOwnProperty('fieldValue')) {
2206
+ return;
2207
+ }
2208
+ this.data[params.rowIndex][params.fieldName] = params.fieldValue;
2209
+ this.initSort();
2210
+ this.initBody(true);
2211
+ };
2212
+
2213
+ BootstrapTable.prototype.getOptions = function () {
2214
+ return this.options;
2215
+ };
2216
+
2217
+ BootstrapTable.prototype.getSelections = function () {
2218
+ var that = this;
2219
+
2220
+ return $.grep(this.data, function (row) {
2221
+ return row[that.header.stateField];
2222
+ });
2223
+ };
2224
+
2225
+ BootstrapTable.prototype.getAllSelections = function () {
2226
+ var that = this;
2227
+
2228
+ return $.grep(this.options.data, function (row) {
2229
+ return row[that.header.stateField];
2230
+ });
2231
+ };
2232
+
2233
+ BootstrapTable.prototype.checkAll = function () {
2234
+ this.checkAll_(true);
2235
+ };
2236
+
2237
+ BootstrapTable.prototype.uncheckAll = function () {
2238
+ this.checkAll_(false);
2239
+ };
2240
+
2241
+ BootstrapTable.prototype.checkAll_ = function (checked) {
2242
+ var rows;
2243
+ if (!checked) {
2244
+ rows = this.getSelections();
2245
+ }
2246
+ this.$selectItem.filter(':enabled').prop('checked', checked);
2247
+ this.updateRows();
2248
+ this.updateSelected();
2249
+ if (checked) {
2250
+ rows = this.getSelections();
2251
+ }
2252
+ this.trigger(checked ? 'check-all' : 'uncheck-all', rows);
2253
+ };
2254
+
2255
+ BootstrapTable.prototype.check = function (index) {
2256
+ this.check_(true, index);
2257
+ };
2258
+
2259
+ BootstrapTable.prototype.uncheck = function (index) {
2260
+ this.check_(false, index);
2261
+ };
2262
+
2263
+ BootstrapTable.prototype.check_ = function (checked, index) {
2264
+ this.$selectItem.filter(sprintf('[data-index="%s"]', index)).prop('checked', checked);
2265
+ this.data[index][this.header.stateField] = checked;
2266
+ this.updateSelected();
2267
+ this.trigger(checked ? 'check' : 'uncheck', this.data[index]);
2268
+ };
2269
+
2270
+ BootstrapTable.prototype.checkBy = function (obj) {
2271
+ this.checkBy_(true, obj);
2272
+ };
2273
+
2274
+ BootstrapTable.prototype.uncheckBy = function (obj) {
2275
+ this.checkBy_(false, obj);
2276
+ };
2277
+
2278
+ BootstrapTable.prototype.checkBy_ = function (checked, obj) {
2279
+ if (!obj.hasOwnProperty('field') || !obj.hasOwnProperty('values')) {
2280
+ return;
2281
+ }
2282
+
2283
+ var that = this,
2284
+ rows = [];
2285
+ $.each(this.options.data, function (index, row) {
2286
+ if (!row.hasOwnProperty(obj.field)) {
2287
+ return false;
2288
+ }
2289
+ if ($.inArray(row[obj.field], obj.values) !== -1) {
2290
+ that.$selectItem.filter(sprintf('[data-index="%s"]', index)).prop('checked', checked);
2291
+ row[that.header.stateField] = checked;
2292
+ rows.push(row);
2293
+ that.trigger(checked ? 'check' : 'uncheck', row);
2294
+ }
2295
+ });
2296
+ this.updateSelected();
2297
+ this.trigger(checked ? 'check-some' : 'uncheck-some', rows);
2298
+ };
2299
+
2300
+ BootstrapTable.prototype.destroy = function () {
2301
+ this.$el.insertBefore(this.$container);
2302
+ $(this.options.toolbar).insertBefore(this.$el);
2303
+ this.$container.next().remove();
2304
+ this.$container.remove();
2305
+ this.$el.html(this.$el_.html())
2306
+ .css('margin-top', '0')
2307
+ .attr('class', this.$el_.attr('class') || ''); // reset the class
2308
+ };
2309
+
2310
+ BootstrapTable.prototype.showLoading = function () {
2311
+ this.$tableLoading.show();
2312
+ };
2313
+
2314
+ BootstrapTable.prototype.hideLoading = function () {
2315
+ this.$tableLoading.hide();
2316
+ };
2317
+
2318
+ BootstrapTable.prototype.togglePagination = function () {
2319
+ this.options.pagination = !this.options.pagination;
2320
+ var button = this.$toolbar.find('button[name="paginationSwitch"] i');
2321
+ if (this.options.pagination) {
2322
+ button.attr("class", this.options.iconsPrefix + " " + this.options.icons.paginationSwitchDown);
2323
+ } else {
2324
+ button.attr("class", this.options.iconsPrefix + " " + this.options.icons.paginationSwitchUp);
2325
+ }
2326
+ this.updatePagination();
2327
+ };
2328
+
2329
+ BootstrapTable.prototype.refresh = function (params) {
2330
+ if (params && params.url) {
2331
+ this.options.url = params.url;
2332
+ this.options.pageNumber = 1;
2333
+ }
2334
+ this.initServer(params && params.silent, params && params.query);
2335
+ };
2336
+
2337
+ BootstrapTable.prototype.resetWidth = function () {
2338
+ if (this.options.showHeader && this.options.height) {
2339
+ this.fitHeader();
2340
+ }
2341
+ if (this.options.showFooter) {
2342
+ this.fitFooter();
2343
+ }
2344
+ };
2345
+
2346
+ BootstrapTable.prototype.showColumn = function (field) {
2347
+ this.toggleColumn(getFieldIndex(this.columns, field), true, true);
2348
+ };
2349
+
2350
+ BootstrapTable.prototype.hideColumn = function (field) {
2351
+ this.toggleColumn(getFieldIndex(this.columns, field), false, true);
2352
+ };
2353
+
2354
+ BootstrapTable.prototype.getHiddenColumns = function () {
2355
+ return $.grep(this.columns, function( column ) {
2356
+ return !column.visible;
2357
+ });
2358
+ };
2359
+
2360
+ BootstrapTable.prototype.filterBy = function (columns) {
2361
+ this.filterColumns = $.isEmptyObject(columns) ? {} : columns;
2362
+ this.options.pageNumber = 1;
2363
+ this.initSearch();
2364
+ this.updatePagination();
2365
+ };
2366
+
2367
+ BootstrapTable.prototype.scrollTo = function (value) {
2368
+ if (typeof value === 'string') {
2369
+ value = value === 'bottom' ? this.$tableBody[0].scrollHeight : 0;
2370
+ }
2371
+ if (typeof value === 'number') {
2372
+ this.$tableBody.scrollTop(value);
2373
+ }
2374
+ if (typeof value === 'undefined') {
2375
+ return this.$tableBody.scrollTop();
2376
+ }
2377
+ };
2378
+
2379
+ BootstrapTable.prototype.getScrollPosition = function () {
2380
+ return this.scrollTo();
2381
+ };
2382
+
2383
+ BootstrapTable.prototype.selectPage = function (page) {
2384
+ if (page > 0 && page <= this.options.totalPages) {
2385
+ this.options.pageNumber = page;
2386
+ this.updatePagination();
2387
+ }
2388
+ };
2389
+
2390
+ BootstrapTable.prototype.prevPage = function () {
2391
+ if (this.options.pageNumber > 1) {
2392
+ this.options.pageNumber--;
2393
+ this.updatePagination();
2394
+ }
2395
+ };
2396
+
2397
+ BootstrapTable.prototype.nextPage = function () {
2398
+ if (this.options.pageNumber < this.options.totalPages) {
2399
+ this.options.pageNumber++;
2400
+ this.updatePagination();
2401
+ }
2402
+ };
2403
+
2404
+ BootstrapTable.prototype.toggleView = function () {
2405
+ this.options.cardView = !this.options.cardView;
2406
+ this.initHeader();
2407
+ // Fixed remove toolbar when click cardView button.
2408
+ //that.initToolbar();
2409
+ this.initBody();
2410
+ this.trigger('toggle', this.options.cardView);
2411
+ };
2412
+
2413
+ BootstrapTable.prototype.refreshOptions = function (options) {
2414
+ //If the objects are equivalent then avoid the call of destroy / init methods
2415
+ if (compareObjects(this.options, options, false)) {
2416
+ return;
2417
+ }
2418
+ this.options = $.extend(this.options, options);
2419
+ this.trigger('refresh-options', this.options);
2420
+ this.destroy();
2421
+ this.init();
2422
+ };
2423
+
2424
+ BootstrapTable.prototype.resetSearch = function (text) {
2425
+ var $search = this.$toolbar.find('.search input');
2426
+ $search.val(text || '');
2427
+ this.onSearch({currentTarget: $search});
2428
+ };
2429
+
2430
+ // BOOTSTRAP TABLE PLUGIN DEFINITION
2431
+ // =======================
2432
+
2433
+ var allowedMethods = [
2434
+ 'getOptions',
2435
+ 'getSelections', 'getAllSelections', 'getData',
2436
+ 'load', 'append', 'prepend', 'remove', 'removeAll',
2437
+ 'insertRow', 'updateRow', 'updateCell', 'removeByUniqueId',
2438
+ 'getRowByUniqueId', 'showRow', 'hideRow', 'getRowsHidden',
2439
+ 'mergeCells',
2440
+ 'checkAll', 'uncheckAll',
2441
+ 'check', 'uncheck',
2442
+ 'checkBy', 'uncheckBy',
2443
+ 'refresh',
2444
+ 'resetView',
2445
+ 'resetWidth',
2446
+ 'destroy',
2447
+ 'showLoading', 'hideLoading',
2448
+ 'showColumn', 'hideColumn', 'getHiddenColumns',
2449
+ 'filterBy',
2450
+ 'scrollTo',
2451
+ 'getScrollPosition',
2452
+ 'selectPage', 'prevPage', 'nextPage',
2453
+ 'togglePagination',
2454
+ 'toggleView',
2455
+ 'refreshOptions',
2456
+ 'resetSearch'
2457
+ ];
2458
+
2459
+ $.fn.bootstrapTable = function (option) {
2460
+ var value,
2461
+ args = Array.prototype.slice.call(arguments, 1);
2462
+
2463
+ this.each(function () {
2464
+ var $this = $(this),
2465
+ data = $this.data('bootstrap.table'),
2466
+ options = $.extend({}, BootstrapTable.DEFAULTS, $this.data(),
2467
+ typeof option === 'object' && option);
2468
+
2469
+ if (typeof option === 'string') {
2470
+ if ($.inArray(option, allowedMethods) < 0) {
2471
+ throw new Error("Unknown method: " + option);
2472
+ }
2473
+
2474
+ if (!data) {
2475
+ return;
2476
+ }
2477
+
2478
+ value = data[option].apply(data, args);
2479
+
2480
+ if (option === 'destroy') {
2481
+ $this.removeData('bootstrap.table');
2482
+ }
2483
+ }
2484
+
2485
+ if (!data) {
2486
+ $this.data('bootstrap.table', (data = new BootstrapTable(this, options)));
2487
+ }
2488
+ });
2489
+
2490
+ return typeof value === 'undefined' ? this : value;
2491
+ };
2492
+
2493
+ $.fn.bootstrapTable.Constructor = BootstrapTable;
2494
+ $.fn.bootstrapTable.defaults = BootstrapTable.DEFAULTS;
2495
+ $.fn.bootstrapTable.columnDefaults = BootstrapTable.COLUMN_DEFAULTS;
2496
+ $.fn.bootstrapTable.locales = BootstrapTable.LOCALES;
2497
+ $.fn.bootstrapTable.methods = allowedMethods;
2498
+
2499
+ // BOOTSTRAP TABLE INIT
2500
+ // =======================
2501
+
2502
+ $(function () {
2503
+ $('[data-toggle="table"]').bootstrapTable();
2504
+ });
2505
+
2506
+ }(jQuery);