/*! Selectric ϟ v1.6.6 (2014-04-04) - git.io/tjl9sQ - Copyright (c) 2014 Leonardo Santos - Dual licensed: MIT/GPL */ !function(a) { var b = "selectric", c = function(a) { var b, c = "40-46 50-53 54-57 62-70 71-74 61 47 77".replace(/\d+/g, "\\3$&").split(" "); for (b in c) { if (!c.hasOwnProperty(b)) return; a = a.toLowerCase().replace(RegExp("[" + c[b] + "]", "g"), "aeiouncy".charAt(b)) } return a }, d = function(d, e) { function f() { function d(a) { /^(9|13|27)$/.test(a.keyCode || a.which) && (a.stopPropagation(), k(v, !0)) } var f = B.children(); _$li = ""), H.html(G[w].text)), D.add(B).off(I), F.data(b, !0).prop("class", [r[6], B.prop("class"), N, e.responsive ? r[8] : ""].join(" ")), B.prop("disabled") ? C.prop("disabled", !0) : (F.removeClass(N).hover(function() { a(this).toggleClass(r[7]) }), C.prop("disabled", !1), e.openOnHover && D.on("mouseenter" + I, h), D.on(L, function(a) { s ? j() : h(a) }), C.off().on({keypress: d, keydown: function(a) { d(a), clearTimeout(u), u = setTimeout(function() { C.val("") }, e.keySearchTimeout); var b = a.keyCode || a.which; b > 36 && 41 > b && k(39 > b ? n() : m()) }, focusin: function(a) { C.one("blur", function() { C.blur() }), s || h(a) }}).on(Q, function() { C.val().length && a.each(G, function(a, b) { return RegExp("^" + C.val(), "i").test(b.slug) && !b.disabled ? (k(a), !1) : void 0 }) }), t = a("li", E.removeAttr("style")).click(function() { return k(a(this).index(), !0), !1 })) } function g() { var a = E.closest(":visible").children(":hidden"), b = e.maxHeight; a.addClass(O); var c = E.outerWidth(), d = D.outerWidth() - (c - E.width()); !e.expandToItemText || d > c ? z = d : (E.css("overflow", "scroll"), F.width(9e4), z = c, E.css("overflow", ""), F.width("")), E.width(z).height() > b && E.height(b), a.removeClass(O) } function h(b) { b.preventDefault(), b.stopPropagation(), g(), a("." + M).removeClass(M), s = !0, x = E.outerHeight(), i(), C.val("").is(":focus") || C.focus(), J.on(L, j), e.openOnHover && (clearTimeout(y), F.one("mouseleave" + I, function() { y = setTimeout(j, 500) })), F.addClass(M), l(v), e.onOpen(d) } function i() { s && (g(), E.css("top", F.offset().top + F.outerHeight() + x > K.scrollTop() + K.height() ? -x : ""), setTimeout(i, 100)) } function j(a) { if (!a && w != v) { var b = G[v].text; B.prop("selectedIndex", w = v).data("value", b).trigger("change", [b, w]), e.onChange(d), H.html(b) } J.off(I), F.removeClass(M), s = !1, e.onClose(d) } function k(a, b) { G[v = a].disabled || (t.removeClass(P).eq(a).addClass(P), l(a), b && j()) } function l(a) { var b = t.eq(a).outerHeight(), c = t[a].offsetTop, d = E.scrollTop(), e = c + 2 * b; E.scrollTop(e > d + x ? e - x : d > c - b ? c - b : d) } function m(a) { if (G[a = (v + 1) % A].disabled) for (; G[a = (a + 1) % A].disabled; ) ; return a } function n(a) { if (G[a = (v > 0 ? v : A) - 1].disabled) for (; G[a = (a > 0?a:A) - 1].disabled; ) ; return a } var o, e = a.extend({onOpen: a.noop, onClose: a.noop, onChange: a.noop, maxHeight: 300, keySearchTimeout: 500, arrowButtonMarkup: '', disableOnMobile: !0, openOnHover: !1, expandToItemText: !1, responsive: !1, customClass: {prefix: "selectric", postfixes: "Input Items Open Disabled TempShow HideSelect Wrapper Hover Responsive", camelCase: !0}}, e), p = e.customClass, q = p.postfixes.split(" "), r = []; if (!e.disableOnMobile || !/android|ip(hone|od|ad)/i.test(navigator.userAgent)) { for (; o = q.shift(); ) r.push(p.camelCase ? p.prefix + o : (p.prefix + o).replace(/([A-Z])/g, "-$&").toLowerCase()); var s, t, u, v, w, x, y, z, A, B = a(d), C = a(''), D = a('

' + e.arrowButtonMarkup + "

"), E = a('
'), F = B.data(b, !0).wrap("
").parent().append(D.add(E).add(C)), G = [], H = a(".label", D), I = ".sl", J = a(document), K = a(window), L = "click" + I, M = r[2], N = r[3], O = r[4], P = "selected", Q = "oninput"in C[0] ? "input" : "keyup"; B.wrap('
'), f(), B.on({refresh: f, destroy: function() { E.add(D).add(C).remove(), B.removeData(b).removeData("value").off(I + " refresh destroy open close").unwrap().unwrap() }, open: h, close: j}) } }; a.fn[b] = function(c, e) { return this.each(function() { a(this).data(b) ? "" + c === c && a(this).trigger(c) : d(this, c || e) }) } }(jQuery);