!function(h){var o={placeholder:"Select options",columns:1,search:!1,searchOptions:{default:"Search",showOptGroups:!1,onSearch:function(t){}},selectAll:!1,selectGroup:!1,minHeight:200,maxHeight:null,showCheckbox:!0,jqActualOpts:{},onLoad:function(t){h(t).hide()},onOptionClick:function(t,e){},maxWidth:null,minSelect:!1,maxSelect:!1},i=1;function s(t,e){this.element=t,this.options=h.extend({},o,e),this.load()}s.prototype={load:function(){var o=this;if("SELECT"!=o.element.nodeName||h(o.element).hasClass("jqmsLoaded"))return!0;h(o.element).addClass("jqmsLoaded"),h(o.element).after('
');var t=h(o.element).next(".ms-options-wrap").find("> button:first-child"),i=h(o.element).next(".ms-options-wrap").find("> .ms-options"),s=i.find("> ul"),e=!!h(o.element).find("optgroup").length,n=null;"number"==typeof o.options.width?(i.parent().css("position","relative"),n=o.options.width):"string"==typeof o.options.width?(h(o.options.width).css("position","relative"),n="100%"):i.parent().css("position","relative");var l=h(window).height()-i.offset().top-20;if(o.options.maxHeight&&(l=(l=h(window).height()-i.offset().top-20)h(this)[0].scrollHeight&&(t.preventDefault(),this.scrollTop+=o<0?1:-1)}}),h(document).off("click.ms-hideopts").on("click.ms-hideopts",function(t){h(t.target).closest(".ms-options-wrap").length||h(".ms-options-wrap > .ms-options:visible").hide()}),t.bind("mousedown",function(t){if(1!=t.which)return!0;if(h(".ms-options-wrap > .ms-options:visible").each(function(){h(this).parent().prev()[0]!=i.parent().prev()[0]&&h(this).hide()}),i.toggle(),i.is(":visible")){i.css("maxHeight","");var e=h(window).height()-i.offset().top-20;o.options.maxHeight&&(e=(e=h(window).height()-i.offset().top-20)');var a=i.find(".ms-search input");a.on("keyup",function(){if(h(this).data("lastsearch")==h(this).val())return!0;h(this).data("lastsearch",h(this).val()),"function"==typeof o.options.searchOptions.onSearch&&o.options.searchOptions.onSearch(o.element),s.find("li:not(.optgroup)").each(function(){-1Select all'),i.on("click",".ms-selectall",function(t){if(t.preventDefault(),h(this).hasClass("global"))s.find("li:not(.optgroup)").filter(":not(.selected)").length?s.find("li:not(.optgroup)").filter(":not(.selected)").find('input[type="checkbox"]').trigger("click"):s.find('li:not(.optgroup).selected input[type="checkbox"]').trigger("click");else if(h(this).closest("li").hasClass("optgroup")){var e=h(this).closest("li.optgroup");e.find("li:not(.selected)").length?e.find('li:not(.selected) input[type="checkbox"]').trigger("click"):e.find('li.selected input[type="checkbox"]').trigger("click")}});var p=[];h(o.element).children().each(function(){if("OPTGROUP"==this.nodeName){var t=[];h(this).children("option").each(function(){t[h(this).val()]={name:h(this).text(),value:h(this).val(),checked:h(this).prop("selected")}}),p.push({label:h(this).attr("label"),options:t})}else{if("OPTION"!=this.nodeName)return!0;p.push({name:h(this).text(),value:h(this).val(),checked:h(this).prop("selected")})}}),o.loadOptions(p),e?(s.find("> li:not(.optgroup)").css({float:"left",width:100/o.options.columns+"%"}),s.find("li.optgroup").css({clear:"both"}).find("> ul").css({"column-count":o.options.columns,"column-gap":0,"-webkit-column-count":o.options.columns,"-webkit-column-gap":0,"-moz-column-count":o.options.columns,"-moz-column-gap":0}),this._ieVersion()&&this._ieVersion()<10&&s.find("li.optgroup > ul > li").css({float:"left",width:100/o.options.columns+"%"})):(s.css({"column-count":o.options.columns,"column-gap":0,"-webkit-column-count":o.options.columns,"-webkit-column-gap":0,"-moz-column-count":o.options.columns,"-moz-column-gap":0}),this._ieVersion()&&this._ieVersion()<10&&s.find("> li").css({float:"left",width:100/o.options.columns+"%"})),i.on("click",'input[type="checkbox"]',function(){h(this).closest("li").toggleClass("selected"),i.parent().prev().find('option[value="'+h(this).val()+'"]').prop("selected",h(this).is(":checked")).closest("select").trigger("change"),"function"==typeof o.options.onOptionClick&&o.options.onOptionClick(),o._updatePlaceholderText()}),"function"==typeof o.options.onLoad?o.options.onLoad(o.element):h(o.element).hide()},loadOptions:function(t,e){e="boolean"!=typeof e||e;var o=this,i=h(o.element).next(".ms-options-wrap").find("> .ms-options > ul");for(var s in e&&i.find("> li").remove(),t){var n=t[s],l=h("
  • ");if(n.hasOwnProperty("options"))for(var a in l.addClass("optgroup"),l.append(''+n.label+""),l.find("> .label").css({clear:"both"}),o.options.selectGroup&&l.append('Select all'),l.append("
      "),n.options){var p=n.options[a],c=h("
    • ").addClass("ms-reflow");o._addOption(c,p),l.find("> ul").append(c)}else n.hasOwnProperty("value")&&(l.addClass("ms-reflow"),o._addOption(l,n));i.append(l)}i.find('.ms-reflow input[type="checkbox"]').each(function(t){if(h(this).css("display").match(/block$/)){var e=h(this).outerWidth();e=e||15,h(this).closest("label").css("padding-left",2*parseInt(h(this).closest("label").css("padding-left"))+e),h(this).closest(".ms-reflow").removeClass("ms-reflow")}}),o._updatePlaceholderText()},unload:function(){h(this.element).next(".ms-options-wrap").remove(),h(this.element).show(function(){h(this).css("display","").removeClass("jqmsLoaded")})},reload:function(){h(this.element).next(".ms-options-wrap").remove(),h(this.element).removeClass("jqmsLoaded"),this.load()},_updatePlaceholderText:function(){var t=this,e=h(t.element).next(".ms-options-wrap").find("> button:first-child"),o=h(t.element).next(".ms-options-wrap").find("> .ms-options"),i=o.parent().prev(),s=[];i.find("option:selected").each(function(){s.push(h(this).text())}),e.text(s.join(", "));var n=e.clone().css({display:"inline",width:"auto",visibility:"hidden"}).appendTo(o.parent()),l=void 0!==h.fn.actual?n.actual("width",t.options.jqActualOpts):n.width();(void 0!==h.fn.actual?e.actual("width",t.options.jqActualOpts):e.width())').val(e.value).attr("title",e.name).attr("id","ms-opt-"+i)),e.checked&&(t.addClass("default"),t.addClass("selected"),t.find('input[type="checkbox"]').prop("checked",!0));var o=h("").attr("for","ms-opt-"+i);t.wrapInner(o),this.options.showCheckbox||t.find('input[id="ms-opt-'+i+'"]').hide(),i+=1},_ieVersion:function(){var t=navigator.userAgent.toLowerCase();return-1!=t.indexOf("msie")&&parseInt(t.split("msie")[1])}},h.fn.multiselect=function(e){var o,i=arguments;return void 0===e||"object"==typeof e?this.each(function(){h.data(this,"plugin_multiselect")||h.data(this,"plugin_multiselect",new s(this,e))}):"string"==typeof e&&"_"!==e[0]&&"init"!==e?(this.each(function(){var t=h.data(this,"plugin_multiselect");t instanceof s&&"function"==typeof t[e]&&(o=t[e].apply(t,Array.prototype.slice.call(i,1))),"unload"===e&&h.data(this,"plugin_multiselect",null)}),o):void 0}}(jQuery); //# sourceMappingURL=jquery.multiselect.js.map