text: !function(n){n.fn.niceSelect=function(e){if("string"==typeof e)return"update"==e?this.each(function(e,t){var s=n(this),l=n(this).next(".nice-select"),c=l.hasClass("open");l.length&&(l.remove(),a(s,e),c&&s.next().trigger("click"))}):"destroy"==e?(this.each(function(){var e=n(this),t=n(this).next(".nice-select");t.length&&(t.remove(),e.css("display",""))}),0==n(".nice-select").length&&n(document).off(".nice_select")):console.log('Method "'+e+'" does not exist.'),this;function a(e,t){e.after(n("<div></div>").addClass("nice-select").addClass(e.attr("class")||"").addClass(e.attr("disabled")?"disabled":"").addClass(e.attr("multiple")?"has-multiple":"").attr("tabindex",e.attr("disabled")?null:"0").css("zIndex",1001-t).html(e.attr("multiple")?'<span class="multiple-options"></span><ul class="list"></ul>':'<span class="current"></span><ul class="list"></ul>'));var c=e.next(),s=e.find("option");if(e.attr("multiple")){var l=e.find("option:selected"),a="";l.each(function(){$selected_option=n(this),$selected_text=$selected_option.data("display")||$selected_option.text(),$selected_option.val()&&(a+='<span class="current">'+$selected_text+"</span>")}),$select_placeholder=e.data("js-placeholder")||e.attr("js-placeholder"),$select_placeholder=$select_placeholder||"Select",console.log($select_placeholder),a=""===a?$select_placeholder:a,c.find(".multiple-options").html(a)}else{l=e.find("option:selected");c.find(".current").html(l.data("display")||l.text())}s.each(function(e){var t=n(this),s=t.data("display"),l=t.data("url")?'<a href="'+t.data("url")+'"> '+t.text()+"</a>":t.text();c.find("ul").append(n("<li></li>").attr("data-value",t.val()).attr("data-display",s||null).addClass("option"+(t.is(":selected")?" selected":"")+(t.is(":disabled")?" disabled":"")).html(l))}),c.find("ul").outerWidth()&&c.css("width",c.find("ul").outerWidth())}this.hide(),this.each(function(e,t){var s=n(this);s.next().hasClass("nice-select")||a(s,e)}),n(document).off(".nice_select"),n(document).on("click.nice_select",".nice-select",function(e){var t=n(this);n(".nice-select").not(t).removeClass("open"),t.toggleClass("open"),t.hasClass("open")?(t.find(".option"),t.find(".nice-select-search").val(""),t.find(".nice-select-search").focus(),t.find(".focus").removeClass("focus"),t.find(".selected").addClass("focus"),t.find("ul li").show()):t.focus()}),n(document).on("click",".nice-select-search-box",function(e){return e.stopPropagation(),!1}),n(document).on("keyup.nice-select-search",".nice-select",function(){var e=n(this),t=e.find(".nice-select-search").val(),s=e.find("ul li");if(""==t)s.show();else if(e.hasClass("open")){t=t.toLowerCase();var l=new RegExp(t);0<s.length?s.each(function(){var e=n(this),t=e.text().toLowerCase();l.test(t)?e.show():e.hide()}):s.show()}e.find(".option"),e.find(".focus").removeClass("focus"),e.find(".selected").addClass("focus")}),n(document).on("click.nice_select",function(e){0===n(e.target).closest(".nice-select").length&&n(".nice-select").removeClass("open").find(".option")}),n(document).on("click.nice_select",".nice-select .option:not(.disabled)",function(e){var t=n(this),s=t.closest(".nice-select");if(s.hasClass("has-multiple"))console.log("clicked",t),t.hasClass("selected")?t.removeClass("selected"):t.addClass("selected"),$selected_html="",$selected_values=[],s.find(".selected").each(function(){$selected_option=n(this);var e=$selected_option.data("display")||$selected_option.text();$selected_html+='<span class="current">'+e+"</span>",$selected_values.push($selected_option.data("value"))}),$select_placeholder=s.prev("select").data("js-placeholder")||s.prev("select").attr("js-placeholder"),console.log(s.prev("select")),$select_placeholder=$select_placeholder||"Select",$selected_html=""===$selected_html?$select_placeholder:$selected_html,s.find(".multiple-options").html($selected_html),s.prev("select").val($selected_values).trigger("change");else{s.find(".selected").removeClass("selected"),t.addClass("selected");var l=t.data("display")||t.text();s.find(".current").text(l),s.prev("select").val(t.data("value")).trigger("change")}}),n(document).on("keydown.nice_select",".nice-select",function(e){var t=n(this),s=n(t.find(".focus")||t.find(".list .option.selected"));if(32==e.keyCode||13==e.keyCode)return t.hasClass("open")?s.trigger("click"):t.trigger("click"),!1;if(40==e.keyCode){if(t.hasClass("open")){var l=s.nextAll(".option:not(.disabled)").first();0<l.length&&(t.find(".focus").removeClass("focus"),l.addClass("focus"))}else t.trigger("click");return!1}if(38==e.keyCode){if(t.hasClass("open")){var c=s.prevAll(".option:not(.disabled)").first();0<c.length&&(t.find(".focus").removeClass("focus"),c.addClass("focus"))}else t.trigger("click");return!1}if(27==e.keyCode)t.hasClass("open")&&t.trigger("click");else if(9==e.keyCode&&t.hasClass("open"))return!1});var t=document.createElement("a").style;return t.cssText="pointer-events:auto","auto"!==t.pointerEvents&&n("html").addClass("no-csspointerevents"),this}}(jQuery);