var ComponentsSelect2=function(){var handleDemo=function(){$.fn.select2.defaults.set("theme","bootstrap");var placeholder="Select a State";$(".select2, .select2-multiple").select2({placeholder:placeholder,width:null});$(".select2-allow-clear").select2({allowClear:true,placeholder:placeholder,width:null});function formatRepo(repo){if(repo.loading)return repo.text;var markup="<div class='select2-result-repository clearfix'>"+
"<div class='select2-result-repository__avatar'><img src='"+repo.owner.avatar_url+"' /></div>"+
"<div class='select2-result-repository__meta'>"+
"<div class='select2-result-repository__title'>"+repo.full_name+"</div>";if(repo.description){markup+="<div class='select2-result-repository__description'>"+repo.description+"</div>";}
markup+="<div class='select2-result-repository__statistics'>"+
"<div class='select2-result-repository__forks'><span class='glyphicon glyphicon-flash'></span> "+repo.forks_count+" Forks</div>"+
"<div class='select2-result-repository__stargazers'><span class='glyphicon glyphicon-star'></span> "+repo.stargazers_count+" Stars</div>"+
"<div class='select2-result-repository__watchers'><span class='glyphicon glyphicon-eye-open'></span> "+repo.watchers_count+" Watchers</div>"+
"</div>"+
"</div></div>";return markup;}
function formatRepoSelection(repo){return repo.full_name||repo.text;}
$(".js-data-example-ajax").select2({width:"off",ajax:{url:"https://api.github.com/search/repositories",dataType:'json',delay:250,data:function(params){return{q:params.term,page:params.page};},processResults:function(data,page){return{results:data.items};},cache:true},escapeMarkup:function(markup){return markup;},minimumInputLength:1,templateResult:formatRepo,templateSelection:formatRepoSelection});$("button[data-select2-open]").click(function(){$("#"+$(this).data("select2-open")).select2("open");});$(":checkbox").on("click",function(){$(this).parent().nextAll("select").prop("disabled",!this.checked);});$(".select2, .select2-multiple, .select2-allow-clear, .js-data-example-ajax").on("select2:open",function(){if($(this).parents("[class*='has-']").length){var classNames=$(this).parents("[class*='has-']")[0].className.split(/\s+/);for(var i=0;i<classNames.length;++i){if(classNames[i].match("has-")){$("body > .select2-container").addClass(classNames[i]);}}}
$("#select2-select2-single-input-sm-results").find("li").each(function(index,element){var results_id=$(element).attr("id");if(results_id){if(results_id.indexOf('all|_|0|_|0|')>-1){$(element).addClass("select2-results_top");}}})});$(".js-btn-set-scaling-classes").on("click",function(){$("#select2-multiple-input-sm, #select2-single-input-sm").next(".select2-container--bootstrap").addClass("input-sm");$("#select2-multiple-input-lg, #select2-single-input-lg").next(".select2-container--bootstrap").addClass("input-lg");$(this).removeClass("btn-primary btn-outline").prop("disabled",true);});}
return{init:function(){handleDemo();}};}();if(App.isAngularJsApp()===false){jQuery(document).ready(function(){ComponentsSelect2.init();});}