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="
"+ "
"+ "
"+ "
"+repo.full_name+"
";if(repo.description){markup+="
"+repo.description+"
";} markup+="
"+ "
"+repo.forks_count+" Forks
"+ "
"+repo.stargazers_count+" Stars
"+ "
"+repo.watchers_count+" Watchers
"+ "
"+ "
";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 .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();});}