1/* Chosen v1.1.0 | (c) 2011-2013 by Harvest | MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md */ 2!function () { 3 var a, 4 AbstractChosen, 5 Chosen, 6 SelectParser, 7 b, 8 c = {}.hasOwnProperty, 9 d = function (a, b) { 10 function d() { 11 this.constructor = a; 12 } 13 for (var e in b) c.call(b, e) && (a[e] = b[e]); 14 return (d.prototype = b.prototype), (a.prototype = new d()), (a.__super__ = b.prototype), a; 15 }; 16 (SelectParser = (function () { 17 function SelectParser() { 18 (this.options_index = 0), (this.parsed = []); 19 } 20 return ( 21 (SelectParser.prototype.add_node = function (a) { 22 return "OPTGROUP" === a.nodeName.toUpperCase() ? this.add_group(a) : this.add_option(a); 23 }), 24 (SelectParser.prototype.add_group = function (a) { 25 var b, c, d, e, f, g; 26 for (b = this.parsed.length, this.parsed.push({ array_index: b, group: !0, label: this.escapeExpression(a.label), children: 0, disabled: a.disabled }), f = a.childNodes, g = [], d = 0, e = f.length; e > d; d++) 27 (c = f[d]), g.push(this.add_option(c, b, a.disabled)); 28 return g; 29 }), 30 (SelectParser.prototype.add_option = function (a, b, c) { 31 return "OPTION" === a.nodeName.toUpperCase() 32 ? ("" !== a.text 33 ? (null != b && (this.parsed[b].children += 1), 34 this.parsed.push({ 35 array_index: this.parsed.length, 36 options_index: this.options_index, 37 value: a.value, 38 text: a.text, 39 html: a.innerHTML, 40 selected: a.selected, 41 disabled: c === !0 ? c : a.disabled, 42 group_array_index: b, 43 classes: a.className, 44 style: a.style.cssText, 45 })) 46 : this.parsed.push({ array_index: this.parsed.length, options_index: this.options_index, empty: !0 }), 47 (this.options_index += 1)) 48 : void 0; 49 }), 50 (SelectParser.prototype.escapeExpression = function (a) { 51 var b, c; 52 return null == a || a === !1 53 ? "" 54 : /[\&\<\>\"\'\`]/.test(a) 55 ? ((b = { "<": "<", ">": ">", '"': """, "'": "'", "`": "`" }), 56 (c = /&(?!\w+;)|[\<\>\"\'\`]/g), 57 a.replace(c, function (a) { 58 return b[a] || "&"; 59 })) 60 : a; 61 }), 62 SelectParser 63 ); 64 })()), 65 (SelectParser.select_to_array = function (a) { 66 var b, c, d, e, f; 67 for (c = new SelectParser(), f = a.childNodes, d = 0, e = f.length; e > d; d++) (b = f[d]), c.add_node(b); 68 return c.parsed; 69 }), 70 (AbstractChosen = (function () { 71 function AbstractChosen(a, b) { 72 (this.form_field = a), 73 (this.options = null != b ? b : {}), 74 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()); 75 } 76 return ( 77 (AbstractChosen.prototype.set_default_values = function () { 78 var a = this; 79 return ( 80 (this.click_test_action = function (b) { 81 return a.test_active_click(b); 82 }), 83 (this.activate_action = function (b) { 84 return a.activate_field(b); 85 }), 86 (this.active_field = !1), 87 (this.mouse_on_container = !1), 88 (this.results_showing = !1), 89 (this.result_highlighted = null),
90 (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), 91 (this.disable_search_threshold = this.options.disable_search_threshold || 0), 92 (this.disable_search = this.options.disable_search || !1), 93 (this.enable_split_word_search = null != this.options.enable_split_word_search ? this.options.enable_split_word_search : !0), 94 (this.group_search = null != this.options.group_search ? this.options.group_search : !0), 95 (this.search_contains = this.options.search_contains || !1), 96 (this.single_backstroke_delete = null != this.options.single_backstroke_delete ? this.options.single_backstroke_delete : !0), 97 (this.max_selected_options = this.options.max_selected_options || 1 / 0), 98 (this.inherit_select_classes = this.options.inherit_select_classes || !1), 99 (this.display_selected_options = null != this.options.display_selected_options ? this.options.display_selected_options : !0), 100 (this.display_disabled_options = null != this.options.display_disabled_options ? this.options.display_disabled_options : !0) 101 ); 102 }), 103 (AbstractChosen.prototype.set_default_text = function () { 104 return ( 105 (this.default_text = this.form_field.getAttribute("data-placeholder") 106 ? this.form_field.getAttribute("data-placeholder") 107 : this.is_multiple 108 ? this.options.placeholder_text_multiple || this.options.placeholder_text || AbstractChosen.default_multiple_text 109 : this.options.placeholder_text_single || this.options.placeholder_text || AbstractChosen.default_single_text), 110 (this.results_none_found = this.form_field.getAttribute("data-no_results_text") || this.options.no_results_text || AbstractChosen.default_no_result_text) 111 ); 112 }), 113 (AbstractChosen.prototype.mouse_enter = function () { 114 return (this.mouse_on_container = !0); 115 }), 116 (AbstractChosen.prototype.mouse_leave = function () { 117 return (this.mouse_on_container = !1); 118 }), 119 (AbstractChosen.prototype.input_focus = function () { 120 var a = this; 121 if (this.is_multiple) { 122 if (!this.active_field) 123 return setTimeout(function () { 124 return a.container_mousedown(); 125 }, 50); 126 } else if (!this.active_field) return this.activate_field(); 127 }), 128 (AbstractChosen.prototype.input_blur = function () { 129 var a = this; 130 return this.mouse_on_container 131 ? void 0 132 : ((this.active_field = !1), 133 setTimeout(function () { 134 return a.blur_test(); 135 }, 100)); 136 }), 137 (AbstractChosen.prototype.results_option_build = function (a) { 138 var b, c, d, e, f; 139 for (b = "", f = this.results_data, d = 0, e = f.length; e > d; d++) 140 (c = f[d]), 141 (b += c.group ? this.result_add_group(c) : this.result_add_option(c)), 142 (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(c.text)); 143 return b; 144 }), 145 (AbstractChosen.prototype.result_add_option = function (a) { 146 var b, c; 147 return a.search_match 148 ? this.include_option_in_results(a) 149 ? ((b = []), 150 a.disabled || (a.selected && this.is_multiple) || b.push("active-result"), 151 !a.disabled || (a.selected && this.is_multiple) || b.push("disabled-result"), 152 a.selected && b.push("result-selected"), 153 null != a.group_array_index && b.push("group-option"), 154 "" !== a.classes && b.push(a.classes), 155 (c = document.createElement("li")), 156 (c.className = b.join(" ")), 157 (c.style.cssText = a.style), 158 c.setAttribute("data-option-array-index", a.array_index), 159 (c.innerHTML = a.search_text), 160 this.outerHTML(c)) 161 : "" 162 : ""; 163 }), 164 (AbstractChosen.prototype.result_add_group = function (a) { 165 var b;
166 return a.search_match || a.group_match ? (a.active_options > 0 ? ((b = document.createElement("li")), (b.className = "group-result"), (b.innerHTML = a.search_text), this.outerHTML(b)) : "") : ""; 167 }), 168 (AbstractChosen.prototype.results_update_field = function () { 169 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; 170 }), 171 (AbstractChosen.prototype.reset_single_select_options = function () { 172 var a, b, c, d, e; 173 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); 174 return e; 175 }), 176 (AbstractChosen.prototype.results_toggle = function () { 177 return this.results_showing ? this.results_hide() : this.results_show(); 178 }), 179 (AbstractChosen.prototype.results_search = function () { 180 return this.results_showing ? this.winnow_results() : this.results_show(); 181 }), 182 (AbstractChosen.prototype.winnow_results = function () { 183 var a, b, c, d, e, f, g, h, i, j, k, l, m; 184 for ( 185 this.no_results_clear(), 186 e = 0, 187 g = this.get_search_text(), 188 a = g.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 189 d = this.search_contains ? "" : "^", 190 c = new RegExp(d + a, "i"), 191 j = new RegExp(a, "i"), 192 m = this.results_data, 193 k = 0, 194 l = m.length; 195 l > k; 196 k++ 197 ) 198 (b = m[k]), 199 (b.search_match = !1), 200 (f = null), 201 this.include_option_in_results(b) && 202 (b.group && ((b.group_match = !1), (b.active_options = 0)), 203 null != b.group_array_index && this.results_data[b.group_array_index] && ((f = this.results_data[b.group_array_index]), 0 === f.active_options && f.search_match && (e += 1), (f.active_options += 1)), 204 (!b.group || this.group_search) && 205 ((b.search_text = b.group ? b.label : b.html), 206 (b.search_match = this.search_string_match(b.search_text, c)), 207 b.search_match && !b.group && (e += 1), 208 b.search_match 209 ? (g.length && ((h = b.search_text.search(j)), (i = b.search_text.substr(0, h + g.length) + "</em>" + b.search_text.substr(h + g.length)), (b.search_text = i.substr(0, h) + "<em>" + i.substr(h))), 210 null != f && (f.group_match = !0)) 211 : null != b.group_array_index && this.results_data[b.group_array_index].search_match && (b.search_match = !0))); 212 return this.result_clear_highlight(), 1 > e && g.length ? (this.update_results_content(""), this.no_results(g)) : (this.update_results_content(this.results_option_build()), this.winnow_results_set_highlight()); 213 }), 214 (AbstractChosen.prototype.search_string_match = function (a, b) { 215 var c, d, e, f; 216 if (b.test(a)) return !0; 217 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; 218 }), 219 (AbstractChosen.prototype.choices_count = function () { 220 var a, b, c, d; 221 if (null != this.selected_option_count) return this.selected_option_count; 222 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); 223 return this.selected_option_count; 224 }), 225 (AbstractChosen.prototype.choices_click = function (a) { 226 return a.preventDefault(), this.results_showing || this.is_disabled ? void 0 : this.results_show(); 227 }), 228 (AbstractChosen.prototype.keyup_checker = function (a) { 229 var b, c; 230 switch (((b = null != (c = a.which) ? c : a.keyCode), this.search_field_scale(), b)) { 231 case 8: 232 if (this.is_multiple && this.backstroke_length < 1 && this.choices_count() > 0) return this.keydown_backstroke(); 233 if (!this.pending_backstroke) return this.result_clear_highlight(), this.results_search(); 234 break; 235 case 13: 236 if ((a.preventDefault(), this.results_showing)) return this.result_select(a); 237 break; 238 case 27: 239 return this.results_showing && this.results_hide(), !0; 240 case 9: 241 case 38: 242 case 40: 243 case 16: 244 case 91: 245 case 17: 246 break; 247 default: 248 return this.results_search(); 249 } 250 }), 251 (AbstractChosen.prototype.clipboard_event_checker = function () { 252 var a = this; 253 return setTimeout(function () { 254 return a.results_search(); 255 }, 50); 256 }), 257 (AbstractChosen.prototype.container_width = function () { 258 return null != this.options.width ? this.options.width : "" + this.form_field.offsetWidth + "px"; 259 }), 260 (AbstractChosen.prototype.include_option_in_results = function (a) { 261 return this.is_multiple && !this.display_selected_options && a.selected ? !1 : !this.display_disabled_options && a.disabled ? !1 : a.empty ? !1 : !0; 262 }), 263 (AbstractChosen.prototype.search_results_touchstart = function (a) { 264 return (this.touch_started = !0), this.search_results_mouseover(a); 265 }), 266 (AbstractChosen.prototype.search_results_touchmove = function (a) { 267 return (this.touch_started = !1), this.search_results_mouseout(a); 268 }), 269 (AbstractChosen.prototype.search_results_touchend = function (a) { 270 return this.touch_started ? this.search_results_mouseup(a) : void 0; 271 }), 272 (AbstractChosen.prototype.outerHTML = function (a) { 273 var b; 274 return a.outerHTML ? a.outerHTML : ((b = document.createElement("div")), b.appendChild(a), b.innerHTML); 275 }), 276 (AbstractChosen.browser_is_supported = function () { 277 return "Microsoft Internet Explorer" === window.navigator.appName 278 ? document.documentMode >= 8 279 : /iP(od|hone)/i.test(window.navigator.userAgent) 280 ? !0 281 : /Android/i.test(window.navigator.userAgent) && /Mobile/i.test(window.navigator.userAgent) 282 ? !0 283 : !0; 284 }), 285 (AbstractChosen.default_multiple_text = "Select Some Options"), 286 (AbstractChosen.default_single_text = "Select an Option"), 287 (AbstractChosen.default_no_result_text = "No results match"), 288 AbstractChosen 289 ); 290 })()), 291 (a = jQuery), 292 a.fn.extend({ 293 chosen: function (b) { 294 return AbstractChosen.browser_is_supported() 295 ? this.each(function () { 296 var c, d; 297 (c = a(this)), (d = c.data("chosen")), "destroy" === b && d ? d.destroy() : d || c.data("chosen", new Chosen(this, b)); 298 }) 299 : this; 300 }, 301 }), 302 (Chosen = (function (c) { 303 function Chosen() { 304 return (b = Chosen.__super__.constructor.apply(this, arguments)); 305 } 306 return ( 307 d(Chosen, c), 308 (Chosen.prototype.setup = function () { 309 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")); 310 }), 311 (Chosen.prototype.set_up_html = function () { 312 var b, c; 313 return ( 314 (b = ["chosen-container"]), 315 b.push("chosen-container-" + (this.is_multiple ? "multi" : "single")), 316 this.inherit_select_classes && this.form_field.className && b.push(this.form_field.className), 317 this.is_rtl && b.push("chosen-rtl"), 318 (c = { class: b.join(" "), style: "width: " + this.container_width() + ";", title: this.form_field.title }), 319 this.form_field.id.length && (c.id = this.form_field.id.replace(/[^\w]/g, "_") + "_chosen"), 320 (this.container = a("<div />", c)), 321 this.is_multiple 322 ? this.container.html( 323 '<ul class="chosen-choices"><li class="search-field"><input type="text" value="' + 324 this.default_text + 325 '" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chosen-drop"><ul class="chosen-results"></ul></div>' 326 ) 327 : this.container.html( 328 '<a class="chosen-single chosen-default" tabindex="-1"><span>' + 329 this.default_text + 330 '</span><div><b></b></div></a><div class="chosen-drop"><div class="chosen-search"><input type="text" autocomplete="off" /></div><ul class="chosen-results"></ul></div>' 331 ), 332 this.form_field_jq.hide().after(this.container), 333 (this.dropdown = this.container.find("div.chosen-drop").first()), 334 (this.search_field = this.container.find("input").first()), 335 (this.search_results = this.container.find("ul.chosen-results").first()), 336 this.search_field_scale(), 337 (this.search_no_results = this.container.find("li.no-results").first()), 338 this.is_multiple 339 ? ((this.search_choices = this.container.find("ul.chosen-choices").first()), (this.search_container = this.container.find("li.search-field").first())) 340 : ((this.search_container = this.container.find("div.chosen-search").first()), (this.selected_item = this.container.find(".chosen-single").first())), 341 this.results_build(), 342 this.set_tab_index(), 343 this.set_label_behavior(), 344 this.form_field_jq.trigger("chosen:ready", { chosen: this }) 345 ); 346 }), 347 (Chosen.prototype.register_observers = function () { 348 var a = this; 349 return ( 350 this.container.bind("mousedown.chosen", function (b) { 351 a.container_mousedown(b); 352 }), 353 this.container.bind("mouseup.chosen", function (b) { 354 a.container_mouseup(b); 355 }), 356 this.container.bind("mouseenter.chosen", function (b) { 357 a.mouse_enter(b); 358 }), 359 this.container.bind("mouseleave.chosen", function (b) { 360 a.mouse_leave(b); 361 }), 362 this.search_results.bind("mouseup.chosen", function (b) { 363 a.search_results_mouseup(b); 364 }), 365 this.search_results.bind("mouseover.chosen", function (b) { 366 a.search_results_mouseover(b); 367 }), 368 this.search_results.bind("mouseout.chosen", function (b) { 369 a.search_results_mouseout(b); 370 }), 371 this.search_results.bind("mousewheel.chosen DOMMouseScroll.chosen", function (b) { 372 a.search_results_mousewheel(b); 373 }), 374 this.search_results.bind("touchstart.chosen", function (b) { 375 a.search_results_touchstart(b); 376 }), 377 this.search_results.bind("touchmove.chosen", function (b) { 378 a.search_results_touchmove(b); 379 }), 380 this.search_results.bind("touchend.chosen", function (b) { 381 a.search_results_touchend(b); 382 }), 383 this.form_field_jq.bind("chosen:updated.chosen", function (b) { 384 a.results_update_field(b); 385 }), 386 this.form_field_jq.bind("chosen:activate.chosen", function (b) { 387 a.activate_field(b); 388 }), 389 this.form_field_jq.bind("chosen:open.chosen", function (b) { 390 a.container_mousedown(b); 391 }), 392 this.form_field_jq.bind("chosen:close.chosen", function (b) { 393 a.input_blur(b); 394 }), 395 this.search_field.bind("blur.chosen", function (b) { 396 a.input_blur(b); 397 }), 398 this.search_field.bind("keyup.chosen", function (b) { 399 a.keyup_checker(b); 400 }), 401 this.search_field.bind("keydown.chosen", function (b) { 402 a.keydown_checker(b); 403 }), 404 this.search_field.bind("focus.chosen", function (b) { 405 a.input_focus(b); 406 }), 407 this.search_field.bind("cut.chosen", function (b) { 408 a.clipboard_event_checker(b); 409 }), 410 this.search_field.bind("paste.chosen", function (b) { 411 a.clipboard_event_checker(b); 412 }), 413 this.is_multiple 414 ? this.search_choices.bind("click.chosen", function (b) { 415 a.choices_click(b); 416 }) 417 : this.container.bind("click.chosen", function (a) { 418 a.preventDefault(); 419 }) 420 ); 421 }), 422 (Chosen.prototype.destroy = function () { 423 return ( 424 a(this.container[0].ownerDocument).unbind("click.chosen", this.click_test_action), 425 this.search_field[0].tabIndex && (this.form_field_jq[0].tabIndex = this.search_field[0].tabIndex), 426
426 this.container.remove(), 427 this.form_field_jq.removeData("chosen"), 428 this.form_field_jq.show() 429 ); 430 }), 431 (Chosen.prototype.search_field_disabled = function () { 432 return ( 433 (this.is_disabled = this.form_field_jq[0].disabled), 434 this.is_disabled 435 ? (this.container.addClass("chosen-disabled"), (this.search_field[0].disabled = !0), this.is_multiple || this.selected_item.unbind("focus.chosen", this.activate_action), this.close_field()) 436 : (this.container.removeClass("chosen-disabled"), (this.search_field[0].disabled = !1), this.is_multiple ? void 0 : this.selected_item.bind("focus.chosen", this.activate_action)) 437 ); 438 }), 439 (Chosen.prototype.container_mousedown = function (b) { 440 return this.is_disabled || (b && "mousedown" === b.type && !this.results_showing && b.preventDefault(), null != b && a(b.target).hasClass("search-choice-close")) 441 ? void 0 442 : (this.active_field 443 ? this.is_multiple || !b || (a(b.target)[0] !== this.selected_item[0] && !a(b.target).parents("a.chosen-single").length) || (b.preventDefault(), this.results_toggle()) 444 : (this.is_multiple && this.search_field.val(""), a(this.container[0].ownerDocument).bind("click.chosen", this.click_test_action), this.results_show()), 445 this.activate_field()); 446 }), 447 (Chosen.prototype.container_mouseup = function (a) { 448 return "ABBR" !== a.target.nodeName || this.is_disabled ? void 0 : this.results_reset(a); 449 }), 450 (Chosen.prototype.search_results_mousewheel = function (a) { 451 var b; 452 return ( 453 a.originalEvent && (b = -a.originalEvent.wheelDelta || a.originalEvent.detail), 454 null != b ? (a.preventDefault(), "DOMMouseScroll" === a.type && (b = 40 * b), this.search_results.scrollTop(b + this.search_results.scrollTop())) : void 0 455 ); 456 }), 457 (Chosen.prototype.blur_test = function () { 458 return !this.active_field && this.container.hasClass("chosen-container-active") ? this.close_field() : void 0; 459 }), 460 (Chosen.prototype.close_field = function () { 461 return ( 462 a(this.container[0].ownerDocument).unbind("click.chosen", this.click_test_action), 463 (this.active_field = !1), 464 this.results_hide(), 465 this.container.removeClass("chosen-container-active"), 466 this.clear_backstroke(), 467 this.show_search_field_default(), 468 this.search_field_scale() 469 ); 470 }), 471 (Chosen.prototype.activate_field = function () { 472 return this.container.addClass("chosen-container-active"), (this.active_field = !0), this.search_field.val(this.search_field.val()), this.search_field.focus(); 473 }), 474 (Chosen.prototype.test_active_click = function (b) { 475 var c; 476 return (c = a(b.target).closest(".chosen-container")), c.length && this.container[0] === c[0] ? (this.active_field = !0) : this.close_field(); 477 }), 478 (Chosen.prototype.results_build = function () { 479 return ( 480 (this.parsing = !0), 481 (this.selected_option_count = null), 482 (this.results_data = SelectParser.select_to_array(this.form_field)), 483 this.is_multiple 484 ? this.search_choices.find("li.search-choice").remove() 485 : this.is_multiple || 486 (this.single_set_selected_text(), 487 this.disable_search || this.form_field.options.length <= this.disable_search_threshold 488 ? ((this.search_field[0].readOnly = !0), this.container.addClass("chosen-container-single-nosearch")) 489 : ((this.search_field[0].readOnly = !1), this.container.removeClass("chosen-container-single-nosearch"))), 490 this.update_results_content(this.results_option_build({ first: !0 })), 491 this.search_field_disabled(), 492 this.show_search_field_default(), 493 this.search_field_scale(), 494 (this.parsing = !1) 495 ); 496 }), 497 (Chosen.prototype.result_do_highlight = function (a) { 498 var b, c, d, e, f; 499 if (a.length) { 500 if ( 501 (this.result_clear_highlight(), 502 (this.result_highlight = a), 503 this.result_highlight.addClass("highlighted"), 504 (d = parseInt(this.search_results.css("maxHeight"), 10)), 505 (f = this.search_results.scrollTop()), 506 (e = d + f), 507 (c = this.result_highlight.position().top + this.search_results.scrollTop()), 508 (b = c + this.result_highlight.outerHeight()), 509 b >= e) 510 ) 511 return this.search_results.scrollTop(b - d > 0 ? b - d : 0); 512 if (f > c) return this.search_results.scrollTop(c); 513 } 514 }), 515 (Chosen.prototype.result_clear_highlight = function () { 516 return this.result_highlight && this.result_highlight.removeClass("highlighted"), (this.result_highlight = null); 517 }), 518 (Chosen.prototype.results_show = function () { 519 return this.is_multiple && this.max_selected_options <= this.choices_count() 520 ? (this.form_field_jq.trigger("chosen:maxselected", { chosen: this }), !1) 521 : (this.container.addClass("chosen-with-drop"), 522 (this.results_showing = !0), 523 this.search_field.focus(), 524 this.search_field.val(this.search_field.val()), 525 this.winnow_results(), 526 this.form_field_jq.trigger("chosen:showing_dropdown", { chosen: this })); 527 }), 528 (Chosen.prototype.update_results_content = function (a) { 529 return this.search_results.html(a); 530 }), 531 (Chosen.prototype.results_hide = function () { 532 return this.results_showing && (this.result_clear_highlight(), this.container.removeClass("chosen-with-drop"), this.form_field_jq.trigger("chosen:hiding_dropdown", { chosen: this })), (this.results_showing = !1); 533 }), 534 (Chosen.prototype.set_tab_index = function () { 535 var a; 536 return this.form_field.tabIndex ? ((a = this.form_field.tabIndex), (this.form_field.tabIndex = -1), (this.search_field[0].tabIndex = a)) : void 0; 537 }), 538 (Chosen.prototype.set_label_behavior = function () { 539 var b = this; 540 return ( 541 (this.form_field_label = this.form_field_jq.parents("label")), 542 !this.form_field_label.length && this.form_field.id.length && (this.form_field_label = a("label[for='" + this.form_field.id + "']")), 543 this.form_field_label.length > 0 544 ? this.form_field_label.bind("click.chosen", function (a) { 545 return b.is_multiple ? b.container_mousedown(a) : b.activate_field(); 546 }) 547 : void 0 548 ); 549 }), 550 (Chosen.prototype.show_search_field_default = function () { 551 return this.is_multiple && this.choices_count() < 1 && !this.active_field 552 ? (this.search_field.val(this.default_text), this.search_field.addClass("default")) 553 : (this.search_field.val(""), this.search_field.removeClass("default")); 554 }), 555 (Chosen.prototype.search_results_mouseup = function (b) { 556 var c; 557 return (c = a(b.target).hasClass("active-result") ? a(b.target) : a(b.target).parents(".active-result").first()), c.length ? ((this.result_highlight = c), this.result_select(b), this.search_field.focus()) : void 0; 558 }), 559 (Chosen.prototype.search_results_mouseover = function (b) { 560 var c; 561 return (c = a(b.target).hasClass("active-result") ? a(b.target) : a(b.target).parents(".active-result").first()), c ? this.result_do_highlight(c) : void 0; 562 }), 563 (Chosen.prototype.search_results_mouseout = function (b) { 564 return a(b.target).hasClass("active-result") ? this.result_clear_highlight() : void 0; 565 }), 566 (Chosen.prototype.choice_build = function (b) { 567 var c, 568 d, 569 e = this; 570 return ( 571 (c = a("<li />", { class: "search-choice" }).html("<span>" + b.html + "</span>")), 572 b.disabled 573 ? c.addClass("search-choice-disabled") 574 : ((d = a("<a />", { class: "search-choice-close", "data-option-array-index": b.array_index })), 575 d.bind("click.chosen", function (a) { 576 return e.choice_destroy_link_click(a); 577 }), 578 c.append(d)), 579 this.search_container.before(c) 580 ); 581 }), 582 (Chosen.prototype.choice_destroy_link_click = function (b) { 583 return b.preventDefault(), b.stopPropagation(), this.is_disabled ? void 0 : this.choice_destroy(a(b.target)); 584 }), 585 (Chosen.prototype.choice_destroy = function (a) {
586 return this.result_deselect(a[0].getAttribute("data-option-array-index")) 587 ? (this.show_search_field_default(), this.is_multiple && this.choices_count() > 0 && this.search_field.val().length < 1 && this.results_hide(), a.parents("li").first().remove(), this.search_field_scale()) 588 : void 0; 589 }), 590 (Chosen.prototype.results_reset = function () { 591 return ( 592 this.reset_single_select_options(), 593 (this.form_field.options[0].selected = !0), 594 this.single_set_selected_text(), 595 this.show_search_field_default(), 596 this.results_reset_cleanup(), 597 this.form_field_jq.trigger("change"), 598 this.active_field ? this.results_hide() : void 0 599 ); 600 }), 601 (Chosen.prototype.results_reset_cleanup = function () { 602 return (this.current_selectedIndex = this.form_field.selectedIndex), this.selected_item.find("abbr").remove(); 603 }), 604 (Chosen.prototype.result_select = function (a) { 605 var b, c; 606 return this.result_highlight 607 ? ((b = this.result_highlight), 608 this.result_clear_highlight(), 609 this.is_multiple && this.max_selected_options <= this.choices_count() 610 ? (this.form_field_jq.trigger("chosen:maxselected", { chosen: this }), !1) 611 : (this.is_multiple ? b.removeClass("active-result") : this.reset_single_select_options(), 612 (c = this.results_data[b[0].getAttribute("data-option-array-index")]), 613 (c.selected = !0), 614 (this.form_field.options[c.options_index].selected = !0), 615 (this.selected_option_count = null), 616 this.is_multiple ? this.choice_build(c) : this.single_set_selected_text(c.text), 617 ((a.metaKey || a.ctrlKey) && this.is_multiple) || this.results_hide(), 618 this.search_field.val(""), 619 (this.is_multiple || this.form_field.selectedIndex !== this.current_selectedIndex) && this.form_field_jq.trigger("change", { selected: this.form_field.options[c.options_index].value }), 620 (this.current_selectedIndex = this.form_field.selectedIndex), 621 this.search_field_scale())) 622 : void 0; 623 }), 624 (Chosen.prototype.single_set_selected_text = function (a) { 625 return ( 626 null == a && (a = this.default_text), 627 a === this.default_text ? this.selected_item.addClass("chosen-default") : (this.single_deselect_control_build(), this.selected_item.removeClass("chosen-default")), 628 this.selected_item.find("span").text(a) 629 ); 630 }), 631 (Chosen.prototype.result_deselect = function (a) { 632 var b; 633 return ( 634 (b = this.results_data[a]), 635 this.form_field.options[b.options_index].disabled 636 ? !1 637 : ((b.selected = !1), 638 (this.form_field.options[b.options_index].selected = !1), 639 (this.selected_option_count = null), 640 this.result_clear_highlight(), 641 this.results_showing && this.winnow_results(), 642 this.form_field_jq.trigger("change", { deselected: this.form_field.options[b.options_index].value }), 643 this.search_field_scale(), 644 !0) 645 ); 646 }), 647 (Chosen.prototype.single_deselect_control_build = function () { 648 return this.allow_single_deselect 649 ? (this.selected_item.find("abbr").length || this.selected_item.find("span").first().after('<abbr class="search-choice-close"></abbr>'), this.selected_item.addClass("chosen-single-with-deselect")) 650 : void 0; 651 }), 652 (Chosen.prototype.get_search_text = function () { 653 return this.search_field.val() === this.default_text ? "" : a("<div/>").text(a.trim(this.search_field.val())).html(); 654 }), 655 (Chosen.prototype.winnow_results_set_highlight = function () { 656 var a, b; 657 return ( 658 (b = this.is_multiple ? [] : this.search_results.find(".result-selected.active-result")), 659 (a = b.length ? b.first() : this.search_results.find(".active-result").first()), 660 null != a ? this.result_do_highlight(a) : void 0 661 ); 662 }), 663 (Chosen.prototype.no_results = function (b) { 664 var c; 665 return ( 666 (c = a('<li class="no-results">' + this.results_none_found + ' "<span></span>"</li>')), c.find("span").first().html(b), this.search_results.append(c), this.form_field_jq.trigger("chosen:no_results", { chosen: this }) 667 ); 668 }), 669 (Chosen.prototype.no_results_clear = function () { 670 return this.search_results.find(".no-results").remove(); 671 }), 672 (Chosen.prototype.keydown_arrow = function () { 673 var a; 674 return this.results_showing && this.result_highlight ? ((a = this.result_highlight.nextAll("li.active-result").first()) ? this.result_do_highlight(a) : void 0) : this.results_show(); 675 }), 676 (Chosen.prototype.keyup_arrow = function () { 677 var a; 678 return this.results_showing || this.is_multiple 679 ? this.result_highlight 680 ? ((a = this.result_highlight.prevAll("li.active-result")), a.length ? this.result_do_highlight(a.first()) : (this.choices_count() > 0 && this.results_hide(), this.result_clear_highlight())) 681 : void 0 682 : this.results_show(); 683 }), 684 (Chosen.prototype.keydown_backstroke = function () { 685 var a; 686 return this.pending_backstroke 687 ? (this.choice_destroy(this.pending_backstroke.find("a").first()), this.clear_backstroke()) 688 : ((a = this.search_container.siblings("li.search-choice").last()), 689 a.length && !a.hasClass("search-choice-disabled") ? ((this.pending_backstroke = a), this.single_backstroke_delete ? this.keydown_backstroke() : this.pending_backstroke.addClass("search-choice-focus")) : void 0); 690 }), 691 (Chosen.prototype.clear_backstroke = function () { 692 return this.pending_backstroke && this.pending_backstroke.removeClass("search-choice-focus"), (this.pending_backstroke = null); 693 }), 694 (Chosen.prototype.keydown_checker = function (a) { 695 var b, c; 696 switch (((b = null != (c = a.which) ? c : a.keyCode), this.search_field_scale(), 8 !== b && this.pending_backstroke && this.clear_backstroke(), b)) { 697 case 8: 698 this.backstroke_length = this.search_field.val().length; 699 break; 700 case 9: 701 this.results_showing && !this.is_multiple && this.result_select(a), (this.mouse_on_container = !1); 702 break; 703 case 13: 704 a.preventDefault(); 705 break; 706 case 38: 707 a.preventDefault(), this.keyup_arrow(); 708 break; 709 case 40: 710 a.preventDefault(), this.keydown_arrow(); 711 } 712 }), 713 (Chosen.prototype.search_field_scale = function () { 714 var b, c, d, e, f, g, h, i, j; 715 if (this.is_multiple) { 716 for ( 717 d = 0, 718 h = 0, 719 f = "position:absolute; left: -1000px; top: -1000px; display:none;", 720 g = ["font-size", "font-style", "font-weight", "font-family", "line-height", "text-transform", "letter-spacing"], 721 i = 0, 722 j = g.length; 723 j > i; 724 i++ 725 ) 726 (e = g[i]), (f += e + ":" + this.search_field.css(e) + ";"); 727 return ( 728 (b = a("<div />", { style: f })), 729 b.text(this.search_field.val()), 730 a("body").append(b), 731 (h = b.width() + 25), 732 b.remove(), 733 (c = this.container.outerWidth()), 734 h > c - 10 && (h = c - 10), 735 this.search_field.css({ width: h + "px" }) 736 ); 737 } 738 }), 739 Chosen 740 ); 741 })(AbstractChosen)); 742}.call(this);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.