531 lines
22 KiB
JavaScript
531 lines
22 KiB
JavaScript
// Chosen, a Select Box Enhancer for jQuery and Protoype
|
|
// by Patrick Filler for Harvest, http://getharvest.com
|
|
//
|
|
// Version 0.9.5
|
|
// 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
|
|
// This file is generated by `cake build`, do not edit it by hand.
|
|
(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].text===""?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(){var e;
|
|
e=this.generate_random_id();
|
|
this.form_field.id=e;
|
|
return e;
|
|
};
|
|
d.prototype.generate_random_char=function(){var g,f,e;
|
|
g="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZ";
|
|
e=Math.floor(Math.random()*g.length);
|
|
return f=g.substring(e,e+1);
|
|
};
|
|
return d;
|
|
})();
|
|
a.AbstractChosen=b;
|
|
}).call(this);
|
|
(function(){var f,g,e,a;
|
|
var c=Object.prototype.hasOwnProperty,d=function(k,i){for(var h in i){if(c.call(i,h)){k[h]=i[h];
|
|
}}function j(){this.constructor=k;
|
|
}j.prototype=i.prototype;
|
|
k.prototype=new j;
|
|
k.__super__=i.prototype;
|
|
return k;
|
|
},b=function(h,i){return function(){return h.apply(i,arguments);
|
|
};
|
|
};
|
|
a=this;
|
|
f=jQuery;
|
|
f.fn.extend({chosen:function(h){if(f.browser.msie&&f.browser.version==="6.0"){return this;
|
|
}return f(this).each(function(i){if(!(f(this)).hasClass("chzn-done")){return new g(this,h);
|
|
}});
|
|
}});
|
|
g=(function(){d(h,AbstractChosen);
|
|
function h(){h.__super__.constructor.apply(this,arguments);
|
|
}h.prototype.setup=function(){this.form_field_jq=f(this.form_field);
|
|
return this.is_rtl=this.form_field_jq.hasClass("chzn-rtl");
|
|
};
|
|
h.prototype.finish_setup=function(){return this.form_field_jq.addClass("chzn-done");
|
|
};
|
|
h.prototype.set_up_html=function(){var l,k,j,i;
|
|
this.container_id=this.form_field.id.length?this.form_field.id.replace(/(:|\.)/g,"_"):this.generate_field_id();
|
|
this.container_id+="_chzn";
|
|
this.f_width=this.form_field_jq.outerWidth();
|
|
this.default_text=this.form_field_jq.data("placeholder")?this.form_field_jq.data("placeholder"):this.default_text_default;
|
|
l=f("<div />",{id:this.container_id,"class":"chzn-container"+(this.is_rtl?" chzn-rtl":""),style:"width: "+this.f_width+"px;"});
|
|
if(this.is_multiple){l.html('<ul class="chzn-choices"><li class="search-field"><input type="text" value="'+this.default_text+'" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop" style="left:-9000px;"><ul class="chzn-results"></ul></div>');
|
|
}else{l.html('<a href="javascript:void(0)" class="chzn-single"><span>'+this.default_text+'</span><div><b></b></div></a><div class="chzn-drop" style="left:-9000px;"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>');
|
|
}this.form_field_jq.hide().after(l);
|
|
this.container=f("#"+this.container_id);
|
|
this.container.addClass("chzn-container-"+(this.is_multiple?"multi":"single"));
|
|
this.dropdown=this.container.find("div.chzn-drop").first();
|
|
k=this.container.height();
|
|
j=this.f_width-e(this.dropdown);
|
|
this.dropdown.css({"width":j+"px","top":k+"px"});
|
|
this.search_field=this.container.find("input").first();
|
|
this.search_results=this.container.find("ul.chzn-results").first();
|
|
this.search_field_scale();
|
|
this.search_no_results=this.container.find("li.no-results").first();
|
|
if(this.is_multiple){this.search_choices=this.container.find("ul.chzn-choices").first();
|
|
this.search_container=this.container.find("li.search-field").first();
|
|
}else{this.search_container=this.container.find("div.chzn-search").first();
|
|
this.selected_item=this.container.find(".chzn-single").first();
|
|
i=j-e(this.search_container)-e(this.search_field);
|
|
this.search_field.css({"width":i+"px"});
|
|
}this.results_build();
|
|
this.set_tab_index();
|
|
return this.form_field_jq.trigger("liszt:ready",{chosen:this});
|
|
};
|
|
h.prototype.register_observers=function(){this.container.mousedown(b(function(i){return this.container_mousedown(i);
|
|
},this));
|
|
this.container.mouseup(b(function(i){return this.container_mouseup(i);
|
|
},this));
|
|
this.container.mouseenter(b(function(i){return this.mouse_enter(i);
|
|
},this));
|
|
this.container.mouseleave(b(function(i){return this.mouse_leave(i);
|
|
},this));
|
|
this.search_results.mouseup(b(function(i){return this.search_results_mouseup(i);
|
|
},this));
|
|
this.search_results.mouseover(b(function(i){return this.search_results_mouseover(i);
|
|
},this));
|
|
this.search_results.mouseout(b(function(i){return this.search_results_mouseout(i);
|
|
},this));
|
|
this.form_field_jq.bind("liszt:updated",b(function(i){return this.results_update_field(i);
|
|
},this));
|
|
this.search_field.blur(b(function(i){return this.input_blur(i);
|
|
},this));
|
|
this.search_field.keyup(b(function(i){return this.keyup_checker(i);
|
|
},this));
|
|
this.search_field.keydown(b(function(i){return this.keydown_checker(i);
|
|
},this));
|
|
if(this.is_multiple){this.search_choices.click(b(function(i){return this.choices_click(i);
|
|
},this));
|
|
return this.search_field.focus(b(function(i){return this.input_focus(i);
|
|
},this));
|
|
}};
|
|
h.prototype.search_field_disabled=function(){this.is_disabled=this.form_field_jq[0].disabled;
|
|
if(this.is_disabled){this.container.addClass("chzn-disabled");
|
|
this.search_field[0].disabled=true;
|
|
if(!this.is_multiple){this.selected_item.unbind("focus",this.activate_action);
|
|
}return this.close_field();
|
|
}else{this.container.removeClass("chzn-disabled");
|
|
this.search_field[0].disabled=false;
|
|
if(!this.is_multiple){return this.selected_item.bind("focus",this.activate_action);
|
|
}}};
|
|
h.prototype.container_mousedown=function(i){var j;
|
|
if(!this.is_disabled){j=i!=null?(f(i.target)).hasClass("search-choice-close"):false;
|
|
if(i&&i.type==="mousedown"){i.stopPropagation();
|
|
}if(!this.pending_destroy_click&&!j){if(!this.active_field){if(this.is_multiple){this.search_field.val("");
|
|
}f(document).click(this.click_test_action);
|
|
this.results_show();
|
|
}else{if(!this.is_multiple&&i&&((f(i.target)[0]===this.selected_item[0])||f(i.target).parents("a.chzn-single").length)){i.preventDefault();
|
|
this.results_toggle();
|
|
}}return this.activate_field();
|
|
}else{return this.pending_destroy_click=false;
|
|
}}};
|
|
h.prototype.container_mouseup=function(i){if(i.target.nodeName==="ABBR"){return this.results_reset(i);
|
|
}};
|
|
h.prototype.blur_test=function(i){if(!this.active_field&&this.container.hasClass("chzn-container-active")){return this.close_field();
|
|
}};
|
|
h.prototype.close_field=function(){f(document).unbind("click",this.click_test_action);
|
|
if(!this.is_multiple){this.selected_item.attr("tabindex",this.search_field.attr("tabindex"));
|
|
this.search_field.attr("tabindex",-1);
|
|
}this.active_field=false;
|
|
this.results_hide();
|
|
this.container.removeClass("chzn-container-active");
|
|
this.winnow_results_clear();
|
|
this.clear_backstroke();
|
|
this.show_search_field_default();
|
|
return this.search_field_scale();
|
|
};
|
|
h.prototype.activate_field=function(){if(!this.is_multiple&&!this.active_field){this.search_field.attr("tabindex",this.selected_item.attr("tabindex"));
|
|
this.selected_item.attr("tabindex",-1);
|
|
}this.container.addClass("chzn-container-active");
|
|
this.active_field=true;
|
|
this.search_field.val(this.search_field.val());
|
|
return this.search_field.focus();
|
|
};
|
|
h.prototype.test_active_click=function(i){if(f(i.target).parents("#"+this.container_id).length){return this.active_field=true;
|
|
}else{return this.close_field();
|
|
}};
|
|
h.prototype.results_build=function(){var j,m,l,i,k;
|
|
this.parsing=true;
|
|
this.results_data=a.SelectParser.select_to_array(this.form_field);
|
|
if(this.is_multiple&&this.choices>0){this.search_choices.find("li.search-choice").remove();
|
|
this.choices=0;
|
|
}else{if(!this.is_multiple){this.selected_item.find("span").text(this.default_text);
|
|
if(this.form_field.options.length<=this.disable_search_threshold){this.container.addClass("chzn-container-single-nosearch");
|
|
}else{this.container.removeClass("chzn-container-single-nosearch");
|
|
}}}j="";
|
|
k=this.results_data;
|
|
for(l=0,i=k.length;
|
|
l<i;
|
|
l++){m=k[l];
|
|
if(m.group){j+=this.result_add_group(m);
|
|
}else{if(!m.empty){j+=this.result_add_option(m);
|
|
if(m.selected&&this.is_multiple){this.choice_build(m);
|
|
}else{if(m.selected&&!this.is_multiple){this.selected_item.find("span").text(m.text);
|
|
if(this.allow_single_deselect){this.single_deselect_control_build();
|
|
}}}}}}this.search_field_disabled();
|
|
this.show_search_field_default();
|
|
this.search_field_scale();
|
|
this.search_results.html(j);
|
|
return this.parsing=false;
|
|
};
|
|
h.prototype.result_add_group=function(i){if(!i.disabled){i.dom_id=this.container_id+"_g_"+i.array_index;
|
|
return'<li id="'+i.dom_id+'" class="group-result">'+f("<div />").text(i.label).html()+"</li>";
|
|
}else{return"";
|
|
}};
|
|
h.prototype.result_do_highlight=function(j){var n,m,k,l,i;
|
|
if(j.length){this.result_clear_highlight();
|
|
this.result_highlight=j;
|
|
this.result_highlight.addClass("highlighted");
|
|
k=parseInt(this.search_results.css("maxHeight"),10);
|
|
i=this.search_results.scrollTop();
|
|
l=k+i;
|
|
m=this.result_highlight.position().top+this.search_results.scrollTop();
|
|
n=m+this.result_highlight.outerHeight();
|
|
if(n>=l){return this.search_results.scrollTop((n-k)>0?n-k:0);
|
|
}else{if(m<i){return this.search_results.scrollTop(m);
|
|
}}}};
|
|
h.prototype.result_clear_highlight=function(){if(this.result_highlight){this.result_highlight.removeClass("highlighted");
|
|
}return this.result_highlight=null;
|
|
};
|
|
h.prototype.results_show=function(){var i;
|
|
if(!this.is_multiple){this.selected_item.addClass("chzn-single-with-drop");
|
|
if(this.result_single_selected){this.result_do_highlight(this.result_single_selected);
|
|
}}i=this.is_multiple?this.container.height():this.container.height()-1;
|
|
this.dropdown.css({"top":i+"px","left":0});
|
|
this.results_showing=true;
|
|
this.search_field.focus();
|
|
this.search_field.val(this.search_field.val());
|
|
return this.winnow_results();
|
|
};
|
|
h.prototype.results_hide=function(){if(!this.is_multiple){this.selected_item.removeClass("chzn-single-with-drop");
|
|
}this.result_clear_highlight();
|
|
this.dropdown.css({"left":"-9000px"});
|
|
return this.results_showing=false;
|
|
};
|
|
h.prototype.set_tab_index=function(j){var i;
|
|
if(this.form_field_jq.attr("tabindex")){i=this.form_field_jq.attr("tabindex");
|
|
this.form_field_jq.attr("tabindex",-1);
|
|
if(this.is_multiple){return this.search_field.attr("tabindex",i);
|
|
}else{this.selected_item.attr("tabindex",i);
|
|
return this.search_field.attr("tabindex",-1);
|
|
}}};
|
|
h.prototype.show_search_field_default=function(){if(this.is_multiple&&this.choices<1&&!this.active_field){this.search_field.val(this.default_text);
|
|
return this.search_field.addClass("default");
|
|
}else{this.search_field.val("");
|
|
return this.search_field.removeClass("default");
|
|
}};
|
|
h.prototype.search_results_mouseup=function(i){var j;
|
|
j=f(i.target).hasClass("active-result")?f(i.target):f(i.target).parents(".active-result").first();
|
|
if(j.length){this.result_highlight=j;
|
|
return this.result_select(i);
|
|
}};
|
|
h.prototype.search_results_mouseover=function(i){var j;
|
|
j=f(i.target).hasClass("active-result")?f(i.target):f(i.target).parents(".active-result").first();
|
|
if(j){return this.result_do_highlight(j);
|
|
}};
|
|
h.prototype.search_results_mouseout=function(i){if(f(i.target).hasClass("active-result"||f(i.target).parents(".active-result").first())){return this.result_clear_highlight();
|
|
}};
|
|
h.prototype.choices_click=function(i){i.preventDefault();
|
|
if(this.active_field&&!(f(i.target).hasClass("search-choice"||f(i.target).parents(".search-choice").first))&&!this.results_showing){return this.results_show();
|
|
}};
|
|
h.prototype.choice_build=function(k){var i,j;
|
|
i=this.container_id+"_c_"+k.array_index;
|
|
this.choices+=1;
|
|
this.search_container.before('<li class="search-choice" id="'+i+'"><span>'+k.html+'</span><a href="javascript:void(0)" class="search-choice-close" rel="'+k.array_index+'"></a></li>');
|
|
j=f("#"+i).find("a").first();
|
|
return j.click(b(function(l){return this.choice_destroy_link_click(l);
|
|
},this));
|
|
};
|
|
h.prototype.choice_destroy_link_click=function(i){i.preventDefault();
|
|
if(!this.is_disabled){this.pending_destroy_click=true;
|
|
return this.choice_destroy(f(i.target));
|
|
}else{return i.stopPropagation;
|
|
}};
|
|
h.prototype.choice_destroy=function(i){this.choices-=1;
|
|
this.show_search_field_default();
|
|
if(this.is_multiple&&this.choices>0&&this.search_field.val().length<1){this.results_hide();
|
|
}this.result_deselect(i.attr("rel"));
|
|
return i.parents("li").first().remove();
|
|
};
|
|
h.prototype.results_reset=function(i){this.form_field.options[0].selected=true;
|
|
this.selected_item.find("span").text(this.default_text);
|
|
this.show_search_field_default();
|
|
f(i.target).remove();
|
|
this.form_field_jq.trigger("change");
|
|
if(this.active_field){return this.results_hide();
|
|
}};
|
|
h.prototype.result_select=function(j){var m,l,k,i;
|
|
if(this.result_highlight){m=this.result_highlight;
|
|
l=m.attr("id");
|
|
this.result_clear_highlight();
|
|
if(this.is_multiple){this.result_deactivate(m);
|
|
}else{this.search_results.find(".result-selected").removeClass("result-selected");
|
|
this.result_single_selected=m;
|
|
}m.addClass("result-selected");
|
|
i=l.substr(l.lastIndexOf("_")+1);
|
|
k=this.results_data[i];
|
|
k.selected=true;
|
|
this.form_field.options[k.options_index].selected=true;
|
|
if(this.is_multiple){this.choice_build(k);
|
|
}else{this.selected_item.find("span").first().text(k.text);
|
|
if(this.allow_single_deselect){this.single_deselect_control_build();
|
|
}}if(!(j.metaKey&&this.is_multiple)){this.results_hide();
|
|
}this.search_field.val("");
|
|
this.form_field_jq.trigger("change");
|
|
return this.search_field_scale();
|
|
}};
|
|
h.prototype.result_activate=function(i){return i.addClass("active-result");
|
|
};
|
|
h.prototype.result_deactivate=function(i){return i.removeClass("active-result");
|
|
};
|
|
h.prototype.result_deselect=function(k){var i,j;
|
|
j=this.results_data[k];
|
|
j.selected=false;
|
|
this.form_field.options[j.options_index].selected=false;
|
|
i=f("#"+this.container_id+"_o_"+k);
|
|
i.removeClass("result-selected").addClass("active-result").show();
|
|
this.result_clear_highlight();
|
|
this.winnow_results();
|
|
this.form_field_jq.trigger("change");
|
|
return this.search_field_scale();
|
|
};
|
|
h.prototype.single_deselect_control_build=function(){if(this.allow_single_deselect&&this.selected_item.find("abbr").length<1){return this.selected_item.find("span").first().after('<abbr class="search-choice-close"></abbr>');
|
|
}};
|
|
h.prototype.winnow_results=function(){var x,q,k,n,u,y,s,p,w,r,v,j,m,l,t,i,o;
|
|
this.no_results_clear();
|
|
p=0;
|
|
w=this.search_field.val()===this.default_text?"":f("<div/>").text(f.trim(this.search_field.val())).html();
|
|
u=new RegExp(w.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i");
|
|
j=new RegExp(w.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i");
|
|
o=this.results_data;
|
|
for(m=0,t=o.length;
|
|
m<t;
|
|
m++){q=o[m];
|
|
if(!q.disabled&&!q.empty){if(q.group){f("#"+q.dom_id).css("display","none");
|
|
}else{if(!(this.is_multiple&&q.selected)){x=false;
|
|
s=q.dom_id;
|
|
y=f("#"+s);
|
|
if(u.test(q.html)){x=true;
|
|
p+=1;
|
|
}else{if(q.html.indexOf(" ")>=0||q.html.indexOf("[")===0){n=q.html.replace(/\[|\]/g,"").split(" ");
|
|
if(n.length){for(l=0,i=n.length;
|
|
l<i;
|
|
l++){k=n[l];
|
|
if(u.test(k)){x=true;
|
|
p+=1;
|
|
}}}}}if(x){if(w.length){r=q.html.search(j);
|
|
v=q.html.substr(0,r+w.length)+"</em>"+q.html.substr(r+w.length);
|
|
v=v.substr(0,r)+"<em>"+v.substr(r);
|
|
}else{v=q.html;
|
|
}y.html(v);
|
|
this.result_activate(y);
|
|
if(q.group_array_index!=null){f("#"+this.results_data[q.group_array_index].dom_id).css("display","list-item");
|
|
}}else{if(this.result_highlight&&s===this.result_highlight.attr("id")){this.result_clear_highlight();
|
|
}this.result_deactivate(y);
|
|
}}}}}if(p<1&&w.length){return this.no_results(w);
|
|
}else{return this.winnow_results_set_highlight();
|
|
}};
|
|
h.prototype.winnow_results_clear=function(){var i,l,m,k,j;
|
|
this.search_field.val("");
|
|
l=this.search_results.find("li");
|
|
j=[];
|
|
for(m=0,k=l.length;
|
|
m<k;
|
|
m++){i=l[m];
|
|
i=f(i);
|
|
j.push(i.hasClass("group-result")?i.css("display","auto"):!this.is_multiple||!i.hasClass("result-selected")?this.result_activate(i):void 0);
|
|
}return j;
|
|
};
|
|
h.prototype.winnow_results_set_highlight=function(){var i,j;
|
|
if(!this.result_highlight){j=!this.is_multiple?this.search_results.find(".result-selected.active-result"):[];
|
|
i=j.length?j.first():this.search_results.find(".active-result").first();
|
|
if(i!=null){return this.result_do_highlight(i);
|
|
}}};
|
|
h.prototype.no_results=function(i){var j;
|
|
j=f('<li class="no-results">'+this.results_none_found+' "<span></span>"</li>');
|
|
j.find("span").first().html(i);
|
|
return this.search_results.append(j);
|
|
};
|
|
h.prototype.no_results_clear=function(){return this.search_results.find(".no-results").remove();
|
|
};
|
|
h.prototype.keydown_arrow=function(){var j,i;
|
|
if(!this.result_highlight){j=this.search_results.find("li.active-result").first();
|
|
if(j){this.result_do_highlight(f(j));
|
|
}}else{if(this.results_showing){i=this.result_highlight.nextAll("li.active-result").first();
|
|
if(i){this.result_do_highlight(i);
|
|
}}}if(!this.results_showing){return this.results_show();
|
|
}};
|
|
h.prototype.keyup_arrow=function(){var i;
|
|
if(!this.results_showing&&!this.is_multiple){return this.results_show();
|
|
}else{if(this.result_highlight){i=this.result_highlight.prevAll("li.active-result");
|
|
if(i.length){return this.result_do_highlight(i.first());
|
|
}else{if(this.choices>0){this.results_hide();
|
|
}return this.result_clear_highlight();
|
|
}}}};
|
|
h.prototype.keydown_backstroke=function(){if(this.pending_backstroke){this.choice_destroy(this.pending_backstroke.find("a").first());
|
|
return this.clear_backstroke();
|
|
}else{this.pending_backstroke=this.search_container.siblings("li.search-choice").last();
|
|
return this.pending_backstroke.addClass("search-choice-focus");
|
|
}};
|
|
h.prototype.clear_backstroke=function(){if(this.pending_backstroke){this.pending_backstroke.removeClass("search-choice-focus");
|
|
}return this.pending_backstroke=null;
|
|
};
|
|
h.prototype.keydown_checker=function(i){var k,j;
|
|
k=(j=i.which)!=null?j:i.keyCode;
|
|
this.search_field_scale();
|
|
if(k!==8&&this.pending_backstroke){this.clear_backstroke();
|
|
}switch(k){case 8:this.backstroke_length=this.search_field.val().length;
|
|
break;
|
|
case 9:if(this.results_showing&&!this.is_multiple){this.result_select(i);
|
|
}this.mouse_on_container=false;
|
|
break;
|
|
case 13:i.preventDefault();
|
|
break;
|
|
case 38:i.preventDefault();
|
|
this.keyup_arrow();
|
|
break;
|
|
case 40:this.keydown_arrow();
|
|
break;
|
|
}};
|
|
h.prototype.search_field_scale=function(){var q,i,l,j,o,p,n,k,m;
|
|
if(this.is_multiple){l=0;
|
|
n=0;
|
|
o="position:absolute; left: -1000px; top: -1000px; display:none;";
|
|
p=["font-size","font-style","font-weight","font-family","line-height","text-transform","letter-spacing"];
|
|
for(k=0,m=p.length;
|
|
k<m;
|
|
k++){j=p[k];
|
|
o+=j+":"+this.search_field.css(j)+";";
|
|
}i=f("<div />",{"style":o});
|
|
i.text(this.search_field.val());
|
|
f("body").append(i);
|
|
n=i.width()+25;
|
|
i.remove();
|
|
if(n>this.f_width-10){n=this.f_width-10;
|
|
}this.search_field.css({"width":n+"px"});
|
|
q=this.container.height();
|
|
return this.dropdown.css({"top":q+"px"});
|
|
}};
|
|
h.prototype.generate_random_id=function(){var i;
|
|
i="sel"+this.generate_random_char()+this.generate_random_char()+this.generate_random_char();
|
|
while(f("#"+i).length>0){i+=this.generate_random_char();
|
|
}return i;
|
|
};
|
|
return h;
|
|
})();
|
|
e=function(h){var i;
|
|
return i=h.outerWidth()-h.width();
|
|
};
|
|
a.get_side_border_padding=e;
|
|
}).call(this);
|