!function(b){var a=function(d,c,f){if(f){f.stopPropagation();f.preventDefault()}this.$element=b(d);this.$newElement=null;this.button=null;this.options=b.extend({},b.fn.selectpicker.defaults,this.$element.data(),typeof c=="object"&&c);this.style=this.options.style;this.size=this.options.size;this.init()};a.prototype={constructor:a,init:function(s){this.$element.hide();var v=this.$element.attr("class")!==undefined?this.$element.attr("class").split(/\s+/):"";var u=this.getTemplate();var o=this.$element.attr("id");u=this.createLi(u);this.$element.after(u);this.$newElement=this.$element.next(".bootstrap-select");var p=this.$newElement;var d=this.$newElement.find(".dropdown-menu");var m=d.find("li > a");var g=parseInt(m.css("line-height"))+m.outerHeight();var h=d.find("li .divider").outerHeight(true);var j=this.$newElement.offset().top;var l=0;var n=0;var t=this.$newElement.outerHeight();this.button=this.$newElement.find("> button");if(o!==undefined){this.button.attr("id",o);b('label[for="'+o+'"]').click(function(){p.find("button#"+o).focus()})}for(var r=0;rthis.size){var k=d.find("li > *").filter(":not(.div-contain)").slice(0,this.size).last().parent().index();var c=d.find("li").slice(0,k+1).find(".div-contain").length;n=g*this.size+c*h+q;d.css({"max-height":n+"px","overflow-y":"scroll"})}}this.$element.bind("DOMNodeInserted",b.proxy(this.reloadLi,this))},getTemplate:function(){var c="
";return c},reloadLi:function(){var f=[];var g=[];var c="";this.$newElement.find("li").remove();this.$element.find("option").each(function(){f.push(b(this).text())});this.$element.find("option").each(function(){var j=b(this).attr("class")!==undefined?b(this).attr("class"):"";var i=b(this).data("subtext")!==undefined?''+b(this).data("subtext")+"":"";var h=b(this).parent().data("subtext")!==undefined?''+b(this).parent().data("subtext")+"":"";if(b(this).parent().is("optgroup")&&b(this).data("divider")!=true){if(b(this).index()==0){if(b(this)[0].index!=0){g.push('
'+b(this).parent().attr("label")+h+'
'+b(this).text()+i+"")}else{g.push("
"+b(this).parent().attr("label")+h+'
'+b(this).text()+i+"")}}else{g.push(''+b(this).text()+i+"")}}else{if(b(this).data("divider")==true){g.push('
')}else{g.push(''+b(this).text()+i+"")}}});if(f.length>0){for(var d=0;d"+g[d]+"")}}this.$newElement.find("li.disabled a, li dt, li .div-contain").on("click",function(h){h.preventDefault();h.stopPropagation();$select=b(this).parent().parents(".bootstrap-select");$select.find("button").focus()});if(this.$element.find("option:selected").attr("title")!=undefined){this.$newElement.find(".filter-option").html(this.$element.find("option:selected").attr("title"))}else{this.$newElement.find(".filter-option").html(this.$element.find("option:selected").text())}},createLi:function(g){var f=[];var k=[];var c="";var j=this;var h=this.$element[0].selectedIndex?this.$element[0].selectedIndex:0;this.$element.find("option").each(function(){f.push(b(this).text())});this.$element.find("option").each(function(){var m=b(this).attr("class")!==undefined?b(this).attr("class"):"";var l=b(this).data("subtext")!==undefined?''+b(this).data("subtext")+"":"";var i=b(this).parent().data("subtext")!==undefined?''+b(this).parent().data("subtext")+"":"";if(b(this).parent().is("optgroup")&&b(this).data("divider")!=true){if(b(this).index()==0){if(b(this)[0].index!=0){k.push('
'+b(this).parent().attr("label")+i+'
'+b(this).text()+l+"")}else{k.push("
"+b(this).parent().attr("label")+i+'
'+b(this).text()+l+"")}}else{k.push(''+b(this).text()+l+"")}}else{if(b(this).data("divider")==true){k.push('
')}else{k.push(''+b(this).text()+l+"")}}});if(f.length>0){g=g.replace("__SELECTED_OPTION",f[h]);for(var d=0;d"+k[d]+""}}else{g=g.replace("__SELECTED_OPTION","")}this.$element.find("option").eq(h).prop("selected",true);g=g.replace("__ADD_LI",c);return g},checkDisabled:function(){if(this.$element.is(":disabled")){this.button.addClass("disabled");this.button.click(function(c){c.preventDefault()})}},checkTabIndex:function(){if(this.$element.is("[tabindex]")){var c=this.$element.attr("tabindex");this.button.attr("tabindex",c)}},clickListener:function(){b("body").on("touchstart.dropdown",".dropdown-menu",function(c){c.stopPropagation()});this.$newElement.find("li.disabled a, li dt, li .div-contain").on("click",function(c){c.preventDefault();c.stopPropagation();$select=b(this).parent().parents(".bootstrap-select");$select.find("button").focus()});this.$newElement.on("click","li a",function(g){g.preventDefault();var d=b(this).parent().index(),f=b(this).parent(),c=f.parents(".bootstrap-select");if(c.prev("select").not(":disabled")){c.prev("select").find("option").removeAttr("selected");c.prev("select").find("option").eq(d).prop("selected",true).attr("selected","selected");c.find(".filter-option").html(f.text());c.find("button").focus();c.prev("select").trigger("change")}});this.$element.on("change",function(c){if(b(this).find("option:selected").attr("title")!=undefined){b(this).next(".bootstrap-select").find(".filter-option").html(b(this).find("option:selected").attr("title"))}else{b(this).next(".bootstrap-select").find(".filter-option").html(b(this).find("option:selected").text())}})}};b.fn.selectpicker=function(c,d){return this.each(function(){var g=b(this),f=g.data("selectpicker"),e=typeof c=="object"&&c;if(!f){g.data("selectpicker",(f=new a(this,e,d)))}if(typeof c=="string"){f[c]()}})};b.fn.selectpicker.defaults={style:null,size:"auto"}}(window.jQuery);