New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support chars with accents #536
Comments
I agree with gemal. I've already found a function for that, if I only could hook the chosen's search to a custom function (like jstree does, for instance: http://www.jstree.com/documentation/search). This function removes all diacritics from a string and replace them with it's normalized equivalent. |
The function that does this is Chosen.prototype.winnow_results. It's a bit difficult to wrestle with the regular expressions :/ |
This can be useful and related to this problem: #628 |
+1 |
1 similar comment
+1 |
I modified the Chosen.prototype.winnow_results method to clean the search string accents before searching, not my best code, but it works as expected: Chosen.prototype.winnow_results = function() {
var found, option, part, parts, regex, regexAnchor, result, result_id, results, searchText, startpos, text, zregex, _i, _j, _len, _len1, _ref;
this.no_results_clear();
results = 0;
var defaultDiacriticsRemovalMap = [
{'base':'A', 'letters':/[\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F]/g},
{'base':'AA','letters':/[\uA732]/g},
{'base':'AE','letters':/[\u00C6\u01FC\u01E2]/g},
{'base':'AO','letters':/[\uA734]/g},
{'base':'AU','letters':/[\uA736]/g},
{'base':'AV','letters':/[\uA738\uA73A]/g},
{'base':'AY','letters':/[\uA73C]/g},
{'base':'B', 'letters':/[\u0042\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181]/g},
{'base':'C', 'letters':/[\u0043\u24B8\uFF23\u0106\u0108\u010A\u010C\u00C7\u1E08\u0187\u023B\uA73E]/g},
{'base':'D', 'letters':/[\u0044\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018B\u018A\u0189\uA779]/g},
{'base':'DZ','letters':/[\u01F1\u01C4]/g},
{'base':'Dz','letters':/[\u01F2\u01C5]/g},
{'base':'E', 'letters':/[\u0045\u24BA\uFF25\u00C8\u00C9\u00CA\u1EC0\u1EBE\u1EC4\u1EC2\u1EBC\u0112\u1E14\u1E16\u0114\u0116\u00CB\u1EBA\u011A\u0204\u0206\u1EB8\u1EC6\u0228\u1E1C\u0118\u1E18\u1E1A\u0190\u018E]/g},
{'base':'F', 'letters':/[\u0046\u24BB\uFF26\u1E1E\u0191\uA77B]/g},
{'base':'G', 'letters':/[\u0047\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E]/g},
{'base':'H', 'letters':/[\u0048\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D]/g},
{'base':'I', 'letters':/[\u0049\u24BE\uFF29\u00CC\u00CD\u00CE\u0128\u012A\u012C\u0130\u00CF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197]/g},
{'base':'J', 'letters':/[\u004A\u24BF\uFF2A\u0134\u0248]/g},
{'base':'K', 'letters':/[\u004B\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2]/g},
{'base':'L', 'letters':/[\u004C\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780]/g},
{'base':'LJ','letters':/[\u01C7]/g},
{'base':'Lj','letters':/[\u01C8]/g},
{'base':'M', 'letters':/[\u004D\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C]/g},
{'base':'N', 'letters':/[\u004E\u24C3\uFF2E\u01F8\u0143\u00D1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u0220\u019D\uA790\uA7A4]/g},
{'base':'NJ','letters':/[\u01CA]/g},
{'base':'Nj','letters':/[\u01CB]/g},
{'base':'O', 'letters':/[\u004F\u24C4\uFF2F\u00D2\u00D3\u00D4\u1ED2\u1ED0\u1ED6\u1ED4\u00D5\u1E4C\u022C\u1E4E\u014C\u1E50\u1E52\u014E\u022E\u0230\u00D6\u022A\u1ECE\u0150\u01D1\u020C\u020E\u01A0\u1EDC\u1EDA\u1EE0\u1EDE\u1EE2\u1ECC\u1ED8\u01EA\u01EC\u00D8\u01FE\u0186\u019F\uA74A\uA74C]/g},
{'base':'OI','letters':/[\u01A2]/g},
{'base':'OO','letters':/[\uA74E]/g},
{'base':'OU','letters':/[\u0222]/g},
{'base':'P', 'letters':/[\u0050\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754]/g},
{'base':'Q', 'letters':/[\u0051\u24C6\uFF31\uA756\uA758\u024A]/g},
{'base':'R', 'letters':/[\u0052\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782]/g},
{'base':'S', 'letters':/[\u0053\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784]/g},
{'base':'T', 'letters':/[\u0054\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786]/g},
{'base':'TZ','letters':/[\uA728]/g},
{'base':'U', 'letters':/[\u0055\u24CA\uFF35\u00D9\u00DA\u00DB\u0168\u1E78\u016A\u1E7A\u016C\u00DC\u01DB\u01D7\u01D5\u01D9\u1EE6\u016E\u0170\u01D3\u0214\u0216\u01AF\u1EEA\u1EE8\u1EEE\u1EEC\u1EF0\u1EE4\u1E72\u0172\u1E76\u1E74\u0244]/g},
{'base':'V', 'letters':/[\u0056\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245]/g},
{'base':'VY','letters':/[\uA760]/g},
{'base':'W', 'letters':/[\u0057\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72]/g},
{'base':'X', 'letters':/[\u0058\u24CD\uFF38\u1E8A\u1E8C]/g},
{'base':'Y', 'letters':/[\u0059\u24CE\uFF39\u1EF2\u00DD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE]/g},
{'base':'Z', 'letters':/[\u005A\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762]/g},
{'base':'a', 'letters':/[\u0061\u24D0\uFF41\u1E9A\u00E0\u00E1\u00E2\u1EA7\u1EA5\u1EAB\u1EA9\u00E3\u0101\u0103\u1EB1\u1EAF\u1EB5\u1EB3\u0227\u01E1\u00E4\u01DF\u1EA3\u00E5\u01FB\u01CE\u0201\u0203\u1EA1\u1EAD\u1EB7\u1E01\u0105\u2C65\u0250]/g},
{'base':'aa','letters':/[\uA733]/g},
{'base':'ae','letters':/[\u00E6\u01FD\u01E3]/g},
{'base':'ao','letters':/[\uA735]/g},
{'base':'au','letters':/[\uA737]/g},
{'base':'av','letters':/[\uA739\uA73B]/g},
{'base':'ay','letters':/[\uA73D]/g},
{'base':'b', 'letters':/[\u0062\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253]/g},
{'base':'c', 'letters':/[\u0063\u24D2\uFF43\u0107\u0109\u010B\u010D\u00E7\u1E09\u0188\u023C\uA73F\u2184]/g},
{'base':'d', 'letters':/[\u0064\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\uA77A]/g},
{'base':'dz','letters':/[\u01F3\u01C6]/g},
{'base':'e', 'letters':/[\u0065\u24D4\uFF45\u00E8\u00E9\u00EA\u1EC1\u1EBF\u1EC5\u1EC3\u1EBD\u0113\u1E15\u1E17\u0115\u0117\u00EB\u1EBB\u011B\u0205\u0207\u1EB9\u1EC7\u0229\u1E1D\u0119\u1E19\u1E1B\u0247\u025B\u01DD]/g},
{'base':'f', 'letters':/[\u0066\u24D5\uFF46\u1E1F\u0192\uA77C]/g},
{'base':'g', 'letters':/[\u0067\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\u1D79\uA77F]/g},
{'base':'h', 'letters':/[\u0068\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265]/g},
{'base':'hv','letters':/[\u0195]/g},
{'base':'i', 'letters':/[\u0069\u24D8\uFF49\u00EC\u00ED\u00EE\u0129\u012B\u012D\u00EF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131]/g},
{'base':'j', 'letters':/[\u006A\u24D9\uFF4A\u0135\u01F0\u0249]/g},
{'base':'k', 'letters':/[\u006B\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3]/g},
{'base':'l', 'letters':/[\u006C\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747]/g},
{'base':'lj','letters':/[\u01C9]/g},
{'base':'m', 'letters':/[\u006D\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F]/g},
{'base':'n', 'letters':/[\u006E\u24DD\uFF4E\u01F9\u0144\u00F1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5]/g},
{'base':'nj','letters':/[\u01CC]/g},
{'base':'o', 'letters':/[\u006F\u24DE\uFF4F\u00F2\u00F3\u00F4\u1ED3\u1ED1\u1ED7\u1ED5\u00F5\u1E4D\u022D\u1E4F\u014D\u1E51\u1E53\u014F\u022F\u0231\u00F6\u022B\u1ECF\u0151\u01D2\u020D\u020F\u01A1\u1EDD\u1EDB\u1EE1\u1EDF\u1EE3\u1ECD\u1ED9\u01EB\u01ED\u00F8\u01FF\u0254\uA74B\uA74D\u0275]/g},
{'base':'oi','letters':/[\u01A3]/g},
{'base':'ou','letters':/[\u0223]/g},
{'base':'oo','letters':/[\uA74F]/g},
{'base':'p','letters':/[\u0070\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755]/g},
{'base':'q','letters':/[\u0071\u24E0\uFF51\u024B\uA757\uA759]/g},
{'base':'r','letters':/[\u0072\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783]/g},
{'base':'s','letters':/[\u0073\u24E2\uFF53\u00DF\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B]/g},
{'base':'t','letters':/[\u0074\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787]/g},
{'base':'tz','letters':/[\uA729]/g},
{'base':'u','letters':/[\u0075\u24E4\uFF55\u00F9\u00FA\u00FB\u0169\u1E79\u016B\u1E7B\u016D\u00FC\u01DC\u01D8\u01D6\u01DA\u1EE7\u016F\u0171\u01D4\u0215\u0217\u01B0\u1EEB\u1EE9\u1EEF\u1EED\u1EF1\u1EE5\u1E73\u0173\u1E77\u1E75\u0289]/g},
{'base':'v','letters':/[\u0076\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C]/g},
{'base':'vy','letters':/[\uA761]/g},
{'base':'w','letters':/[\u0077\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73]/g},
{'base':'x','letters':/[\u0078\u24E7\uFF58\u1E8B\u1E8D]/g},
{'base':'y','letters':/[\u0079\u24E8\uFF59\u1EF3\u00FD\u0177\u1EF9\u0233\u1E8F\u00FF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF]/g},
{'base':'z','letters':/[\u007A\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763]/g}
];
var changes;
function removeDiacritics (str) {
if(!changes) {
changes = defaultDiacriticsRemovalMap;
}
for(var i=0; i<changes.length; i++) {
str = str.replace(changes[i].letters, changes[i].base);
}
return str;
}
searchText = this.search_field.val() === this.default_text ? "" : $('<div/>').text(removeDiacritics($.trim(this.search_field.val()))).html();
regexAnchor = this.search_contains ? "" : "^";
regex = new RegExp(regexAnchor + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
_ref = this.results_data;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
option = _ref[_i];
if (!option.disabled && !option.empty) {
if (option.group) {
$('#' + option.dom_id).css('display', 'none');
} else if (!(this.is_multiple && option.selected)) {
found = false;
result_id = option.dom_id;
result = $("#" + result_id);
if (regex.test(removeDiacritics(option.html))) {
found = true;
results += 1;
} else if (this.enable_split_word_search && (option.html.indexOf(" ") >= 0 || option.html.indexOf("[") === 0)) {
parts = removeDiacritics(option.html).replace(/\[|\]/g, "").split(" ");
if (parts.length) {
for (_j = 0, _len1 = parts.length; _j < _len1; _j++) {
part = parts[_j];
if (regex.test(part)) {
found = true;
results += 1;
}
}
}
}
if (found) {
if (searchText.length) {
startpos = removeDiacritics(option.html).search(zregex);
text = option.html.substr(0, startpos + searchText.length) + '</em>' + option.html.substr(startpos + searchText.length);
text = text.substr(0, startpos) + '<em>' + text.substr(startpos);
} else {
text = option.html;
}
result.html(text);
this.result_activate(result);
if (option.group_array_index != null) {
$("#" + this.results_data[option.group_array_index].dom_id).css('display', 'list-item');
}
} else {
if (this.result_highlight && result_id === this.result_highlight.attr('id')) {
this.result_clear_highlight();
}
this.result_deactivate(result);
}
}
}
}
if (results < 1 && searchText.length) {
return this.no_results(searchText);
} else {
return this.winnow_results_set_highlight();
}
}; Ready for using: (function(){var e;e=function(){function e(){this.options_index=0;this.parsed=[]}e.prototype.add_node=function(e){if(e.nodeName.toUpperCase()==="OPTGROUP"){return this.add_group(e)}else{return this.add_option(e)}};e.prototype.add_group=function(e){var t,n,r,i,s,o;t=this.parsed.length;this.parsed.push({array_index:t,group:true,label:e.label,children:0,disabled:e.disabled});s=e.childNodes;o=[];for(r=0,i=s.length;r<i;r++){n=s[r];o.push(this.add_option(n,t,e.disabled))}return o};e.prototype.add_option=function(e,t,n){if(e.nodeName.toUpperCase()==="OPTION"){if(e.text!==""){if(t!=null){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,selected:e.selected,disabled:n===true?n:e.disabled,group_array_index:t,classes:e.className,style:e.style.cssText})}else{this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,empty:true})}return this.options_index+=1}};return e}();e.select_to_array=function(t){var n,r,i,s,o;r=new e;o=t.childNodes;for(i=0,s=o.length;i<s;i++){n=o[i];r.add_node(n)}return r.parsed};this.SelectParser=e}).call(this);(function(){var e,t;t=this;e=function(){function e(e,t){this.form_field=e;this.options=t!=null?t:{};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.finish_setup()}e.prototype.set_default_values=function(){var e=this;this.click_test_action=function(t){return e.test_active_click(t)};this.activate_action=function(t){return e.activate_field(t)};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.disable_search=this.options.disable_search||false;this.enable_split_word_search=this.options.enable_split_word_search!=null?this.options.enable_split_word_search:true;this.search_contains=this.options.search_contains||false;this.choices=0;this.single_backstroke_delete=this.options.single_backstroke_delete||false;this.max_selected_options=this.options.max_selected_options||Infinity;return this.inherit_select_classes=this.options.inherit_select_classes||false};e.prototype.set_default_text=function(){if(this.form_field.getAttribute("data-placeholder")){this.default_text=this.form_field.getAttribute("data-placeholder")}else if(this.is_multiple){this.default_text=this.options.placeholder_text_multiple||this.options.placeholder_text||"Select Some Options"}else{this.default_text=this.options.placeholder_text_single||this.options.placeholder_text||"Select an Option"}return this.results_none_found=this.form_field.getAttribute("data-no_results_text")||this.options.no_results_text||"No results match"};e.prototype.mouse_enter=function(){return this.mouse_on_container=true};e.prototype.mouse_leave=function(){return this.mouse_on_container=false};e.prototype.input_focus=function(e){var t=this;if(this.is_multiple){if(!this.active_field){return setTimeout(function(){return t.container_mousedown()},50)}}else{if(!this.active_field){return this.activate_field()}}};e.prototype.input_blur=function(e){var t=this;if(!this.mouse_on_container){this.active_field=false;return setTimeout(function(){return t.blur_test()},100)}};e.prototype.result_add_option=function(e){var t,n;if(!e.disabled){e.dom_id=this.container_id+"_o_"+e.array_index;t=e.selected&&this.is_multiple?[]:["active-result"];if(e.selected){t.push("result-selected")}if(e.group_array_index!=null){t.push("group-option")}if(e.classes!==""){t.push(e.classes)}n=e.style.cssText!==""?' style="'+e.style+'"':"";return'<li id="'+e.dom_id+'" class="'+t.join(" ")+'"'+n+">"+e.html+"</li>"}else{return""}};e.prototype.results_update_field=function(){if(!this.is_multiple){this.results_reset_cleanup()}this.result_clear_highlight();this.result_single_selected=null;return this.results_build()};e.prototype.results_toggle=function(){if(this.results_showing){return this.results_hide()}else{return this.results_show()}};e.prototype.results_search=function(e){if(this.results_showing){return this.winnow_results()}else{return this.results_show()}};e.prototype.keyup_checker=function(e){var t,n;t=(n=e.which)!=null?n:e.keyCode;this.search_field_scale();switch(t){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){this.results_hide()}return true;case 9:case 38:case 40:case 16:case 91:case 17:break;default:return this.results_search()}};e.prototype.generate_field_id=function(){var e;e=this.generate_random_id();this.form_field.id=e;return e};e.prototype.generate_random_char=function(){var e,t,n;e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";n=Math.floor(Math.random()*e.length);return t=e.substring(n,n+1)};return e}();t.AbstractChosen=e}).call(this);(function(){var e,t,n,r,i={}.hasOwnProperty,s=function(e,t){function r(){this.constructor=e}for(var n in t){if(i.call(t,n))e[n]=t[n]}r.prototype=t.prototype;e.prototype=new r;e.__super__=t.prototype;return e};r=this;e=jQuery;e.fn.extend({chosen:function(n){var r,i,s;s=navigator.userAgent.toLowerCase();i=/(msie) ([\w.]+)/.exec(s)||[];r={name:i[1]||"",version:i[2]||"0"};if(r.name==="msie"&&(r.version==="6.0"||r.version==="7.0"&&document.documentMode===7)){return this}return this.each(function(r){var i;i=e(this);if(!i.hasClass("chzn-done")){return i.data("chosen",new t(this,n))}})}});t=function(t){function i(){return i.__super__.constructor.apply(this,arguments)}s(i,t);i.prototype.setup=function(){this.form_field_jq=e(this.form_field);this.current_value=this.form_field_jq.val();return this.is_rtl=this.form_field_jq.hasClass("chzn-rtl")};i.prototype.finish_setup=function(){return this.form_field_jq.addClass("chzn-done")};i.prototype.set_up_html=function(){var t,r,i,s,o,u;this.container_id=this.form_field.id.length?this.form_field.id.replace(/[^\w]/g,"_"):this.generate_field_id();this.container_id+="_chzn";t=["chzn-container"];t.push("chzn-container-"+(this.is_multiple?"multi":"single"));if(this.inherit_select_classes&&this.form_field.className){t.push(this.form_field.className)}if(this.is_rtl){t.push("chzn-rtl")}this.f_width=this.form_field_jq.outerWidth();i={id:this.container_id,"class":t.join(" "),style:"width: "+this.f_width+"px;",title:this.form_field.title};r=e("<div />",i);if(this.is_multiple){r.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{r.html('<a href="javascript:void(0)" class="chzn-single chzn-default" tabindex="-1"><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(r);this.container=e("#"+this.container_id);this.dropdown=this.container.find("div.chzn-drop").first();s=this.container.height();o=this.f_width-n(this.dropdown);this.dropdown.css({width:o+"px",top:s+"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();u=o-n(this.search_container)-n(this.search_field);this.search_field.css({width:u+"px"})}this.results_build();this.set_tab_index();return this.form_field_jq.trigger("liszt:ready",{chosen:this})};i.prototype.register_observers=function(){var e=this;this.container.mousedown(function(t){return e.container_mousedown(t)});this.container.mouseup(function(t){return e.container_mouseup(t)});this.container.mouseenter(function(t){return e.mouse_enter(t)});this.container.mouseleave(function(t){return e.mouse_leave(t)});this.search_results.mouseup(function(t){return e.search_results_mouseup(t)});this.search_results.mouseover(function(t){return e.search_results_mouseover(t)});this.search_results.mouseout(function(t){return e.search_results_mouseout(t)});this.form_field_jq.bind("liszt:updated",function(t){return e.results_update_field(t)});this.form_field_jq.bind("liszt:activate",function(t){return e.activate_field(t)});this.form_field_jq.bind("liszt:open",function(t){return e.container_mousedown(t)});this.search_field.blur(function(t){return e.input_blur(t)});this.search_field.keyup(function(t){return e.keyup_checker(t)});this.search_field.keydown(function(t){return e.keydown_checker(t)});this.search_field.focus(function(t){return e.input_focus(t)});if(this.is_multiple){return this.search_choices.click(function(t){return e.choices_click(t)})}else{return this.container.click(function(e){return e.preventDefault()})}};i.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)}}};i.prototype.container_mousedown=function(t){var n;if(!this.is_disabled){n=t!=null?e(t.target).hasClass("search-choice-close"):false;if(t&&t.type==="mousedown"&&!this.results_showing){t.preventDefault()}if(!this.pending_destroy_click&&!n){if(!this.active_field){if(this.is_multiple){this.search_field.val("")}e(document).click(this.click_test_action);this.results_show()}else if(!this.is_multiple&&t&&(e(t.target)[0]===this.selected_item[0]||e(t.target).parents("a.chzn-single").length)){t.preventDefault();this.results_toggle()}return this.activate_field()}else{return this.pending_destroy_click=false}}};i.prototype.container_mouseup=function(e){if(e.target.nodeName==="ABBR"&&!this.is_disabled){return this.results_reset(e)}};i.prototype.blur_test=function(e){if(!this.active_field&&this.container.hasClass("chzn-container-active")){return this.close_field()}};i.prototype.close_field=function(){e(document).unbind("click",this.click_test_action);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()};i.prototype.activate_field=function(){this.container.addClass("chzn-container-active");this.active_field=true;this.search_field.val(this.search_field.val());return this.search_field.focus()};i.prototype.test_active_click=function(t){if(e(t.target).parents("#"+this.container_id).length){return this.active_field=true}else{return this.close_field()}};i.prototype.results_build=function(){var e,t,n,i,s;this.parsing=true;this.results_data=r.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.addClass("chzn-default").find("span").text(this.default_text);if(this.disable_search||this.form_field.options.length<=this.disable_search_threshold){this.container.addClass("chzn-container-single-nosearch")}else{this.container.removeClass("chzn-container-single-nosearch")}}e="";s=this.results_data;for(n=0,i=s.length;n<i;n++){t=s[n];if(t.group){e+=this.result_add_group(t)}else if(!t.empty){e+=this.result_add_option(t);if(t.selected&&this.is_multiple){this.choice_build(t)}else if(t.selected&&!this.is_multiple){this.selected_item.removeClass("chzn-default").find("span").text(t.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(e);return this.parsing=false};i.prototype.result_add_group=function(t){if(!t.disabled){t.dom_id=this.container_id+"_g_"+t.array_index;return'<li id="'+t.dom_id+'" class="group-result">'+e("<div />").text(t.label).html()+"</li>"}else{return""}};i.prototype.result_do_highlight=function(e){var t,n,r,i,s;if(e.length){this.result_clear_highlight();this.result_highlight=e;this.result_highlight.addClass("highlighted");r=parseInt(this.search_results.css("maxHeight"),10);s=this.search_results.scrollTop();i=r+s;n=this.result_highlight.position().top+this.search_results.scrollTop();t=n+this.result_highlight.outerHeight();if(t>=i){return this.search_results.scrollTop(t-r>0?t-r:0)}else if(n<s){return this.search_results.scrollTop(n)}}};i.prototype.result_clear_highlight=function(){if(this.result_highlight){this.result_highlight.removeClass("highlighted")}return this.result_highlight=null};i.prototype.results_show=function(){var e;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)}}else if(this.max_selected_options<=this.choices){this.form_field_jq.trigger("liszt:maxselected",{chosen:this});return false}e=this.is_multiple?this.container.height():this.container.height()-1;this.form_field_jq.trigger("liszt:showing_dropdown",{chosen:this});this.dropdown.css({top:e+"px",left:0});this.results_showing=true;this.search_field.focus();this.search_field.val(this.search_field.val());return this.winnow_results()};i.prototype.results_hide=function(){if(!this.is_multiple){this.selected_item.removeClass("chzn-single-with-drop")}this.result_clear_highlight();this.form_field_jq.trigger("liszt:hiding_dropdown",{chosen:this});this.dropdown.css({left:"-9000px"});return this.results_showing=false};i.prototype.set_tab_index=function(e){var t;if(this.form_field_jq.attr("tabindex")){t=this.form_field_jq.attr("tabindex");this.form_field_jq.attr("tabindex",-1);return this.search_field.attr("tabindex",t)}};i.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")}};i.prototype.search_results_mouseup=function(t){var n;n=e(t.target).hasClass("active-result")?e(t.target):e(t.target).parents(".active-result").first();if(n.length){this.result_highlight=n;this.result_select(t);return this.search_field.focus()}};i.prototype.search_results_mouseover=function(t){var n;n=e(t.target).hasClass("active-result")?e(t.target):e(t.target).parents(".active-result").first();if(n){return this.result_do_highlight(n)}};i.prototype.search_results_mouseout=function(t){if(e(t.target).hasClass("active-result"||e(t.target).parents(".active-result").first())){return this.result_clear_highlight()}};i.prototype.choices_click=function(t){t.preventDefault();if(this.active_field&&!e(t.target).hasClass("search-choice"||e(t.target).parents(".search-choice").first)&&!this.results_showing){return this.results_show()}};i.prototype.choice_build=function(t){var n,r,i,s=this;if(this.is_multiple&&this.max_selected_options<=this.choices){this.form_field_jq.trigger("liszt:maxselected",{chosen:this});return false}n=this.container_id+"_c_"+t.array_index;this.choices+=1;if(t.disabled){r='<li class="search-choice search-choice-disabled" id="'+n+'"><span>'+t.html+"</span></li>"}else{r='<li class="search-choice" id="'+n+'"><span>'+t.html+'</span><a href="javascript:void(0)" class="search-choice-close" rel="'+t.array_index+'"></a></li>'}this.search_container.before(r);i=e("#"+n).find("a").first();return i.click(function(e){return s.choice_destroy_link_click(e)})};i.prototype.choice_destroy_link_click=function(t){t.preventDefault();if(!this.is_disabled){this.pending_destroy_click=true;return this.choice_destroy(e(t.target))}else{return t.stopPropagation}};i.prototype.choice_destroy=function(e){if(this.result_deselect(e.attr("rel"))){this.choices-=1;this.show_search_field_default();if(this.is_multiple&&this.choices>0&&this.search_field.val().length<1){this.results_hide()}e.parents("li").first().remove();return this.search_field_scale()}};i.prototype.results_reset=function(){this.form_field.options[0].selected=true;this.selected_item.find("span").text(this.default_text);if(!this.is_multiple){this.selected_item.addClass("chzn-default")}this.show_search_field_default();this.results_reset_cleanup();this.form_field_jq.trigger("change");if(this.active_field){return this.results_hide()}};i.prototype.results_reset_cleanup=function(){this.current_value=this.form_field_jq.val();return this.selected_item.find("abbr").remove()};i.prototype.result_select=function(e){var t,n,r,i;if(this.result_highlight){t=this.result_highlight;n=t.attr("id");this.result_clear_highlight();if(this.is_multiple){this.result_deactivate(t)}else{this.search_results.find(".result-selected").removeClass("result-selected");this.result_single_selected=t;this.selected_item.removeClass("chzn-default")}t.addClass("result-selected");i=n.substr(n.lastIndexOf("_")+1);r=this.results_data[i];r.selected=true;this.form_field.options[r.options_index].selected=true;if(this.is_multiple){this.choice_build(r)}else{this.selected_item.find("span").first().text(r.text);if(this.allow_single_deselect){this.single_deselect_control_build()}}if(!((e.metaKey||e.ctrlKey)&&this.is_multiple)){this.results_hide()}this.search_field.val("");if(this.is_multiple||this.form_field_jq.val()!==this.current_value){this.form_field_jq.trigger("change",{selected:this.form_field.options[r.options_index].value})}this.current_value=this.form_field_jq.val();return this.search_field_scale()}};i.prototype.result_activate=function(e){return e.addClass("active-result")};i.prototype.result_deactivate=function(e){return e.removeClass("active-result")};i.prototype.result_deselect=function(t){var n,r;r=this.results_data[t];if(!this.form_field.options[r.options_index].disabled){r.selected=false;this.form_field.options[r.options_index].selected=false;n=e("#"+this.container_id+"_o_"+t);n.removeClass("result-selected").addClass("active-result").show();this.result_clear_highlight();this.winnow_results();this.form_field_jq.trigger("change",{deselected:this.form_field.options[r.options_index].value});this.search_field_scale();return true}else{return false}};i.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>')}};i.prototype.winnow_results=function(){function E(e){if(!w){w=b}for(var t=0;t<w.length;t++){e=e.replace(w[t].letters,w[t].base)}return e}var t,n,r,i,s,o,u,a,f,l,c,h,p,d,v,m,g,y;this.no_results_clear();f=0;var b=[{base:"A",letters:/[\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F]/g},{base:"AA",letters:/[\uA732]/g},{base:"AE",letters:/[\u00C6\u01FC\u01E2]/g},{base:"AO",letters:/[\uA734]/g},{base:"AU",letters:/[\uA736]/g},{base:"AV",letters:/[\uA738\uA73A]/g},{base:"AY",letters:/[\uA73C]/g},{base:"B",letters:/[\u0042\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181]/g},{base:"C",letters:/[\u0043\u24B8\uFF23\u0106\u0108\u010A\u010C\u00C7\u1E08\u0187\u023B\uA73E]/g},{base:"D",letters:/[\u0044\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018B\u018A\u0189\uA779]/g},{base:"DZ",letters:/[\u01F1\u01C4]/g},{base:"Dz",letters:/[\u01F2\u01C5]/g},{base:"E",letters:/[\u0045\u24BA\uFF25\u00C8\u00C9\u00CA\u1EC0\u1EBE\u1EC4\u1EC2\u1EBC\u0112\u1E14\u1E16\u0114\u0116\u00CB\u1EBA\u011A\u0204\u0206\u1EB8\u1EC6\u0228\u1E1C\u0118\u1E18\u1E1A\u0190\u018E]/g},{base:"F",letters:/[\u0046\u24BB\uFF26\u1E1E\u0191\uA77B]/g},{base:"G",letters:/[\u0047\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E]/g},{base:"H",letters:/[\u0048\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D]/g},{base:"I",letters:/[\u0049\u24BE\uFF29\u00CC\u00CD\u00CE\u0128\u012A\u012C\u0130\u00CF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197]/g},{base:"J",letters:/[\u004A\u24BF\uFF2A\u0134\u0248]/g},{base:"K",letters:/[\u004B\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2]/g},{base:"L",letters:/[\u004C\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780]/g},{base:"LJ",letters:/[\u01C7]/g},{base:"Lj",letters:/[\u01C8]/g},{base:"M",letters:/[\u004D\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C]/g},{base:"N",letters:/[\u004E\u24C3\uFF2E\u01F8\u0143\u00D1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u0220\u019D\uA790\uA7A4]/g},{base:"NJ",letters:/[\u01CA]/g},{base:"Nj",letters:/[\u01CB]/g},{base:"O",letters:/[\u004F\u24C4\uFF2F\u00D2\u00D3\u00D4\u1ED2\u1ED0\u1ED6\u1ED4\u00D5\u1E4C\u022C\u1E4E\u014C\u1E50\u1E52\u014E\u022E\u0230\u00D6\u022A\u1ECE\u0150\u01D1\u020C\u020E\u01A0\u1EDC\u1EDA\u1EE0\u1EDE\u1EE2\u1ECC\u1ED8\u01EA\u01EC\u00D8\u01FE\u0186\u019F\uA74A\uA74C]/g},{base:"OI",letters:/[\u01A2]/g},{base:"OO",letters:/[\uA74E]/g},{base:"OU",letters:/[\u0222]/g},{base:"P",letters:/[\u0050\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754]/g},{base:"Q",letters:/[\u0051\u24C6\uFF31\uA756\uA758\u024A]/g},{base:"R",letters:/[\u0052\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782]/g},{base:"S",letters:/[\u0053\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784]/g},{base:"T",letters:/[\u0054\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786]/g},{base:"TZ",letters:/[\uA728]/g},{base:"U",letters:/[\u0055\u24CA\uFF35\u00D9\u00DA\u00DB\u0168\u1E78\u016A\u1E7A\u016C\u00DC\u01DB\u01D7\u01D5\u01D9\u1EE6\u016E\u0170\u01D3\u0214\u0216\u01AF\u1EEA\u1EE8\u1EEE\u1EEC\u1EF0\u1EE4\u1E72\u0172\u1E76\u1E74\u0244]/g},{base:"V",letters:/[\u0056\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245]/g},{base:"VY",letters:/[\uA760]/g},{base:"W",letters:/[\u0057\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72]/g},{base:"X",letters:/[\u0058\u24CD\uFF38\u1E8A\u1E8C]/g},{base:"Y",letters:/[\u0059\u24CE\uFF39\u1EF2\u00DD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE]/g},{base:"Z",letters:/[\u005A\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762]/g},{base:"a",letters:/[\u0061\u24D0\uFF41\u1E9A\u00E0\u00E1\u00E2\u1EA7\u1EA5\u1EAB\u1EA9\u00E3\u0101\u0103\u1EB1\u1EAF\u1EB5\u1EB3\u0227\u01E1\u00E4\u01DF\u1EA3\u00E5\u01FB\u01CE\u0201\u0203\u1EA1\u1EAD\u1EB7\u1E01\u0105\u2C65\u0250]/g},{base:"aa",letters:/[\uA733]/g},{base:"ae",letters:/[\u00E6\u01FD\u01E3]/g},{base:"ao",letters:/[\uA735]/g},{base:"au",letters:/[\uA737]/g},{base:"av",letters:/[\uA739\uA73B]/g},{base:"ay",letters:/[\uA73D]/g},{base:"b",letters:/[\u0062\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253]/g},{base:"c",letters:/[\u0063\u24D2\uFF43\u0107\u0109\u010B\u010D\u00E7\u1E09\u0188\u023C\uA73F\u2184]/g},{base:"d",letters:/[\u0064\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\uA77A]/g},{base:"dz",letters:/[\u01F3\u01C6]/g},{base:"e",letters:/[\u0065\u24D4\uFF45\u00E8\u00E9\u00EA\u1EC1\u1EBF\u1EC5\u1EC3\u1EBD\u0113\u1E15\u1E17\u0115\u0117\u00EB\u1EBB\u011B\u0205\u0207\u1EB9\u1EC7\u0229\u1E1D\u0119\u1E19\u1E1B\u0247\u025B\u01DD]/g},{base:"f",letters:/[\u0066\u24D5\uFF46\u1E1F\u0192\uA77C]/g},{base:"g",letters:/[\u0067\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\u1D79\uA77F]/g},{base:"h",letters:/[\u0068\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265]/g},{base:"hv",letters:/[\u0195]/g},{base:"i",letters:/[\u0069\u24D8\uFF49\u00EC\u00ED\u00EE\u0129\u012B\u012D\u00EF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131]/g},{base:"j",letters:/[\u006A\u24D9\uFF4A\u0135\u01F0\u0249]/g},{base:"k",letters:/[\u006B\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3]/g},{base:"l",letters:/[\u006C\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747]/g},{base:"lj",letters:/[\u01C9]/g},{base:"m",letters:/[\u006D\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F]/g},{base:"n",letters:/[\u006E\u24DD\uFF4E\u01F9\u0144\u00F1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5]/g},{base:"nj",letters:/[\u01CC]/g},{base:"o",letters:/[\u006F\u24DE\uFF4F\u00F2\u00F3\u00F4\u1ED3\u1ED1\u1ED7\u1ED5\u00F5\u1E4D\u022D\u1E4F\u014D\u1E51\u1E53\u014F\u022F\u0231\u00F6\u022B\u1ECF\u0151\u01D2\u020D\u020F\u01A1\u1EDD\u1EDB\u1EE1\u1EDF\u1EE3\u1ECD\u1ED9\u01EB\u01ED\u00F8\u01FF\u0254\uA74B\uA74D\u0275]/g},{base:"oi",letters:/[\u01A3]/g},{base:"ou",letters:/[\u0223]/g},{base:"oo",letters:/[\uA74F]/g},{base:"p",letters:/[\u0070\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755]/g},{base:"q",letters:/[\u0071\u24E0\uFF51\u024B\uA757\uA759]/g},{base:"r",letters:/[\u0072\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783]/g},{base:"s",letters:/[\u0073\u24E2\uFF53\u00DF\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B]/g},{base:"t",letters:/[\u0074\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787]/g},{base:"tz",letters:/[\uA729]/g},{base:"u",letters:/[\u0075\u24E4\uFF55\u00F9\u00FA\u00FB\u0169\u1E79\u016B\u1E7B\u016D\u00FC\u01DC\u01D8\u01D6\u01DA\u1EE7\u016F\u0171\u01D4\u0215\u0217\u01B0\u1EEB\u1EE9\u1EEF\u1EED\u1EF1\u1EE5\u1E73\u0173\u1E77\u1E75\u0289]/g},{base:"v",letters:/[\u0076\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C]/g},{base:"vy",letters:/[\uA761]/g},{base:"w",letters:/[\u0077\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73]/g},{base:"x",letters:/[\u0078\u24E7\uFF58\u1E8B\u1E8D]/g},{base:"y",letters:/[\u0079\u24E8\uFF59\u1EF3\u00FD\u0177\u1EF9\u0233\u1E8F\u00FF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF]/g},{base:"z",letters:/[\u007A\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763]/g}];var w;l=this.search_field.val()===this.default_text?"":e("<div/>").text(E(e.trim(this.search_field.val()))).html();o=this.search_contains?"":"^";s=new RegExp(o+l.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i");p=new RegExp(l.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i");y=this.results_data;for(d=0,m=y.length;d<m;d++){n=y[d];if(!n.disabled&&!n.empty){if(n.group){e("#"+n.dom_id).css("display","none")}else if(!(this.is_multiple&&n.selected)){t=false;a=n.dom_id;u=e("#"+a);if(s.test(E(n.html))){t=true;f+=1}else if(this.enable_split_word_search&&(n.html.indexOf(" ")>=0||n.html.indexOf("[")===0)){i=E(n.html).replace(/\[|\]/g,"").split(" ");if(i.length){for(v=0,g=i.length;v<g;v++){r=i[v];if(s.test(r)){t=true;f+=1}}}}if(t){if(l.length){c=E(n.html).search(p);h=n.html.substr(0,c+l.length)+"</em>"+n.html.substr(c+l.length);h=h.substr(0,c)+"<em>"+h.substr(c)}else{h=n.html}u.html(h);this.result_activate(u);if(n.group_array_index!=null){e("#"+this.results_data[n.group_array_index].dom_id).css("display","list-item")}}else{if(this.result_highlight&&a===this.result_highlight.attr("id")){this.result_clear_highlight()}this.result_deactivate(u)}}}}if(f<1&&l.length){return this.no_results(l)}else{return this.winnow_results_set_highlight()}};i.prototype.winnow_results_clear=function(){var t,n,r,i,s;this.search_field.val("");n=this.search_results.find("li");s=[];for(r=0,i=n.length;r<i;r++){t=n[r];t=e(t);if(t.hasClass("group-result")){s.push(t.css("display","auto"))}else if(!this.is_multiple||!t.hasClass("result-selected")){s.push(this.result_activate(t))}else{s.push(void 0)}}return s};i.prototype.winnow_results_set_highlight=function(){var e,t;if(!this.result_highlight){t=!this.is_multiple?this.search_results.find(".result-selected.active-result"):[];e=t.length?t.first():this.search_results.find(".active-result").first();if(e!=null){return this.result_do_highlight(e)}}};i.prototype.no_results=function(t){var n;n=e('<li class="no-results">'+this.results_none_found+' "<span></span>"</li>');n.find("span").first().html(t);return this.search_results.append(n)};i.prototype.no_results_clear=function(){return this.search_results.find(".no-results").remove()};i.prototype.keydown_arrow=function(){var t,n;if(!this.result_highlight){t=this.search_results.find("li.active-result").first();if(t){this.result_do_highlight(e(t))}}else if(this.results_showing){n=this.result_highlight.nextAll("li.active-result").first();if(n){this.result_do_highlight(n)}}if(!this.results_showing){return this.results_show()}};i.prototype.keyup_arrow=function(){var e;if(!this.results_showing&&!this.is_multiple){return this.results_show()}else if(this.result_highlight){e=this.result_highlight.prevAll("li.active-result");if(e.length){return this.result_do_highlight(e.first())}else{if(this.choices>0){this.results_hide()}return this.result_clear_highlight()}}};i.prototype.keydown_backstroke=function(){var e;if(this.pending_backstroke){this.choice_destroy(this.pending_backstroke.find("a").first());return this.clear_backstroke()}else{e=this.search_container.siblings("li.search-choice").last();if(e.length&&!e.hasClass("search-choice-disabled")){this.pending_backstroke=e;if(this.single_backstroke_delete){return this.keydown_backstroke()}else{return this.pending_backstroke.addClass("search-choice-focus")}}}};i.prototype.clear_backstroke=function(){if(this.pending_backstroke){this.pending_backstroke.removeClass("search-choice-focus")}return this.pending_backstroke=null};i.prototype.keydown_checker=function(e){var t,n;t=(n=e.which)!=null?n:e.keyCode;this.search_field_scale();if(t!==8&&this.pending_backstroke){this.clear_backstroke()}switch(t){case 8:this.backstroke_length=this.search_field.val().length;break;case 9:if(this.results_showing&&!this.is_multiple){this.result_select(e)}this.mouse_on_container=false;break;case 13:e.preventDefault();break;case 38:e.preventDefault();this.keyup_arrow();break;case 40:this.keydown_arrow();break}};i.prototype.search_field_scale=function(){var t,n,r,i,s,o,u,a,f;if(this.is_multiple){r=0;u=0;s="position:absolute; left: -1000px; top: -1000px; display:none;";o=["font-size","font-style","font-weight","font-family","line-height","text-transform","letter-spacing"];for(a=0,f=o.length;a<f;a++){i=o[a];s+=i+":"+this.search_field.css(i)+";"}n=e("<div />",{style:s});n.text(this.search_field.val());e("body").append(n);u=n.width()+25;n.remove();if(u>this.f_width-10){u=this.f_width-10}this.search_field.css({width:u+"px"});t=this.container.height();return this.dropdown.css({top:t+"px"})}};i.prototype.generate_random_id=function(){var t;t="sel"+this.generate_random_char()+this.generate_random_char()+this.generate_random_char();while(e("#"+t).length>0){t+=this.generate_random_char()}return t};return i}(AbstractChosen);r.Chosen=t;n=function(e){var t;return t=e.outerWidth()-e.width()};r.get_side_border_padding=n}).call(this) |
+1 |
Unicode case folding would be good, +1. |
+1 |
sry @tjschuck for duplicate post I found same issue and develop my sloution http://fiddle.jshell.net/whqb5/1/ a item 'República Democrática do Congo' is select with search 'congo republica' in any order in my method, save file in UTF-8 for special caracters strings "(Á|À|Ã|Â|Ä|á|à|ã|â|ä|a|A)". sry for my poor english, "Eu encontrei o mesmo problema desenvolvendo minha solução http://fiddle.jshell.net/whqb5/1/ A busca usa todas as palavras digitadas em qualquer ordem com ou sem acento" *edit new version
|
+1 |
@felpasl could you prepare a PR for this? Thanks! |
+1 |
1 similar comment
+1 |
@manuelv @keeguon maybe you should check this out: http://brianreavis.github.io/selectize.js/ |
I just implemented felpasl's solution (mentioned 5 comments above) & it seems to work fine. warning: remember to save the modified "chosen.jquery.js" in UTF8 as indicated by felpasl. |
I like the version that @felpasl made, but how about more unicode? ;)
Missing anything else? |
@refringe That seems like something best left up to a separate library, whose sole concern is this kind of Latinization -- something like https://github.com/dundalek/latinize or http://semplicewebsites.com/removing-accents-javascript. |
@tjschuck Agreed! Just briefly looking through that latinize code... I can already tell that I've missed quite a few. Regardless, I think the update needs to include a wider range of unicode characters to be normalized. Actually, the map that @zavan mentioned up top is eerily close to what latinize uses here: I like. |
+1 Not sure if related: When the options include questions in spanish language, which are preceded by a opening question mark ('¿'), first words will not be matched. Ex: option: "¿Como estás?" -> "estás" is being found, but not "Como". |
@dgilperez That specific issue might be fixed by #1483 instead. |
Any news? |
Here is a very interesting SO question related to this topic: http://stackoverflow.com/questions/990904/javascript-remove-accents-diacritics-in-strings I actually used the solution mentioned in the currently accepted answer in some professional project & it works just fine. It uses Unicode Standard to encode characters with diactritics to the same character without diactritics. You might want to extend the solution provided to other scripts/languages (it should be easy enough unless you need to support a huge amount). See comments in the SO answer for more details on how to do this. @tjschuck I agree, that's something that should probably be left to an specialized library. I am considering diving into this next year, contact me if interested to join the fun. |
+1 |
1 similar comment
+1 |
@tjschuck if I were to include latinize, how would be the way to add it and use it with npm, etc. I will try to make this work and I will look around how to do it, but if you can share any pointer, it'd help enormously. |
Well, I gave it a try. I just created a pull request with support for this. Worth testing and commenting. Because the pull request modifies the coffeescripts, I released a test version at https://github.com/hanoii/chosen/releases Download v1.4.3-hanoii and test. Not sure if this is the best way to help with reviewing, but probably is not far off. |
Tested @hanoii release, works great for me ! |
If you can try #2618 that's likely to be merged but you have to implement the transliteration yourself. |
The following actions have been done starting from version chosen_v1.6.1 and directly inserting functions on chosen.jquery.js I will try to release the coffee script for the integration ASAP. New options enable_escape_special_char ( true/false default value false)CODE:
inserted after: Changed AbstractChosen.prototype.winnow_resultsCODE EXPLANATION: if option.search_match but startpos < 0 it means that a matching has been found then try to find startpos with cleaned string CODE:
inserted after Changed AbstractChosen.prototype.search_string_matchCODE EXPLANATION: added test if escape_special_char is true replacing if (regex.test(part)) CODE:
inserted after Added AbstractChosen.prototype.get_list_special_charCODE EXPLANATION: Started from #536 refringe commented on 2 Apr 2014 CODE:
inserted after Added AbstractChosen.prototype.escape_special_charCODE EXPLANATION: Started from #536 felpaslcommented on 10 Oct 2013 CODE:
inserted after |
Another quick and dirty fix I use is to replace the specials chars when I populate the select box and then modify the
Considering something like:
or whatever chars you need to map |
That interests me a lot. I saw that there is a pull request that deals with the subject. |
Well, I'll pledge some $ beer money to any developer that is going to get an accent insensitive search option into this library. Maybe others wish to add to my pledge..? Looks like there are definitely plenty of people struggling with this |
Seems like from version |
@seyfer Just to clarify the issue, Chosen should work just fine with characters like Ö. This issue is specifically about wanting to be able to search for something like |
@hanoii This issue vs. #2618 gets into the fine delineation between "issue" and "PR". That PR fixes this issue, but another PR could theoretically as well. I'm fine with keeping this issue as the statement of the problem, and let PRs be solutions to problems. That said, yes, #2618 could be a solution to this problem. I've bumped that PR, because we seemed to be pretty far along on agreeing on it before it lost momentum. Unfortunately, that happens sometimes ¯\_(ツ)_/¯ As for beer money, I think all of the Chosen maintainers are pretty well set for beer (and @adunkman and I mostly only drink cocktails anyway), but thanks for the offers! |
As for beer money, we should have a Chosen anniversary party sometime 😄 |
we worked around our problem by patching some third party code into the
library but I'm totally still up to provide some beer money if this is
done? I don't believe it is though?
that said we are also looking at replacing choosen in our whole project
because we need to be able to template and style the output, something like
how https://selectize.github.io/selectize.js or https://select2.org/dropdown
or http://silviomoreto.github.io/bootstrap-select does it. again it would
make sense for us to simply sponser somebody to add it a template output
feature to the library... just name your $ price.
cheers
…On Tue, Nov 28, 2017 at 8:23 PM, Koen Punt ***@***.***> wrote:
As for beer money, we should have a Chosen anniversary party sometime 😄
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#536 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AMylrptuqHc-0waqy7L8QlPORccRMon2ks5s67T3gaJpZM4AC4UC>
.
|
+1 |
1 similar comment
+1 |
At the end of the day the easiest solution was to use the 2 years old https://github.com/hanoii/chosen/releases/tag/v1.4.3-hanoii |
just add this line to chosen.js t.prototype.search_string_match=function(t,e){var s;var t=t.normalize("NFD") |
if you have a item in the dropdown called "testé"
it would be nice to be able to type "teste" to find it.
right now it's not finding it because of the ´ over the e
perhaps chosen could remove all of those accent first?
The text was updated successfully, but these errors were encountered: