PageSourceSearch

https://cathysnipfamilyrealty.com.au/bootstrap-chosen/chosen.jquery.js

js cathysnipfamilyrealty.com.au collected 2026-10-09 00:58:31 UTC 50,556 bytes, 1,662 lines download raw bytes

1/*!
2Chosen, a Select Box Enhancer for jQuery and Prototype
3by Patrick Filler for Harvest, http://getharvest.com
4
5Version 1.8.7
6Full source at https://github.com/harvesthq/chosen
7Copyright (c) 2011-2018 Harvest http://getharvest.com
8
9MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md
10This file is generated by `grunt build`, do not edit it by hand.
11*/
12
13(function () {
14  var $,
15    AbstractChosen,
16    Chosen,
17    SelectParser,
18    bind = function (fn, me) {
19      return function () {
20        return fn.apply(me, arguments);
21      };
22    },
23    extend = function (child, parent) {
24      for (var key in parent) {
25        if (hasProp.call(parent, key)) child[key] = parent[key];
26      }
27      function ctor() {
28        this.constructor = child;
29      }
30      ctor.prototype = parent.prototype;
31      child.prototype = new ctor();
32      child.__super__ = parent.prototype;
33      return child;
34    },
35    hasProp = {}.hasOwnProperty;
36
37  SelectParser = (function () {
38    function SelectParser() {
39      this.options_index = 0;
40      this.parsed = [];
41    }
42
43    SelectParser.prototype.add_node = function (child) {
44      if (child.nodeName.toUpperCase() === "OPTGROUP") {
45        return this.add_group(child);
46      } else {
47        return this.add_option(child);
48      }
49    };
50
51    SelectParser.prototype.add_group = function (group) {
52      var group_position, i, len, option, ref, results1;
53      group_position = this.parsed.length;
54      this.parsed.push({
55        array_index: group_position,
56        group: true,
57        label: group.label,
58        title: group.title ? group.title : void 0,
59        children: 0,
60        disabled: group.disabled,
61        classes: group.className,
62      });
63      ref = group.childNodes;
64      results1 = [];
65      for (i = 0, len = ref.length; i < len; i++) {
66        option = ref[i];
67        results1.push(this.add_option(option, group_position, group.disabled));
68      }
69      return results1;
70    };
71
72    SelectParser.prototype.add_option = function (
73      option,
74      group_position,
75      group_disabled
76    ) {
77      if (option.nodeName.toUpperCase() === "OPTION") {
78        if (option.text !== "") {
79          if (group_position != null) {
80            this.parsed[group_position].children += 1;
81          }
82          this.parsed.push({
83            array_index: this.parsed.length,
84            options_index: this.options_index,
85            value: option.value,
86            text: option.text,
87            html: option.innerHTML,
88            title: option.title ? option.title : void 0,
89            selected: option.selected,
90            disabled:
91              group_disabled === true ? group_disabled : option.disabled,
92            group_array_index: group_position,
93            group_label:
94              group_position != null ? this.parsed[group_position].label : null,
95            classes: option.className,
96            style: option.style.cssText,
97          });
98        } else {
99          this.parsed.push({
100            array_index: this.parsed.length,
101            options_index: this.options_index,
102            empty: true,
103          });
104        }
105        return (this.options_index += 1);
106      }
107    };
108
109    return SelectParser;
110  })();
111
112  SelectParser.select_to_array = function (select) {
113    var child, i, len, parser, ref;
114    parser = new SelectParser();
115    ref = select.childNodes;
116    for (i = 0, len = ref.length; i < len; i++) {
117      child = ref[i];
118      parser.add_node(child);
119    }
120    return parser.parsed;
121  };
122
123  AbstractChosen = (function () {
124    function AbstractChosen(form_field, options1) {
125      this.form_field = form_field;
126      this.options = options1 != null ? options1 : {};
127      this.label_click_handler = bind(this.label_click_handler, this);
128      if (!AbstractChosen.browser_is_supported()) {
129        return;
130      }
131      this.is_multiple = this.form_field.multiple;
132      this.set_default_text();
133      this.set_default_values();
134      this.setup();
135      this.set_up_html();
136      this.register_observers();
137      this.on_ready();
138    }
139
140    AbstractChosen.prototype.set_default_values = function () {
141      this.click_test_action = (function (_this) {
142        return function (evt) {
143          return _this.test_active_click(evt);
144        };
145      })(this);
146      this.activate_action = (function (_this) {
147        return function (evt) {
148          return _this.activate_field(evt);
149        };
150      })(this);
151      this.active_field = false;
152      this.mouse_on_container = false;
153      this.results_showing = false;
154      this.result_highlighted = null;
155      this.is_rtl =
156        this.options.rtl || /\bchosen-rtl\b/.test(this.form_field.className);
157      this.allow_single_deselect =
158        this.options.allow_single_deselect != null &&
159        this.form_field.options[0] != null &&
160        this.form_field.options[0].text === ""
161          ? this.options.allow_single_deselect
162          : false;
163      this.disable_search_threshold =
164        this.options.disable_search_threshold || 0;
165      this.disable_search = this.options.disable_search || false;
166      this.enable_split_word_search =
167        this.options.enable_split_word_search != null
168          ? this.options.enable_split_word_search
169          : true;
170      this.group_search =
171        this.options.group_search != null ? this.options.group_search : true;
172      this.search_contains = this.options.search_contains || false;
173      this.single_backstroke_delete =
174        this.options.single_backstroke_delete != null
175          ? this.options.single_backstroke_delete
176          : true;
177      this.max_selected_options = this.options.max_selected_options || Infinity;
178      this.inherit_select_classes =
179        this.options.inherit_select_classes || false;
180      this.display_selected_options =
181        this.options.display_selected_options != null
182          ? this.options.display_selected_options
183          : true;
184      this.display_disabled_options =
185        this.options.display_disabled_options != null
186          ? this.options.display_disabled_options
187          : true;
188      this.include_group_label_in_selected =
189        this.options.include_group_label_in_selected || false;
190      this.max_shown_results =
191        this.options.max_shown_results || Number.POSITIVE_INFINITY;
192      this.case_sensitive_search = this.options.case_sensitive_search || false;
193      return (this.hide_results_on_select =
194        this.options.hide_results_on_select != null
195          ? this.options.hide_results_on_select
196          : true);
197    };
198
199    AbstractChosen.prototype.set_default_text = function () {
200      if (this.form_field.getAttribute("data-placeholder")) {
201        this.default_text = this.form_field.getAttribute("data-placeholder");
202      } else if (this.is_multiple) {
203        this.default_text =
204          this.options.placeholder_text_multiple ||
205          this.options.placeholder_text ||
206          AbstractChosen.default_multiple_text;
207      } else {
208        this.default_text =
209          this.options.placeholder_text_single ||
210          this.options.placeholder_text ||
211          AbstractChosen.default_single_text;
212      }
213      this.default_text = this.escape_html(this.default_text);
214      return (this.results_none_found =
215        this.form_field.getAttribute("data-no_results_text") ||
216        this.options.no_results_text ||
217        AbstractChosen.default_no_result_text);
218    };
219
220    AbstractChosen.prototype.choice_label = function (item) {
221      if (this.include_group_label_in_selected && item.group_label != null) {
222        return (
223          "<b class='group-name'>" +
224          this.escape_html(item.group_label) +
225          "</b>" +
226          item.html
227        );
228      } else {
229        return item.html;
230      }
231    };
232
233    AbstractChosen.prototype.mouse_enter = function () {
234      return (this.mouse_on_container = true);
235    };
236
237    AbstractChosen.prototype.mouse_leave = function () {
238      return (this.mouse_on_container = false);
239    };
240
241    AbstractChosen.prototype.input_focus = function (evt) {
242      if (this.is_multiple) {
243        if (!this.active_field) {
244          return setTimeout(
245            (function (_this) {
246              return function () {
247                return _this.container_mousedown();
248              };
249            })(this),
250            50
251          );
252        }
253      } else {
254        if (!this.active_field) {
255          return this.activate_field();
256        }
257      }
258    };
259
260    AbstractChosen.prototype.input_blur = function (evt) {
261      if (!this.mouse_on_container) {
262        this.active_field = false;
263        return setTimeout(
264          (function (_this) {
265            return function () {
266              return _this.blur_test();
267            };
268          })(this),
269          100
270        );
271      }
272    };
273
274    AbstractChosen.prototype.label_click_handler = function (evt) {
275      if (this.is_multiple) {
276        return this.container_mousedown(evt);
277      } else {
278        return this.activate_field();
279      }
280    };
281
282    AbstractChosen.prototype.results_option_build = function (options) {
283      var content, data, data_content, i, len, ref, shown_results;
284      content = "";
285      shown_results = 0;
286      ref = this.results_data;
287      for (i = 0, len = ref.length; i < len; i++) {
288        data = ref[i];
289        data_content = "";
290        if (data.group) {
291          data_content = this.result_add_group(data);
292        } else {
293          data_content = this.result_add_option(data);
294        }
295        if (data_content !== "") {
296          shown_results++;
297          content += data_content;
298        }
299        if (options != null ? options.first : void 0) {
300          if (data.selected && this.is_multiple) {
301            this.choice_build(data);
302          } else if (data.selected && !this.is_multiple) {
303            this.single_set_selected_text(this.choice_label(data));
304          }
305        }
306        if (shown_results >= this.max_shown_results) {
307          break;
308        }
309      }
310      return content;
311    };
312
313    AbstractChosen.prototype.result_add_option = function (option) {
314      var classes, option_el;
315      if (!option.search_match) {
316        return "";
317      }
318      if (!this.include_option_in_results(option)) {
319        return "";
320      }
321      classes = [];
322      if (!option.disabled && !(option.selected && this.is_multiple)) {
323        classes.push("active-result");
324      }
325      if (option.disabled && !(option.selected && this.is_multiple)) {
326        classes.push("disabled-result");
327      }
328      if (option.selected) {
329        classes.push("result-selected");
330      }
331      if (option.group_array_index != null) {
332        classes.push("group-option");
333      }
334      if (option.classes !== "") {
335        classes.push(option.classes);
336      }
337      option_el = document.createElement("li");
338      option_el.className = classes.join(" ");
339      if (option.style) {
340        option_el.style.cssText = option.style;
341      }
342      option_el.setAttribute("data-option-array-index", option.array_index);
343      option_el.innerHTML = option.highlighted_html || option.html;
344      if (option.title) {
345        option_el.title = option.title;
346      }
347      return this.outerHTML(option_el);
348    };
349
350    AbstractChosen.prototype.result_add_group = function (group) {
351      var classes, group_el;
352      if (!(group.search_match || group.group_match)) {
353        return "";
354      }
355      if (!(group.active_options > 0)) {
356        return "";
357      }
358      classes = [];
359      classes.push("group-result");
360      if (group.classes) {
361        classes.push(group.classes);
362      }
363      group_el = document.createElement("li");
364      group_el.className = classes.join(" ");
365      group_el.innerHTML =
366        group.highlighted_html || this.escape_html(group.label);
367      if (group.title) {
368        group_el.title = group.title;
369      }
370      return this.outerHTML(group_el);
371    };
372
373    AbstractChosen.prototype.results_update_field = function () {
374      this.set_default_text();
375      if (!this.is_multiple) {
376        this.results_reset_cleanup();
377      }
378      this.result_clear_highlight();
379      this.results_build();
380      if (this.results_showing) {
381        return this.winnow_results();
382      }
383    };
384
385    AbstractChosen.prototype.reset_single_select_options = function () {
386      var i, len, ref, result, results1;
387      ref = this.results_data;
388      results1 = [];
389      for (i = 0, len = ref.length; i < len; i++) {
390        result = ref[i];
391        if (result.selected) {
392          results1.push((result.selected = false));
393        } else {
394          results1.push(void 0);
395        }
396      }
397      return results1;
398    };
399
400    AbstractChosen.prototype.results_toggle = function () {
401      if (this.results_showing) {
402        return this.results_hide();
403      } else {
404        return this.results_show();
405      }
406    };
407
408    AbstractChosen.prototype.results_search = function (evt) {
409      if (this.results_showing) {
410        return this.winnow_results();
411      } else {
412        return this.results_show();
413      }
414    };
415
416    AbstractChosen.prototype.winnow_results = function (options) {
417      var escapedQuery,
418        fix,
419        i,
420        len,
421        option,
422        prefix,
423        query,
424        ref,
425        regex,
426        results,
427        results_group,
428        search_match,
429        startpos,
430        suffix,
431        text;
432      this.no_results_clear();
433      results = 0;
434      query = this.get_search_text();
435      escapedQuery = query.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
436      regex = this.get_search_regex(escapedQuery);
437      ref = this.results_data;
438      for (i = 0, len = ref.length; i < len; i++) {
439        option = ref[i];
440        option.search_match = false;
vendor: 4,412 bytes, lines 441-571
441        results_group = null;
442        search_match = null;
443        option.highlighted_html = "";
444        if (this.include_option_in_results(option)) {
445          if (option.group) {
446            option.group_match = false;
447            option.active_options = 0;
448          }
449          if (
450            option.group_array_index != null &&
451            this.results_data[option.group_array_index]
452          ) {
453            results_group = this.results_data[option.group_array_index];
454            if (
455              results_group.active_options === 0 &&
456              results_group.search_match
457            ) {
458              results += 1;
459            }
460            results_group.active_options += 1;
461          }
462          text = option.group ? option.label : option.text;
463          if (!(option.group && !this.group_search)) {
464            search_match = this.search_string_match(text, regex);
465            option.search_match = search_match != null;
466            if (option.search_match && !option.group) {
467              results += 1;
468            }
469            if (option.search_match) {
470              if (query.length) {
471                startpos = search_match.index;
472                prefix = text.slice(0, startpos);
473                fix = text.slice(startpos, startpos + query.length);
474                suffix = text.slice(startpos + query.length);
475                option.highlighted_html =
476                  this.escape_html(prefix) +
477                  "<em>" +
478                  this.escape_html(fix) +
479                  "</em>" +
480                  this.escape_html(suffix);
481              }
482              if (results_group != null) {
483                results_group.group_match = true;
484              }
485            } else if (
486              option.group_array_index != null &&
487              this.results_data[option.group_array_index].search_match
488            ) {
489              option.search_match = true;
490            }
491          }
492        }
493      }
494      this.result_clear_highlight();
495      if (results < 1 && query.length) {
496        this.update_results_content("");
497        return this.no_results(query);
498      } else {
499        this.update_results_content(this.results_option_build());
500        if (!(options != null ? options.skip_highlight : void 0)) {
501          return this.winnow_results_set_highlight();
502        }
503      }
504    };
505
506    AbstractChosen.prototype.get_search_regex = function (
507      escaped_search_string
508    ) {
509      var regex_flag, regex_string;
510      regex_string = this.search_contains
511        ? escaped_search_string
512        : "(^|\\s|\\b)" + escaped_search_string + "[^\\s]*";
513      if (!(this.enable_split_word_search || this.search_contains)) {
514        regex_string = "^" + regex_string;
515      }
516      regex_flag = this.case_sensitive_search ? "" : "i";
517      return new RegExp(regex_string, regex_flag);
518    };
519
520    AbstractChosen.prototype.search_string_match = function (
521      search_string,
522      regex
523    ) {
524      var match;
525      match = regex.exec(search_string);
526      if (!this.search_contains && (match != null ? match[1] : void 0)) {
527        match.index += 1;
528      }
529      return match;
530    };
531
532    AbstractChosen.prototype.choices_count = function () {
533      var i, len, option, ref;
534      if (this.selected_option_count != null) {
535        return this.selected_option_count;
536      }
537      this.selected_option_count = 0;
538      ref = this.form_field.options;
539      for (i = 0, len = ref.length; i < len; i++) {
540        option = ref[i];
541        if (option.selected) {
542          this.selected_option_count += 1;
543        }
544      }
545      return this.selected_option_count;
546    };
547
548    AbstractChosen.prototype.choices_click = function (evt) {
549      evt.preventDefault();
550      this.activate_field();
551      if (!(this.results_showing || this.is_disabled)) {
552        return this.results_show();
553      }
554    };
555
556    AbstractChosen.prototype.keydown_checker = function (evt) {
557      var ref, stroke;
558      stroke = (ref = evt.which) != null ? ref : evt.keyCode;
559      this.search_field_scale();
560      if (stroke !== 8 && this.pending_backstroke) {
561        this.clear_backstroke();
562      }
563      switch (stroke) {
564        case 8:
565          this.backstroke_length = this.get_search_field_value().length;
566          break;
567        case 9:
568          if (this.results_showing && !this.is_multiple) {
569            this.result_select(evt);
570          }
571          this.mouse_on_container = false;
572          break;
573        case 13:
574          if (this.results_showing) {
575            evt.preventDefault();
576          }
577          break;
578        case 27:
579          if (this.results_showing) {
580            evt.preventDefault();
581          }
582          break;
583        case 32:
584          if (this.disable_search) {
585            evt.preventDefault();
586          }
587          break;
588        case 38:
589          evt.preventDefault();
590          this.keyup_arrow();
591          break;
592        case 40:
593          evt.preventDefault();
594          this.keydown_arrow();
595          break;
596      }
597    };
598
599    AbstractChosen.prototype.keyup_checker = function (evt) {
600      var ref, stroke;
601      stroke = (ref = evt.which) != null ? ref : evt.keyCode;
602      this.search_field_scale();
603      switch (stroke) {
604        case 8:
605          if (
606            this.is_multiple &&
607            this.backstroke_length < 1 &&
608            this.choices_count() > 0
609          ) {
610            this.keydown_backstroke();
611          } else if (!this.pending_backstroke) {
612            this.result_clear_highlight();
613            this.results_search();
614          }
615          break;
616        case 13:
617          evt.preventDefault();
618          if (this.results_showing) {
619            this.result_select(evt);
620          }
621          break;
622        case 27:
623          if (this.results_showing) {
624            this.results_hide();
625          }
626          break;
627        case 9:
628        case 16:
629        case 17:
630        case 18:
631        case 38:
632        case 40:
633        case 91:
634          break;
635        default:
636          this.results_search();
637          break;
638      }
639    };
640
641    AbstractChosen.prototype.clipboard_event_checker = function (evt) {
642      if (this.is_disabled) {
643        return;
644      }
645      return setTimeout(
646        (function (_this) {
647          return function () {
648            return _this.results_search();
649          };
650        })(this),
651        50
652      );
653    };
654
655    AbstractChosen.prototype.container_width = function () {
656      if (this.options.width != null) {
657        return this.options.width;
658      } else {
659        return this.form_field.offsetWidth + "px";
660      }
661    };
662
663    AbstractChosen.prototype.include_option_in_results = function (option) {
664      if (
665        this.is_multiple &&
666        !this.display_selected_options &&
667        option.selected
668      ) {
669        return false;
670      }
671      if (!this.display_disabled_options && option.disabled) {
672        return false;
673      }
674      if (option.empty) {
675        return false;
676      }
677      return true;
678    };
679
680    AbstractChosen.prototype.search_results_touchstart = function (evt) {
681      this.touch_started = true;
682      return this.search_results_mouseover(evt);
683    };
684
685    AbstractChosen.prototype.search_results_touchmove = function (evt) {
686      this.touch_started = false;
687      return this.search_results_mouseout(evt);
688    };
689
690    AbstractChosen.prototype.search_results_touchend = function (evt) {
691      if (this.touch_started) {
692        return this.search_results_mouseup(evt);
693      }
694    };
695
696    AbstractChosen.prototype.outerHTML = function (element) {
697      var tmp;
698      if (element.outerHTML) {
699        return element.outerHTML;
700      }
701      tmp = document.createElement("div");
702      tmp.appendChild(element);
703      return tmp.innerHTML;
704    };
705
706    AbstractChosen.prototype.get_single_html = function () {
707      return (
708        '<a class="chosen-single chosen-default">\n  <span>' +
709        this.default_text +
710        '</span>\n  <div><b></b></div>\n</a>\n<div class="chosen-drop">\n  <div class="chosen-search">\n    <input class="chosen-search-input" type="text" autocomplete="off" />\n  </div>\n  <ul class="chosen-results"></ul>\n</div>'
711      );
712    };
713
714    AbstractChosen.prototype.get_multi_html = function () {
715      return (
716        '<ul class="chosen-choices">\n  <li class="search-field">\n    <input class="chosen-search-input" type="text" autocomplete="off" value="' +
717        this.default_text +
718        '" />\n  </li>\n</ul>\n<div class="chosen-drop">\n  <ul class="chosen-results"></ul>\n</div>'
719      );
720    };
721
722    AbstractChosen.prototype.get_no_results_html = function (terms) {
723      return (
724        '<li class="no-results">\n  ' +
725        this.results_none_found +
726        " <span>" +
727        this.escape_html(terms) +
728        "</span>\n</li>"
729      );
730    };
731
732    AbstractChosen.browser_is_supported = function () {
733      if ("Microsoft Internet Explorer" === window.navigator.appName) {
734        return document.documentMode >= 8;
735      }
736      if (
737        /iP(od|hone)/i.test(window.navigator.userAgent) ||
738        /IEMobile/i.test(window.navigator.userAgent) ||
739        /Windows Phone/i.test(window.navigator.userAgent) ||
740        /BlackBerry/i.test(window.navigator.userAgent) ||
741        /BB10/i.test(window.navigator.userAgent) ||
742        /Android.*Mobile/i.test(window.navigator.userAgent)
743      ) {
744        return false;
745      }
746      return true;
747    };
748
749    AbstractChosen.default_multiple_text = "Select Some Options";
750
751    AbstractChosen.default_single_text = "Select an Option";
752
753    AbstractChosen.default_no_result_text = "No results match";
754
755    return AbstractChosen;
756  })();
757
758  $ = jQuery;
759
760  $.fn.extend({
761    chosen: function (options) {
762      if (!AbstractChosen.browser_is_supported()) {
763        return this;
764      }
765      return this.each(function (input_field) {
766        var $this, chosen;
767        $this = $(this);
768        chosen = $this.data("chosen");
769        if (options === "destroy") {
770          if (chosen instanceof Chosen) {
771            chosen.destroy();
772          }
773          return;
774        }
775        if (!(chosen instanceof Chosen)) {
776          $this.data("chosen", new Chosen(this, options));
777        }
778      });
779    },
780  });
781
782  Chosen = (function (superClass) {
783    extend(Chosen, superClass);
784
785    function Chosen() {
786      return Chosen.__super__.constructor.apply(this, arguments);
787    }
788
789    Chosen.prototype.setup = function () {
790      this.form_field_jq = $(this.form_field);
791      return (this.current_selectedIndex = this.form_field.selectedIndex);
792    };
793
794    Chosen.prototype.set_up_html = function () {
vendor: 9,025 bytes, lines 795-1108
795      var container_classes, container_props;
796      container_classes = ["chosen-container"];
797      container_classes.push(
798        "chosen-container-" + (this.is_multiple ? "multi" : "single")
799      );
800      if (this.inherit_select_classes && this.form_field.className) {
801        container_classes.push(this.form_field.className);
802      }
803      if (this.is_rtl) {
804        container_classes.push("chosen-rtl");
805      }
806      container_props = {
807        class: container_classes.join(" "),
808        title: this.form_field.title,
809      };
810      if (this.form_field.id.length) {
811        container_props.id =
812          this.form_field.id.replace(/[^\w]/g, "_") + "_chosen";
813      }
814      this.container = $("<div />", container_props);
815      this.container.width(this.container_width());
816      if (this.is_multiple) {
817        this.container.html(this.get_multi_html());
818      } else {
819        this.container.html(this.get_single_html());
820      }
821      this.form_field_jq.hide().after(this.container);
822      this.dropdown = this.container.find("div.chosen-drop").first();
823      this.search_field = this.container.find("input").first();
824      this.search_results = this.container.find("ul.chosen-results").first();
825      this.search_field_scale();
826      this.search_no_results = this.container.find("li.no-results").first();
827      if (this.is_multiple) {
828        this.search_choices = this.container.find("ul.chosen-choices").first();
829        this.search_container = this.container.find("li.search-field").first();
830      } else {
831        this.search_container = this.container
832          .find("div.chosen-search")
833          .first();
834        this.selected_item = this.container.find(".chosen-single").first();
835      }
836      this.results_build();
837      this.set_tab_index();
838      return this.set_label_behavior();
839    };
840
841    Chosen.prototype.on_ready = function () {
842      return this.form_field_jq.trigger("chosen:ready", {
843        chosen: this,
844      });
845    };
846
847    Chosen.prototype.register_observers = function () {
848      this.container.on(
849        "touchstart.chosen",
850        (function (_this) {
851          return function (evt) {
852            _this.container_mousedown(evt);
853          };
854        })(this)
855      );
856      this.container.on(
857        "touchend.chosen",
858        (function (_this) {
859          return function (evt) {
860            _this.container_mouseup(evt);
861          };
862        })(this)
863      );
864      this.container.on(
865        "mousedown.chosen",
866        (function (_this) {
867          return function (evt) {
868            _this.container_mousedown(evt);
869          };
870        })(this)
871      );
872      this.container.on(
873        "mouseup.chosen",
874        (function (_this) {
875          return function (evt) {
876            _this.container_mouseup(evt);
877          };
878        })(this)
879      );
880      this.container.on(
881        "mouseenter.chosen",
882        (function (_this) {
883          return function (evt) {
884            _this.mouse_enter(evt);
885          };
886        })(this)
887      );
888      this.container.on(
889        "mouseleave.chosen",
890        (function (_this) {
891          return function (evt) {
892            _this.mouse_leave(evt);
893          };
894        })(this)
895      );
896      this.search_results.on(
897        "mouseup.chosen",
898        (function (_this) {
899          return function (evt) {
900            _this.search_results_mouseup(evt);
901          };
902        })(this)
903      );
904      this.search_results.on(
905        "mouseover.chosen",
906        (function (_this) {
907          return function (evt) {
908            _this.search_results_mouseover(evt);
909          };
910        })(this)
911      );
912      this.search_results.on(
913        "mouseout.chosen",
914        (function (_this) {
915          return function (evt) {
916            _this.search_results_mouseout(evt);
917          };
918        })(this)
919      );
920      this.search_results.on(
921        "mousewheel.chosen DOMMouseScroll.chosen",
922        (function (_this) {
923          return function (evt) {
924            _this.search_results_mousewheel(evt);
925          };
926        })(this)
927      );
928      this.search_results.on(
929        "touchstart.chosen",
930        (function (_this) {
931          return function (evt) {
932            _this.search_results_touchstart(evt);
933          };
934        })(this)
935      );
936      this.search_results.on(
937        "touchmove.chosen",
938        (function (_this) {
939          return function (evt) {
940            _this.search_results_touchmove(evt);
941          };
942        })(this)
943      );
944      this.search_results.on(
945        "touchend.chosen",
946        (function (_this) {
947          return function (evt) {
948            _this.search_results_touchend(evt);
949          };
950        })(this)
951      );
952      this.form_field_jq.on(
953        "chosen:updated.chosen",
954        (function (_this) {
955          return function (evt) {
956            _this.results_update_field(evt);
957          };
958        })(this)
959      );
960      this.form_field_jq.on(
961        "chosen:activate.chosen",
962        (function (_this) {
963          return function (evt) {
964            _this.activate_field(evt);
965          };
966        })(this)
967      );
968      this.form_field_jq.on(
969        "chosen:open.chosen",
970        (function (_this) {
971          return function (evt) {
972            _this.container_mousedown(evt);
973          };
974        })(this)
975      );
976      this.form_field_jq.on(
977        "chosen:close.chosen",
978        (function (_this) {
979          return function (evt) {
980            _this.close_field(evt);
981          };
982        })(this)
983      );
984      this.search_field.on(
985        "blur.chosen",
986        (function (_this) {
987          return function (evt) {
988            _this.input_blur(evt);
989          };
990        })(this)
991      );
992      this.search_field.on(
993        "keyup.chosen",
994        (function (_this) {
995          return function (evt) {
996            _this.keyup_checker(evt);
997          };
998        })(this)
999      );
1000      this.search_field.on(
1001        "keydown.chosen",
1002        (function (_this) {
1003          return function (evt) {
1004            _this.keydown_checker(evt);
1005          };
1006        })(this)
1007      );
1008      this.search_field.on(
1009        "focus.chosen",
1010        (function (_this) {
1011          return function (evt) {
1012            _this.input_focus(evt);
1013          };
1014        })(this)
1015      );
1016      this.search_field.on(
1017        "cut.chosen",
1018        (function (_this) {
1019          return function (evt) {
1020            _this.clipboard_event_checker(evt);
1021          };
1022        })(this)
1023      );
1024      this.search_field.on(
1025        "paste.chosen",
1026        (function (_this) {
1027          return function (evt) {
1028            _this.clipboard_event_checker(evt);
1029          };
1030        })(this)
1031      );
1032      if (this.is_multiple) {
1033        return this.search_choices.on(
1034          "click.chosen",
1035          (function (_this) {
1036            return function (evt) {
1037              _this.choices_click(evt);
1038            };
1039          })(this)
1040        );
1041      } else {
1042        return this.container.on("click.chosen", function (evt) {
1043          evt.preventDefault();
1044        });
1045      }
1046    };
1047
1048    Chosen.prototype.destroy = function () {
1049      $(this.container[0].ownerDocument).off(
1050        "click.chosen",
1051        this.click_test_action
1052      );
1053      if (this.form_field_label.length > 0) {
1054        this.form_field_label.off("click.chosen");
1055      }
1056      if (this.search_field[0].tabIndex) {
1057        this.form_field_jq[0].tabIndex = this.search_field[0].tabIndex;
1058      }
1059      this.container.remove();
1060      this.form_field_jq.removeData("chosen");
1061      return this.form_field_jq.show();
1062    };
1063
1064    Chosen.prototype.search_field_disabled = function () {
1065      this.is_disabled =
1066        this.form_field.disabled ||
1067        this.form_field_jq.parents("fieldset").is(":disabled");
1068      this.container.toggleClass("chosen-disabled", this.is_disabled);
1069      this.search_field[0].disabled = this.is_disabled;
1070      if (!this.is_multiple) {
1071        this.selected_item.off("focus.chosen", this.activate_field);
1072      }
1073      if (this.is_disabled) {
1074        return this.close_field();
1075      } else if (!this.is_multiple) {
1076        return this.selected_item.on("focus.chosen", this.activate_field);
1077      }
1078    };
1079
1080    Chosen.prototype.container_mousedown = function (evt) {
1081      var ref;
1082      if (this.is_disabled) {
1083        return;
1084      }
1085      if (
1086        evt &&
1087        ((ref = evt.type) === "mousedown" || ref === "touchstart") &&
1088        !this.results_showing
1089      ) {
1090        evt.preventDefault();
1091      }
1092      if (!(evt != null && $(evt.target).hasClass("search-choice-close"))) {
1093        if (!this.active_field) {
1094          if (this.is_multiple) {
1095            this.search_field.val("");
1096          }
1097          $(this.container[0].ownerDocument).on(
1098            "click.chosen",
1099            this.click_test_action
1100          );
1101          this.results_show();
1102        } else if (
1103          !this.is_multiple &&
1104          evt &&
1105          ($(evt.target)[0] === this.selected_item[0] ||
1106            $(evt.target).parents("a.chosen-single").length)
1107        ) {
1108          evt.preventDefault();
1109          this.results_toggle();
1110        }
1111        return this.activate_field();
1112      }
1113    };
1114
1115    Chosen.prototype.container_mouseup = function (evt) {
1116      if (evt.target.nodeName === "ABBR" && !this.is_disabled) {
1117        return this.results_reset(evt);
1118      }
1119    };
1120
1121    Chosen.prototype.search_results_mousewheel = function (evt) {
1122      var delta;
1123      if (evt.originalEvent) {
1124        delta =
1125          evt.originalEvent.deltaY ||
1126          -evt.originalEvent.wheelDelta ||
1127          evt.originalEvent.detail;
1128      }
1129      if (delta != null) {
1130        evt.preventDefault();
1131        if (evt.type === "DOMMouseScroll") {
1132          delta = delta * 40;
1133        }
1134        return this.search_results.scrollTop(
1135          delta + this.search_results.scrollTop()
1136        );
1137      }
1138    };
1139
1140    Chosen.prototype.blur_test = function (evt) {
1141      if (
1142        !this.active_field &&
1143        this.container.hasClass("chosen-container-active")
1144      ) {
1145        return this.close_field();
1146      }
1147    };
1148
1149    Chosen.prototype.close_field = function () {
1150      $(this.container[0].ownerDocument).off(
1151        "click.chosen",
1152        this.click_test_action
1153      );
1154      this.active_field = false;
1155      this.results_hide();
1156      this.container.removeClass("chosen-container-active");
1157      this.clear_backstroke();
1158      this.show_search_field_default();
1159      this.search_field_scale();
1160      return this.search_field.blur();
1161    };
1162
1163    Chosen.prototype.activate_field = function () {
1164      if (this.is_disabled) {
1165        return;
1166      }
1167      this.container.addClass("chosen-container-active");
1168      this.active_field = true;
1169      this.search_field.val(this.search_field.val());
1170      return this.search_field.focus();
1171    };
1172
1173    Chosen.prototype.test_active_click = function (evt) {
1174      var active_container;
1175      active_container = $(evt.target).closest(".chosen-container");
1176      if (
1177        active_container.length &&
1178        this.container[0] === active_container[0]
1179      ) {
1180        return (this.active_field = true);
1181      } else {
1182        return this.close_field();
1183      }
1184    };
1185
1186    Chosen.prototype.results_build = function () {
1187      this.parsing = true;
1188      this.selected_option_count = null;
1189      this.results_data = SelectParser.select_to_array(this.form_field);
1190      if (this.is_multiple) {
1191        this.search_choices.find("li.search-choice").remove();
1192      } else {
1193        this.single_set_selected_text();
1194        if (
1195          this.disable_search ||
1196          this.form_field.options.length <= this.disable_search_threshold
1197        ) {
1198          this.search_field[0].readOnly = true;
1199          this.container.addClass("chosen-container-single-nosearch");
1200        } else {
1201          this.search_field[0].readOnly = false;
1202          this.container.removeClass("chosen-container-single-nosearch");
1203        }
1204      }
1205      this.update_results_content(
1206        this.results_option_build({
1207          first: true,
1208        })
1209      );
1210      this.search_field_disabled();
1211      this.show_search_field_default();
1212      this.search_field_scale();
1213      return (this.parsing = false);
1214    };
1215
1216    Chosen.prototype.result_do_highlight = function (el) {
1217      var high_bottom, high_top, maxHeight, visible_bottom, visible_top;
1218      if (el.length) {
1219        this.result_clear_highlight();
1220        this.result_highlight = el;
1221        this.result_highlight.addClass("highlighted");
1222        maxHeight = parseInt(this.search_results.css("maxHeight"), 10);
1223        visible_top = this.search_results.scrollTop();
1224        visible_bottom = maxHeight + visible_top;
1225        high_top =
1226          this.result_highlight.position().top +
1227          this.search_results.scrollTop();
1228        high_bottom = high_top + this.result_highlight.outerHeight();
1229        if (high_bottom >= visible_bottom) {
1230          return this.search_results.scrollTop(
1231            high_bottom - maxHeight > 0 ? high_bottom - maxHeight : 0
1232          );
1233        } else if (high_top < visible_top) {
1234          return this.search_results.scrollTop(high_top);
1235        }
1236      }
1237    };
1238
1239    Chosen.prototype.result_clear_highlight = function () {
1240      if (this.result_highlight) {
1241        this.result_highlight.removeClass("highlighted");
1242      }
1243      return (this.result_highlight = null);
1244    };
1245
1246    Chosen.prototype.results_show = function () {
1247      if (
1248        this.is_multiple &&
1249        this.max_selected_options <= this.choices_count()
1250      ) {
1251        this.form_field_jq.trigger("chosen:maxselected", {
1252          chosen: this,
1253        });
1254        return false;
1255      }
1256      this.container.addClass("chosen-with-drop");
1257      this.results_showing = true;
1258      this.search_field.focus();
1259      this.search_field.val(this.get_search_field_value());
1260      this.winnow_results();
1261      return this.form_field_jq.trigger("chosen:showing_dropdown", {
1262        chosen: this,
1263      });
1264    };
1265
1266    Chosen.prototype.update_results_content = function (content) {
1267      return this.search_results.html(content);
1268    };
1269
1270    Chosen.prototype.results_hide = function () {
1271      if (this.results_showing) {
1272        this.result_clear_highlight();
1273        this.container.removeClass("chosen-with-drop");
1274        this.form_field_jq.trigger("chosen:hiding_dropdown", {
1275          chosen: this,
1276        });
1277      }
1278      return (this.results_showing = false);
1279    };
1280
1281    Chosen.prototype.set_tab_index = function (el) {
1282      var ti;
1283      if (this.form_field.tabIndex) {
1284        ti = this.form_field.tabIndex;
1285        this.form_field.tabIndex = -1;
1286        return (this.search_field[0].tabIndex = ti);
1287      }
1288    };
1289
1290    Chosen.prototype.set_label_behavior = function () {
1291      this.form_field_label = this.form_field_jq.parents("label");
1292      if (!this.form_field_label.length && this.form_field.id.length) {
1293        this.form_field_label = $("label[for='" + this.form_field.id + "']");
1294      }
1295      if (this.form_field_label.length > 0) {
1296        return this.form_field_label.on(
1297          "click.chosen",
1298          this.label_click_handler
1299        );
1300      }
1301    };
1302
1303    Chosen.prototype.show_search_field_default = function () {
1304      if (this.is_multiple && this.choices_count() < 1 && !this.active_field) {
1305        this.search_field.val(this.default_text);
1306        return this.search_field.addClass("default");
1307      } else {
1308        this.search_field.val("");
1309        return this.search_field.removeClass("default");
1310      }
1311    };
1312
1313    Chosen.prototype.search_results_mouseup = function (evt) {
1314      var target;
1315      target = $(evt.target).hasClass("active-result")
1316        ? $(evt.target)
1317        : $(evt.target).parents(".active-result").first();
1318      if (target.length) {
1319        this.result_highlight = target;
1320        this.result_select(evt);
1321        return this.search_field.focus();
1322      }
1323    };
1324
1325    Chosen.prototype.search_results_mouseover = function (evt) {
1326      var target;
1327      target = $(evt.target).hasClass("active-result")
1328        ? $(evt.target)
1329        : $(evt.target).parents(".active-result").first();
1330      if (target) {
1331        return this.result_do_highlight(target);
1332      }
1333    };
1334
1335    Chosen.prototype.search_results_mouseout = function (evt) {
1336      if (
1337        $(evt.target).hasClass("active-result") ||
1338        $(evt.target).parents(".active-result").first()
1339      ) {
1340        return this.result_clear_highlight();
1341      }
1342    };
1343
1344    Chosen.prototype.choice_build = function (item) {
1345      var choice, close_link;
1346      choice = $("<li />", {
1347        class: "search-choice",
1348      }).html("<span>" + this.choice_label(item) + "</span>");
1349      if (item.disabled) {
1350        choice.addClass("search-choice-disabled");
1351      } else {
1352        close_link = $("<a />", {
1353          class: "search-choice-close",
1354          "data-option-array-index": item.array_index,
1355        });
1356        close_link.on(
1357          "click.chosen",
1358          (function (_this) {
1359            return function (evt) {
1360              return _this.choice_destroy_link_click(evt);
1361            };
1362          })(this)
1363        );
1364        choice.append(close_link);
1365      }
1366      return this.search_container.before(choice);
1367    };
1368
1369    Chosen.prototype.choice_destroy_link_click = function (evt) {
1370      evt.preventDefault();
1371      evt.stopPropagation();
1372      if (!this.is_disabled) {
1373        return this.choice_destroy($(evt.target));
1374      }
1375    };
1376
1377    Chosen.prototype.choice_destroy = function (link) {
1378      if (
1379        this.result_deselect(link[0].getAttribute("data-option-array-index"))
1380      ) {
1381        if (this.active_field) {
1382          this.search_field.focus();
1383        } else {
1384          this.show_search_field_default();
1385        }
1386        if (
1387          this.is_multiple &&
1388          this.choices_count() > 0 &&
1389          this.get_search_field_value().length < 1
1390        ) {
1391          this.results_hide();
1392        }
1393        link.parents("li").first().remove();
1394        return this.search_field_scale();
1395      }
1396    };
1397
1398    Chosen.prototype.results_reset = function () {
1399      this.reset_single_select_options();
1400      this.form_field.options[0].selected = true;
1401      this.single_set_selected_text();
1402      this.show_search_field_default();
1403      this.results_reset_cleanup();
1404      this.trigger_form_field_change();
1405      if (this.active_field) {
1406        return this.results_hide();
1407      }
1408    };
1409
1410    Chosen.prototype.results_reset_cleanup = function () {
1411      this.current_selectedIndex = this.form_field.selectedIndex;
1412      return this.selected_item.find("abbr").remove();
1413    };
1414
1415    Chosen.prototype.result_select = function (evt) {
1416      var high, item;
1417      if (this.result_highlight) {
1418        high = this.result_highlight;
1419        this.result_clear_highlight();
1420        if (
1421          this.is_multiple &&
1422          this.max_selected_options <= this.choices_count()
1423        ) {
1424          this.form_field_jq.trigger("chosen:maxselected", {
1425            chosen: this,
1426          });
1427          return false;
vendor: 7,393 bytes, lines 1428-1662
1428        }
1429        if (this.is_multiple) {
1430          high.removeClass("active-result");
1431        } else {
1432          this.reset_single_select_options();
1433        }
1434        high.addClass("result-selected");
1435        item =
1436          this.results_data[high[0].getAttribute("data-option-array-index")];
1437        item.selected = true;
1438        this.form_field.options[item.options_index].selected = true;
1439        this.selected_option_count = null;
1440        if (this.is_multiple) {
1441          this.choice_build(item);
1442        } else {
1443          this.single_set_selected_text(this.choice_label(item));
1444        }
1445        if (
1446          this.is_multiple &&
1447          (!this.hide_results_on_select || evt.metaKey || evt.ctrlKey)
1448        ) {
1449          if (evt.metaKey || evt.ctrlKey) {
1450            this.winnow_results({
1451              skip_highlight: true,
1452            });
1453          } else {
1454            this.search_field.val("");
1455            this.winnow_results();
1456          }
1457        } else {
1458          this.results_hide();
1459          this.show_search_field_default();
1460        }
1461        if (
1462          this.is_multiple ||
1463          this.form_field.selectedIndex !== this.current_selectedIndex
1464        ) {
1465          this.trigger_form_field_change({
1466            selected: this.form_field.options[item.options_index].value,
1467          });
1468        }
1469        this.current_selectedIndex = this.form_field.selectedIndex;
1470        evt.preventDefault();
1471        return this.search_field_scale();
1472      }
1473    };
1474
1475    Chosen.prototype.single_set_selected_text = function (text) {
1476      if (text == null) {
1477        text = this.default_text;
1478      }
1479      if (text === this.default_text) {
1480        this.selected_item.addClass("chosen-default");
1481      } else {
1482        this.single_deselect_control_build();
1483        this.selected_item.removeClass("chosen-default");
1484      }
1485      return this.selected_item.find("span").html(text);
1486    };
1487
1488    Chosen.prototype.result_deselect = function (pos) {
1489      var result_data;
1490      result_data = this.results_data[pos];
1491      if (!this.form_field.options[result_data.options_index].disabled) {
1492        result_data.selected = false;
1493        this.form_field.options[result_data.options_index].selected = false;
1494        this.selected_option_count = null;
1495        this.result_clear_highlight();
1496        if (this.results_showing) {
1497          this.winnow_results();
1498        }
1499        this.trigger_form_field_change({
1500          deselected: this.form_field.options[result_data.options_index].value,
1501        });
1502        this.search_field_scale();
1503        return true;
1504      } else {
1505        return false;
1506      }
1507    };
1508
1509    Chosen.prototype.single_deselect_control_build = function () {
1510      if (!this.allow_single_deselect) {
1511        return;
1512      }
1513      if (!this.selected_item.find("abbr").length) {
1514        this.selected_item
1515          .find("span")
1516          .first()
1517          .after('<abbr class="search-choice-close"></abbr>');
1518      }
1519      return this.selected_item.addClass("chosen-single-with-deselect");
1520    };
1521
1522    Chosen.prototype.get_search_field_value = function () {
1523      return this.search_field.val();
1524    };
1525
1526    Chosen.prototype.get_search_text = function () {
1527      return $.trim(this.get_search_field_value());
1528    };
1529
1530    Chosen.prototype.escape_html = function (text) {
1531      return $("<div/>").text(text).html();
1532    };
1533
1534    Chosen.prototype.winnow_results_set_highlight = function () {
1535      var do_high, selected_results;
1536      selected_results = !this.is_multiple
1537        ? this.search_results.find(".result-selected.active-result")
1538        : [];
1539      do_high = selected_results.length
1540        ? selected_results.first()
1541        : this.search_results.find(".active-result").first();
1542      if (do_high != null) {
1543        return this.result_do_highlight(do_high);
1544      }
1545    };
1546
1547    Chosen.prototype.no_results = function (terms) {
1548      var no_results_html;
1549      no_results_html = this.get_no_results_html(terms);
1550      this.search_results.append(no_results_html);
1551      return this.form_field_jq.trigger("chosen:no_results", {
1552        chosen: this,
1553      });
1554    };
1555
1556    Chosen.prototype.no_results_clear = function () {
1557      return this.search_results.find(".no-results").remove();
1558    };
1559
1560    Chosen.prototype.keydown_arrow = function () {
1561      var next_sib;
1562      if (this.results_showing && this.result_highlight) {
1563        next_sib = this.result_highlight.nextAll("li.active-result").first();
1564        if (next_sib) {
1565          return this.result_do_highlight(next_sib);
1566        }
1567      } else {
1568        return this.results_show();
1569      }
1570    };
1571
1572    Chosen.prototype.keyup_arrow = function () {
1573      var prev_sibs;
1574      if (!this.results_showing && !this.is_multiple) {
1575        return this.results_show();
1576      } else if (this.result_highlight) {
1577        prev_sibs = this.result_highlight.prevAll("li.active-result");
1578        if (prev_sibs.length) {
1579          return this.result_do_highlight(prev_sibs.first());
1580        } else {
1581          if (this.choices_count() > 0) {
1582            this.results_hide();
1583          }
1584          return this.result_clear_highlight();
1585        }
1586      }
1587    };
1588
1589    Chosen.prototype.keydown_backstroke = function () {
1590      var next_available_destroy;
1591      if (this.pending_backstroke) {
1592        this.choice_destroy(this.pending_backstroke.find("a").first());
1593        return this.clear_backstroke();
1594      } else {
1595        next_available_destroy = this.search_container
1596          .siblings("li.search-choice")
1597          .last();
1598        if (
1599          next_available_destroy.length &&
1600          !next_available_destroy.hasClass("search-choice-disabled")
1601        ) {
1602          this.pending_backstroke = next_available_destroy;
1603          if (this.single_backstroke_delete) {
1604            return this.keydown_backstroke();
1605          } else {
1606            return this.pending_backstroke.addClass("search-choice-focus");
1607          }
1608        }
1609      }
1610    };
1611
1612    Chosen.prototype.clear_backstroke = function () {
1613      if (this.pending_backstroke) {
1614        this.pending_backstroke.removeClass("search-choice-focus");
1615      }
1616      return (this.pending_backstroke = null);
1617    };
1618
1619    Chosen.prototype.search_field_scale = function () {
1620      var div, i, len, style, style_block, styles, width;
1621      if (!this.is_multiple) {
1622        return;
1623      }
1624      style_block = {
1625        position: "absolute",
1626        left: "-1000px",
1627        top: "-1000px",
1628        display: "none",
1629        whiteSpace: "pre",
1630      };
1631      styles = [
1632        "fontSize",
1633        "fontStyle",
1634        "fontWeight",
1635        "fontFamily",
1636        "lineHeight",
1637        "textTransform",
1638        "letterSpacing",
1639      ];
1640      for (i = 0, len = styles.length; i < len; i++) {
1641        style = styles[i];
1642        style_block[style] = this.search_field.css(style);
1643      }
1644      div = $("<div />").css(style_block);
1645      div.text(this.get_search_field_value());
1646      $("body").append(div);
1647      width = div.width() + 25;
1648      div.remove();
1649      if (this.container.is(":visible")) {
1650        width = Math.min(this.container.outerWidth() - 10, width);
1651      }
1652      return this.search_field.width(width);
1653    };
1654
1655    Chosen.prototype.trigger_form_field_change = function (extra) {
1656      this.form_field_jq.trigger("input", extra);
1657      return this.form_field_jq.trigger("change", extra);
1658    };
1659
1660    return Chosen;
1661  })(AbstractChosen);
1662}.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.