11 lines
27 KiB
JavaScript
11 lines
27 KiB
JavaScript
|
|
/*!
|
||
|
|
Chosen, a Select Box Enhancer for jQuery and Prototype
|
||
|
|
by Patrick Filler for Harvest, http://getharvest.com
|
||
|
|
|
||
|
|
Version 1.1.0
|
||
|
|
Full source at https://github.com/harvesthq/chosen
|
||
|
|
Copyright (c) 2011 Harvest http://getharvest.com
|
||
|
|
|
||
|
|
MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md
|
||
|
|
*/
|
||
|
|
(function(){var t,e,s,i,r,o={}.hasOwnProperty,h=function(t,e){function s(){this.constructor=t}for(var i in e)o.call(e,i)&&(t[i]=e[i]);return s.prototype=e.prototype,t.prototype=new s,t.__super__=e.prototype,t},n={zh_cn:{no_results_text:"没有找到"},zh_tw:{no_results_text:"沒有找到"},en:{no_results_text:"No results match"}};i=function(){function e(){this.options_index=0,this.parsed=[]}return e.prototype.add_node=function(t){return"OPTGROUP"===t.nodeName.toUpperCase()?this.add_group(t):this.add_option(t)},e.prototype.add_group=function(e){var s,i,r,o,h,n;for(s=this.parsed.length,this.parsed.push({array_index:s,group:!0,label:this.escapeExpression(e.label),children:0,disabled:e.disabled,title:e.title,search_keys:t.trim(e.getAttribute("data-keys")||"").replace(/,/g," ")}),h=e.childNodes,n=[],r=0,o=h.length;r<o;r++)i=h[r],n.push(this.add_option(i,s,e.disabled));return n},e.prototype.add_option=function(e,s,i){if("OPTION"===e.nodeName.toUpperCase())return""!==e.text?(null!=s&&(this.parsed[s].children+=1),this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,value:e.value,text:e.text,title:e.title,html:e.innerHTML,selected:e.selected,disabled:i===!0?i:e.disabled,group_array_index:s,classes:e.className,style:e.style.cssText,search_keys:(t.trim(e.getAttribute("data-keys")||"")+e.value).replace(/,/," ")})):this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,empty:!0}),this.options_index+=1},e.prototype.escapeExpression=function(t){var e,s;return null==t||t===!1?"":/[\&\<\>\"\'\`]/.test(t)?(e={"<":"<",">":">",'"':""","'":"'","`":"`"},s=/&(?!\w+;)|[\<\>\"\'\`]/g,t.replace(s,function(t){return e[t]||"&"})):t},e}(),i.select_to_array=function(t){var e,s,r,o,h;for(s=new i,h=t.childNodes,r=0,o=h.length;r<o;r++)e=h[r],s.add_node(e);return s.parsed},e=function(){function e(s,i){this.form_field=s,this.options=null!=i?i:{},e.browser_is_supported()&&(this.lang=n[this.options.lang||(t.zui.clientLang?t.zui.clientLang():"zh_cn")],this.is_multiple=this.form_field.multiple,this.set_default_text(),this.set_default_values(),this.setup(),this.set_up_html(),this.register_observers())}return e.prototype.set_default_values=function(){var t=this;return this.click_test_action=function(e){return t.test_active_click(e)},this.activate_action=function(e){return t.activate_field(e)},this.active_field=!1,this.mouse_on_container=!1,this.results_showing=!1,this.result_highlighted=null,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.drop_direction=this.options.drop_direction||"auto",this.middle_highlight=this.options.middle_highlight,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},e.prototype.set_default_text=function(){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||e.default_multiple_text:this.default_text=this.options.placeholder_text_single||this.options.placeholder_text||e.default_single_text,this.results_none_found=this.form_field.getAttribute("data-no_results_text")||this.options.no_
|