-
Notifications
You must be signed in to change notification settings - Fork 0
/
chosen.jquery.min.js
20 lines (20 loc) · 25.2 KB
/
chosen.jquery.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/* Chosen v1.8.7 | (c) 2011-2024 by Harvest | MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md */
!function(){var o,e,h,r=class{constructor(){this.options_index=0,this.parsed=[]}add_node(e){return"OPTGROUP"===e.nodeName.toUpperCase()?this.add_group(e):this.add_option(e)}add_group(e){var t,s,i,h,l,r=this.parsed.length;for(this.parsed.push({array_index:r,group:!0,label:e.label,title:e.title||void 0,children:0,disabled:e.disabled,classes:e.className}),l=[],t=0,s=(h=e.childNodes).length;t<s;t++)i=h[t],l.push(this.add_option(i,r,e.disabled));return l}add_option(e,t,s){if("OPTION"===e.nodeName.toUpperCase())return""!==e.text?(null!=t&&(this.parsed[t].children+=1),this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,value:e.value,text:e.text,html:e.innerHTML,title:e.title||void 0,selected:e.selected,disabled:!0===s?s:e.disabled,group_array_index:t,group_label:null!=t?this.parsed[t].label:null,classes:e.className,style:e.style.cssText})):this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,empty:!0}),this.options_index+=1}};r.select_to_array=function(e){for(var t,s=new r,i=e.childNodes,h=0,l=i.length;h<l;h++)t=i[h],s.add_node(t);return s.parsed},e=function(){class s{constructor(e,t={}){this.label_click_handler=this.label_click_handler.bind(this),this.form_field=e,this.options=t,s.browser_is_supported()&&(this.is_multiple=this.form_field.multiple,this.set_default_text(),this.set_default_values(),this.setup(),this.set_up_html(),this.register_observers(),this.on_ready())}set_default_values(){return this.click_test_action=e=>this.test_active_click(e),this.activate_action=e=>this.activate_field(e),this.active_field=!1,this.mouse_on_container=!1,this.results_showing=!1,this.result_highlighted=null,this.is_rtl=this.options.rtl||/\bchosen-rtl\b/.test(this.form_field.className),this.allow_single_deselect=null!=this.options.allow_single_deselect&&null!=this.form_field.options[0]&&""===this.form_field.options[0].text&&this.options.allow_single_deselect,this.disable_search_threshold=this.options.disable_search_threshold||0,this.disable_search=this.options.disable_search||!1,this.enable_split_word_search=null==this.options.enable_split_word_search||this.options.enable_split_word_search,this.group_search=null==this.options.group_search||this.options.group_search,this.search_contains=this.options.search_contains||!1,this.single_backstroke_delete=null==this.options.single_backstroke_delete||this.options.single_backstroke_delete,this.max_selected_options=this.options.max_selected_options||1/0,this.inherit_select_classes=this.options.inherit_select_classes||!1,this.display_selected_options=null==this.options.display_selected_options||this.options.display_selected_options,this.display_disabled_options=null==this.options.display_disabled_options||this.options.display_disabled_options,this.include_group_label_in_selected=this.options.include_group_label_in_selected||!1,this.max_shown_results=this.options.max_shown_results||Number.POSITIVE_INFINITY,this.case_sensitive_search=this.options.case_sensitive_search||!1,this.hide_results_on_select=null==this.options.hide_results_on_select||this.options.hide_results_on_select}set_default_text(){return this.form_field.getAttribute("data-placeholder")?this.default_text=this.form_field.getAttribute("data-placeholder"):this.is_multiple?this.default_text=this.options.placeholder_text_multiple||this.options.placeholder_text||s.default_multiple_text:this.default_text=this.options.placeholder_text_single||this.options.placeholder_text||s.default_single_text,this.default_text=this.escape_html(this.default_text),this.results_none_found=this.form_field.getAttribute("data-no_results_text")||this.options.no_results_text||s.default_no_result_text}choice_label(e){return this.include_group_label_in_selected&&null!=e.group_label?`<b class='group-name'>${this.escape_html(e.group_label)}</b>`+e.html:e.html}mouse_enter(){return this.mouse_on_container=!0}mouse_leave(){return this.mouse_on_container=!1}input_focus(e){if(this.is_multiple){if(!this.active_field)return setTimeout(()=>this.container_mousedown(),50)}else if(!this.active_field)return this.activate_field()}input_blur(e){if(!this.mouse_on_container)return this.active_field=!1,setTimeout(()=>this.blur_test(),100)}label_click_handler(e){return this.is_multiple?this.container_mousedown(e):this.activate_field()}results_option_build(e){for(var t,s,i="",h=0,l=this.results_data,r=0,o=l.length;r<o&&((s="")!==(s=(t=l[r]).group?this.result_add_group(t):this.result_add_option(t))&&(h++,i+=s),null!=e&&e.first&&(t.selected&&this.is_multiple?this.choice_build(t):t.selected&&!this.is_multiple&&this.single_set_selected_text(this.choice_label(t))),!(h>=this.max_shown_results));r++);return i}result_add_option(e){var t,s;return e.search_match&&this.include_option_in_results(e)?(t=[],e.disabled||e.selected&&this.is_multiple||t.push("active-result"),!e.disabled||e.selected&&this.is_multiple||t.push("disabled-result"),e.selected&&t.push("result-selected"),null!=e.group_array_index&&t.push("group-option"),""!==e.classes&&t.push(e.classes),(s=document.createElement("li")).className=t.join(" "),e.style&&(s.style.cssText=e.style),s.setAttribute("data-option-array-index",e.array_index),s.innerHTML=e.highlighted_html||e.html,e.title&&(s.title=e.title),this.outerHTML(s)):""}result_add_group(e){var t,s;return(e.search_match||e.group_match)&&0<e.active_options?((t=[]).push("group-result"),e.classes&&t.push(e.classes),(s=document.createElement("li")).className=t.join(" "),s.innerHTML=e.highlighted_html||this.escape_html(e.label),e.title&&(s.title=e.title),this.outerHTML(s)):""}results_update_field(){if(this.set_default_text(),this.is_multiple||this.results_reset_cleanup(),this.result_clear_highlight(),this.results_build(),this.results_showing)return this.winnow_results()}reset_single_select_options(){for(var e,t=this.results_data,s=[],i=0,h=t.length;i<h;i++)(e=t[i]).selected?s.push(e.selected=!1):s.push(void 0);return s}results_toggle(){return this.results_showing?this.results_hide():this.results_show()}results_search(e){return this.results_showing?this.winnow_results():this.results_show()}winnow_results(e){var t,s,i,h,l,r,o,_,n,a,c,d,u;for(this.no_results_clear(),a=0,t=(o=this.get_search_text()).replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),n=this.get_search_regex(t),i=0,h=(_=this.results_data).length;i<h;i++)(l=_[i]).search_match=!1,c=null,l.highlighted_html="",this.include_option_in_results(l)&&(l.group&&(l.group_match=!1,l.active_options=0),null!=l.group_array_index&&this.results_data[l.group_array_index]&&(0===(c=this.results_data[l.group_array_index]).active_options&&c.search_match&&(a+=1),c.active_options+=1),u=l.group?l.label:l.text,l.group&&!this.group_search||(d=this.search_string_match(u,n),l.search_match=null!=d,l.search_match&&!l.group&&(a+=1),l.search_match?(o.length&&(d=d.index,r=u.slice(0,d),s=u.slice(d,d+o.length),d=u.slice(d+o.length),l.highlighted_html=`${this.escape_html(r)}<em>${this.escape_html(s)}</em>`+this.escape_html(d)),null!=c&&(c.group_match=!0)):null!=l.group_array_index&&this.results_data[l.group_array_index].search_match&&(l.search_match=!0)));return this.result_clear_highlight(),a<1&&o.length?(this.update_results_content(""),this.no_results(o)):(this.update_results_content(this.results_option_build()),null!=e&&e.skip_highlight?void 0:this.winnow_results_set_highlight())}get_search_regex(e){var t,e=this.search_contains?e:`(^|\\s|\\b)${e}[^\\s]*`;return this.enable_split_word_search||this.search_contains||(e="^"+e),t=this.case_sensitive_search?"":"i",new RegExp(e,t)}search_string_match(e,t){e=t.exec(e);return!this.search_contains&&null!=e&&e[1]&&(e.index+=1),e}choices_count(){var e,t,s;if(null==this.selected_option_count)for(e=this.selected_option_count=0,t=(s=this.form_field.options).length;e<t;e++)s[e].selected&&(this.selected_option_count+=1);return this.selected_option_count}choices_click(e){if(e.preventDefault(),this.activate_field(),!this.results_showing&&!this.is_disabled)return this.results_show()}keydown_checker(e){var t=null!=(t=e.which)?t:e.keyCode;switch(this.search_field_scale(),8!==t&&this.pending_backstroke&&this.clear_backstroke(),t){case 8:this.backstroke_length=this.get_search_field_value().length;break;case 9:this.results_showing&&!this.is_multiple&&this.result_select(e),this.mouse_on_container=!1;break;case 13:case 27:this.results_showing&&e.preventDefault();break;case 32:this.disable_search&&e.preventDefault();break;case 38:e.preventDefault(),this.keyup_arrow();break;case 40:e.preventDefault(),this.keydown_arrow()}}keyup_checker(e){var t=null!=(t=e.which)?t:e.keyCode;switch(this.search_field_scale(),t){case 8:this.is_multiple&&this.backstroke_length<1&&0<this.choices_count()?this.keydown_backstroke():this.pending_backstroke||(this.result_clear_highlight(),this.results_search());break;case 13:e.preventDefault(),this.results_showing&&this.result_select(e);break;case 27:this.results_showing&&this.results_hide();break;case 9:case 16:case 17:case 18:case 38:case 40:case 91:break;default:this.results_search()}}clipboard_event_checker(e){if(!this.is_disabled)return setTimeout(()=>this.results_search(),50)}container_width(){return null!=this.options.width?this.options.width:this.form_field.offsetWidth+"px"}include_option_in_results(e){return!(this.is_multiple&&!this.display_selected_options&&e.selected||!this.display_disabled_options&&e.disabled||e.empty)}search_results_touchstart(e){return this.touch_started=!0,this.search_results_mouseover(e)}search_results_touchmove(e){return this.touch_started=!1,this.search_results_mouseout(e)}search_results_touchend(e){if(this.touch_started)return this.search_results_mouseup(e)}outerHTML(e){var t;return e.outerHTML||((t=document.createElement("div")).appendChild(e),t.innerHTML)}get_single_html(){return`<a class="chosen-single chosen-default">
<span>${this.default_text}</span>
<div><b></b></div>
</a>
<div class="chosen-drop">
<div class="chosen-search">
<input class="chosen-search-input" type="text" autocomplete="off" />
</div>
<ul class="chosen-results"></ul>
</div>`}get_multi_html(){return`<ul class="chosen-choices">
<li class="search-field">
<input class="chosen-search-input" type="text" autocomplete="off" value="${this.default_text}" />
</li>
</ul>
<div class="chosen-drop">
<ul class="chosen-results"></ul>
</div>`}get_no_results_html(e){return`<li class="no-results">
${this.results_none_found} <span>${this.escape_html(e)}</span>
</li>`}static browser_is_supported(){return"Microsoft Internet Explorer"===window.navigator.appName?8<=document.documentMode:!(/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))}}return s.default_multiple_text="Select Some Options",s.default_single_text="Select an Option",s.default_no_result_text="No results match",s}.call(this),(o=jQuery).fn.extend({chosen:function(i){return e.browser_is_supported()?this.each(function(e){var t=o(this),s=t.data("chosen");"destroy"===i?s instanceof h&&s.destroy():s instanceof h||t.data("chosen",new h(this,i))}):this}}),h=class extends e{setup(){return this.form_field_jq=o(this.form_field),this.current_selectedIndex=this.form_field.selectedIndex}set_up_html(){var e=["chosen-container"];return e.push("chosen-container-"+(this.is_multiple?"multi":"single")),this.inherit_select_classes&&this.form_field.className&&e.push(this.form_field.className),this.is_rtl&&e.push("chosen-rtl"),e={"class":e.join(" "),title:this.form_field.title},this.form_field.id.length&&(e.id=this.form_field.id.replace(/[^\w]/g,"_")+"_chosen"),this.container=o("<div />",e),this.container.width(this.container_width()),this.is_multiple?this.container.html(this.get_multi_html()):this.container.html(this.get_single_html()),this.form_field_jq.hide().after(this.container),this.dropdown=this.container.find("div.chosen-drop").first(),this.search_field=this.container.find("input").first(),this.search_results=this.container.find("ul.chosen-results").first(),this.search_field_scale(),this.search_no_results=this.container.find("li.no-results").first(),this.is_multiple?(this.search_choices=this.container.find("ul.chosen-choices").first(),this.search_container=this.container.find("li.search-field").first()):(this.search_container=this.container.find("div.chosen-search").first(),this.selected_item=this.container.find(".chosen-single").first()),this.results_build(),this.set_tab_index(),this.set_label_behavior()}on_ready(){return this.form_field_jq.trigger("chosen:ready",{chosen:this})}register_observers(){return this.container.on("touchstart.chosen",e=>{this.container_mousedown(e)}),this.container.on("touchend.chosen",e=>{this.container_mouseup(e)}),this.container.on("mousedown.chosen",e=>{this.container_mousedown(e)}),this.container.on("mouseup.chosen",e=>{this.container_mouseup(e)}),this.container.on("mouseenter.chosen",e=>{this.mouse_enter(e)}),this.container.on("mouseleave.chosen",e=>{this.mouse_leave(e)}),this.search_results.on("mouseup.chosen",e=>{this.search_results_mouseup(e)}),this.search_results.on("mouseover.chosen",e=>{this.search_results_mouseover(e)}),this.search_results.on("mouseout.chosen",e=>{this.search_results_mouseout(e)}),this.search_results.on("mousewheel.chosen DOMMouseScroll.chosen",e=>{this.search_results_mousewheel(e)}),this.search_results.on("touchstart.chosen",e=>{this.search_results_touchstart(e)}),this.search_results.on("touchmove.chosen",e=>{this.search_results_touchmove(e)}),this.search_results.on("touchend.chosen",e=>{this.search_results_touchend(e)}),this.form_field_jq.on("chosen:updated.chosen",e=>{this.results_update_field(e)}),this.form_field_jq.on("chosen:activate.chosen",e=>{this.activate_field(e)}),this.form_field_jq.on("chosen:open.chosen",e=>{this.container_mousedown(e)}),this.form_field_jq.on("chosen:close.chosen",e=>{this.close_field(e)}),this.search_field.on("blur.chosen",e=>{this.input_blur(e)}),this.search_field.on("keyup.chosen",e=>{this.keyup_checker(e)}),this.search_field.on("keydown.chosen",e=>{this.keydown_checker(e)}),this.search_field.on("focus.chosen",e=>{this.input_focus(e)}),this.search_field.on("cut.chosen",e=>{this.clipboard_event_checker(e)}),this.search_field.on("paste.chosen",e=>{this.clipboard_event_checker(e)}),this.is_multiple?this.search_choices.on("click.chosen",e=>{this.choices_click(e)}):this.container.on("click.chosen",function(e){e.preventDefault()})}destroy(){return o(this.container[0].ownerDocument).off("click.chosen",this.click_test_action),0<this.form_field_label.length&&this.form_field_label.off("click.chosen"),this.search_field[0].tabIndex&&(this.form_field_jq[0].tabIndex=this.search_field[0].tabIndex),this.container.remove(),this.form_field_jq.removeData("chosen"),this.form_field_jq.show()}search_field_disabled(){return this.is_disabled=this.form_field.disabled||this.form_field_jq.parents("fieldset").is(":disabled"),this.container.toggleClass("chosen-disabled",this.is_disabled),this.search_field[0].disabled=this.is_disabled,this.is_multiple||this.selected_item.off("focus.chosen",this.activate_field),this.is_disabled?this.close_field():this.is_multiple?void 0:this.selected_item.on("focus.chosen",this.activate_field)}container_mousedown(e){var t;if(!this.is_disabled)return!e||"mousedown"!==(t=e.type)&&"touchstart"!==t||this.results_showing||e.preventDefault(),null!=e&&o(e.target).hasClass("search-choice-close")?void 0:(this.active_field?this.is_multiple||!e||o(e.target)[0]!==this.selected_item[0]&&!o(e.target).parents("a.chosen-single").length||(e.preventDefault(),this.results_toggle()):(this.is_multiple&&this.search_field.val(""),o(this.container[0].ownerDocument).on("click.chosen",this.click_test_action),this.results_show()),this.activate_field())}container_mouseup(e){if("ABBR"===e.target.nodeName&&!this.is_disabled)return this.results_reset(e)}search_results_mousewheel(e){var t;if(null!=(t=e.originalEvent?e.originalEvent.deltaY||-e.originalEvent.wheelDelta||e.originalEvent.detail:t))return e.preventDefault(),"DOMMouseScroll"===e.type&&(t*=40),this.search_results.scrollTop(t+this.search_results.scrollTop())}blur_test(e){if(!this.active_field&&this.container.hasClass("chosen-container-active"))return this.close_field()}close_field(){return o(this.container[0].ownerDocument).off("click.chosen",this.click_test_action),this.active_field=!1,this.results_hide(),this.container.removeClass("chosen-container-active"),this.clear_backstroke(),this.show_search_field_default(),this.search_field_scale(),this.search_field.trigger("blur")}activate_field(){if(!this.is_disabled)return this.container.addClass("chosen-container-active"),this.active_field=!0,this.search_field.val(this.search_field.val()),this.search_field.trigger("focus")}test_active_click(e){e=o(e.target).closest(".chosen-container");return e.length&&this.container[0]===e[0]?this.active_field=!0:this.close_field()}results_build(){return this.parsing=!0,this.selected_option_count=null,this.results_data=r.select_to_array(this.form_field),this.is_multiple?this.search_choices.find("li.search-choice").remove():(this.single_set_selected_text(),this.disable_search||this.form_field.options.length<=this.disable_search_threshold?(this.search_field[0].readOnly=!0,this.container.addClass("chosen-container-single-nosearch")):(this.search_field[0].readOnly=!1,this.container.removeClass("chosen-container-single-nosearch"))),this.update_results_content(this.results_option_build({first:!0})),this.search_field_disabled(),this.show_search_field_default(),this.search_field_scale(),this.parsing=!1}result_do_highlight(e){var t,s,i;if(e.length)return this.result_clear_highlight(),this.result_highlight=e,this.result_highlight.addClass("highlighted"),(e=parseInt(this.search_results.css("maxHeight"),10))+(i=this.search_results.scrollTop())<=(t=(s=this.result_highlight.position().top+this.search_results.scrollTop())+this.result_highlight.outerHeight())?this.search_results.scrollTop(0<t-e?t-e:0):s<i?this.search_results.scrollTop(s):void 0}result_clear_highlight(){return this.result_highlight&&this.result_highlight.removeClass("highlighted"),this.result_highlight=null}results_show(){return this.is_multiple&&this.max_selected_options<=this.choices_count()?(this.form_field_jq.trigger("chosen:maxselected",{chosen:this}),!1):(this.container.addClass("chosen-with-drop"),this.results_showing=!0,this.search_field.trigger("focus"),this.search_field.val(this.get_search_field_value()),this.winnow_results(),this.form_field_jq.trigger("chosen:showing_dropdown",{chosen:this}))}update_results_content(e){return this.search_results.html(e)}results_hide(){return this.results_showing&&(this.result_clear_highlight(),this.container.removeClass("chosen-with-drop"),this.form_field_jq.trigger("chosen:hiding_dropdown",{chosen:this})),this.results_showing=!1}set_tab_index(e){var t;if(this.form_field.tabIndex)return t=this.form_field.tabIndex,this.form_field.tabIndex=-1,this.search_field[0].tabIndex=t}set_label_behavior(){if(this.form_field_label=this.form_field_jq.parents("label"),!this.form_field_label.length&&this.form_field.id.length&&(this.form_field_label=o(`label[for='${this.form_field.id}']`)),0<this.form_field_label.length)return this.form_field_label.on("click.chosen",this.label_click_handler)}show_search_field_default(){return this.is_multiple&&this.choices_count()<1&&!this.active_field?(this.search_field.val(this.default_text),this.search_field.addClass("default")):(this.search_field.val(""),this.search_field.removeClass("default"))}search_results_mouseup(e){var t=o(e.target).hasClass("active-result")?o(e.target):o(e.target).parents(".active-result").first();if(t.length)return this.result_highlight=t,this.result_select(e),this.search_field.trigger("focus")}search_results_mouseover(e){e=o(e.target).hasClass("active-result")?o(e.target):o(e.target).parents(".active-result").first();if(e)return this.result_do_highlight(e)}search_results_mouseout(e){if(o(e.target).hasClass("active-result")||o(e.target).parents(".active-result").first())return this.result_clear_highlight()}choice_build(e){var t=o("<li />",{"class":"search-choice"}).html(`<span>${this.choice_label(e)}</span>`);return e.disabled?t.addClass("search-choice-disabled"):((e=o("<a />",{"class":"search-choice-close","data-option-array-index":e.array_index})).on("click.chosen",e=>this.choice_destroy_link_click(e)),t.append(e)),this.search_container.before(t)}choice_destroy_link_click(e){if(e.preventDefault(),e.stopPropagation(),!this.is_disabled)return this.choice_destroy(o(e.target))}choice_destroy(e){if(this.result_deselect(e[0].getAttribute("data-option-array-index")))return this.active_field?this.search_field.trigger("focus"):this.show_search_field_default(),this.is_multiple&&0<this.choices_count()&&this.get_search_field_value().length<1&&this.results_hide(),e.parents("li").first().remove(),this.search_field_scale()}results_reset(){if(this.reset_single_select_options(),this.form_field.options[0].selected=!0,this.single_set_selected_text(),this.show_search_field_default(),this.results_reset_cleanup(),this.trigger_form_field_change(),this.active_field)return this.results_hide()}results_reset_cleanup(){return this.current_selectedIndex=this.form_field.selectedIndex,this.selected_item.find("abbr").remove()}result_select(e){var t;if(this.result_highlight)return t=this.result_highlight,this.result_clear_highlight(),this.is_multiple&&this.max_selected_options<=this.choices_count()?(this.form_field_jq.trigger("chosen:maxselected",{chosen:this}),!1):(this.is_multiple?t.removeClass("active-result"):this.reset_single_select_options(),t.addClass("result-selected"),(t=this.results_data[t[0].getAttribute("data-option-array-index")]).selected=!0,this.form_field.options[t.options_index].selected=!0,this.selected_option_count=null,this.is_multiple?this.choice_build(t):this.single_set_selected_text(this.choice_label(t)),this.is_multiple&&(!this.hide_results_on_select||e.metaKey||e.ctrlKey)?e.metaKey||e.ctrlKey?this.winnow_results({skip_highlight:!0}):(this.search_field.val(""),this.winnow_results()):(this.results_hide(),this.show_search_field_default()),!this.is_multiple&&this.form_field.selectedIndex===this.current_selectedIndex||this.trigger_form_field_change({selected:this.form_field.options[t.options_index].value}),this.current_selectedIndex=this.form_field.selectedIndex,e.preventDefault(),this.search_field_scale())}single_set_selected_text(e=this.default_text){return e===this.default_text?this.selected_item.addClass("chosen-default"):(this.single_deselect_control_build(),this.selected_item.removeClass("chosen-default")),this.selected_item.find("span").html(e)}result_deselect(e){e=this.results_data[e];return!this.form_field.options[e.options_index].disabled&&(e.selected=!1,this.form_field.options[e.options_index].selected=!1,this.selected_option_count=null,this.result_clear_highlight(),this.results_showing&&this.winnow_results(),this.trigger_form_field_change({deselected:this.form_field.options[e.options_index].value}),this.search_field_scale(),!0)}single_deselect_control_build(){if(this.allow_single_deselect)return this.selected_item.find("abbr").length||this.selected_item.find("span").first().after('<abbr class="search-choice-close"></abbr>'),this.selected_item.addClass("chosen-single-with-deselect")}get_search_field_value(){return this.search_field.val()}get_search_text(){return this.get_search_field_value().trim()}escape_html(e){return o("<div/>").text(e).html()}winnow_results_set_highlight(){var e=this.is_multiple?[]:this.search_results.find(".result-selected.active-result"),e=(e.length?e:this.search_results.find(".active-result")).first();if(null!=e)return this.result_do_highlight(e)}no_results(e){e=this.get_no_results_html(e);return this.search_results.append(e),this.form_field_jq.trigger("chosen:no_results",{chosen:this})}no_results_clear(){return this.search_results.find(".no-results").remove()}keydown_arrow(){var e;return this.results_showing&&this.result_highlight?(e=this.result_highlight.nextAll("li.active-result").first())?this.result_do_highlight(e):void 0:this.results_show()}keyup_arrow(){var e;return this.results_showing||this.is_multiple?this.result_highlight?(e=this.result_highlight.prevAll("li.active-result")).length?this.result_do_highlight(e.first()):(0<this.choices_count()&&this.results_hide(),this.result_clear_highlight()):void 0:this.results_show()}keydown_backstroke(){var e;return this.pending_backstroke?(this.choice_destroy(this.pending_backstroke.find("a").first()),this.clear_backstroke()):(e=this.search_container.siblings("li.search-choice").last()).length&&!e.hasClass("search-choice-disabled")?(this.pending_backstroke=e,this.single_backstroke_delete?this.keydown_backstroke():this.pending_backstroke.addClass("search-choice-focus")):void 0}clear_backstroke(){return this.pending_backstroke&&this.pending_backstroke.removeClass("search-choice-focus"),this.pending_backstroke=null}search_field_scale(){var e,t,s,i,h,l,r;if(this.is_multiple){for(h={position:"absolute",left:"-1000px",top:"-1000px",display:"none",whiteSpace:"pre"},t=0,s=(l=["fontSize","fontStyle","fontWeight","fontFamily","lineHeight","textTransform","letterSpacing"]).length;t<s;t++)h[i=l[t]]=this.search_field.css(i);return(e=o("<div />").css(h)).text(this.get_search_field_value()),o("body").append(e),r=e.width()+25,e.remove(),this.container.is(":visible")&&(r=Math.min(this.container.outerWidth()-10,r)),this.search_field.width(r)}}trigger_form_field_change(e){return this.form_field_jq.trigger("input",e),this.form_field_jq.trigger("change",e)}}}.call(this);