/*
* bootstrap-table - v1.12.1 - 2018-03-12
* https://github.com/wenzhixin/bootstrap-table
* Copyright (c) 2018 zhixin wen
* Licensed MIT License
*/
!function(a){"use strict";var b,c,d=function(a){var b=arguments,c=!0,d=1;return a=a.replace(/%s/g,function(){var a=b[d++];return"undefined"==typeof a?(c=!1,""):a}),c?a:""},e=function(a,b){var c={};return a.forEach(function(a){var d=b(a);c[d]=c[d]||[],c[d].push(a)}),c};a.extend(a.fn.bootstrapTable.defaults,{groupBy:!1,groupByField:""});var f=a.fn.bootstrapTable.Constructor,g=f.prototype.initSort,h=f.prototype.initBody,i=f.prototype.updateSelected;f.prototype.initSort=function(){g.apply(this,Array.prototype.slice.apply(arguments));var b=this;if(c=[],this.options.groupBy&&""!==this.options.groupByField){this.options.sortName!=this.options.groupByField&&this.data.sort(function(a,c){return a[b.options.groupByField].localeCompare(c[b.options.groupByField])});var b=this,d=e(b.data,function(a){return[a[b.options.groupByField]]}),f=0;a.each(d,function(a,b){c.push({id:f,name:a}),b.forEach(function(a){a._data||(a._data={}),a._data["parent-index"]=f}),f++})}},f.prototype.initBody=function(){if(b=!0,h.apply(this,Array.prototype.slice.apply(arguments)),this.options.groupBy&&""!==this.options.groupByField){var e=this,f=!1,g=0;this.columns.forEach(function(a){a.checkbox?f=!0:a.visible&&(g+=1)}),this.options.detailView&&!this.options.cardView&&(g+=1),c.forEach(function(b){var c=[];c.push(d('
',b.id)),e.options.detailView&&!e.options.cardView&&c.push(' | '),f&&c.push('',''," | "),c.push("",b.name," | "),c.push("
"),e.$body.find("tr[data-parent-index="+b.id+"]:first").before(a(c.join("")))}),this.$selectGroup=[],this.$body.find('[name="btSelectGroup"]').each(function(){var b=a(this);e.$selectGroup.push({group:b,item:e.$selectItem.filter(function(){return a(this).closest("tr").data("parent-index")===b.closest("tr").data("group-index")})})}),this.$container.off("click",".groupBy").on("click",".groupBy",function(){a(this).toggleClass("expanded"),e.$body.find("tr[data-parent-index="+a(this).closest("tr").data("group-index")+"]").toggleClass("hidden")}),this.$container.off("click",'[name="btSelectGroup"]').on("click",'[name="btSelectGroup"]',function(b){b.stopImmediatePropagation();var c=a(this),d=c.prop("checked");e[d?"checkGroup":"uncheckGroup"](a(this).closest("tr").data("group-index"))})}b=!1,this.updateSelected()},f.prototype.updateSelected=function(){b||(i.apply(this,Array.prototype.slice.apply(arguments)),this.options.groupBy&&""!==this.options.groupByField&&this.$selectGroup.forEach(function(a){var b=a.item.filter(":enabled").length===a.item.filter(":enabled").filter(":checked").length;a.group.prop("checked",b)}))},f.prototype.getGroupSelections=function(b){var c=this;return a.grep(this.data,function(a){return a[c.header.stateField]&&a._data["parent-index"]===b})},f.prototype.checkGroup=function(a){this.checkGroup_(a,!0)},f.prototype.uncheckGroup=function(a){this.checkGroup_(a,!1)},f.prototype.checkGroup_=function(b,c){var d,e=function(){return a(this).closest("tr").data("parent-index")===b};c||(d=this.getGroupSelections(b)),this.$selectItem.filter(e).prop("checked",c),this.updateRows(),this.updateSelected(),c&&(d=this.getGroupSelections(b)),this.trigger(c?"check-all":"uncheck-all",d)}}(jQuery);