You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
yacy_search_server/htroot/yacy/ui/js/jquery.multiselect.min.js

20 lines
9.7 KiB

/*
* jQuery MultiSelect UI Widget 1.9
* Copyright (c) 2011 Eric Hynds
*
* http://www.erichynds.com/jquery/jquery-ui-multiselect-widget/
*
* Depends:
* - jQuery 1.4.2+
* - jQuery UI 1.8 widget factory
*
* Optional:
* - jQuery UI effects
* - jQuery UI position utility
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/
(function(d){var o=0;d.widget("ech.multiselect",{options:{header:true,height:175,minWidth:225,classes:"",checkAllText:"Check all",uncheckAllText:"Uncheck all",noneSelectedText:"Select options",selectedText:"# selected",selectedList:0,show:"",hide:"",autoOpen:false,multiple:true,position:{}},_create:function(){var a=this.element.hide(),b=this.options;this.speed=d.fx.speeds._default;this._isOpen=false;a=(this.button=d('<button type="button"><span class="ui-icon ui-icon-triangle-2-n-s"></span></button>')).addClass("ui-multiselect ui-widget ui-state-default ui-corner-all").addClass(b.classes).attr({title:a.attr("title"), "aria-haspopup":true}).insertAfter(a);(this.buttonlabel=d("<span />")).html(b.noneSelectedText).appendTo(a);a=(this.menu=d("<div />")).addClass("ui-multiselect-menu ui-widget ui-widget-content ui-corner-all").addClass(b.classes).insertAfter(a);var e=(this.header=d("<div />")).addClass("ui-widget-header ui-corner-all ui-multiselect-header ui-helper-clearfix").appendTo(a);(this.headerLinkContainer=d("<ul />")).addClass("ui-helper-reset").html(function(){return b.header===true?'<li><a class="ui-multiselect-all" href="#"><span class="ui-icon ui-icon-check"></span><span>'+ b.checkAllText+'</span></a></li><li><a class="ui-multiselect-none" href="#"><span class="ui-icon ui-icon-closethick"></span><span>'+b.uncheckAllText+"</span></a></li>":typeof b.header==="string"?"<li>"+b.header+"</li>":""}).append('<li class="ui-multiselect-close"><a href="#" class="ui-multiselect-close"><span class="ui-icon ui-icon-circle-close"></span></a></li>').appendTo(e);(this.checkboxContainer=d("<ul />")).addClass("ui-multiselect-checkboxes ui-helper-reset").appendTo(a);this._bindEvents(); this.refresh(true);b.multiple||a.addClass("ui-multiselect-single")},_init:function(){this.options.header===false&&this.header.hide();this.options.multiple||this.headerLinkContainer.find(".ui-multiselect-all, .ui-multiselect-none").hide();this.options.autoOpen&&this.open();this.element.is(":disabled")&&this.disable()},refresh:function(a){var b=this.options,e=this.menu,c=this.button,g=this.checkboxContainer,f=[],h=this.element.attr("id")||o++;g.empty();this.element.find("option").each(function(k){var i= d(this),m=i.html(),n=this.value;k=this.id||"ui-multiselect-"+h+"-option-"+k;var j=i.parent();i=i.is(":disabled");var l=["ui-corner-all"];if(j.is("optgroup")){j=j.attr("label");if(d.inArray(j,f)===-1){d('<li><a href="#">'+j+"</a></li>").addClass("ui-multiselect-optgroup-label").appendTo(g);f.push(j)}}if(n.length>0){i&&l.push("ui-state-disabled");j=d("<li />").addClass(i?"ui-multiselect-disabled":"").appendTo(g);l=d("<label />").attr("for",k).addClass(l.join(" ")).appendTo(j);d('<input type="'+(b.multiple? "checkbox":"radio")+'" '+(this.selected?'checked="checked"':"")+' name="multiselect_'+h+'" />').attr({id:k,checked:this.selected,title:m,disabled:i,"aria-disabled":i,"aria-selected":this.selected}).val(n).appendTo(l).after("<span>"+m+"</span>")}});this.labels=e.find("label");this._setButtonWidth();this._setMenuWidth();c[0].defaultValue=this.update();a||this._trigger("refresh")},update:function(){var a=this.options,b=this.labels.find("input"),e=b.filter(":checked"),c=e.length;a=c===0?a.noneSelectedText: d.isFunction(a.selectedText)?a.selectedText.call(this,c,b.length,e.get()):/\d/.test(a.selectedList)&&a.selectedList>0&&c<=a.selectedList?e.map(function(){return this.title}).get().join(", "):a.selectedText.replace("#",c).replace("#",b.length);this.buttonlabel.html(a);return a},_bindEvents:function(){function a(){b[b._isOpen?"close":"open"]();return false}var b=this,e=this.button;e.find("span").bind("click.multiselect",a);e.bind({click:a,keypress:function(c){switch(c.which){case 27:case 38:case 37:b.close(); break;case 39:case 40:b.open()}},mouseenter:function(){e.hasClass("ui-state-disabled")||d(this).addClass("ui-state-hover")},mouseleave:function(){d(this).removeClass("ui-state-hover")},focus:function(){e.hasClass("ui-state-disabled")||d(this).addClass("ui-state-focus")},blur:function(){d(this).removeClass("ui-state-focus")}});this.header.delegate("a","