2011-12-18 13:41:42 +00:00
|
|
|
(function(){var a;a=(function(){function b(){this.options_index=0;this.parsed=[]}b.prototype.add_node=function(c){if(c.nodeName==="OPTGROUP"){return this.add_group(c)}else{return this.add_option(c)}};b.prototype.add_group=function(i){var h,e,g,d,f,c;h=this.parsed.length;this.parsed.push({array_index:h,group:true,label:i.label,children:0,disabled:i.disabled});f=i.childNodes;c=[];for(g=0,d=f.length;g<d;g++){e=f[g];c.push(this.add_option(e,h,i.disabled))}return c};b.prototype.add_option=function(d,e,c){if(d.nodeName==="OPTION"){if(d.text!==""){if(e!=null){this.parsed[e].children+=1}this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,value:d.value,text:d.text,html:d.innerHTML,selected:d.selected,disabled:c===true?c:d.disabled,group_array_index:e,classes:d.className,style:d.style.cssText})}else{this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,empty:true})}return this.options_index+=1}};return b})();a.select_to_array=function(b){var g,f,e,c,d;f=new a();d=b.childNodes;for(e=0,c=d.length;e<c;e++){g=d[e];f.add_node(g)}return f.parsed};this.SelectParser=a}).call(this);(function(){var b,a;var c=function(d,e){return function(){return d.apply(e,arguments)}};a=this;b=(function(){function d(e,f){this.form_field=e;this.options=f!=null?f:{};this.set_default_values();this.is_multiple=this.form_field.multiple;this.default_text_default=this.is_multiple?"Select Some Options":"Select an Option";this.setup();this.set_up_html();this.register_observers();this.finish_setup()}d.prototype.set_default_values=function(){this.click_test_action=c(function(e){return this.test_active_click(e)},this);this.activate_action=c(function(e){return this.activate_field(e)},this);this.active_field=false;this.mouse_on_container=false;this.results_showing=false;this.result_highlighted=null;this.result_single_selected=null;this.allow_single_deselect=(this.options.allow_single_deselect!=null)&&(this.form_field.options[0]!=null)&&this.form_field.options[0].value===""?this.options.allow_single_deselect:false;this.disable_search_threshold=this.options.disable_search_threshold||0;this.choices=0;return this.results_none_found=this.options.no_results_text||"No results match"};d.prototype.mouse_enter=function(){return this.mouse_on_container=true};d.prototype.mouse_leave=function(){return this.mouse_on_container=false};d.prototype.input_focus=function(e){if(!this.active_field){return setTimeout((c(function(){return this.container_mousedown()},this)),50)}};d.prototype.input_blur=function(e){if(!this.mouse_on_container){this.active_field=false;return setTimeout((c(function(){return this.blur_test()},this)),100)}};d.prototype.result_add_option=function(g){var e,f;if(!g.disabled){g.dom_id=this.container_id+"_o_"+g.array_index;e=g.selected&&this.is_multiple?[]:["active-result"];if(g.selected){e.push("result-selected")}if(g.group_array_index!=null){e.push("group-option")}if(g.classes!==""){e.push(g.classes)}f=g.style.cssText!==""?' style="'+g.style+'"':"";return'<li id="'+g.dom_id+'" class="'+e.join(" ")+'"'+f+">"+g.html+"</li>"}else{return""}};d.prototype.results_update_field=function(){this.result_clear_highlight();this.result_single_selected=null;return this.results_build()};d.prototype.results_toggle=function(){if(this.results_showing){return this.results_hide()}else{return this.results_show()}};d.prototype.results_search=function(e){if(this.results_showing){return this.winnow_results()}else{return this.results_show()}};d.prototype.keyup_checker=function(e){var g,f;g=(f=e.which)!=null?f:e.keyCode;this.search_field_scale();switch(g){case 8:if(this.is_multiple&&this.backstroke_length<1&&this.choices>0){return this.keydown_backstroke()}else{if(!this.pending_backstroke){this.result_clear_highlight();return this.results_search()}}break;case 13:e.preventDefault();if(this.results_showing){return this.result_select(e)}break;case 27:if(this.results_showing){return this.results_hide()}break;case 9:case 38:case 40:case 16:case 91:case 17:break;default:return this.results_search()}};d.prototype.generate_field_id=function(){va
|