You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
monaco-editor/website/lib/bootstrap-select.min.js

1 line
7.4 KiB
JavaScript

!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;r<v.length;r++){if(v[r]!="selectpicker"){this.$newElement.addClass(v[r])}}this.button.addClass(this.style);this.checkDisabled();this.checkTabIndex();this.clickListener();var q=parseInt(d.css("padding-top"))+parseInt(d.css("padding-bottom"))+parseInt(d.css("border-top-width"))+parseInt(d.css("border-bottom-width"));if(this.size=="auto"){function f(){var e=j-b(window).scrollTop();var x=window.innerHeight;var i=q+parseInt(d.css("margin-top"))+parseInt(d.css("margin-bottom"))+2;var w=x-e-t-i;n=w;if(p.hasClass("dropup")){n=e-i}d.css({"max-height":n+"px","overflow-y":"auto","min-height":g*3+"px"})}f();b(window).resize(f);b(window).scroll(f);this.$element.bind("DOMNodeInserted",f)}else{if(this.size&&this.size!="auto"&&d.find("li").length>this.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="<div class='btn-group bootstrap-select'><button class='btn dropdown-toggle clearfix' data-toggle='dropdown'><span class='filter-option pull-left'>__SELECTED_OPTION</span>&nbsp;<span class='caret'></span></button><ul class='dropdown-menu' role='menu'>__ADD_LI</ul></div>";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?'<small class="muted">'+b(this).data("subtext")+"</small>":"";var h=b(this).parent().data("subtext")!==undefined?'<small class="muted">'+b(this).parent().data("subtext")+"</small>":"";if(b(this).parent().is("optgroup")&&b(this).data("divider")!=true){if(b(this).index()==0){if(b(this)[0].index!=0){g.push('<div class="div-contain"><div class="divider"></div></div><dt>'+b(this).parent().attr("label")+h+'</dt><a tabindex="-1" href="#" class="opt '+j+'">'+b(this).text()+i+"</a>")}else{g.push("<dt>"+b(this).parent().attr("label")+h+'</dt><a tabindex="-1" href="#" class="opt '+j+'">'+b(this).text()+i+"</a>")}}else{g.push('<a tabindex="-1" href="#" class="opt '+j+'">'+b(this).text()+i+"</a>")}}else{if(b(this).data("divider")==true){g.push('<div class="div-contain"><div class="divider"></div></div>')}else{g.push('<a tabindex="-1" href="#" class="'+j+'">'+b(this).text()+i+"</a>")}}});if(f.length>0){for(var d=0;d<f.length;d++){var e=this.$element.find("option").eq(d).is(":disabled")||this.$element.find("option").eq(d).parent().is(":disabled")?'class="disabled"':"";this.$newElement.find("ul").append("<li rel="+d+" "+e+">"+g[d]+"</li>")}}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.$e