PageSourceSearch

https://mylibidodoc.com/wp-content/plugins/woocommerce-products-filter/js/chosen/chosen.jquery.js?ver=1.4.5

js mylibidodoc.com collected 2026-09-24 19:05:15 UTC 47,503 bytes, 1,361 lines download raw bytes

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