/* Chosen v1.4.1 | (c) 2011-2015 by Harvest | MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md */
(function () {
var a, AbstractChosen, Chosen, SelectParser, b, c = {}.hasOwnProperty, d = function (a, b) {
function d() {
this.constructor = a
}
for (var e in b)c.call(b, e) && (a[e] = b[e]);
return d.prototype = b.prototype, a.prototype = new d, a.__super__ = b.prototype, a
};
SelectParser = function () {
function SelectParser() {
this.options_index = 0, this.parsed = []
}
return SelectParser.prototype.add_node = function (a) {
return "OPTGROUP" === a.nodeName.toUpperCase() ? this.add_group(a) : this.add_option(a)
}, SelectParser.prototype.add_group = function (a) {
var b, c, d, e, f, g;
for (b = this.parsed.length, this.parsed.push({
array_index: b,
group: !0,
label: this.escapeExpression(a.label),
title: a.title ? a.title : void 0,
children: 0,
disabled: a.disabled,
classes: a.className
}), f = a.childNodes, g = [], d = 0, e = f.length; e > d; d++)c = f[d], g.push(this.add_option(c, b, a.disabled));
return g
}, SelectParser.prototype.add_option = function (a, b, c) {
return "OPTION" === a.nodeName.toUpperCase() ? ("" !== a.text ? (null != b && (this.parsed[b].children += 1), this.parsed.push({
array_index: this.parsed.length,
options_index: this.options_index,
value: a.value,
text: a.text,
html: a.innerHTML,
title: a.title ? a.title : void 0,
selected: a.selected,
disabled: c === !0 ? c : a.disabled,
group_array_index: b,
group_label: null != b ? this.parsed[b].label : null,
classes: a.className,
style: a.style.cssText
})) : this.parsed.push({
array_index: this.parsed.length,
options_index: this.options_index,
empty: !0
}), this.options_index += 1) : void 0
}, SelectParser.prototype.escapeExpression = function (a) {
var b, c;
return null == a || a === !1 ? "" : /[\&\<\>\"\'\`]/.test(a) ? (b = {
"<": "<",
">": ">",
'"': """,
"'": "'",
"`": "`"
}, c = /&(?!\w+;)|[\<\>\"\'\`]/g, a.replace(c, function (a) {
return b[a] || "&"
})) : a
}, SelectParser
}(), SelectParser.select_to_array = function (a) {
var b, c, d, e, f;
for (c = new SelectParser, f = a.childNodes, d = 0, e = f.length; e > d; d++)b = f[d], c.add_node(b);
return c.parsed
}, AbstractChosen = function () {
function AbstractChosen(a, b) {
this.form_field = a, this.options = null != b ? b : {}, AbstractChosen.browser_is_supported() && (this.is_multiple = this.form_field.multiple, this.set_default_text(), this.set_default_values(), this.setup(), this.set_up_html(), this.register_observers(), this.on_ready())
}
return AbstractChosen.prototype.set_default_values = function () {
var a = this;
return this.click_test_action = function (b) {
return a.test_active_click(b)
}, this.activate_action = function (b) {
return a.activate_field(b)
}, this.active_field = !1, this.mouse_on_container = !1, this.results_showing = !1, this.result_highlighted = null, this.allow_single_deselect = null != this.options.allow_single_deselect && null != this.form_field.options[0] && "" === this.form_field.options[0].text ? this.options.allow_single_deselect : !1, this.disable_search_threshold = this.options.disable_search_threshold || 0, this.disable_search = this.options.disable_search || !1, this.enable_split_word_search = null != this.options.enable_split_word_search ? this.options.enable_split_word_search : !0, this.group_search = null != this.options.group_search ? this.options.group_search : !0, this.search_contains = this.options.search_contains || !1, this.single_backstroke_delete = null != this.options.single_backstroke_delete ? this.options.single_backstroke_delete : !0, this.max_selected_options = this.options.max_selected_options || 1 / 0, this.inherit_select_classes = this.options.inherit_select_classes || !1, this.display_selected_options = null != this.options.display_selected_options ? this.options.display_selected_options : !0, this.display_disabled_options = null != this.options.display_disabled_options ? this.options.display_disabled_options : !0, this.include_group_label_in_selected = this.options.include_group_label_in_selected || !1
}, AbstractChosen.prototype.set_default_text = function () {
return this.default_text = this.form_field.getAttribute("data-placeholder") ? this.form_field.getAttribute("data-placeholder") : this.is_multiple ? this.options.placeholder_text_multiple || this.options.placeholder_text || AbstractChosen.default_multiple_text : this.options.placeholder_text_single || this.options.placeholder_text || AbstractChosen.default_single_text, this.results_none_found = this.form_field.getAttribute("data-no_results_text") || this.options.no_results_text || AbstractChosen.default_no_result_text
}, AbstractChosen.prototype.choice_label = function (a) {
return this.include_group_label_in_selected && null != a.group_label ? "" + a.group_label + "" + a.html : a.html
}, AbstractChosen.prototype.mouse_enter = function () {
return this.mouse_on_container = !0
}, AbstractChosen.prototype.mouse_leave = function () {
return this.mouse_on_container = !1
}, AbstractChosen.prototype.input_focus = function () {
var a = this;
if (this.is_multiple) {
if (!this.active_field)return setTimeout(function () {
return a.container_mousedown()
}, 50)
} else if (!this.active_field)return this.activate_field()
}, AbstractChosen.prototype.input_blur = function () {
var a = this;
return this.mouse_on_container ? void 0 : (this.active_field = !1, setTimeout(function () {
return a.blur_test()
}, 100))
}, AbstractChosen.prototype.results_option_build = function (a) {
var b, c, d, e, f;
for (b = "", f = this.results_data, d = 0, e = f.length; e > d; d++)c = f[d], b += c.group ? this.result_add_group(c) : this.result_add_option(c), (null != a ? a.first : void 0) && (c.selected && this.is_multiple ? this.choice_build(c) : c.selected && !this.is_multiple && this.single_set_selected_text(this.choice_label(c)));
return b
}, AbstractChosen.prototype.result_add_option = function (a) {
var b, c;
return a.search_match ? this.include_option_in_results(a) ? (b = [], a.disabled || a.selected && this.is_multiple || b.push("active-result"), !a.disabled || a.selected && this.is_multiple || b.push("disabled-result"), a.selected && b.push("result-selected"), null != a.group_array_index && b.push("group-option"), "" !== a.classes && b.push(a.classes), c = document.createElement("li"), c.className = b.join(" "), c.style.cssText = a.style, c.setAttribute("data-option-array-index", a.array_index), c.innerHTML = a.search_text, a.title && (c.title = a.title), this.outerHTML(c)) : "" : ""
}, AbstractChosen.prototype.result_add_group = function (a) {
var b, c;
return a.search_match || a.group_match ? a.active_options > 0 ? (b = [], b.push("group-result"), a.classes && b.push(a.classes), c = document.createElement("li"), c.className = b.join(" "), c.innerHTML = a.search_text, a.title && (c.title = a.title), this.outerHTML(c)) : "" : ""
}, AbstractChosen.prototype.results_update_field = function () {
return this.set_default_text(), this.is_multiple || this.results_reset_cleanup(), this.result_clear_highlight(), this.results_build(), this.results_showing ? this.winnow_results() : void 0
}, AbstractChosen.prototype.reset_single_select_options = function () {
var a, b, c, d, e;
for (d = this.results_data, e = [], b = 0, c = d.length; c > b; b++)a = d[b], a.selected ? e.push(a.selected = !1) : e.push(void 0);
return e
}, AbstractChosen.prototype.results_toggle = function () {
return this.results_showing ? this.results_hide() : this.results_show()
}, AbstractChosen.prototype.results_search = function () {
return this.results_showing ? this.winnow_results() : this.results_show()
}, AbstractChosen.prototype.winnow_results = function () {
var a, b, c, d, e, f, g, h, i, j, k, l;
for (this.no_results_clear(), d = 0, f = this.get_search_text(), a = f.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), i = new RegExp(a, "i"), c = this.get_search_regex(a), l = this.results_data, j = 0, k = l.length; k > j; j++)b = l[j], b.search_match = !1, e = null, this.include_option_in_results(b) && (b.group && (b.group_match = !1, b.active_options = 0), null != b.group_array_index && this.results_data[b.group_array_index] && (e = this.results_data[b.group_array_index], 0 === e.active_options && e.search_match && (d += 1), e.active_options += 1), b.search_text = b.group ? b.label : b.html, (!b.group || this.group_search) && (b.search_match = this.search_string_match(b.search_text, c), b.search_match && !b.group && (d += 1), b.search_match ? (f.length && (g = b.search_text.search(i), h = b.search_text.substr(0, g + f.length) + "" + b.search_text.substr(g + f.length), b.search_text = h.substr(0, g) + "" + h.substr(g)), null != e && (e.group_match = !0)) : null != b.group_array_index && this.results_data[b.group_array_index].search_match && (b.search_match = !0)));
return this.result_clear_highlight(), 1 > d && f.length ? (this.update_results_content(""), this.no_results(f)) : (this.update_results_content(this.results_option_build()), this.winnow_results_set_highlight())
}, AbstractChosen.prototype.get_search_regex = function (a) {
var b;
return b = this.search_contains ? "" : "^", new RegExp(b + a, "i")
}, AbstractChosen.prototype.search_string_match = function (a, b) {
var c, d, e, f;
if (b.test(a))return !0;
if (this.enable_split_word_search && (a.indexOf(" ") >= 0 || 0 === a.indexOf("[")) && (d = a.replace(/\[|\]/g, "").split(" "), d.length))for (e = 0, f = d.length; f > e; e++)if (c = d[e], b.test(c))return !0
}, AbstractChosen.prototype.choices_count = function () {
var a, b, c, d;
if (null != this.selected_option_count)return this.selected_option_count;
for (this.selected_option_count = 0, d = this.form_field.options, b = 0, c = d.length; c > b; b++)a = d[b], a.selected && (this.selected_option_count += 1);
return this.selected_option_count
}, AbstractChosen.prototype.choices_click = function (a) {
return a.preventDefault(), this.results_showing || this.is_disabled ? void 0 : this.results_show()
}, AbstractChosen.prototype.keyup_checker = function (a) {
var b, c;
switch (b = null != (c = a.which) ? c : a.keyCode, this.search_field_scale(), b) {
case 8:
if (this.is_multiple && this.backstroke_length < 1 && this.choices_count() > 0)return this.keydown_backstroke();
if (!this.pending_backstroke)return this.result_clear_highlight(), this.results_search();
break;
case 13:
if (a.preventDefault(), this.results_showing)return this.result_select(a);
break;
case 27:
return this.results_showing && this.results_hide(), !0;
case 9:
case 38:
case 40:
case 16:
case 91:
case 17:
break;
default:
return this.results_search()
}
}, AbstractChosen.prototype.clipboard_event_checker = function () {
var a = this;
return setTimeout(function () {
return a.results_search()
}, 50)
}, AbstractChosen.prototype.container_width = function () {
return null != this.options.width ? this.options.width : "" + this.form_field.offsetWidth + "px"
}, AbstractChosen.prototype.include_option_in_results = function (a) {
return this.is_multiple && !this.display_selected_options && a.selected ? !1 : !this.display_disabled_options && a.disabled ? !1 : a.empty ? !1 : !0
}, AbstractChosen.prototype.search_results_touchstart = function (a) {
return this.touch_started = !0, this.search_results_mouseover(a)
}, AbstractChosen.prototype.search_results_touchmove = function (a) {
return this.touch_started = !1, this.search_results_mouseout(a)
}, AbstractChosen.prototype.search_results_touchend = function (a) {
return this.touch_started ? this.search_results_mouseup(a) : void 0
}, AbstractChosen.prototype.outerHTML = function (a) {
var b;
return a.outerHTML ? a.outerHTML : (b = document.createElement("div"), b.appendChild(a), b.innerHTML)
}, AbstractChosen.browser_is_supported = function () {
return "Microsoft Internet Explorer" === window.navigator.appName ? document.documentMode >= 8 : /iP(od|hone)/i.test(window.navigator.userAgent) ? !1 : /Android/i.test(window.navigator.userAgent) && /Mobile/i.test(window.navigator.userAgent) ? !1 : !0
}, AbstractChosen.default_multiple_text = "Select Some Options", AbstractChosen.default_single_text = "Select an Option", AbstractChosen.default_no_result_text = "No results match", AbstractChosen
}(), a = jQuery, a.fn.extend({
chosen: function (b) {
return AbstractChosen.browser_is_supported() ? this.each(function () {
var c, d;
c = a(this), d = c.data("chosen"), "destroy" === b && d instanceof Chosen ? d.destroy() : d instanceof Chosen || c.data("chosen", new Chosen(this, b))
}) : this
}
}), Chosen = function (c) {
function Chosen() {
return b = Chosen.__super__.constructor.apply(this, arguments)
}
return d(Chosen, c), Chosen.prototype.setup = function () {
return this.form_field_jq = a(this.form_field), this.current_selectedIndex = this.form_field.selectedIndex, this.is_rtl = this.form_field_jq.hasClass("chosen-rtl")
}, Chosen.prototype.set_up_html = function () {
var b, c;
return b = ["chosen-container"], b.push("chosen-container-" + (this.is_multiple ? "multi" : "single")), this.inherit_select_classes && this.form_field.className && b.push(this.form_field.className), this.is_rtl && b.push("chosen-rtl"), c = {
"class": b.join(" "),
style: "width: " + this.container_width() + ";",
title: this.form_field.title
}, this.form_field.id.length && (c.id = this.form_field.id.replace(/[^\w]/g, "_") + "_chosen"), this.container = a("", c), this.is_multiple ? this.container.html('