!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(n){this.$element.hide();var f=this.$element.attr("class")!==undefined?this.$element.attr("class").split(/\s+/):"";var q=this.getTemplate();var d=this.$element.attr("id");q=this.createLi(q);this.$element.after(q);this.$newElement=this.$element.next(".bootstrap-select");var p=this.$newElement;var g=this.$newElement.find(".dropdown-menu");var m=this.$newElement.find(".dropdown-menu li > a");var o=parseInt(m.css("line-height"))+m.outerHeight();var j=this.$newElement.offset().top;var s=0;var h=0;var l=this.$newElement.outerHeight();this.button=this.$newElement.find("> button");if(d!==undefined){this.button.attr("id",d);b('label[for="'+d+'"]').click(function(){p.find("button#"+d).focus()})}for(var k=0;ks){g.css({"max-height":h+"px","overflow-y":"scroll"})}else{g.css({"max-height":"none","overflow-y":"auto"})}}r();b(window).resize(r);b(window).scroll(r);this.$element.bind("DOMNodeInserted",r)}else{if(this.size&&this.size!="auto"&&g.find("li").length>this.size){h=o*this.size+c;if(this.size==1){h=h+8}g.css({"max-height":h+"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 h=b(this).attr("class")!==undefined?b(this).attr("class"):"";if(b(this).parent().is("optgroup")){if(b(this).index()==0){if(b(this)[0].index!=0){g.push('
'+b(this).parent().attr("label")+'
'+b(this).text()+"")}else{g.push("
"+b(this).parent().attr("label")+'
'+b(this).text()+"")}}else{g.push(''+b(this).text()+"")}}else{g.push(''+b(this).text()+"")}});if(f.length>0){for(var d=0;d"+g[d]+"")}}this.$newElement.find("li dt").on("click",function(h){h.stopPropagation();$select=b(this).parent().parents(".bootstrap-select");$select.find("button").focus()});this.$newElement.find("li.disabled a").on("click",function(h){h.stopPropagation();$select=b(this).parent().parents(".bootstrap-select");$select.find("button").focus()})},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 i=b(this).attr("class")!==undefined?b(this).attr("class"):"";if(b(this).parent().is("optgroup")){if(b(this).index()==0){if(b(this)[0].index!=0){k.push('
'+b(this).parent().attr("label")+'
'+b(this).text()+"")}else{k.push("
"+b(this).parent().attr("label")+'
'+b(this).text()+"")}}else{k.push(''+b(this).text()+"")}}else{k.push(''+b(this).text()+"")}});if(f.length>0){g=g.replace("__SELECTED_OPTION",f[h]);for(var d=0;d"+k[d]+""}}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 dt").on("click",function(c){c.stopPropagation();$select=b(this).parent().parents(".bootstrap-select");$select.find("button").focus()});this.$newElement.find("li.disabled a").on("click",function(c){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);