6 lines
18 KiB
JavaScript
6 lines
18 KiB
JavaScript
|
/*!
|
||
|
* bootstrap-select v1.3.7 (http://silviomoreto.github.io/bootstrap-select)
|
||
|
* Copyright 2013 bootstrap-select
|
||
|
* Licensed under the MIT license
|
||
|
*/
|
||
|
;!function(b){b.expr[":"].icontains=function(e,c,d){return b(e).text().toUpperCase().indexOf(d[3].toUpperCase())>=0;};var a=function(d,c,f){if(f){f.stopPropagation();f.preventDefault();}this.$element=b(d);this.$newElement=null;this.$button=null;this.$menu=null;this.options=b.extend({},b.fn.selectpicker.defaults,this.$element.data(),typeof c=="object"&&c);if(this.options.title===null){this.options.title=this.$element.attr("title");}if(this.options.titleIcon===null){this.options.titleIcon=this.$element.attr("title-icon");}this.val=a.prototype.val;this.render=a.prototype.render;this.refresh=a.prototype.refresh;this.setStyle=a.prototype.setStyle;this.selectAll=a.prototype.selectAll;this.deselectAll=a.prototype.deselectAll;this.init();};a.prototype={constructor:a,init:function(){this.$element.hide();this.multiple=this.$element.prop("multiple");var d=this.$element.attr("id");this.$newElement=this.createView();this.$element.after(this.$newElement);this.$menu=this.$newElement.find("> .dropdown-menu");this.$button=this.$newElement.find("> button");this.$searchbox=this.$newElement.find("input");if(d!==undefined){var c=this;this.$button.attr("data-id",d);b('label[for="'+d+'"]').click(function(f){f.preventDefault();c.$button.focus();});}this.checkDisabled();this.clickListener();if(this.options.liveSearch){this.liveSearchListener();}this.render();this.liHeight();this.setStyle();this.setWidth();if(this.options.container){this.selectPosition();}this.$menu.data("this",this);this.$newElement.data("this",this);},createDropdown:function(){var c=this.multiple?" show-tick":"";var f=this.options.header?'<div class="popover-title"><button type="button" class="close" aria-hidden="true">×</button>'+this.options.header+"</div>":"";var e=this.options.liveSearch?'<div class="bootstrap-select-searchbox"><input type="text" class="input-block-level form-control" /></div>':"";var d='<div class="btn-group bootstrap-select'+c+'"><button type="button" class="btn dropdown-toggle selectpicker" data-toggle="dropdown"><span class="filter-option pull-left"></span> <span class="caret"></span></button><div class="dropdown-menu open">'+f+e+'<ul class="dropdown-menu inner selectpicker" role="menu"></ul></div></div>';return b(d);},createView:function(){var c=this.createDropdown();var d=this.createLi();c.find("ul").append(d);return c;},reloadLi:function(){this.destroyLi();var c=this.createLi();this.$menu.find("ul").append(c);},destroyLi:function(){this.$menu.find("li").remove();},createLi:function(){var d=this,e=[],c="";this.$element.find("option").each(function(){var j=b(this);var h=j.attr("class")||"";var g=j.attr("href")||"";var i=j.attr("style")||"";var n=j.data("content")?j.data("content"):j.html();var l=j.data("subtext")!==undefined?'<small class="muted text-muted">'+j.data("subtext")+"</small>":"";var k=j.data("icon")!==undefined?'<i class="'+d.options.iconBase+" "+j.data("icon")+'"></i> ':"";if(k!==""&&(j.is(":disabled")||j.parent().is(":disabled"))){k="<span>"+k+"</span>";}if(!j.data("content")){n=k+'<span class="text">'+n+l+"</span>";}if(d.options.hideDisabled&&(j.is(":disabled")||j.parent().is(":disabled"))){e.push('<a style="min-height: 0; padding: 0"></a>');}else{if(j.parent().is("optgroup")&&j.data("divider")!==true){if(j.index()===0){var m=j.parent().attr("label");var o=j.parent().data("subtext")!==undefined?'<small class="muted text-muted">'+j.parent().data("subtext")+"</small>":"";var f=j.parent().data("icon")?'<i class="'+j.parent().data("icon")+'"></i> ':"";m=f+'<span class="text">'+m+o+"</span>";if(j[0].index!==0){e.push('<div class="div-contain"><div class="divider"></div></div><dt>'+m+"</dt>"+d.createA(n,"opt "+h,i,g));}else{e.push("<dt>"+m+"</dt>"+d.createA(n,"opt "+h,i,g));}}else{e.push(d.createA(n,"opt "+h,i,g));}}else{if(j.data("divider")===true){e.push('<div class="div-contain"><div class="divider"></div></div>');}else{if(b(this).data("hidden")===true){e.push("");}else{e.push(d.createA(n,h,i,g));}}}}});b.each(e,function(f,g){c+="<li rel="+f+">"+g+"</li>";});if(!this.multiple&&this.$element.find("option:selected").length===0&&!t
|