(function (n) { n.fn.niceSelect = function (e) { if ("string" == typeof e) return "update" == e ? this.each(function () { var e = n(this), t = n(this).next(".nice-select"), i = t.hasClass("open"); t.length && (t.remove(), s(e), i && e.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")), this; function s(e) { e.after(n("
").addClass("nice-select").addClass(e.attr("class") || "").addClass(e.attr("disabled") ? "disabled" : "").attr("tabindex", e.attr("disabled") ? null : "0").html('')); var a = e.next(), t = e.find("option"), i = e.find("option:selected"), e = e.find("option:selected").data("placeholder"); a.find(".current").html(i.data("display") || i.text()), a.find(".current").addClass(e ? "placeholder" : ""), t.each(function (e) { var t = n(this), i = t.data("display"), s = t.data("placeholder"); a.find("ul").append(n("
  • ").attr("data-value", t.val()).attr("data-display", i || null).attr("data-placeholder", s || null).addClass("option" + (t.is(":selected") ? " selected" : "") + (t.is(":disabled") ? " disabled" : "")).html(t.text())) }) } this.hide(), this.each(function () { var e = n(this); e.next().hasClass("nice-select") || 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(".focus").removeClass("focus"), t.find(".selected").addClass("focus")) : t.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), i = t.closest(".nice-select"); i.find(".selected").removeClass("selected"), t.addClass("selected"); var s = t.data("display") || t.text(); i.find(".current").text(s), i.find(".current").removeClass("placeholder"), n(this).data("placeholder") && i.find(".current").addClass("placeholder"), i.prev("select").val(t.data("value")).trigger("change") }), n(document).on("keydown.nice_select", ".nice-select", function (e) { var t, i = n(this), s = n(i.find(".focus") || i.find(".list .option.selected")); if (32 == e.keyCode || 13 == e.keyCode) return (i.hasClass("open") ? s : i).trigger("click"), !1; if (40 == e.keyCode) return i.hasClass("open") ? 0 < (t = s.nextAll(".option:not(.disabled)").first()).length && (i.find(".focus").removeClass("focus"), t.addClass("focus")) : i.trigger("click"), !1; if (38 == e.keyCode) return i.hasClass("open") ? 0 < (s = s.prevAll(".option:not(.disabled)").first()).length && (i.find(".focus").removeClass("focus"), s.addClass("focus")) : i.trigger("click"), !1; if (27 == e.keyCode) i.hasClass("open") && i.trigger("click"); else if (9 == e.keyCode && i.hasClass("open")) return !1 }); e = document.createElement("a").style; return e.cssText = "pointer-events:auto", "auto" !== e.pointerEvents && n("html").addClass("no-csspointerevents"), this } })(jQuery);