Permalink
Browse files

prepping 1.1

  • Loading branch information...
1 parent 7fb0650 commit f1032e404e0f5233c2b255a5421941b347aabe93 @ehynds committed May 26, 2010
Showing with 44 additions and 2 deletions.
  1. +10 −0 CHANGELOG
  2. +1 −1 demos/demos.htm
  3. BIN screenshot.gif
  4. +1 −1 src/jquery.multiselect.js
  5. +32 −0 src/jquery.multiselect.min.js
View
@@ -0,0 +1,10 @@
+jQuery UI Multiselect Widget Changelog
+
+Version 1.0
+==============================================
+Initial release
+
+
+Version 1.1 - 05/26/2010
+==============================================
+- Modified: renamed "_updateSelected" to "update", exposing it as a method in the process.
View
@@ -16,7 +16,7 @@
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.js" type="text/javascript"></script>
<script src="http://jqueryui.com/themeroller/themeswitchertool/" type="text/javascript"></script>
-<script src="../src/jquery.multiselect.js" type="text/javascript"></script>
+<script src="../src/jquery.multiselect.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -1,5 +1,5 @@
/*
- * jQuery MultiSelect UI Widget 1.0
+ * jQuery MultiSelect UI Widget 1.1
* Copyright (c) 2010 Eric Hynds
*
* http://www.erichynds.com/jquery-ui-multiselect-widget/
@@ -0,0 +1,32 @@
+/*
+ * jQuery MultiSelect UI Widget 1.1
+ * Copyright (c) 2010 Eric Hynds
+ *
+ * http://www.erichynds.com/jquery-ui-multiselect-widget/
+ *
+ * Depends:
+ * - jQuery 1.4.2
+ * - jQuery UI 1.8 (core, widget factory, and effects if you want to use them)
+ *
+ * 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 n=0;d.widget("ui.multiselect",{options:{header:true,height:175,minWidth:225,checkAllText:"Check all",uncheckAllText:"Uncheck all",noneSelectedText:"Select options",selectedText:"# selected",selectedList:0,show:"",hide:"",autoOpen:false,multiple:true},_create:function(){var a=this.element,b=this.options,c=[],e=[],h=a.attr("title");id=a.id||n++;name=a.attr("name");this.speed=400;this._isOpen=false;c.push('<button type="button" class="ui-multiselect ui-widget ui-state-default ui-corner-all"');
+h.length&&c.push(' title="'+h+'"');c.push('><span class="ui-icon ui-icon-triangle-1-s"></span>'+b.noneSelectedText+"</button>");c.push('<div class="ui-multiselect-menu ui-widget ui-widget-content ui-corner-all">');c.push('<div class="ui-widget-header ui-corner-all ui-multiselect-header ui-helper-clearfix">');c.push('<ul class="ui-helper-reset">');if(b.header===true){c.push('<li><a class="ui-multiselect-all" href=""><span class="ui-icon ui-icon-check"></span><span>'+b.checkAllText+"</span></a></li>");
+c.push('<li><a class="ui-multiselect-none" href=""><span class="ui-icon ui-icon-closethick"></span><span>'+b.uncheckAllText+"</span></a></li>")}else typeof b.header==="string"&&c.push("<li>"+b.header+"</li>");c.push('<li class="ui-multiselect-close"><a href="" class="ui-multiselect-close"><span class="ui-icon ui-icon-circle-close"></span></a></li>');c.push("</ul>");c.push("</div>");c.push('<ul class="ui-multiselect-checkboxes ui-helper-reset">');a.find("option").each(function(f){var i=d(this),k=i.html(),
+l=this.value;f=this.id||"ui-multiselect-"+id+"-option-"+f;var g=i.parent(),j=i.is(":disabled"),m=["ui-corner-all"];if(g.is("optgroup")){g=g.attr("label");if(d.inArray(g,e)===-1){c.push('<li class="ui-multiselect-optgroup-label"><a href="#">'+g+"</a></li>");e.push(g)}}if(l.length>0){j&&m.push("ui-state-disabled");c.push('<li class="'+(j?"ui-multiselect-disabled":"")+'">');c.push('<label for="'+f+'" class="'+m.join(" ")+'"><input id="'+f+'" type="'+(b.multiple?"checkbox":"radio")+'" name="'+name+'" value="'+
+l+'" title="'+k+'"');i.is(":selected")&&c.push(' checked="checked"');j&&c.push(' disabled="disabled"');c.push(" />"+k+"</label></li>")}});c.push("</ul></div>");this.button=a.after(c.join("")).hide().next("button");this.menu=this.button.next("div.ui-multiselect-menu");this.labels=this.menu.find("label");this.optiontags=this.element.find("option");this._setButtonWidth();this._setMenuWidth();this._bindEvents();d.ui.multiselect.instances.push(this.element);this.button[0].defaultValue=this.update()},_init:function(){this.options.header||
+this.menu.find("div.ui-multiselect-header").hide();this.options.autoOpen&&this.open();this.element.is(":disabled")&&this.disable()},_bindEvents:function(){var a=this;this.button.bind({click:function(){a[a._isOpen?"close":"open"]()},keypress:function(b){switch(b.keyCode){case 27:case 38:case 37:a.close();break;case 39:case 40:a.open();break}},mouseenter:function(){a.button.hasClass("ui-state-disabled")||d(this).addClass("ui-state-hover")},mouseleave:function(){d(this).removeClass("ui-state-hover")},
+focus:function(){a.button.hasClass("ui-state-disabled")||d(this).addClass("ui-state-focus")},blur:function(){d(this).removeClass("ui-state-focus")}});this.menu.find("div.ui-multiselect-header a").bind("click",function(b){d(this).hasClass("ui-multiselect-close")?a.close():a[d(this).hasClass("ui-multiselect-all")?"checkAll":"uncheckAll"]();b.preventDefault()}).end().find("li.ui-multiselect-optgroup-label a").bind("click",function(b){var c=d(this),e=c.parent().nextUntil("li.ui-multiselect-optgroup-label").find("input");
+a._toggleChecked(e.filter(":checked").length!==e.length,e);a._trigger("optgroupToggle",b,{inputs:e.get(),label:c.parent().text(),checked:e[0].checked});b.preventDefault()}).end().delegate("label","mouseenter",function(){if(!d(this).hasClass("ui-state-disabled")){a.labels.removeClass("ui-state-hover");d(this).addClass("ui-state-hover").find("input").focus()}}).delegate("label","keydown",function(b){switch(b.keyCode){case 9:case 27:a.close();break;case 38:case 40:case 37:case 39:a._traverse(b.keyCode,
+this);break;case 13:b.preventDefault();d(this).find("input").trigger("click");break}}).delegate("input","click",function(b){var c=d(this),e=this.value;if(c.is(":disabled")||a._trigger("click",b,{value:this.value,text:this.title,checked:this.checked})===false)b.preventDefault();else{a.optiontags.filter(function(){return this.value===e}).attr("selected",c.is(":checked"));a.update()}});d(document).bind("click",function(b){b=d(b.target);a._isOpen&&!b.closest("div.ui-multiselect-menu").length&&!b.is("button.ui-multiselect")&&
+a.close()})},_setButtonWidth:function(){var a=this.element.outerWidth(),b=this.options;if(/\d/.test(b.minWidth)&&a<b.minWidth)a=b.minWidth;this.button.width(a)},_setMenuWidth:function(){var a=this.menu,b=this.button.outerWidth()-parseInt(a.css("padding-left"),10)-parseInt(a.css("padding-right"),10)-parseInt(a.css("border-right-width"),10)-parseInt(a.css("border-left-width"),10);a.width(b)},update:function(){var a=this.options,b=this.labels.find("input"),c=b.filter(":checked"),e=c.length;a=e===0?a.noneSelectedText:
+d.isFunction(a.selectedText)?a.selectedText.call(this,e,b.length,c.get()):/\d/.test(a.selectedList)&&a.selectedList>0&&e<=a.selectedList?c.map(function(){return this.title}).get().join(", "):a.selectedText.replace("#",e).replace("#",b.length);return this.button.contents()[1].nodeValue=a},_traverse:function(a,b){var c=d(b),e=a===38||a===37?true:false;c=c.parent()[e?"prevAll":"nextAll"]("li:not(.ui-multiselect-disabled, .ui-multiselect-optgroup-label)")[e?"last":"first"]();if(c.length)c.find("label").trigger("mouseover");
+else{c=this.menu.find("ul:last");this.menu.find("label")[e?"last":"first"]().trigger("mouseover");c.scrollTop(e?c.height():0)}},_toggleChecked:function(a,b){(b&&b.length?b:this.labels.find("input")).not(":disabled").attr("checked",a?"checked":"");this.optiontags.not("disabled").attr("selected",a?"selected":"");this.update()},_toggleDisabled:function(a){this.button.attr("disabled",a?"disabled":"")[a?"addClass":"removeClass"]("ui-state-disabled");this.menu.find("input").attr("disabled",a?"disabled":
+"").parent()[a?"addClass":"removeClass"]("ui-state-disabled");this.element.attr("disabled",a?"disabled":"")},_getOtherInstances:function(){var a=this.element;return d.grep(d.ui.multiselect.instances,function(b){return b!==a})},open:function(){if(!(this._trigger("open")===false||this.button.hasClass("ui-state-disabled")||this._isOpen)){d.each(this._getOtherInstances(),function(){var f=d(this);f.multiselect("isOpen")&&f.multiselect("close")});var a=this.menu.find("ul:last"),b=this.options,c=b.show,
+e=this.speed,h=this.button.position();this.button.addClass("ui-state-active");this.labels.first().trigger("mouseover").trigger("mouseenter").find("input").trigger("focus");if(d.isArray(b.show)){c=b.show[0];e=b.show[1]||this.speed}this.menu.css({top:h.top+this.button.outerHeight(),left:h.left}).show(c,e);this._isOpen=true;a.scrollTop(0).height(b.height);return this}},close:function(){if(this._trigger("close")!==false){var a=this.options,b=a.hide,c=this.speed;if(d.isArray(a.hide)){b=a.hide[0];c=a.hide[1]||
+this.speed}this.menu.hide(b,c);this.button.removeClass("ui-state-active").trigger("blur").trigger("mouseleave");this._isOpen=false;return this}},enable:function(){this._toggleDisabled(false);return this},disable:function(){this._toggleDisabled(true);return this},checkAll:function(){this._toggleChecked(true);this._trigger("checkAll")},uncheckAll:function(){this._toggleChecked(false);this._trigger("uncheckAll");return this},destroy:function(){d.Widget.prototype.destroy.call(this);var a=d.inArray(this.element,
+d.ui.multiselect.instances);a>-1&&d.ui.multiselect.instances.splice(a,1);this.button.remove();this.menu.remove();this.element.show();return this},isOpen:function(){return this._isOpen},widget:function(){return this.menu},_setOption:function(a,b){this.options[a]=b;switch(a){case "header":this.menu.find("div.ui-multiselect-header")[b?"show":"hide"]();break;case "checkAllText":this.menu.find("a.ui-multiselect-all span").eq(-1).text(b);break;case "uncheckAllText":this.menu.find("a.ui-multiselect-none span").eq(-1).text(b);
+break;case "height":this.menu.find("ul:last").height(parseInt(b,10));break;case "minWidth":this.options[a]=parseInt(b,10);this._setButtonWidth();this._setMenuWidth();break;case "selectedText":case "selectedList":case "noneSelectedText":this.update();break}}});d.extend(d.ui.multiselect,{instances:[]})})(jQuery);

0 comments on commit f1032e4

Please sign in to comment.