1/* Chosen v1.6.1 | (c) 2011-2016 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 ( 15 (d.prototype = b.prototype), 16 (a.prototype = new d()), 17 (a.__super__ = b.prototype), 18 a 19 ); 20 }; 21 (SelectParser = (function () { 22 function SelectParser() { 23 (this.options_index = 0), (this.parsed = []); 24 } 25 return ( 26 (SelectParser.prototype.add_node = function (a) { 27 return "OPTGROUP" === a.nodeName.toUpperCase() 28 ? this.add_group(a) 29 : this.add_option(a); 30 }), 31 (SelectParser.prototype.add_group = function (a) { 32 var b, c, d, e, f, g; 33 for ( 34 b = this.parsed.length, 35 this.parsed.push({ 36 array_index: b, 37 group: !0, 38 label: this.escapeExpression(a.label), 39 title: a.title ? a.title : void 0, 40 children: 0, 41 disabled: a.disabled, 42 classes: a.className, 43 }), 44 f = a.childNodes, 45 g = [], 46 d = 0, 47 e = f.length; 48 e > d; 49 d++ 50 ) 51 (c = f[d]), g.push(this.add_option(c, b, a.disabled)); 52 return g; 53 }), 54 (SelectParser.prototype.add_option = function (a, b, c) { 55 return "OPTION" === a.nodeName.toUpperCase() 56 ? ("" !== a.text 57 ? (null != b && (this.parsed[b].children += 1), 58 this.parsed.push({ 59 array_index: this.parsed.length, 60 options_index: this.options_index, 61 value: a.value, 62 text: a.text, 63 html: a.innerHTML, 64 title: a.title ? a.title : void 0, 65 selected: a.selected, 66 disabled: c === !0 ? c : a.disabled, 67 group_array_index: b, 68 group_label: null != b ? this.parsed[b].label : null, 69 classes: a.className, 70 style: a.style.cssText, 71 })) 72 : this.parsed.push({ 73 array_index: this.parsed.length, 74 options_index: this.options_index, 75 empty: !0, 76 }), 77 (this.options_index += 1)) 78 : void 0; 79 }), 80 (SelectParser.prototype.escapeExpression = function (a) { 81 var b, c; 82 return null == a || a === !1 83 ? "" 84 : /[\&\<\>\"\'\`]/.test(a) 85 ? ((b = { 86 "<": "<", 87 ">": ">", 88 '"': """, 89 "'": "'", 90 "`": "`", 91 }), 92 (c = /&(?!\w+;)|[\<\>\"\'\`]/g), 93 a.replace(c, function (a) { 94 return b[a] || "&"; 95 })) 96 : a; 97 }), 98 SelectParser 99 ); 100 })()), 101 (SelectParser.select_to_array = function (a) { 102 var b, c, d, e, f; 103 for ( 104 c = new SelectParser(), f = a.childNodes, d = 0, e = f.length; 105 e > d; 106 d++ 107 ) 108 (b = f[d]), c.add_node(b); 109 return c.parsed; 110 }), 111 (AbstractChosen = (function () { 112 function AbstractChosen(a, b) { 113 (this.form_field = a), 114 (this.options = null != b ? b : {}), 115 AbstractChosen.browser_is_supported() && 116 ((this.is_multiple = this.form_field.multiple), 117 this.set_default_text(), 118 this.set_default_values(), 119 this.setup(), 120 this.set_up_html(), 121 this.register_observers(), 122 this.on_ready()); 123 } 124 return ( 125 (AbstractChosen.prototype.set_default_values = function () { 126 var a = this; 127 return ( 128 (this.click_test_action = function (b) { 129 return a.test_active_click(b); 130 }), 131 (this.activate_action = function (b) { 132 return a.activate_field(b); 133 }), 134 (this.active_field = !1), 135 (this.mouse_on_container = !1), 136 (this.results_showing = !1), 137 (this.result_highlighted = null),
138 (this.allow_single_deselect = 139 null != this.options.allow_single_deselect && 140 null != this.form_field.options[0] && 141 "" === this.form_field.options[0].text 142 ? this.options.allow_single_deselect 143 : !1), 144 (this.disable_search_threshold = 145 this.options.disable_search_threshold || 0), 146 (this.disable_search = this.options.disable_search || !1), 147 (this.enable_split_word_search = 148 null != this.options.enable_split_word_search 149 ? this.options.enable_split_word_search 150 : !0), 151 (this.group_search = 152 null != this.options.group_search 153 ? this.options.group_search 154 : !0), 155 (this.search_contains = this.options.search_contains || !1), 156 (this.single_backstroke_delete = 157 null != this.options.single_backstroke_delete 158 ? this.options.single_backstroke_delete 159 : !0), 160 (this.max_selected_options = 161 this.options.max_selected_options || 1 / 0), 162 (this.inherit_select_classes = 163 this.options.inherit_select_classes || !1), 164 (this.display_selected_options = 165 null != this.options.display_selected_options 166 ? this.options.display_selected_options 167 : !0), 168 (this.display_disabled_options = 169 null != this.options.display_disabled_options 170 ? this.options.display_disabled_options 171 : !0), 172 (this.include_group_label_in_selected = 173 this.options.include_group_label_in_selected || !1), 174 (this.max_shown_results = 175 this.options.max_shown_results || Number.POSITIVE_INFINITY), 176 (this.case_sensitive_search = 177 this.options.case_sensitive_search || !1) 178 ); 179 }), 180 (AbstractChosen.prototype.set_default_text = function () { 181 return ( 182 this.form_field.getAttribute("data-placeholder") 183 ? (this.default_text = 184 this.form_field.getAttribute("data-placeholder")) 185 : this.is_multiple 186 ? (this.default_text = 187 this.options.placeholder_text_multiple || 188 this.options.placeholder_text || 189 AbstractChosen.default_multiple_text) 190 : (this.default_text = 191 this.options.placeholder_text_single || 192 this.options.placeholder_text || 193 AbstractChosen.default_single_text), 194 (this.results_none_found = 195 this.form_field.getAttribute("data-no_results_text") || 196 this.options.no_results_text || 197 AbstractChosen.default_no_result_text) 198 ); 199 }), 200 (AbstractChosen.prototype.choice_label = function (a) { 201 return this.include_group_label_in_selected && null != a.group_label 202 ? "<b class='group-name'>" + a.group_label + "</b>" + a.html 203 : a.html; 204 }), 205 (AbstractChosen.prototype.mouse_enter = function () { 206 return (this.mouse_on_container = !0); 207 }), 208 (AbstractChosen.prototype.mouse_leave = function () { 209 return (this.mouse_on_container = !1); 210 }), 211 (AbstractChosen.prototype.input_focus = function (a) { 212 var b = this; 213 if (this.is_multiple) { 214 if (!this.active_field) 215 return setTimeout(function () { 216 return b.container_mousedown(); 217 }, 50); 218 } else if (!this.active_field) return this.activate_field(); 219 }), 220 (AbstractChosen.prototype.input_blur = function (a) { 221 var b = this; 222 return this.mouse_on_container 223 ? void 0 224 : ((this.active_field = !1), 225 setTimeout(function () { 226 return b.blur_test(); 227 }, 100)); 228 }), 229 (AbstractChosen.prototype.results_option_build = function (a) { 230 var b, c, d, e, f, g, h; 231 for ( 232 b = "", e = 0, h = this.results_data, f = 0, g = h.length; 233 g > f && 234 ((c = h[f]), 235 (d = ""), 236 (d = c.group 237 ? this.result_add_group(c) 238 : this.result_add_option(c)), 239 "" !== d && (e++, (b += d)), 240 (null != a ? a.first : void 0) && 241 (c.selected && this.is_multiple 242 ? this.choice_build(c) 243 : c.selected && 244 !this.is_multiple && 245 this.single_set_selected_text(this.choice_label(c))), 246 !(e >= this.max_shown_results)); 247 f++ 248 ); 249 return b; 250 }), 251 (AbstractChosen.prototype.result_add_option = function (a) { 252 var b, c; 253 return a.search_match && this.include_option_in_results(a) 254 ? ((b = []), 255 a.disabled || 256 (a.selected && this.is_multiple) || 257 b.push("active-result"), 258 !a.disabled || 259 (a.selected && this.is_multiple) || 260 b.push("disabled-result"), 261 a.selected && b.push("result-selected"), 262 null != a.group_array_index && b.push("group-option"), 263 "" !== a.classes && b.push(a.classes), 264 (c = document.createElement("li")), 265 (c.className = b.join(" ")), 266 (c.style.cssText = a.style), 267 c.setAttribute("data-option-array-index", a.array_index), 268 (c.innerHTML = a.search_text), 269 a.title && (c.title = a.title), 270 this.outerHTML(c)) 271 : ""; 272 }), 273 (AbstractChosen.prototype.result_add_group = function (a) { 274 var b, c; 275 return (a.search_match || a.group_match) && a.active_options > 0 276 ? ((b = []), 277 b.push("group-result"), 278 a.classes && b.push(a.classes), 279 (c = document.createElement("li")), 280 (c.className = b.join(" ")), 281 (c.innerHTML = a.search_text), 282 a.title && (c.title = a.title), 283 this.outerHTML(c)) 284 : ""; 285 }), 286 (AbstractChosen.prototype.results_update_field = function () { 287 return ( 288 this.set_default_text(), 289 this.is_multiple || this.results_reset_cleanup(), 290 this.result_clear_highlight(), 291 this.results_build(), 292 this.results_showing ? this.winnow_results() : void 0 293 ); 294 }), 295 (AbstractChosen.prototype.reset_single_select_options = function () { 296 var a, b, c, d, e; 297 for (d = this.results_data, e = [], b = 0, c = d.length; c > b; b++) 298 (a = d[b]), a.selected ? e.push((a.selected = !1)) : e.push(void 0); 299 return e; 300 }), 301 (AbstractChosen.prototype.results_toggle = function () { 302 return this.results_showing 303 ? this.results_hide() 304 : this.results_show(); 305 }), 306 (AbstractChosen.prototype.results_search = function (a) { 307 return this.results_showing 308 ? this.winnow_results() 309 : this.results_show(); 310 }), 311 (AbstractChosen.prototype.winnow_results = function () { 312 var a, b, c, d, e, f, g, h, i, j, k, l; 313 for ( 314 this.no_results_clear(), 315 d = 0, 316 f = this.get_search_text(), 317 a = f.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 318 i = new RegExp(a, "i"), 319 c = this.get_search_regex(a), 320 l = this.results_data, 321 j = 0, 322 k = l.length; 323 k > j; 324 j++ 325 ) 326 (b = l[j]), 327 (b.search_match = !1), 328 (e = null),
329 this.include_option_in_results(b) && 330 (b.group && ((b.group_match = !1), (b.active_options = 0)), 331 null != b.group_array_index && 332 this.results_data[b.group_array_index] && 333 ((e = this.results_data[b.group_array_index]), 334 0 === e.active_options && e.search_match && (d += 1), 335 (e.active_options += 1)), 336 (b.search_text = b.group ? b.label : b.html), 337 (!b.group || this.group_search) && 338 ((b.search_match = this.search_string_match( 339 b.search_text, 340 c 341 )), 342 b.search_match && !b.group && (d += 1), 343 b.search_match 344 ? (f.length && 345 ((g = b.search_text.search(i)), 346 (h = 347 b.search_text.substr(0, g + f.length) + 348 "</em>" + 349 b.search_text.substr(g + f.length)), 350 (b.search_text = 351 h.substr(0, g) + "<em>" + h.substr(g))), 352 null != e && (e.group_match = !0)) 353 : null != b.group_array_index && 354 this.results_data[b.group_array_index].search_match && 355 (b.search_match = !0))); 356 return ( 357 this.result_clear_highlight(), 358 1 > d && f.length 359 ? (this.update_results_content(""), this.no_results(f)) 360 : (this.update_results_content(this.results_option_build()), 361 this.winnow_results_set_highlight()) 362 ); 363 }), 364 (AbstractChosen.prototype.get_search_regex = function (a) { 365 var b, c; 366 return ( 367 (b = this.search_contains ? "" : "^"), 368 (c = this.case_sensitive_search ? "" : "i"), 369 new RegExp(b + a, c) 370 ); 371 }), 372 (AbstractChosen.prototype.search_string_match = function (a, b) { 373 var c, d, e, f; 374 if (b.test(a)) return !0; 375 if ( 376 this.enable_split_word_search && 377 (a.indexOf(" ") >= 0 || 0 === a.indexOf("[")) && 378 ((d = a.replace(/\[|\]/g, "").split(" ")), d.length) 379 ) 380 for (e = 0, f = d.length; f > e; e++) 381 if (((c = d[e]), b.test(c))) return !0; 382 }), 383 (AbstractChosen.prototype.choices_count = function () { 384 var a, b, c, d; 385 if (null != this.selected_option_count) 386 return this.selected_option_count; 387 for ( 388 this.selected_option_count = 0, 389 d = this.form_field.options, 390 b = 0, 391 c = d.length; 392 c > b; 393 b++ 394 ) 395 (a = d[b]), a.selected && (this.selected_option_count += 1); 396 return this.selected_option_count; 397 }), 398 (AbstractChosen.prototype.choices_click = function (a) { 399 return ( 400 a.preventDefault(), 401 this.results_showing || this.is_disabled 402 ? void 0 403 : this.results_show() 404 ); 405 }), 406 (AbstractChosen.prototype.keyup_checker = function (a) { 407 var b, c; 408 switch ( 409 ((b = null != (c = a.which) ? c : a.keyCode), 410 this.search_field_scale(), 411 b) 412 ) { 413 case 8: 414 if ( 415 this.is_multiple && 416 this.backstroke_length < 1 && 417 this.choices_count() > 0 418 ) 419 return this.keydown_backstroke(); 420 if (!this.pending_backstroke) 421 return this.result_clear_highlight(), this.results_search(); 422 break; 423 case 13: 424 if ((a.preventDefault(), this.results_showing)) 425 return this.result_select(a); 426 break; 427 case 27: 428 return this.results_showing && this.results_hide(), !0; 429 case 9: 430 case 38: 431 case 40: 432 case 16: 433 case 91: 434 case 17: 435 case 18: 436 break; 437 default: 438 return this.results_search(); 439 } 440 }), 441 (AbstractChosen.prototype.clipboard_event_checker = function (a) { 442 var b = this; 443 return setTimeout(function () { 444 return b.results_search(); 445 }, 50); 446 }), 447 (AbstractChosen.prototype.container_width = function () { 448 return null != this.options.width 449 ? this.options.width 450 : "" + this.form_field.offsetWidth + "px"; 451 }), 452 (AbstractChosen.prototype.include_option_in_results = function (a) { 453 return this.is_multiple && 454 !this.display_selected_options && 455 a.selected 456 ? !1 457 : !this.display_disabled_options && a.disabled 458 ? !1 459 : a.empty 460 ? !1 461 : !0; 462 }), 463 (AbstractChosen.prototype.search_results_touchstart = function (a) { 464 return (this.touch_started = !0), this.search_results_mouseover(a); 465 }), 466 (AbstractChosen.prototype.search_results_touchmove = function (a) { 467 return (this.touch_started = !1), this.search_results_mouseout(a); 468 }), 469 (AbstractChosen.prototype.search_results_touchend = function (a) { 470 return this.touch_started ? this.search_results_mouseup(a) : void 0; 471 }), 472 (AbstractChosen.prototype.outerHTML = function (a) { 473 var b; 474 return a.outerHTML 475 ? a.outerHTML 476 : ((b = document.createElement("div")), 477 b.appendChild(a), 478 b.innerHTML); 479 }), 480 (AbstractChosen.browser_is_supported = function () { 481 return "Microsoft Internet Explorer" === window.navigator.appName 482 ? document.documentMode >= 8 483 : /iPod/i.test(window.navigator.userAgent) || 484 /iPhone/i.test(window.navigator.userAgent) || 485 /IEMobile/i.test(window.navigator.userAgent) || 486 /Windows Phone/i.test(window.navigator.userAgent) || 487 /BlackBerry/i.test(window.navigator.userAgent) || 488 /BB10/i.test(window.navigator.userAgent) || 489 /Android.*Mobile/i.test(window.navigator.userAgent) 490 ? !1 491 : !0; 492 }), 493 (AbstractChosen.default_multiple_text = "Select Some Options"), 494 (AbstractChosen.default_single_text = "Select an Option"), 495 (AbstractChosen.default_no_result_text = "No results match"), 496 AbstractChosen 497 ); 498 })()), 499 (a = jQuery), 500 a.fn.extend({ 501 chosen: function (b) { 502 return AbstractChosen.browser_is_supported() 503 ? this.each(function (c) { 504 var d, e; 505 return ( 506 (d = a(this)), 507 (e = d.data("chosen")), 508 "destroy" === b 509 ? void (e instanceof Chosen && e.destroy()) 510 : void ( 511 e instanceof Chosen || 512 d.data("chosen", new Chosen(this, b)) 513 ) 514 ); 515 }) 516 : this; 517 }, 518 }), 519 (Chosen = (function (c) { 520 function Chosen() { 521 return (b = Chosen.__super__.constructor.apply(this, arguments)); 522 } 523 return ( 524 d(Chosen, c), 525 (Chosen.prototype.setup = function () { 526 return ( 527 (this.form_field_jq = a(this.form_field)), 528 (this.current_selectedIndex = this.form_field.selectedIndex), 529 (this.is_rtl = this.form_field_jq.hasClass("chosen-rtl")) 530 ); 531 }), 532 (Chosen.prototype.set_up_html = function () { 533 var b, c; 534 return ( 535 (b = ["chosen-container"]), 536 b.push( 537 "chosen-container-" + (this.is_multiple ? "multi" : "single") 538 ), 539 this.inherit_select_classes && 540 this.form_field.className && 541 b.push(this.form_field.className), 542 this.is_rtl && b.push("chosen-rtl"), 543 (c = { 544 class: b.join(" "), 545 style: "width: " + this.container_width() + ";", 546 title: this.form_field.title, 547 }), 548 this.form_field.id.length && 549 (c.id = this.form_field.id.replace(/[^\w]/g, "_") + "_chosen"), 550 (this.container = a("<div />", c)), 551 this.is_multiple 552 ? this.container.html( 553 '<ul class="chosen-choices"><li class="search-field"><input type="text" value="' + 554 this.default_text + 555 '" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chosen-drop"><ul class="chosen-results"></ul></div>' 556 ) 557 : this.container.html( 558 '<a class="chosen-single chosen-default"><span>' + 559 this.default_text + 560 '</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>' 561 ), 562 this.form_field_jq.hide().after(this.container), 563 (this.dropdown = this.container.find("div.chosen-drop").first()), 564 (this.search_field = this.container.find("input").first()), 565 (this.search_results = this.container 566 .find("ul.chosen-results") 567 .first()), 568 this.search_field_scale(), 569 (this.search_no_results = this.container 570 .find("li.no-results") 571 .first()), 572 this.is_multiple 573 ? ((this.search_choices = this.container 574 .find("ul.chosen-choices") 575 .first()), 576 (this.search_container = this.container 577 .find("li.search-field") 578 .first())) 579 : ((this.search_container = this.container 580 .find("div.chosen-search") 581 .first()), 582 (this.selected_item = this.container 583 .find(".chosen-single") 584 .first())), 585 this.results_build(), 586 this.set_tab_index(), 587 this.set_label_behavior() 588 ); 589 }), 590 (Chosen.prototype.on_ready = function () { 591 return this.form_field_jq.trigger("chosen:ready", { chosen: this }); 592 }), 593 (Chosen.prototype.register_observers = function () { 594 var a = this; 595 return ( 596 this.container.bind("touchstart.chosen", function (b) { 597 return a.container_mousedown(b), b.preventDefault(); 598 }), 599 this.container.bind("touchend.chosen", function (b) { 600 return a.container_mouseup(b), b.preventDefault(); 601 }), 602 this.container.bind("mousedown.chosen", function (b) { 603 a.container_mousedown(b); 604 }), 605 this.container.bind("mouseup.chosen", function (b) { 606 a.container_mouseup(b); 607 }), 608 this.container.bind("mouseenter.chosen", function (b) { 609 a.mouse_enter(b); 610 }), 611 this.container.bind("mouseleave.chosen", function (b) { 612 a.mouse_leave(b); 613 }), 614 this.search_results.bind("mouseup.chosen", function (b) { 615 a.search_results_mouseup(b); 616 }), 617 this.search_results.bind("mouseover.chosen", function (b) { 618 a.search_results_mouseover(b); 619 }), 620 this.search_results.bind("mouseout.chosen", function (b) { 621 a.search_results_mouseout(b); 622 }), 623 this.search_results.bind( 624 "mousewheel.chosen DOMMouseScroll.chosen", 625 function (b) { 626 a.search_results_mousewheel(b); 627 } 628 ), 629 this.search_results.bind("touchstart.chosen", function (b) { 630 a.search_results_touchstart(b); 631 }), 632 this.search_results.bind("touchmove.chosen", function (b) { 633 a.search_results_touchmove(b); 634 }), 635 this.search_results.bind("touchend.chosen", function (b) { 636 a.search_results_touchend(b); 637 }), 638 this.form_field_jq.bind("chosen:updated.chosen", function (b) { 639 a.results_update_field(b); 640 }), 641 this.form_field_jq.bind("chosen:activate.chosen", function (b) { 642 a.activate_field(b); 643 }), 644 this.form_field_jq.bind("chosen:open.chosen", function (b) { 645 a.container_mousedown(b); 646 }), 647 this.form_field_jq.bind("chosen:close.chosen", function (b) { 648 a.input_blur(b); 649 }), 650 this.search_field.bind("blur.chosen", function (b) { 651 a.input_blur(b); 652 }), 653 this.search_field.bind("keyup.chosen", function (b) { 654 a.keyup_checker(b); 655 }), 656 this.search_field.bind("keydown.chosen", function (b) { 657 a.keydown_checker(b); 658 }), 659 this.search_field.bind("focus.chosen", function (b) { 660 a.input_focus(b); 661 }), 662 this.search_field.bind("cut.chosen", function (b) { 663 a.clipboard_event_checker(b); 664 }), 665 this.search_field.bind("paste.chosen", function (b) { 666 a.clipboard_event_checker(b); 667 }), 668 this.is_multiple 669 ? this.search_choices.bind("click.chosen", function (b) { 670 a.choices_click(b); 671 }) 672 : this.container.bind("click.chosen", function (a) { 673 a.preventDefault(); 674 }) 675 ); 676 }), 677 (Chosen.prototype.destroy = function () { 678 return ( 679 a(this.container[0].ownerDocument).unbind( 680 "click.chosen", 681 this.click_test_action 682 ), 683 this.search_field[0].tabIndex && 684 (this.form_field_jq[0].tabIndex = this.search_field[0].tabIndex), 685 this.container.remove(), 686 this.form_field_jq.removeData("chosen"), 687 this.form_field_jq.show() 688 ); 689 }), 690 (Chosen.prototype.search_field_disabled = function () { 691 return ( 692 (this.is_disabled = this.form_field_jq[0].disabled), 693 this.is_disabled 694 ? (this.container.addClass("chosen-disabled"), 695 (this.search_field[0].disabled = !0), 696 this.is_multiple || 697 this.selected_item.unbind( 698 "focus.chosen", 699 this.activate_action 700 ), 701 this.close_field()) 702 : (this.container.removeClass("chosen-disabled"), 703 (this.search_field[0].disabled = !1), 704 this.is_multiple 705 ? void 0 706 : this.selected_item.bind( 707 "focus.chosen", 708 this.activate_action 709 )) 710 ); 711 }), 712 (Chosen.prototype.container_mousedown = function (b) { 713 return this.is_disabled || 714 (b && 715 "mousedown" === b.type && 716 !this.results_showing && 717 b.preventDefault(), 718 null != b && a(b.target).hasClass("search-choice-close")) 719 ? void 0 720 : (this.active_field 721 ? this.is_multiple || 722 !b || 723 (a(b.target)[0] !== this.selected_item[0] && 724 !a(b.target).parents("a.chosen-single").length) ||
725 (b.preventDefault(), this.results_toggle()) 726 : (this.is_multiple && this.search_field.val(""), 727 a(this.container[0].ownerDocument).bind( 728 "click.chosen", 729 this.click_test_action 730 ), 731 this.results_show()), 732 this.activate_field()); 733 }), 734 (Chosen.prototype.container_mouseup = function (a) { 735 return "ABBR" !== a.target.nodeName || this.is_disabled 736 ? void 0 737 : this.results_reset(a); 738 }), 739 (Chosen.prototype.search_results_mousewheel = function (a) { 740 var b; 741 return ( 742 a.originalEvent && 743 (b = 744 a.originalEvent.deltaY || 745 -a.originalEvent.wheelDelta || 746 a.originalEvent.detail), 747 null != b 748 ? (a.preventDefault(), 749 "DOMMouseScroll" === a.type && (b = 40 * b), 750 this.search_results.scrollTop( 751 b + this.search_results.scrollTop() 752 )) 753 : void 0 754 ); 755 }), 756 (Chosen.prototype.blur_test = function (a) { 757 return !this.active_field && 758 this.container.hasClass("chosen-container-active") 759 ? this.close_field() 760 : void 0; 761 }), 762 (Chosen.prototype.close_field = function () { 763 return ( 764 a(this.container[0].ownerDocument).unbind( 765 "click.chosen", 766 this.click_test_action 767 ), 768 (this.active_field = !1), 769 this.results_hide(), 770 this.container.removeClass("chosen-container-active"), 771 this.clear_backstroke(), 772 this.show_search_field_default(), 773 this.search_field_scale() 774 ); 775 }), 776 (Chosen.prototype.activate_field = function () { 777 return ( 778 this.container.addClass("chosen-container-active"), 779 (this.active_field = !0), 780 this.search_field.val(this.search_field.val()), 781 this.search_field.focus() 782 ); 783 }), 784 (Chosen.prototype.test_active_click = function (b) { 785 var c; 786 return ( 787 (c = a(b.target).closest(".chosen-container")), 788 c.length && this.container[0] === c[0] 789 ? (this.active_field = !0) 790 : this.close_field() 791 ); 792 }), 793 (Chosen.prototype.results_build = function () { 794 return ( 795 (this.parsing = !0), 796 (this.selected_option_count = null), 797 (this.results_data = SelectParser.select_to_array(this.form_field)), 798 this.is_multiple 799 ? this.search_choices.find("li.search-choice").remove() 800 : this.is_multiple || 801 (this.single_set_selected_text(), 802 this.disable_search || 803 this.form_field.options.length <= this.disable_search_threshold 804 ? ((this.search_field[0].readOnly = !0), 805 this.container.addClass("chosen-container-single-nosearch")) 806 : ((this.search_field[0].readOnly = !1), 807 this.container.removeClass( 808 "chosen-container-single-nosearch" 809 ))), 810 this.update_results_content( 811 this.results_option_build({ first: !0 }) 812 ), 813 this.search_field_disabled(), 814 this.show_search_field_default(), 815 this.search_field_scale(), 816 (this.parsing = !1) 817 ); 818 }), 819 (Chosen.prototype.result_do_highlight = function (a) { 820 var b, c, d, e, f; 821 if (a.length) { 822 if ( 823 (this.result_clear_highlight(), 824 (this.result_highlight = a), 825 this.result_highlight.addClass("highlighted"), 826 (d = parseInt(this.search_results.css("maxHeight"), 10)), 827 (f = this.search_results.scrollTop()), 828 (e = d + f), 829 (c = 830 this.result_highlight.position().top + 831 this.search_results.scrollTop()), 832 (b = c + this.result_highlight.outerHeight()), 833 b >= e) 834 ) 835 return this.search_results.scrollTop(b - d > 0 ? b - d : 0); 836 if (f > c) return this.search_results.scrollTop(c); 837 } 838 }), 839 (Chosen.prototype.result_clear_highlight = function () { 840 return ( 841 this.result_highlight && 842 this.result_highlight.removeClass("highlighted"), 843 (this.result_highlight = null) 844 ); 845 }), 846 (Chosen.prototype.results_show = function () { 847 return this.is_multiple && 848 this.max_selected_options <= this.choices_count() 849 ? (this.form_field_jq.trigger("chosen:maxselected", { 850 chosen: this, 851 }), 852 !1) 853 : (this.container.addClass("chosen-with-drop"), 854 (this.results_showing = !0), 855 this.search_field.focus(), 856 this.search_field.val(this.search_field.val()), 857 this.winnow_results(), 858 this.form_field_jq.trigger("chosen:showing_dropdown", { 859 chosen: this, 860 })); 861 }), 862 (Chosen.prototype.update_results_content = function (a) { 863 return this.search_results.html(a); 864 }), 865 (Chosen.prototype.results_hide = function () { 866 return ( 867 this.results_showing && 868 (this.result_clear_highlight(), 869 this.container.removeClass("chosen-with-drop"), 870 this.form_field_jq.trigger("chosen:hiding_dropdown", { 871 chosen: this, 872 })), 873 (this.results_showing = !1) 874 ); 875 }), 876 (Chosen.prototype.set_tab_index = function (a) { 877 var b; 878 return this.form_field.tabIndex 879 ? ((b = this.form_field.tabIndex), 880 (this.form_field.tabIndex = -1), 881 (this.search_field[0].tabIndex = b)) 882 : void 0; 883 }), 884 (Chosen.prototype.set_label_behavior = function () { 885 var b = this; 886 return ( 887 (this.form_field_label = this.form_field_jq.parents("label")), 888 !this.form_field_label.length && 889 this.form_field.id.length && 890 (this.form_field_label = a( 891 "label[for='" + this.form_field.id + "']" 892 )), 893 this.form_field_label.length > 0 894 ? this.form_field_label.bind("click.chosen", function (a) { 895 return b.is_multiple 896 ? b.container_mousedown(a) 897 : b.activate_field(); 898 }) 899 : void 0 900 ); 901 }), 902 (Chosen.prototype.show_search_field_default = function () { 903 return this.is_multiple && 904 this.choices_count() < 1 && 905 !this.active_field 906 ? (this.search_field.val(this.default_text), 907 this.search_field.addClass("default")) 908 : (this.search_field.val(""), 909 this.search_field.removeClass("default")); 910 }), 911 (Chosen.prototype.search_results_mouseup = function (b) { 912 var c; 913 return ( 914 (c = a(b.target).hasClass("active-result") 915 ? a(b.target) 916 : a(b.target).parents(".active-result").first()), 917 c.length 918 ? ((this.result_highlight = c), 919 this.result_select(b), 920 this.search_field.focus()) 921 : void 0 922 ); 923 }), 924 (Chosen.prototype.search_results_mouseover = function (b) { 925 var c; 926 return ( 927 (c = a(b.target).hasClass("active-result") 928 ? a(b.target) 929 : a(b.target).parents(".active-result").first()), 930 c ? this.result_do_highlight(c) : void 0 931 ); 932 }), 933 (Chosen.prototype.search_results_mouseout = function (b) { 934 return a(b.target).hasClass("active-result") 935 ? this.result_clear_highlight() 936 : void 0; 937 }), 938 (Chosen.prototype.choice_build = function (b) { 939 var c, 940 d, 941 e = this; 942 return ( 943 (c = a("<li />", { class: "search-choice" }).html( 944 "<span>" + this.choice_label(b) + "</span>" 945 )), 946 b.disabled 947 ? c.addClass("search-choice-disabled") 948 : ((d = a("<a />", { 949 class: "search-choice-close", 950 "data-option-array-index": b.array_index, 951 })), 952 d.bind("click.chosen", function (a) { 953 return e.choice_destroy_link_click(a); 954 }), 955 c.append(d)), 956 this.search_container.before(c) 957 ); 958 }), 959 (Chosen.prototype.choice_destroy_link_click = function (b) { 960 return ( 961 b.preventDefault(), 962 b.stopPropagation(), 963 this.is_disabled ? void 0 : this.choice_destroy(a(b.target)) 964 ); 965 }), 966 (Chosen.prototype.choice_destroy = function (a) { 967 return this.result_deselect( 968 a[0].getAttribute("data-option-array-index") 969 ) 970 ? (this.show_search_field_default(), 971 this.is_multiple && 972 this.choices_count() > 0 && 973 this.search_field.val().length < 1 && 974 this.results_hide(), 975 a.parents("li").first().remove(), 976 this.search_field_scale()) 977 : void 0; 978 }), 979 (Chosen.prototype.results_reset = function () { 980 return ( 981 this.reset_single_select_options(), 982 (this.form_field.options[0].selected = !0), 983 this.single_set_selected_text(), 984 this.show_search_field_default(), 985 this.results_reset_cleanup(), 986 this.form_field_jq.trigger("change"), 987 this.active_field ? this.results_hide() : void 0 988 ); 989 }), 990 (Chosen.prototype.results_reset_cleanup = function () { 991 return ( 992 (this.current_selectedIndex = this.form_field.selectedIndex), 993 this.selected_item.find("abbr").remove() 994 ); 995 }), 996 (Chosen.prototype.result_select = function (a) { 997 var b, c; 998 return this.result_highlight 999 ? ((b = this.result_highlight), 1000 this.result_clear_highlight(), 1001 this.is_multiple && 1002 this.max_selected_options <= this.choices_count() 1003 ? (this.form_field_jq.trigger("chosen:maxselected", { 1004 chosen: this, 1005 }), 1006 !1) 1007 : (this.is_multiple 1008 ? b.removeClass("active-result") 1009 : this.reset_single_select_options(), 1010 b.addClass("result-selected"), 1011 (c = 1012 this.results_data[ 1013 b[0].getAttribute("data-option-array-index") 1014 ]), 1015 (c.selected = !0), 1016 (this.form_field.options[c.options_index].selected = !0), 1017 (this.selected_option_count = null),
1018 this.is_multiple 1019 ? this.choice_build(c) 1020 : this.single_set_selected_text(this.choice_label(c)), 1021 ((a.metaKey || a.ctrlKey) && this.is_multiple) || 1022 this.results_hide(), 1023 this.show_search_field_default(), 1024 (this.is_multiple || 1025 this.form_field.selectedIndex !== 1026 this.current_selectedIndex) && 1027 this.form_field_jq.trigger("change", { 1028 selected: this.form_field.options[c.options_index].value, 1029 }), 1030 (this.current_selectedIndex = this.form_field.selectedIndex), 1031 a.preventDefault(), 1032 this.search_field_scale())) 1033 : void 0; 1034 }), 1035 (Chosen.prototype.single_set_selected_text = function (a) { 1036 return ( 1037 null == a && (a = this.default_text), 1038 a === this.default_text 1039 ? this.selected_item.addClass("chosen-default") 1040 : (this.single_deselect_control_build(), 1041 this.selected_item.removeClass("chosen-default")), 1042 this.selected_item.find("span").html(a) 1043 ); 1044 }), 1045 (Chosen.prototype.result_deselect = function (a) { 1046 var b; 1047 return ( 1048 (b = this.results_data[a]), 1049 this.form_field.options[b.options_index].disabled 1050 ? !1 1051 : ((b.selected = !1), 1052 (this.form_field.options[b.options_index].selected = !1), 1053 (this.selected_option_count = null), 1054 this.result_clear_highlight(), 1055 this.results_showing && this.winnow_results(), 1056 this.form_field_jq.trigger("change", { 1057 deselected: this.form_field.options[b.options_index].value, 1058 }), 1059 this.search_field_scale(), 1060 !0) 1061 ); 1062 }), 1063 (Chosen.prototype.single_deselect_control_build = function () { 1064 return this.allow_single_deselect 1065 ? (this.selected_item.find("abbr").length || 1066 this.selected_item 1067 .find("span") 1068 .first() 1069 .after('<abbr class="search-choice-close"></abbr>'), 1070 this.selected_item.addClass("chosen-single-with-deselect")) 1071 : void 0; 1072 }), 1073 (Chosen.prototype.get_search_text = function () { 1074 return a("<div/>").text(a.trim(this.search_field.val())).html(); 1075 }), 1076 (Chosen.prototype.winnow_results_set_highlight = function () { 1077 var a, b; 1078 return ( 1079 (b = this.is_multiple 1080 ? [] 1081 : this.search_results.find(".result-selected.active-result")), 1082 (a = b.length 1083 ? b.first() 1084 : this.search_results.find(".active-result").first()), 1085 null != a ? this.result_do_highlight(a) : void 0 1086 ); 1087 }), 1088 (Chosen.prototype.no_results = function (b) { 1089 var c; 1090 return ( 1091 (c = a( 1092 '<li class="no-results">' + 1093 this.results_none_found + 1094 ' "<span></span>"</li>' 1095 )), 1096 c.find("span").first().html(b), 1097 this.search_results.append(c), 1098 this.form_field_jq.trigger("chosen:no_results", { chosen: this }) 1099 ); 1100 }), 1101 (Chosen.prototype.no_results_clear = function () { 1102 return this.search_results.find(".no-results").remove(); 1103 }), 1104 (Chosen.prototype.keydown_arrow = function () { 1105 var a; 1106 return this.results_showing && this.result_highlight 1107 ? (a = this.result_highlight.nextAll("li.active-result").first()) 1108 ? this.result_do_highlight(a) 1109 : void 0 1110 : this.results_show(); 1111 }), 1112 (Chosen.prototype.keyup_arrow = function () { 1113 var a; 1114 return this.results_showing || this.is_multiple 1115 ? this.result_highlight 1116 ? ((a = this.result_highlight.prevAll("li.active-result")), 1117 a.length 1118 ? this.result_do_highlight(a.first()) 1119 : (this.choices_count() > 0 && this.results_hide(), 1120 this.result_clear_highlight())) 1121 : void 0 1122 : this.results_show(); 1123 }), 1124 (Chosen.prototype.keydown_backstroke = function () { 1125 var a; 1126 return this.pending_backstroke 1127 ? (this.choice_destroy(this.pending_backstroke.find("a").first()), 1128 this.clear_backstroke()) 1129 : ((a = this.search_container.siblings("li.search-choice").last()), 1130 a.length && !a.hasClass("search-choice-disabled") 1131 ? ((this.pending_backstroke = a), 1132 this.single_backstroke_delete 1133 ? this.keydown_backstroke() 1134 : this.pending_backstroke.addClass("search-choice-focus")) 1135 : void 0); 1136 }), 1137 (Chosen.prototype.clear_backstroke = function () { 1138 return ( 1139 this.pending_backstroke && 1140 this.pending_backstroke.removeClass("search-choice-focus"), 1141 (this.pending_backstroke = null) 1142 ); 1143 }), 1144 (Chosen.prototype.keydown_checker = function (a) { 1145 var b, c; 1146 switch ( 1147 ((b = null != (c = a.which) ? c : a.keyCode), 1148 this.search_field_scale(), 1149 8 !== b && this.pending_backstroke && this.clear_backstroke(), 1150 b) 1151 ) { 1152 case 8: 1153 this.backstroke_length = this.search_field.val().length; 1154 break; 1155 case 9: 1156 this.results_showing && 1157 !this.is_multiple && 1158 this.result_select(a), 1159 (this.mouse_on_container = !1); 1160 break; 1161 case 13: 1162 this.results_showing && a.preventDefault(); 1163 break; 1164 case 32: 1165 this.disable_search && a.preventDefault(); 1166 break; 1167 case 38: 1168 a.preventDefault(), this.keyup_arrow(); 1169 break; 1170 case 40: 1171 a.preventDefault(), this.keydown_arrow(); 1172 } 1173 }), 1174 (Chosen.prototype.search_field_scale = function () { 1175 var b, c, d, e, f, g, h, i, j; 1176 if (this.is_multiple) { 1177 for ( 1178 d = 0, 1179 h = 0, 1180 f = 1181 "position:absolute; left: -1000px; top: -1000px; display:none;", 1182 g = [ 1183 "font-size", 1184 "font-style", 1185 "font-weight", 1186 "font-family", 1187 "line-height", 1188 "text-transform", 1189 "letter-spacing", 1190 ], 1191 i = 0, 1192 j = g.length; 1193 j > i; 1194 i++ 1195 ) 1196 (e = g[i]), (f += e + ":" + this.search_field.css(e) + ";"); 1197 return ( 1198 (b = a("<div />", { style: f })), 1199 b.text(this.search_field.val()), 1200 a("body").append(b), 1201 (h = b.width() + 25), 1202 b.remove(), 1203 (c = this.container.outerWidth()), 1204 h > c - 10 && (h = c - 10), 1205 this.search_field.css({ width: h + "px" }) 1206 ); 1207 } 1208 }), 1209 Chosen 1210 ); 1211 })(AbstractChosen)); 1212}).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.