Advanced Search

# ferric84 / jquery-multiselect

- Admin
- Watch Unwatch
- Fork
- Your Fork
- Pull Request
- Download Source
- - 35
  - 1

- Source
- Commits
- Network (1)
- Issues (0)
- Downloads (5)
- Wiki (1)
- Graphs
- Branch: `master`

click here to add a description

click here to add a homepage

Sending Request…
Enable Donations

## Pledgie Donations

Paypal Email

Once activated, we'll place the following badge in your repository's detail box:
This service is courtesy of Pledgie.

jQuery MultiSelect Plugin — Read more

Cancel

http://www.erichynds.com/jquery/jquery-multiselect-plugin-with-themeroller-support/

Cancel

- Private
- Read-Only
- HTTP Read-Only

This URL has Read+Write access

    patched bug with disabled selects in webkit, jQuery bug #6211

ferric84 (author)
Fri Mar 05 13:34:52 -0800 2010
commit ec38bd9179c15da2a519d817e3f94afeca927519
tree f8d18ddf32d09962d620f2d3b11954c9d1520919
parent 142e1b1c95ec49f4c3239aa8b7f0d2e143415b15
jquery-multiselect / src / jquery.multiselect.min.js src/jquery.multiselect.min.js
100644 13 lines (12 sloc) 6.544 kb
edit raw blame history

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    /* * jQuery MultiSelect Plugin 0.4.1 * Copyright (c) 2010 Eric Hynds * * http://www.erichynds.com/jquery/jquery-multiselect-plugin-with-themeroller-support/ * Inspired by Cory S.N. LaViska's implementation, A Beautiful Site (http://abeautifulsite.net/) 2009 * * 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){d.fn.extend({multiSelect:function(i){i=d.extend({},d.fn.multiSelect.defaults,i);return this.each(function(){new t(this,i)})}});var t=function(i,f){function m(){var a=l.find("input"),b=a.filter(":checked"),c="",j=b.length;if(j===0)c=f.noneSelected;else if(f.selectedList&&b.length<=f.selectedList)b.each(function(){var k=d(this).parent().text();c=c.length?(c+=", "+k):k});else c=f.selectedText.replace("#",j).replace("#",a.length);h.find("input").val(c).attr("title",c);return c}var h=$original= d(i),e,l,g=[],p=[];g.push('<a class="ui-multiselect ui-widget ui-state-default ui-corner-all"><input readonly="readonly" type="text" class="ui-state-default" value="'+f.noneSelected+'" /><span class="ui-icon ui-icon-triangle-1-s"></span></a>');g.push('<div class="ui-multiselect-options'+(f.shadow?" ui-multiselect-shadow":"")+' ui-widget ui-widget-content ui-corner-bl ui-corner-br ui-corner-tr">');if(f.showHeader){g.push('<div class="ui-widget-header ui-helper-clearfix ui-corner-all ui-multiselect-header">'); g.push('<ul class="ui-helper-reset">');g.push('<li><a class="ui-multiselect-all" href=""><span class="ui-icon ui-icon-check"></span>'+f.checkAllText+"</a></li>");g.push('<li><a class="ui-multiselect-none" href=""><span class="ui-icon ui-icon-closethick"></span>'+f.unCheckAllText+"</a></li>");g.push('<li class="ui-multiselect-close"><a href="" class="ui-multiselect-close ui-icon ui-icon-circle-close"></a></li>');g.push("</ul>");g.push("</div>")}g.push('<ul class="ui-multiselect-checkboxes ui-helper-reset">'); h.find("option").each(function(){var a=d(this),b=a.html(),c=a.val(),j=c.length,k=a.parent(),u=k.is("optgroup"),q=a.is(":disabled"),r=["ui-corner-all"],s=[];if(u){k=k.attr("label");if(d.inArray(k,p)===-1){g.push('<li class="ui-multiselect-optgroup-label"><a href="#">'+k+"</a></li>");p.push(k)}}if(j>0){if(q){r.push("ui-state-disabled");s.push("ui-multiselect-disabled")}g.push('<li class="'+s.join(" ")+'">');g.push('<label class="'+r.join(" ")+'"><input type="checkbox" name="'+h.attr("name")+'" value="'+ c+'" title="'+b+'"');a.is(":selected")&&g.push(' checked="checked"');q&&g.push(' disabled="disabled"');g.push(" />"+b+"</label></li>")}});g.push("</ul></div>");h=h.after(g.join("")).next("a.ui-multiselect");e=h.next("div.ui-multiselect-options");$header=e.find("div.ui-multiselect-header");l=e.find("label").not(".ui-state-disabled");i=h.find("span.ui-icon").outerWidth();var n=$original.outerWidth(),o=n+i;if(/\d/.test(f.minWidth)&&o<f.minWidth){n=f.minWidth-i;o=f.minWidth}h.width(o+"px").find("input").width(n+ "px");f.showHeader&&$header.find("a").click(function(a){var b=d(a.target);if(b.hasClass("ui-multiselect-close"))e.trigger("close");else{b=b.hasClass("ui-multiselect-all");e.trigger("toggleChecked",[b?true:false]);f[b?"onCheckAll":"onUncheckAll"].call(this)}a.preventDefault()});h.bind({click:function(){e.trigger("toggle")},keypress:function(a){switch(a.keyCode){case 27:case 38:e.trigger("close");break;case 40:case 0:e.trigger("toggle");break}},mouseenter:function(){d(this).addClass("ui-state-hover")}, mouseleave:function(){d(this).removeClass("ui-state-hover")},focus:function(){d(this).addClass("ui-state-focus")},blur:function(){d(this).removeClass("ui-state-focus")}});e.bind({close:function(a,b){b=b||false;if(b===true)d("div.ui-multiselect-options").filter(":visible").fadeOut(f.fadeSpeed).prev("a.ui-multiselect").removeClass("ui-state-active").trigger("mouseout");else{h.removeClass("ui-state-active").trigger("mouseout");e.fadeOut(f.fadeSpeed)}},open:function(){var a=h.position(),b=e.find("ul:last"), c,j;h.addClass("ui-state-active");e.trigger("close",[true]);c=f.position==="middle"?a.top+h.height()/2-e.outerHeight()/2:f.position==="top"?a.top-e.outerHeight():a.top+h.outerHeight();j=h.width()-parseInt(e.css("padding-left"))-parseInt(e.css("padding-right"));l.filter("label:first").trigger("mouseenter").trigger("focus");e.css({position:"absolute",top:c+"px",left:a.left+"px",width:j+"px"}).show();b.scrollTop(0);f.maxHeight&&b.css("height",f.maxHeight);f.onOpen.call(e[0])},toggle:function(){e.trigger(d(this).is(":hidden")? "open":"close")},traverse:function(a,b,c){a=d(b);c=c===38||c===37?true:false;a=a.parent()[c?"prevAll":"nextAll"]("li:not(.ui-multiselect-disabled, .ui-multiselect-optgroup-label)")[c?"last":"first"]();if(a.length)a.find("label").trigger("mouseenter");else{a=e.find("ul:last");e.find("label")[c?"last":"first"]().trigger("mouseover");a.scrollTop(c?a.height():0)}},toggleChecked:function(a,b,c){(c&&c.length?c:l.find("input")).not(":disabled").attr("checked",b?"checked":"");m()}}).find("li.ui-multiselect-optgroup-label a").click(function(a){var b= d(this).parent().nextUntil("li.ui-multiselect-optgroup-label").find("input"),c=b.length,j=b.filter(":checked").length;e.trigger("toggleChecked",[j===c?false:true,b]);f.onOptgroupToggle.call(this,b.get());a.preventDefault()});l.bind({mouseenter:function(){l.removeClass("ui-state-hover");d(this).addClass("ui-state-hover").find("input").focus()},click:function(a){a.preventDefault();d(this).find("input").trigger("click",[true])},keyup:function(a){switch(a.keyCode){case 27:e.trigger("close");break;case 38:case 40:case 37:case 39:e.trigger("traverse", [this,a.keyCode]);break;case 13:a.preventDefault();d(this).click();break}}}).find("input").bind("click",function(a,b){var c=d(this);b=b||false;a.stopPropagation();if(b){a.preventDefault();c.attr("checked",c.is(":checked")?"":"checked")}f.onCheck.call(c[0]);m()});d.fn.bgiframe&&e.bgiframe();$original.remove();h.find("input")[0].defaultValue=m()};d(document).bind("click",function(i){i=d(i.target);!i.closest("div.ui-multiselect-options").length&&!i.parent().hasClass("ui-multiselect")&&d("div.ui-multiselect-options").trigger("close", [true])});d.fn.multiSelect.defaults={showHeader:true,maxHeight:175,minWidth:200,checkAllText:"Check all",unCheckAllText:"Uncheck all",noneSelected:"Select options",selectedList:false,selectedText:"# selected",position:"bottom",shadow:false,fadeSpeed:200,onCheck:function(){},onOpen:function(){},onCheckAll:function(){},onUncheckAll:function(){},onOptgroupToggle:function(){}}})(jQuery);