Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix chosen.jquery.js in-script CSS when the control is used in RTL state

When the control is used as RTL the way to hide the drop-down list is to put it on positive 9000px and when used in LTR -9000px is use
  • Loading branch information...
commit 462858159c33990055f681479a1e32791673f7a4 1 parent 29a5ac1
Ido Ran authored
70 chosen/chosen.jquery.js
@@ -11,7 +11,6 @@
11 11 var SelectParser;
12 12
13 13 SelectParser = (function() {
14   -
15 14 function SelectParser() {
16 15 this.options_index = 0;
17 16 this.parsed = [];
@@ -27,6 +26,7 @@
27 26
28 27 SelectParser.prototype.add_group = function(group) {
29 28 var group_position, option, _i, _len, _ref, _results;
  29 +
30 30 group_position = this.parsed.length;
31 31 this.parsed.push({
32 32 array_index: group_position,
@@ -79,6 +79,7 @@
79 79
80 80 SelectParser.select_to_array = function(select) {
81 81 var child, parser, _i, _len, _ref;
  82 +
82 83 parser = new SelectParser();
83 84 _ref = select.childNodes;
84 85 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
@@ -91,7 +92,6 @@
91 92 this.SelectParser = SelectParser;
92 93
93 94 }).call(this);
94   -
95 95 /*
96 96 Chosen source: generate output using 'cake build'
97 97 Copyright (c) 2011 by Harvest
@@ -104,7 +104,6 @@ Copyright (c) 2011 by Harvest
104 104 root = this;
105 105
106 106 AbstractChosen = (function() {
107   -
108 107 function AbstractChosen(form_field, options) {
109 108 this.form_field = form_field;
110 109 this.options = options != null ? options : {};
@@ -119,6 +118,7 @@ Copyright (c) 2011 by Harvest
119 118
120 119 AbstractChosen.prototype.set_default_values = function() {
121 120 var _this = this;
  121 +
122 122 this.click_test_action = function(evt) {
123 123 return _this.test_active_click(evt);
124 124 };
@@ -162,6 +162,7 @@ Copyright (c) 2011 by Harvest
162 162
163 163 AbstractChosen.prototype.input_focus = function(evt) {
164 164 var _this = this;
  165 +
165 166 if (this.is_multiple) {
166 167 if (!this.active_field) {
167 168 return setTimeout((function() {
@@ -177,6 +178,7 @@ Copyright (c) 2011 by Harvest
177 178
178 179 AbstractChosen.prototype.input_blur = function(evt) {
179 180 var _this = this;
  181 +
180 182 if (!this.mouse_on_container) {
181 183 this.active_field = false;
182 184 return setTimeout((function() {
@@ -187,6 +189,7 @@ Copyright (c) 2011 by Harvest
187 189
188 190 AbstractChosen.prototype.result_add_option = function(option) {
189 191 var classes, style;
  192 +
190 193 if (!option.disabled) {
191 194 option.dom_id = this.container_id + "_o_" + option.array_index;
192 195 classes = option.selected && this.is_multiple ? [] : ["active-result"];
@@ -233,6 +236,7 @@ Copyright (c) 2011 by Harvest
233 236
234 237 AbstractChosen.prototype.keyup_checker = function(evt) {
235 238 var stroke, _ref;
  239 +
236 240 stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
237 241 this.search_field_scale();
238 242 switch (stroke) {
@@ -269,6 +273,7 @@ Copyright (c) 2011 by Harvest
269 273
270 274 AbstractChosen.prototype.generate_field_id = function() {
271 275 var new_id;
  276 +
272 277 new_id = this.generate_random_id();
273 278 this.form_field.id = new_id;
274 279 return new_id;
@@ -276,6 +281,7 @@ Copyright (c) 2011 by Harvest
276 281
277 282 AbstractChosen.prototype.generate_random_char = function() {
278 283 var chars, newchar, rand;
  284 +
279 285 chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
280 286 rand = Math.floor(Math.random() * chars.length);
281 287 return newchar = chars.substring(rand, rand + 1);
@@ -288,7 +294,6 @@ Copyright (c) 2011 by Harvest
288 294 root.AbstractChosen = AbstractChosen;
289 295
290 296 }).call(this);
291   -
292 297 /*
293 298 Chosen source: generate output using 'cake build'
294 299 Copyright (c) 2011 by Harvest
@@ -296,7 +301,7 @@ Copyright (c) 2011 by Harvest
296 301
297 302
298 303 (function() {
299   - var $, Chosen, get_side_border_padding, root,
  304 + var $, Chosen, get_side_border_padding, root, _ref,
300 305 __hasProp = {}.hasOwnProperty,
301 306 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
302 307
@@ -307,6 +312,7 @@ Copyright (c) 2011 by Harvest
307 312 $.fn.extend({
308 313 chosen: function(options) {
309 314 var browser, match, ua;
  315 +
310 316 ua = navigator.userAgent.toLowerCase();
311 317 match = /(msie) ([\w.]+)/.exec(ua) || [];
312 318 browser = {
@@ -318,6 +324,7 @@ Copyright (c) 2011 by Harvest
318 324 }
319 325 return this.each(function(input_field) {
320 326 var $this;
  327 +
321 328 $this = $(this);
322 329 if (!$this.hasClass("chzn-done")) {
323 330 return $this.data('chosen', new Chosen(this, options));
@@ -327,11 +334,11 @@ Copyright (c) 2011 by Harvest
327 334 });
328 335
329 336 Chosen = (function(_super) {
330   -
331 337 __extends(Chosen, _super);
332 338
333 339 function Chosen() {
334   - Chosen.__super__.constructor.apply(this, arguments);
  340 + _ref = Chosen.__super__.constructor.apply(this, arguments);
  341 + return _ref;
335 342 }
336 343
337 344 Chosen.prototype.setup = function() {
@@ -346,6 +353,7 @@ Copyright (c) 2011 by Harvest
346 353
347 354 Chosen.prototype.set_up_html = function() {
348 355 var container_classes, container_div, container_props, dd_top, dd_width, sf_width;
  356 +
349 357 this.container_id = this.form_field.id.length ? this.form_field.id.replace(/[^\w]/g, '_') : this.generate_field_id();
350 358 this.container_id += "_chzn";
351 359 container_classes = ["chzn-container"];
@@ -365,9 +373,9 @@ Copyright (c) 2011 by Harvest
365 373 };
366 374 container_div = $("<div />", container_props);
367 375 if (this.is_multiple) {
368   - container_div.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>');
  376 + container_div.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:' + (this.is_rtl ? '' : '-') + '9000px;"><ul class="chzn-results"></ul></div>');
369 377 } else {
370   - container_div.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>');
  378 + container_div.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:' + (this.is_rtl ? '' : '-') + '9000px;"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>');
371 379 }
372 380 this.form_field_jq.hide().after(container_div);
373 381 this.container = $('#' + this.container_id);
@@ -402,6 +410,7 @@ Copyright (c) 2011 by Harvest
402 410
403 411 Chosen.prototype.register_observers = function() {
404 412 var _this = this;
  413 +
405 414 this.container.mousedown(function(evt) {
406 415 _this.container_mousedown(evt);
407 416 });
@@ -475,6 +484,7 @@ Copyright (c) 2011 by Harvest
475 484
476 485 Chosen.prototype.container_mousedown = function(evt) {
477 486 var target_closelink;
  487 +
478 488 if (!this.is_disabled) {
479 489 target_closelink = evt != null ? ($(evt.target)).hasClass("search-choice-close") : false;
480 490 if (evt && evt.type === "mousedown" && !this.results_showing) {
@@ -537,7 +547,8 @@ Copyright (c) 2011 by Harvest
537 547 };
538 548
539 549 Chosen.prototype.results_build = function() {
540   - var content, data, _i, _len, _ref;
  550 + var content, data, _i, _len, _ref1;
  551 +
541 552 this.parsing = true;
542 553 this.results_data = root.SelectParser.select_to_array(this.form_field);
543 554 if (this.is_multiple && this.choices > 0) {
@@ -552,9 +563,9 @@ Copyright (c) 2011 by Harvest
552 563 }
553 564 }
554 565 content = '';
555   - _ref = this.results_data;
556   - for (_i = 0, _len = _ref.length; _i < _len; _i++) {
557   - data = _ref[_i];
  566 + _ref1 = this.results_data;
  567 + for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
  568 + data = _ref1[_i];
558 569 if (data.group) {
559 570 content += this.result_add_group(data);
560 571 } else if (!data.empty) {
@@ -587,6 +598,7 @@ Copyright (c) 2011 by Harvest
587 598
588 599 Chosen.prototype.result_do_highlight = function(el) {
589 600 var high_bottom, high_top, maxHeight, visible_bottom, visible_top;
  601 +
590 602 if (el.length) {
591 603 this.result_clear_highlight();
592 604 this.result_highlight = el;
@@ -613,6 +625,7 @@ Copyright (c) 2011 by Harvest
613 625
614 626 Chosen.prototype.results_show = function() {
615 627 var dd_top;
  628 +
616 629 if (!this.is_multiple) {
617 630 this.selected_item.addClass("chzn-single-with-drop");
618 631 if (this.result_single_selected) {
@@ -647,13 +660,14 @@ Copyright (c) 2011 by Harvest
647 660 chosen: this
648 661 });
649 662 this.dropdown.css({
650   - "left": "-9000px"
  663 + "left": (this.is_rtl ? '' : '-') + "9000px"
651 664 });
652 665 return this.results_showing = false;
653 666 };
654 667
655 668 Chosen.prototype.set_tab_index = function(el) {
656 669 var ti;
  670 +
657 671 if (this.form_field_jq.attr("tabindex")) {
658 672 ti = this.form_field_jq.attr("tabindex");
659 673 this.form_field_jq.attr("tabindex", -1);
@@ -673,6 +687,7 @@ Copyright (c) 2011 by Harvest
673 687
674 688 Chosen.prototype.search_results_mouseup = function(evt) {
675 689 var target;
  690 +
676 691 target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
677 692 if (target.length) {
678 693 this.result_highlight = target;
@@ -683,6 +698,7 @@ Copyright (c) 2011 by Harvest
683 698
684 699 Chosen.prototype.search_results_mouseover = function(evt) {
685 700 var target;
  701 +
686 702 target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
687 703 if (target) {
688 704 return this.result_do_highlight(target);
@@ -705,6 +721,7 @@ Copyright (c) 2011 by Harvest
705 721 Chosen.prototype.choice_build = function(item) {
706 722 var choice_id, html, link,
707 723 _this = this;
  724 +
708 725 if (this.is_multiple && this.max_selected_options <= this.choices) {
709 726 this.form_field_jq.trigger("liszt:maxselected", {
710 727 chosen: this
@@ -768,6 +785,7 @@ Copyright (c) 2011 by Harvest
768 785
769 786 Chosen.prototype.result_select = function(evt) {
770 787 var high, high_id, item, position;
  788 +
771 789 if (this.result_highlight) {
772 790 high = this.result_highlight;
773 791 high_id = high.attr("id");
@@ -816,6 +834,7 @@ Copyright (c) 2011 by Harvest
816 834
817 835 Chosen.prototype.result_deselect = function(pos) {
818 836 var result, result_data;
  837 +
819 838 result_data = this.results_data[pos];
820 839 if (!this.form_field.options[result_data.options_index].disabled) {
821 840 result_data.selected = false;
@@ -841,16 +860,17 @@ Copyright (c) 2011 by Harvest
841 860 };
842 861
843 862 Chosen.prototype.winnow_results = function() {
844   - var found, option, part, parts, regex, regexAnchor, result, result_id, results, searchText, startpos, text, zregex, _i, _j, _len, _len1, _ref;
  863 + var found, option, part, parts, regex, regexAnchor, result, result_id, results, searchText, startpos, text, zregex, _i, _j, _len, _len1, _ref1;
  864 +
845 865 this.no_results_clear();
846 866 results = 0;
847 867 searchText = this.search_field.val() === this.default_text ? "" : $('<div/>').text($.trim(this.search_field.val())).html();
848 868 regexAnchor = this.search_contains ? "" : "^";
849 869 regex = new RegExp(regexAnchor + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
850 870 zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
851   - _ref = this.results_data;
852   - for (_i = 0, _len = _ref.length; _i < _len; _i++) {
853   - option = _ref[_i];
  871 + _ref1 = this.results_data;
  872 + for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
  873 + option = _ref1[_i];
854 874 if (!option.disabled && !option.empty) {
855 875 if (option.group) {
856 876 $('#' + option.dom_id).css('display', 'none');
@@ -904,6 +924,7 @@ Copyright (c) 2011 by Harvest
904 924
905 925 Chosen.prototype.winnow_results_clear = function() {
906 926 var li, lis, _i, _len, _results;
  927 +
907 928 this.search_field.val("");
908 929 lis = this.search_results.find("li");
909 930 _results = [];
@@ -923,6 +944,7 @@ Copyright (c) 2011 by Harvest
923 944
924 945 Chosen.prototype.winnow_results_set_highlight = function() {
925 946 var do_high, selected_results;
  947 +
926 948 if (!this.result_highlight) {
927 949 selected_results = !this.is_multiple ? this.search_results.find(".result-selected.active-result") : [];
928 950 do_high = selected_results.length ? selected_results.first() : this.search_results.find(".active-result").first();
@@ -934,6 +956,7 @@ Copyright (c) 2011 by Harvest
934 956
935 957 Chosen.prototype.no_results = function(terms) {
936 958 var no_results_html;
  959 +
937 960 no_results_html = $('<li class="no-results">' + this.results_none_found + ' "<span></span>"</li>');
938 961 no_results_html.find("span").first().html(terms);
939 962 return this.search_results.append(no_results_html);
@@ -945,6 +968,7 @@ Copyright (c) 2011 by Harvest
945 968
946 969 Chosen.prototype.keydown_arrow = function() {
947 970 var first_active, next_sib;
  971 +
948 972 if (!this.result_highlight) {
949 973 first_active = this.search_results.find("li.active-result").first();
950 974 if (first_active) {
@@ -963,6 +987,7 @@ Copyright (c) 2011 by Harvest
963 987
964 988 Chosen.prototype.keyup_arrow = function() {
965 989 var prev_sibs;
  990 +
966 991 if (!this.results_showing && !this.is_multiple) {
967 992 return this.results_show();
968 993 } else if (this.result_highlight) {
@@ -980,6 +1005,7 @@ Copyright (c) 2011 by Harvest
980 1005
981 1006 Chosen.prototype.keydown_backstroke = function() {
982 1007 var next_available_destroy;
  1008 +
983 1009 if (this.pending_backstroke) {
984 1010 this.choice_destroy(this.pending_backstroke.find("a").first());
985 1011 return this.clear_backstroke();
@@ -1004,8 +1030,9 @@ Copyright (c) 2011 by Harvest
1004 1030 };
1005 1031
1006 1032 Chosen.prototype.keydown_checker = function(evt) {
1007   - var stroke, _ref;
1008   - stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
  1033 + var stroke, _ref1;
  1034 +
  1035 + stroke = (_ref1 = evt.which) != null ? _ref1 : evt.keyCode;
1009 1036 this.search_field_scale();
1010 1037 if (stroke !== 8 && this.pending_backstroke) {
1011 1038 this.clear_backstroke();
@@ -1035,6 +1062,7 @@ Copyright (c) 2011 by Harvest
1035 1062
1036 1063 Chosen.prototype.search_field_scale = function() {
1037 1064 var dd_top, div, h, style, style_block, styles, w, _i, _len;
  1065 +
1038 1066 if (this.is_multiple) {
1039 1067 h = 0;
1040 1068 w = 0;
@@ -1066,6 +1094,7 @@ Copyright (c) 2011 by Harvest
1066 1094
1067 1095 Chosen.prototype.generate_random_id = function() {
1068 1096 var string;
  1097 +
1069 1098 string = "sel" + this.generate_random_char() + this.generate_random_char() + this.generate_random_char();
1070 1099 while ($("#" + string).length > 0) {
1071 1100 string += this.generate_random_char();
@@ -1081,6 +1110,7 @@ Copyright (c) 2011 by Harvest
1081 1110
1082 1111 get_side_border_padding = function(elmt) {
1083 1112 var side_border_padding;
  1113 +
1084 1114 return side_border_padding = elmt.outerWidth() - elmt.width();
1085 1115 };
1086 1116
2  chosen/chosen.jquery.min.js
@@ -7,4 +7,4 @@
7 7
8 8 // MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md
9 9 // This file is generated by `cake build`, do not edit it by hand.
10   -(function(){var e;e=function(){function e(){this.options_index=0,this.parsed=[]}return e.prototype.add_node=function(e){return e.nodeName.toUpperCase()==="OPTGROUP"?this.add_group(e):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:!0,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")return e.text!==""?(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===!0?n:e.disabled,group_array_index:t,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},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()}return e.prototype.set_default_values=function(){var e=this;return 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=!1,this.mouse_on_container=!1,this.results_showing=!1,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:!1,this.disable_search_threshold=this.options.disable_search_threshold||0,this.disable_search=this.options.disable_search||!1,this.enable_split_word_search=this.options.enable_split_word_search!=null?this.options.enable_split_word_search:!0,this.search_contains=this.options.search_contains||!1,this.choices=0,this.single_backstroke_delete=this.options.single_backstroke_delete||!1,this.max_selected_options=this.options.max_selected_options||Infinity,this.inherit_select_classes=this.options.inherit_select_classes||!1},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||"Select Some Options":this.default_text=this.options.placeholder_text_single||this.options.placeholder_text||"Select an Option",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=!0},e.prototype.mouse_leave=function(){return this.mouse_on_container=!1},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)return this.active_field=!1,setTimeout(function(){return t.blur_test()},100)},e.prototype.result_add_option=function(e){var t,n;return e.disabled?"":(e.dom_id=this.container_id+"_o_"+e.array_index,t=e.selected&&this.is_multiple?[]:["active-result"],e.selected&&t.push("result-selected"),e.group_array_index!=null&&t.push("group-option"),e.classes!==""&&t.push(e.classes),n=e.style.cssText!==""?' style="'+e.style+'"':"",'<li id="'+e.dom_id+'" class="'+t.join(" ")+'"'+n+">"+e.html+"</li>")},e.prototype.results_update_field=function(){return this.is_multiple||this.results_reset_cleanup(),this.result_clear_highlight(),this.result_single_selected=null,this.results_build()},e.prototype.results_toggle=function(){return this.results_showing?this.results_hide():this.results_show()},e.prototype.results_search=function(e){return this.results_showing?this.winnow_results():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();if(!this.pending_backstroke)return this.result_clear_highlight(),this.results_search();break;case 13:e.preventDefault();if(this.results_showing)return this.result_select(e);break;case 27:return this.results_showing&&this.results_hide(),!0;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;return e=this.generate_random_id(),this.form_field.id=e,e},e.prototype.generate_random_char=function(){var e,t,n;return e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",n=Math.floor(Math.random()*e.length),t=e.substring(n,n+1)},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)i.call(t,n)&&(e[n]=t[n]);return r.prototype=t.prototype,e.prototype=new r,e.__super__=t.prototype,e};r=this,e=jQuery,e.fn.extend({chosen:function(n){var r,i,s;return s=navigator.userAgent.toLowerCase(),i=/(msie) ([\w.]+)/.exec(s)||[],r={name:i[1]||"",version:i[2]||"0"},r.name==="msie"&&(r.version==="6.0"||r.version==="7.0"&&document.documentMode===7)?this: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(){i.__super__.constructor.apply(this,arguments)}return s(i,t),i.prototype.setup=function(){return this.form_field_jq=e(this.form_field),this.current_value=this.form_field_jq.val(),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;return 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")),this.inherit_select_classes&&this.form_field.className&&t.push(this.form_field.className),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),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>'):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(),this.is_multiple?(this.search_choices=this.container.find("ul.chzn-choices").first(),this.search_container=this.container.find("li.search-field").first()):(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(),this.form_field_jq.trigger("liszt:ready",{chosen:this})},i.prototype.register_observers=function(){var e=this;return this.container.mousedown(function(t){e.container_mousedown(t)}),this.container.mouseup(function(t){e.container_mouseup(t)}),this.container.mouseenter(function(t){e.mouse_enter(t)}),this.container.mouseleave(function(t){e.mouse_leave(t)}),this.search_results.mouseup(function(t){e.search_results_mouseup(t)}),this.search_results.mouseover(function(t){e.search_results_mouseover(t)}),this.search_results.mouseout(function(t){e.search_results_mouseout(t)}),this.form_field_jq.bind("liszt:updated",function(t){e.results_update_field(t)}),this.form_field_jq.bind("liszt:activate",function(t){e.activate_field(t)}),this.form_field_jq.bind("liszt:open",function(t){e.container_mousedown(t)}),this.search_field.blur(function(t){e.input_blur(t)}),this.search_field.keyup(function(t){e.keyup_checker(t)}),this.search_field.keydown(function(t){e.keydown_checker(t)}),this.search_field.focus(function(t){e.input_focus(t)}),this.is_multiple?this.search_choices.click(function(t){e.choices_click(t)}):this.container.click(function(e){e.preventDefault()})},i.prototype.search_field_disabled=function(){this.is_disabled=this.form_field_jq[0].disabled;if(this.is_disabled)return this.container.addClass("chzn-disabled"),this.search_field[0].disabled=!0,this.is_multiple||this.selected_item.unbind("focus",this.activate_action),this.close_field();this.container.removeClass("chzn-disabled"),this.search_field[0].disabled=!1;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)return n=t!=null?e(t.target).hasClass("search-choice-close"):!1,t&&t.type==="mousedown"&&!this.results_showing&&t.preventDefault(),!this.pending_destroy_click&&!n?(this.active_field?!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()):(this.is_multiple&&this.search_field.val(""),e(document).click(this.click_test_action),this.results_show()),this.activate_field()):this.pending_destroy_click=!1},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(){return e(document).unbind("click",this.click_test_action),this.active_field=!1,this.results_hide(),this.container.removeClass("chzn-container-active"),this.winnow_results_clear(),this.clear_backstroke(),this.show_search_field_default(),this.search_field_scale()},i.prototype.activate_field=function(){return this.container.addClass("chzn-container-active"),this.active_field=!0,this.search_field.val(this.search_field.val()),this.search_field.focus()},i.prototype.test_active_click=function(t){return e(t.target).parents("#"+this.container_id).length?this.active_field=!0:this.close_field()},i.prototype.results_build=function(){var e,t,n,i,s;this.parsing=!0,this.results_data=r.SelectParser.select_to_array(this.form_field),this.is_multiple&&this.choices>0?(this.search_choices.find("li.search-choice").remove(),this.choices=0):this.is_multiple||(this.selected_item.addClass("chzn-default").find("span").text(this.default_text),this.disable_search||this.form_field.options.length<=this.disable_search_threshold?this.container.addClass("chzn-container-single-nosearch"):this.container.removeClass("chzn-container-single-nosearch")),e="",s=this.results_data;for(n=0,i=s.length;n<i;n++)t=s[n],t.group?e+=this.result_add_group(t):t.empty||(e+=this.result_add_option(t),t.selected&&this.is_multiple?this.choice_build(t):t.selected&&!this.is_multiple&&(this.selected_item.removeClass("chzn-default").find("span").text(t.text),this.allow_single_deselect&&this.single_deselect_control_build()));return this.search_field_disabled(),this.show_search_field_default(),this.search_field_scale(),this.search_results.html(e),this.parsing=!1},i.prototype.result_add_group=function(t){return t.disabled?"":(t.dom_id=this.container_id+"_g_"+t.array_index,'<li id="'+t.dom_id+'" class="group-result">'+e("<div />").text(t.label).html()+"</li>")},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);if(n<s)return this.search_results.scrollTop(n)}},i.prototype.result_clear_highlight=function(){return this.result_highlight&&this.result_highlight.removeClass("highlighted"),this.result_highlight=null},i.prototype.results_show=function(){var e;if(!this.is_multiple)this.selected_item.addClass("chzn-single-with-drop"),this.result_single_selected&&this.result_do_highlight(this.result_single_selected);else if(this.max_selected_options<=this.choices)return this.form_field_jq.trigger("liszt:maxselected",{chosen:this}),!1;return 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=!0,this.search_field.focus(),this.search_field.val(this.search_field.val()),this.winnow_results()},i.prototype.results_hide=function(){return 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"}),this.results_showing=!1},i.prototype.set_tab_index=function(e){var t;if(this.form_field_jq.attr("tabindex"))return t=this.form_field_jq.attr("tabindex"),this.form_field_jq.attr("tabindex",-1),this.search_field.attr("tabindex",t)},i.prototype.show_search_field_default=function(){return this.is_multiple&&this.choices<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"))},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)return this.result_highlight=n,this.result_select(t),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"))return this.result_clear_highlight()},i.prototype.choices_click=function(t){t.preventDefault();if(this.active_field&&!e(t.target).hasClass("search-choice")&&!this.results_showing)return this.results_show()},i.prototype.choice_build=function(t){var n,r,i,s=this;return this.is_multiple&&this.max_selected_options<=this.choices?(this.form_field_jq.trigger("liszt:maxselected",{chosen:this}),!1):(n=this.container_id+"_c_"+t.array_index,this.choices+=1,t.disabled?r='<li class="search-choice search-choice-disabled" id="'+n+'"><span>'+t.html+"</span></li>":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(),i.click(function(e){return s.choice_destroy_link_click(e)}))},i.prototype.choice_destroy_link_click=function(t){return t.preventDefault(),this.is_disabled?t.stopPropagation:(this.pending_destroy_click=!0,this.choice_destroy(e(t.target)))},i.prototype.choice_destroy=function(e){if(this.result_deselect(e.attr("rel")))return this.choices-=1,this.show_search_field_default(),this.is_multiple&&this.choices>0&&this.search_field.val().length<1&&this.results_hide(),e.parents("li").first().remove(),this.search_field_scale()},i.prototype.results_reset=function(){this.form_field.options[0].selected=!0,this.selected_item.find("span").text(this.default_text),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(){return this.current_value=this.form_field_jq.val(),this.selected_item.find("abbr").remove()},i.prototype.result_select=function(e){var t,n,r,i;if(this.result_highlight)return t=this.result_highlight,n=t.attr("id"),this.result_clear_highlight(),this.is_multiple?this.result_deactivate(t):(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=!0,this.form_field.options[r.options_index].selected=!0,this.is_multiple?this.choice_build(r):(this.selected_item.find("span").first().text(r.text),this.allow_single_deselect&&this.single_deselect_control_build()),(!e.metaKey&&!e.ctrlKey||!this.is_multiple)&&this.results_hide(),this.search_field.val(""),(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(),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;return r=this.results_data[t],this.form_field.options[r.options_index].disabled?!1:(r.selected=!1,this.form_field.options[r.options_index].selected=!1,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(),!0)},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(){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,l=this.search_field.val()===this.default_text?"":e("<div/>").text(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=!1,a=n.dom_id,u=e("#"+a);if(s.test(n.html))t=!0,f+=1;else if(this.enable_split_word_search&&(n.html.indexOf(" ")>=0||n.html.indexOf("[")===0)){i=n.html.replace(/\[|\]/g,"").split(" ");if(i.length)for(v=0,g=i.length;v<g;v++)r=i[v],s.test(r)&&(t=!0,f+=1)}t?(l.length?(c=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)):h=n.html,u.html(h),this.result_activate(u),n.group_array_index!=null&&e("#"+this.results_data[n.group_array_index].dom_id).css("display","list-item")):(this.result_highlight&&a===this.result_highlight.attr("id")&&this.result_clear_highlight(),this.result_deactivate(u))}}return f<1&&l.length?this.no_results(l):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),t.hasClass("group-result")?s.push(t.css("display","auto")):!this.is_multiple||!t.hasClass("result-selected")?s.push(this.result_activate(t)):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;return n=e('<li class="no-results">'+this.results_none_found+' "<span></span>"</li>'),n.find("span").first().html(t),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;this.result_highlight?this.results_showing&&(n=this.result_highlight.nextAll("li.active-result").first(),n&&this.result_do_highlight(n)):(t=this.search_results.find("li.active-result").first(),t&&this.result_do_highlight(e(t)));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();if(this.result_highlight)return e=this.result_highlight.prevAll("li.active-result"),e.length?this.result_do_highlight(e.first()):(this.choices>0&&this.results_hide(),this.result_clear_highlight())},i.prototype.keydown_backstroke=function(){var e;if(this.pending_backstroke)return this.choice_destroy(this.pending_backstroke.find("a").first()),this.clear_backstroke();e=this.search_container.siblings("li.search-choice").last();if(e.length&&!e.hasClass("search-choice-disabled"))return this.pending_backstroke=e,this.single_backstroke_delete?this.keydown_backstroke():this.pending_backstroke.addClass("search-choice-focus")},i.prototype.clear_backstroke=function(){return this.pending_backstroke&&this.pending_backstroke.removeClass("search-choice-focus"),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(),t!==8&&this.pending_backstroke&&this.clear_backstroke();switch(t){case 8:this.backstroke_length=this.search_field.val().length;break;case 9:this.results_showing&&!this.is_multiple&&this.result_select(e),this.mouse_on_container=!1;break;case 13:e.preventDefault();break;case 38:e.preventDefault(),this.keyup_arrow();break;case 40:this.keydown_arrow()}},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)+";";return n=e("<div />",{style:s}),n.text(this.search_field.val()),e("body").append(n),u=n.width()+25,n.remove(),u>this.f_width-10&&(u=this.f_width-10),this.search_field.css({width:u+"px"}),t=this.container.height(),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},i}(AbstractChosen),r.Chosen=t,n=function(e){var t;return t=e.outerWidth()-e.width()},r.get_side_border_padding=n}.call(this);
  10 +(function(){var e;e=function(){function e(){this.options_index=0,this.parsed=[]}return e.prototype.add_node=function(e){return e.nodeName.toUpperCase()==="OPTGROUP"?this.add_group(e):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:!0,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")return e.text!==""?(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===!0?n:e.disabled,group_array_index:t,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},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()}return e.prototype.set_default_values=function(){var e=this;return 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=!1,this.mouse_on_container=!1,this.results_showing=!1,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:!1,this.disable_search_threshold=this.options.disable_search_threshold||0,this.disable_search=this.options.disable_search||!1,this.enable_split_word_search=this.options.enable_split_word_search!=null?this.options.enable_split_word_search:!0,this.search_contains=this.options.search_contains||!1,this.choices=0,this.single_backstroke_delete=this.options.single_backstroke_delete||!1,this.max_selected_options=this.options.max_selected_options||Infinity,this.inherit_select_classes=this.options.inherit_select_classes||!1},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||"Select Some Options":this.default_text=this.options.placeholder_text_single||this.options.placeholder_text||"Select an Option",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=!0},e.prototype.mouse_leave=function(){return this.mouse_on_container=!1},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)return this.active_field=!1,setTimeout(function(){return t.blur_test()},100)},e.prototype.result_add_option=function(e){var t,n;return e.disabled?"":(e.dom_id=this.container_id+"_o_"+e.array_index,t=e.selected&&this.is_multiple?[]:["active-result"],e.selected&&t.push("result-selected"),e.group_array_index!=null&&t.push("group-option"),e.classes!==""&&t.push(e.classes),n=e.style.cssText!==""?' style="'+e.style+'"':"",'<li id="'+e.dom_id+'" class="'+t.join(" ")+'"'+n+">"+e.html+"</li>")},e.prototype.results_update_field=function(){return this.is_multiple||this.results_reset_cleanup(),this.result_clear_highlight(),this.result_single_selected=null,this.results_build()},e.prototype.results_toggle=function(){return this.results_showing?this.results_hide():this.results_show()},e.prototype.results_search=function(e){return this.results_showing?this.winnow_results():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();if(!this.pending_backstroke)return this.result_clear_highlight(),this.results_search();break;case 13:e.preventDefault();if(this.results_showing)return this.result_select(e);break;case 27:return this.results_showing&&this.results_hide(),!0;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;return e=this.generate_random_id(),this.form_field.id=e,e},e.prototype.generate_random_char=function(){var e,t,n;return e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",n=Math.floor(Math.random()*e.length),t=e.substring(n,n+1)},e}(),t.AbstractChosen=e}.call(this),function(){var e,t,n,r,i,s={}.hasOwnProperty,o=function(e,t){function r(){this.constructor=e}for(var n in t)s.call(t,n)&&(e[n]=t[n]);return r.prototype=t.prototype,e.prototype=new r,e.__super__=t.prototype,e};r=this,e=jQuery,e.fn.extend({chosen:function(n){var r,i,s;return s=navigator.userAgent.toLowerCase(),i=/(msie) ([\w.]+)/.exec(s)||[],r={name:i[1]||"",version:i[2]||"0"},r.name==="msie"&&(r.version==="6.0"||r.version==="7.0"&&document.documentMode===7)?this: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 s(){return i=s.__super__.constructor.apply(this,arguments),i}return o(s,t),s.prototype.setup=function(){return this.form_field_jq=e(this.form_field),this.current_value=this.form_field_jq.val(),this.is_rtl=this.form_field_jq.hasClass("chzn-rtl")},s.prototype.finish_setup=function(){return this.form_field_jq.addClass("chzn-done")},s.prototype.set_up_html=function(){var t,r,i,s,o,u;return 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")),this.inherit_select_classes&&this.form_field.className&&t.push(this.form_field.className),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),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:'+(this.is_rtl?"":"-")+'9000px;"><ul class="chzn-results"></ul></div>'):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:'+(this.is_rtl?"":"-")+'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(),this.is_multiple?(this.search_choices=this.container.find("ul.chzn-choices").first(),this.search_container=this.container.find("li.search-field").first()):(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(),this.form_field_jq.trigger("liszt:ready",{chosen:this})},s.prototype.register_observers=function(){var e=this;return this.container.mousedown(function(t){e.container_mousedown(t)}),this.container.mouseup(function(t){e.container_mouseup(t)}),this.container.mouseenter(function(t){e.mouse_enter(t)}),this.container.mouseleave(function(t){e.mouse_leave(t)}),this.search_results.mouseup(function(t){e.search_results_mouseup(t)}),this.search_results.mouseover(function(t){e.search_results_mouseover(t)}),this.search_results.mouseout(function(t){e.search_results_mouseout(t)}),this.form_field_jq.bind("liszt:updated",function(t){e.results_update_field(t)}),this.form_field_jq.bind("liszt:activate",function(t){e.activate_field(t)}),this.form_field_jq.bind("liszt:open",function(t){e.container_mousedown(t)}),this.search_field.blur(function(t){e.input_blur(t)}),this.search_field.keyup(function(t){e.keyup_checker(t)}),this.search_field.keydown(function(t){e.keydown_checker(t)}),this.search_field.focus(function(t){e.input_focus(t)}),this.is_multiple?this.search_choices.click(function(t){e.choices_click(t)}):this.container.click(function(e){e.preventDefault()})},s.prototype.search_field_disabled=function(){this.is_disabled=this.form_field_jq[0].disabled;if(this.is_disabled)return this.container.addClass("chzn-disabled"),this.search_field[0].disabled=!0,this.is_multiple||this.selected_item.unbind("focus",this.activate_action),this.close_field();this.container.removeClass("chzn-disabled"),this.search_field[0].disabled=!1;if(!this.is_multiple)return this.selected_item.bind("focus",this.activate_action)},s.prototype.container_mousedown=function(t){var n;if(!this.is_disabled)return n=t!=null?e(t.target).hasClass("search-choice-close"):!1,t&&t.type==="mousedown"&&!this.results_showing&&t.preventDefault(),!this.pending_destroy_click&&!n?(this.active_field?!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()):(this.is_multiple&&this.search_field.val(""),e(document).click(this.click_test_action),this.results_show()),this.activate_field()):this.pending_destroy_click=!1},s.prototype.container_mouseup=function(e){if(e.target.nodeName==="ABBR"&&!this.is_disabled)return this.results_reset(e)},s.prototype.blur_test=function(e){if(!this.active_field&&this.container.hasClass("chzn-container-active"))return this.close_field()},s.prototype.close_field=function(){return e(document).unbind("click",this.click_test_action),this.active_field=!1,this.results_hide(),this.container.removeClass("chzn-container-active"),this.winnow_results_clear(),this.clear_backstroke(),this.show_search_field_default(),this.search_field_scale()},s.prototype.activate_field=function(){return this.container.addClass("chzn-container-active"),this.active_field=!0,this.search_field.val(this.search_field.val()),this.search_field.focus()},s.prototype.test_active_click=function(t){return e(t.target).parents("#"+this.container_id).length?this.active_field=!0:this.close_field()},s.prototype.results_build=function(){var e,t,n,i,s;this.parsing=!0,this.results_data=r.SelectParser.select_to_array(this.form_field),this.is_multiple&&this.choices>0?(this.search_choices.find("li.search-choice").remove(),this.choices=0):this.is_multiple||(this.selected_item.addClass("chzn-default").find("span").text(this.default_text),this.disable_search||this.form_field.options.length<=this.disable_search_threshold?this.container.addClass("chzn-container-single-nosearch"):this.container.removeClass("chzn-container-single-nosearch")),e="",s=this.results_data;for(n=0,i=s.length;n<i;n++)t=s[n],t.group?e+=this.result_add_group(t):t.empty||(e+=this.result_add_option(t),t.selected&&this.is_multiple?this.choice_build(t):t.selected&&!this.is_multiple&&(this.selected_item.removeClass("chzn-default").find("span").text(t.text),this.allow_single_deselect&&this.single_deselect_control_build()));return this.search_field_disabled(),this.show_search_field_default(),this.search_field_scale(),this.search_results.html(e),this.parsing=!1},s.prototype.result_add_group=function(t){return t.disabled?"":(t.dom_id=this.container_id+"_g_"+t.array_index,'<li id="'+t.dom_id+'" class="group-result">'+e("<div />").text(t.label).html()+"</li>")},s.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);if(n<s)return this.search_results.scrollTop(n)}},s.prototype.result_clear_highlight=function(){return this.result_highlight&&this.result_highlight.removeClass("highlighted"),this.result_highlight=null},s.prototype.results_show=function(){var e;if(!this.is_multiple)this.selected_item.addClass("chzn-single-with-drop"),this.result_single_selected&&this.result_do_highlight(this.result_single_selected);else if(this.max_selected_options<=this.choices)return this.form_field_jq.trigger("liszt:maxselected",{chosen:this}),!1;return 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=!0,this.search_field.focus(),this.search_field.val(this.search_field.val()),this.winnow_results()},s.prototype.results_hide=function(){return 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:(this.is_rtl?"":"-")+"9000px"}),this.results_showing=!1},s.prototype.set_tab_index=function(e){var t;if(this.form_field_jq.attr("tabindex"))return t=this.form_field_jq.attr("tabindex"),this.form_field_jq.attr("tabindex",-1),this.search_field.attr("tabindex",t)},s.prototype.show_search_field_default=function(){return this.is_multiple&&this.choices<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"))},s.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)return this.result_highlight=n,this.result_select(t),this.search_field.focus()},s.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)},s.prototype.search_results_mouseout=function(t){if(e(t.target).hasClass("active-result"))return this.result_clear_highlight()},s.prototype.choices_click=function(t){t.preventDefault();if(this.active_field&&!e(t.target).hasClass("search-choice")&&!this.results_showing)return this.results_show()},s.prototype.choice_build=function(t){var n,r,i,s=this;return this.is_multiple&&this.max_selected_options<=this.choices?(this.form_field_jq.trigger("liszt:maxselected",{chosen:this}),!1):(n=this.container_id+"_c_"+t.array_index,this.choices+=1,t.disabled?r='<li class="search-choice search-choice-disabled" id="'+n+'"><span>'+t.html+"</span></li>":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(),i.click(function(e){return s.choice_destroy_link_click(e)}))},s.prototype.choice_destroy_link_click=function(t){return t.preventDefault(),this.is_disabled?t.stopPropagation:(this.pending_destroy_click=!0,this.choice_destroy(e(t.target)))},s.prototype.choice_destroy=function(e){if(this.result_deselect(e.attr("rel")))return this.choices-=1,this.show_search_field_default(),this.is_multiple&&this.choices>0&&this.search_field.val().length<1&&this.results_hide(),e.parents("li").first().remove(),this.search_field_scale()},s.prototype.results_reset=function(){this.form_field.options[0].selected=!0,this.selected_item.find("span").text(this.default_text),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()},s.prototype.results_reset_cleanup=function(){return this.current_value=this.form_field_jq.val(),this.selected_item.find("abbr").remove()},s.prototype.result_select=function(e){var t,n,r,i;if(this.result_highlight)return t=this.result_highlight,n=t.attr("id"),this.result_clear_highlight(),this.is_multiple?this.result_deactivate(t):(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=!0,this.form_field.options[r.options_index].selected=!0,this.is_multiple?this.choice_build(r):(this.selected_item.find("span").first().text(r.text),this.allow_single_deselect&&this.single_deselect_control_build()),(!e.metaKey&&!e.ctrlKey||!this.is_multiple)&&this.results_hide(),this.search_field.val(""),(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(),this.search_field_scale()},s.prototype.result_activate=function(e){return e.addClass("active-result")},s.prototype.result_deactivate=function(e){return e.removeClass("active-result")},s.prototype.result_deselect=function(t){var n,r;return r=this.results_data[t],this.form_field.options[r.options_index].disabled?!1:(r.selected=!1,this.form_field.options[r.options_index].selected=!1,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(),!0)},s.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>')},s.prototype.winnow_results=function(){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,l=this.search_field.val()===this.default_text?"":e("<div/>").text(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=!1,a=n.dom_id,u=e("#"+a);if(s.test(n.html))t=!0,f+=1;else if(this.enable_split_word_search&&(n.html.indexOf(" ")>=0||n.html.indexOf("[")===0)){i=n.html.replace(/\[|\]/g,"").split(" ");if(i.length)for(v=0,g=i.length;v<g;v++)r=i[v],s.test(r)&&(t=!0,f+=1)}t?(l.length?(c=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)):h=n.html,u.html(h),this.result_activate(u),n.group_array_index!=null&&e("#"+this.results_data[n.group_array_index].dom_id).css("display","list-item")):(this.result_highlight&&a===this.result_highlight.attr("id")&&this.result_clear_highlight(),this.result_deactivate(u))}}return f<1&&l.length?this.no_results(l):this.winnow_results_set_highlight()},s.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),t.hasClass("group-result")?s.push(t.css("display","auto")):!this.is_multiple||!t.hasClass("result-selected")?s.push(this.result_activate(t)):s.push(void 0);return s},s.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)}},s.prototype.no_results=function(t){var n;return n=e('<li class="no-results">'+this.results_none_found+' "<span></span>"</li>'),n.find("span").first().html(t),this.search_results.append(n)},s.prototype.no_results_clear=function(){return this.search_results.find(".no-results").remove()},s.prototype.keydown_arrow=function(){var t,n;this.result_highlight?this.results_showing&&(n=this.result_highlight.nextAll("li.active-result").first(),n&&this.result_do_highlight(n)):(t=this.search_results.find("li.active-result").first(),t&&this.result_do_highlight(e(t)));if(!this.results_showing)return this.results_show()},s.prototype.keyup_arrow=function(){var e;if(!this.results_showing&&!this.is_multiple)return this.results_show();if(this.result_highlight)return e=this.result_highlight.prevAll("li.active-result"),e.length?this.result_do_highlight(e.first()):(this.choices>0&&this.results_hide(),this.result_clear_highlight())},s.prototype.keydown_backstroke=function(){var e;if(this.pending_backstroke)return this.choice_destroy(this.pending_backstroke.find("a").first()),this.clear_backstroke();e=this.search_container.siblings("li.search-choice").last();if(e.length&&!e.hasClass("search-choice-disabled"))return this.pending_backstroke=e,this.single_backstroke_delete?this.keydown_backstroke():this.pending_backstroke.addClass("search-choice-focus")},s.prototype.clear_backstroke=function(){return this.pending_backstroke&&this.pending_backstroke.removeClass("search-choice-focus"),this.pending_backstroke=null},s.prototype.keydown_checker=function(e){var t,n;t=(n=e.which)!=null?n:e.keyCode,this.search_field_scale(),t!==8&&this.pending_backstroke&&this.clear_backstroke();switch(t){case 8:this.backstroke_length=this.search_field.val().length;break;case 9:this.results_showing&&!this.is_multiple&&this.result_select(e),this.mouse_on_container=!1;break;case 13:e.preventDefault();break;case 38:e.preventDefault(),this.keyup_arrow();break;case 40:this.keydown_arrow()}},s.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)+";";return n=e("<div />",{style:s}),n.text(this.search_field.val()),e("body").append(n),u=n.width()+25,n.remove(),u>this.f_width-10&&(u=this.f_width-10),this.search_field.css({width:u+"px"}),t=this.container.height(),this.dropdown.css({top:t+"px"})}},s.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},s}(AbstractChosen),r.Chosen=t,n=function(e){var t;return t=e.outerWidth()-e.width()},r.get_side_border_padding=n}.call(this);
70 chosen/chosen.proto.js
@@ -11,7 +11,6 @@
11 11 var SelectParser;
12 12
13 13 SelectParser = (function() {
14   -
15 14 function SelectParser() {
16 15 this.options_index = 0;
17 16 this.parsed = [];
@@ -27,6 +26,7 @@
27 26
28 27 SelectParser.prototype.add_group = function(group) {
29 28 var group_position, option, _i, _len, _ref, _results;
  29 +
30 30 group_position = this.parsed.length;
31 31 this.parsed.push({
32 32 array_index: group_position,
@@ -79,6 +79,7 @@
79 79
80 80 SelectParser.select_to_array = function(select) {
81 81 var child, parser, _i, _len, _ref;
  82 +
82 83 parser = new SelectParser();
83 84 _ref = select.childNodes;
84 85 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
@@ -91,7 +92,6 @@
91 92 this.SelectParser = SelectParser;
92 93
93 94 }).call(this);
94   -
95 95 /*
96 96 Chosen source: generate output using 'cake build'
97 97 Copyright (c) 2011 by Harvest
@@ -104,7 +104,6 @@ Copyright (c) 2011 by Harvest
104 104 root = this;
105 105
106 106 AbstractChosen = (function() {
107   -
108 107 function AbstractChosen(form_field, options) {
109 108 this.form_field = form_field;
110 109 this.options = options != null ? options : {};
@@ -119,6 +118,7 @@ Copyright (c) 2011 by Harvest
119 118
120 119 AbstractChosen.prototype.set_default_values = function() {
121 120 var _this = this;
  121 +
122 122 this.click_test_action = function(evt) {
123 123 return _this.test_active_click(evt);
124 124 };
@@ -162,6 +162,7 @@ Copyright (c) 2011 by Harvest
162 162
163 163 AbstractChosen.prototype.input_focus = function(evt) {
164 164 var _this = this;
  165 +
165 166 if (this.is_multiple) {
166 167 if (!this.active_field) {
167 168 return setTimeout((function() {
@@ -177,6 +178,7 @@ Copyright (c) 2011 by Harvest
177 178
178 179 AbstractChosen.prototype.input_blur = function(evt) {
179 180 var _this = this;
  181 +
180 182 if (!this.mouse_on_container) {
181 183 this.active_field = false;
182 184 return setTimeout((function() {
@@ -187,6 +189,7 @@ Copyright (c) 2011 by Harvest
187 189
188 190 AbstractChosen.prototype.result_add_option = function(option) {
189 191 var classes, style;
  192 +
190 193 if (!option.disabled) {
191 194 option.dom_id = this.container_id + "_o_" + option.array_index;
192 195 classes = option.selected && this.is_multiple ? [] : ["active-result"];
@@ -233,6 +236,7 @@ Copyright (c) 2011 by Harvest
233 236
234 237 AbstractChosen.prototype.keyup_checker = function(evt) {
235 238 var stroke, _ref;
  239 +
236 240 stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
237 241 this.search_field_scale();
238 242 switch (stroke) {
@@ -269,6 +273,7 @@ Copyright (c) 2011 by Harvest
269 273
270 274 AbstractChosen.prototype.generate_field_id = function() {
271 275 var new_id;
  276 +
272 277 new_id = this.generate_random_id();
273 278 this.form_field.id = new_id;
274 279 return new_id;
@@ -276,6 +281,7 @@ Copyright (c) 2011 by Harvest
276 281
277 282 AbstractChosen.prototype.generate_random_char = function() {
278 283 var chars, newchar, rand;
  284 +
279 285 chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
280 286 rand = Math.floor(Math.random() * chars.length);
281 287 return newchar = chars.substring(rand, rand + 1);
@@ -288,7 +294,6 @@ Copyright (c) 2011 by Harvest
288 294 root.AbstractChosen = AbstractChosen;
289 295
290 296 }).call(this);
291   -
292 297 /*
293 298 Chosen source: generate output using 'cake build'
294 299 Copyright (c) 2011 by Harvest
@@ -296,18 +301,18 @@ Copyright (c) 2011 by Harvest
296 301
297 302
298 303 (function() {
299   - var Chosen, get_side_border_padding, root,
  304 + var Chosen, get_side_border_padding, root, _ref,
300 305 __hasProp = {}.hasOwnProperty,
301 306 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
302 307
303 308 root = this;
304 309
305 310 Chosen = (function(_super) {
306   -
307 311 __extends(Chosen, _super);
308 312
309 313 function Chosen() {
310   - return Chosen.__super__.constructor.apply(this, arguments);
  314 + _ref = Chosen.__super__.constructor.apply(this, arguments);
  315 + return _ref;
311 316 }
312 317
313 318 Chosen.prototype.setup = function() {
@@ -321,8 +326,8 @@ Copyright (c) 2011 by Harvest
321 326
322 327 Chosen.prototype.set_default_values = function() {
323 328 Chosen.__super__.set_default_values.call(this);
324   - this.single_temp = new Template('<a href="javascript:void(0)" class="chzn-single chzn-default" tabindex="-1"><span>#{default}</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>');
325   - this.multi_temp = new Template('<ul class="chzn-choices"><li class="search-field"><input type="text" value="#{default}" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop" style="left:-9000px;"><ul class="chzn-results"></ul></div>');
  329 + this.single_temp = new Template('<a href="javascript:void(0)" class="chzn-single chzn-default" tabindex="-1"><span>#{default}</span><div><b></b></div></a><div class="chzn-drop" style="left:' + (this.is_rtl ? '' : '-') + '9000px;"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>');
  330 + this.multi_temp = new Template('<ul class="chzn-choices"><li class="search-field"><input type="text" value="#{default}" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop" style="left:' + (this.is_rtl ? '' : '-') + '9000px;"><ul class="chzn-results"></ul></div>');
326 331 this.choice_temp = new Template('<li class="search-choice" id="#{id}"><span>#{choice}</span><a href="javascript:void(0)" class="search-choice-close" rel="#{position}"></a></li>');
327 332 this.choice_noclose_temp = new Template('<li class="search-choice search-choice-disabled" id="#{id}"><span>#{choice}</span></li>');
328 333 return this.no_results_temp = new Template('<li class="no-results">' + this.results_none_found + ' "<span>#{terms}</span>"</li>');
@@ -330,6 +335,7 @@ Copyright (c) 2011 by Harvest
330 335
331 336 Chosen.prototype.set_up_html = function() {
332 337 var base_template, container_classes, container_props, dd_top, dd_width, sf_width;
  338 +
333 339 this.container_id = this.form_field.identify().replace(/[^\w]/g, '_') + "_chzn";
334 340 container_classes = ["chzn-container"];
335 341 container_classes.push("chzn-container-" + (this.is_multiple ? "multi" : "single"));
@@ -386,6 +392,7 @@ Copyright (c) 2011 by Harvest
386 392
387 393 Chosen.prototype.register_observers = function() {
388 394 var _this = this;
  395 +
389 396 this.container.observe("mousedown", function(evt) {
390 397 return _this.container_mousedown(evt);
391 398 });
@@ -459,6 +466,7 @@ Copyright (c) 2011 by Harvest
459 466
460 467 Chosen.prototype.container_mousedown = function(evt) {
461 468 var target_closelink;
  469 +
462 470 if (!this.is_disabled) {
463 471 target_closelink = evt != null ? evt.target.hasClassName("search-choice-close") : false;
464 472 if (evt && evt.type === "mousedown" && !this.results_showing) {
@@ -520,7 +528,8 @@ Copyright (c) 2011 by Harvest
520 528 };
521 529
522 530 Chosen.prototype.results_build = function() {
523   - var content, data, _i, _len, _ref;
  531 + var content, data, _i, _len, _ref1;
  532 +
524 533 this.parsing = true;
525 534 this.results_data = root.SelectParser.select_to_array(this.form_field);
526 535 if (this.is_multiple && this.choices > 0) {
@@ -535,9 +544,9 @@ Copyright (c) 2011 by Harvest
535 544 }
536 545 }
537 546 content = '';
538   - _ref = this.results_data;
539   - for (_i = 0, _len = _ref.length; _i < _len; _i++) {
540   - data = _ref[_i];
  547 + _ref1 = this.results_data;
  548 + for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
  549 + data = _ref1[_i];
541 550 if (data.group) {
542 551 content += this.result_add_group(data);
543 552 } else if (!data.empty) {
@@ -570,6 +579,7 @@ Copyright (c) 2011 by Harvest
570 579
571 580 Chosen.prototype.result_do_highlight = function(el) {
572 581 var high_bottom, high_top, maxHeight, visible_bottom, visible_top;
  582 +
573 583 this.result_clear_highlight();
574 584 this.result_highlight = el;
575 585 this.result_highlight.addClassName("highlighted");
@@ -594,6 +604,7 @@ Copyright (c) 2011 by Harvest
594 604
595 605 Chosen.prototype.results_show = function() {
596 606 var dd_top;
  607 +
597 608 if (!this.is_multiple) {
598 609 this.selected_item.addClassName('chzn-single-with-drop');
599 610 if (this.result_single_selected) {
@@ -628,13 +639,14 @@ Copyright (c) 2011 by Harvest
628 639 chosen: this
629 640 });
630 641 this.dropdown.setStyle({
631   - "left": "-9000px"
  642 + "left": (this.is_rtl ? '' : '-') + "9000px"
632 643 });
633 644 return this.results_showing = false;
634 645 };
635 646
636 647 Chosen.prototype.set_tab_index = function(el) {
637 648 var ti;
  649 +
638 650 if (this.form_field.tabIndex) {
639 651 ti = this.form_field.tabIndex;
640 652 this.form_field.tabIndex = -1;
@@ -654,6 +666,7 @@ Copyright (c) 2011 by Harvest
654 666
655 667 Chosen.prototype.search_results_mouseup = function(evt) {
656 668 var target;
  669 +
657 670 target = evt.target.hasClassName("active-result") ? evt.target : evt.target.up(".active-result");
658 671 if (target) {
659 672 this.result_highlight = target;
@@ -664,6 +677,7 @@ Copyright (c) 2011 by Harvest
664 677
665 678 Chosen.prototype.search_results_mouseover = function(evt) {
666 679 var target;
  680 +
667 681 target = evt.target.hasClassName("active-result") ? evt.target : evt.target.up(".active-result");
668 682 if (target) {
669 683 return this.result_do_highlight(target);
@@ -686,6 +700,7 @@ Copyright (c) 2011 by Harvest
686 700 Chosen.prototype.choice_build = function(item) {
687 701 var choice_id, link,
688 702 _this = this;
  703 +
689 704 if (this.is_multiple && this.max_selected_options <= this.choices) {
690 705 this.form_field.fire("liszt:maxselected", {
691 706 chosen: this
@@ -747,6 +762,7 @@ Copyright (c) 2011 by Harvest
747 762
748 763 Chosen.prototype.results_reset_cleanup = function() {
749 764 var deselect_trigger;
  765 +
750 766 this.current_value = this.form_field.value;
751 767 deselect_trigger = this.selected_item.down("abbr");
752 768 if (deselect_trigger) {
@@ -756,6 +772,7 @@ Copyright (c) 2011 by Harvest
756 772
757 773 Chosen.prototype.result_select = function(evt) {
758 774 var high, item, position;
  775 +
759 776 if (this.result_highlight) {
760 777 high = this.result_highlight;
761 778 this.result_clear_highlight();
@@ -801,6 +818,7 @@ Copyright (c) 2011 by Harvest
801 818
802 819 Chosen.prototype.result_deselect = function(pos) {
803 820 var result, result_data;
  821 +
804 822 result_data = this.results_data[pos];
805 823 if (!this.form_field.options[result_data.options_index].disabled) {
806 824 result_data.selected = false;
@@ -828,16 +846,17 @@ Copyright (c) 2011 by Harvest
828 846 };
829 847
830 848 Chosen.prototype.winnow_results = function() {
831   - var found, option, part, parts, regex, regexAnchor, result_id, results, searchText, startpos, text, zregex, _i, _j, _len, _len1, _ref;
  849 + var found, option, part, parts, regex, regexAnchor, result_id, results, searchText, startpos, text, zregex, _i, _j, _len, _len1, _ref1;
  850 +
832 851 this.no_results_clear();
833 852 results = 0;
834 853 searchText = this.search_field.value === this.default_text ? "" : this.search_field.value.strip().escapeHTML();
835 854 regexAnchor = this.search_contains ? "" : "^";
836 855 regex = new RegExp(regexAnchor + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
837 856 zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
838   - _ref = this.results_data;
839   - for (_i = 0, _len = _ref.length; _i < _len; _i++) {
840   - option = _ref[_i];
  857 + _ref1 = this.results_data;
  858 + for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
  859 + option = _ref1[_i];
841 860 if (!option.disabled && !option.empty) {
842 861 if (option.group) {
843 862 $(option.dom_id).hide();
@@ -894,6 +913,7 @@ Copyright (c) 2011 by Harvest
894 913
895 914 Chosen.prototype.winnow_results_clear = function() {
896 915 var li, lis, _i, _len, _results;
  916 +
897 917 this.search_field.clear();
898 918 lis = this.search_results.select("li");
899 919 _results = [];
@@ -912,11 +932,12 @@ Copyright (c) 2011 by Harvest
912 932
913 933 Chosen.prototype.winnow_results_set_highlight = function() {
914 934 var do_high;
  935 +
915 936 if (!this.result_highlight) {
916 937 if (!this.is_multiple) {
917 938 do_high = this.search_results.down(".result-selected.active-result");
918 939 }
919   - if (!(do_high != null)) {
  940 + if (do_high == null) {
920 941 do_high = this.search_results.down(".active-result");
921 942 }
922 943 if (do_high != null) {
@@ -933,6 +954,7 @@ Copyright (c) 2011 by Harvest
933 954
934 955 Chosen.prototype.no_results_clear = function() {
935 956 var nr, _results;
  957 +
936 958 nr = null;
937 959 _results = [];
938 960 while (nr = this.search_results.down(".no-results")) {
@@ -943,6 +965,7 @@ Copyright (c) 2011 by Harvest
943 965
944 966 Chosen.prototype.keydown_arrow = function() {
945 967 var actives, nexts, sibs;
  968 +
946 969 actives = this.search_results.select("li.active-result");
947 970 if (actives.length) {
948 971 if (!this.result_highlight) {
@@ -962,6 +985,7 @@ Copyright (c) 2011 by Harvest
962 985
963 986 Chosen.prototype.keyup_arrow = function() {
964 987 var actives, prevs, sibs;
  988 +
965 989 if (!this.results_showing && !this.is_multiple) {
966 990 return this.results_show();
967 991 } else if (this.result_highlight) {
@@ -981,6 +1005,7 @@ Copyright (c) 2011 by Harvest
981 1005
982 1006 Chosen.prototype.keydown_backstroke = function() {
983 1007 var next_available_destroy;
  1008 +
984 1009 if (this.pending_backstroke) {
985 1010 this.choice_destroy(this.pending_backstroke.down("a"));
986 1011 return this.clear_backstroke();
@@ -1008,8 +1033,9 @@ Copyright (c) 2011 by Harvest
1008 1033 };
1009 1034
1010 1035 Chosen.prototype.keydown_checker = function(evt) {
1011   - var stroke, _ref;
1012   - stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
  1036 + var stroke, _ref1;
  1037 +
  1038 + stroke = (_ref1 = evt.which) != null ? _ref1 : evt.keyCode;
1013 1039 this.search_field_scale();
1014 1040 if (stroke !== 8 && this.pending_backstroke) {
1015 1041 this.clear_backstroke();
@@ -1039,6 +1065,7 @@ Copyright (c) 2011 by Harvest
1039 1065
1040 1066 Chosen.prototype.search_field_scale = function() {
1041 1067 var dd_top, div, h, style, style_block, styles, w, _i, _len;
  1068 +
1042 1069 if (this.is_multiple) {
1043 1070 h = 0;
1044 1071 w = 0;
@@ -1081,6 +1108,7 @@ Copyright (c) 2011 by Harvest
1081 1108
1082 1109 get_side_border_padding = function(elmt) {
1083 1110 var layout, side_border_padding;
  1111 +
1084 1112 layout = new Element.Layout(elmt);
1085 1113 return side_border_padding = layout.get("border-left") + layout.get("border-right") + layout.get("padding-left") + layout.get("padding-right");
1086 1114 };
2  chosen/chosen.proto.min.js
@@ -7,4 +7,4 @@
7 7
8 8 // MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md
9 9 // This file is generated by `cake build`, do not edit it by hand.
10   -(function(){var e;e=function(){function e(){this.options_index=0,this.parsed=[]}return e.prototype.add_node=function(e){return e.nodeName.toUpperCase()==="OPTGROUP"?this.add_group(e):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:!0,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")return e.text!==""?(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===!0?n:e.disabled,group_array_index:t,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},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()}return e.prototype.set_default_values=function(){var e=this;return 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=!1,this.mouse_on_container=!1,this.results_showing=!1,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:!1,this.disable_search_threshold=this.options.disable_search_threshold||0,this.disable_search=this.options.disable_search||!1,this.enable_split_word_search=this.options.enable_split_word_search!=null?this.options.enable_split_word_search:!0,this.search_contains=this.options.search_contains||!1,this.choices=0,this.single_backstroke_delete=this.options.single_backstroke_delete||!1,this.max_selected_options=this.options.max_selected_options||Infinity,this.inherit_select_classes=this.options.inherit_select_classes||!1},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||"Select Some Options":this.default_text=this.options.placeholder_text_single||this.options.placeholder_text||"Select an Option",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=!0},e.prototype.mouse_leave=function(){return this.mouse_on_container=!1},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)return this.active_field=!1,setTimeout(function(){return t.blur_test()},100)},e.prototype.result_add_option=function(e){var t,n;return e.disabled?"":(e.dom_id=this.container_id+"_o_"+e.array_index,t=e.selected&&this.is_multiple?[]:["active-result"],e.selected&&t.push("result-selected"),e.group_array_index!=null&&t.push("group-option"),e.classes!==""&&t.push(e.classes),n=e.style.cssText!==""?' style="'+e.style+'"':"",'<li id="'+e.dom_id+'" class="'+t.join(" ")+'"'+n+">"+e.html+"</li>")},e.prototype.results_update_field=function(){return this.is_multiple||this.results_reset_cleanup(),this.result_clear_highlight(),this.result_single_selected=null,this.results_build()},e.prototype.results_toggle=function(){return this.results_showing?this.results_hide():this.results_show()},e.prototype.results_search=function(e){return this.results_showing?this.winnow_results():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();if(!this.pending_backstroke)return this.result_clear_highlight(),this.results_search();break;case 13:e.preventDefault();if(this.results_showing)return this.result_select(e);break;case 27:return this.results_showing&&this.results_hide(),!0;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;return e=this.generate_random_id(),this.form_field.id=e,e},e.prototype.generate_random_char=function(){var e,t,n;return e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",n=Math.floor(Math.random()*e.length),t=e.substring(n,n+1)},e}(),t.AbstractChosen=e}.call(this),function(){var e,t,n,r={}.hasOwnProperty,i=function(e,t){function i(){this.constructor=e}for(var n in t)r.call(t,n)&&(e[n]=t[n]);return i.prototype=t.prototype,e.prototype=new i,e.__super__=t.prototype,e};n=this,e=function(e){function r(){return r.__super__.constructor.apply(this,arguments)}return i(r,e),r.prototype.setup=function(){return this.current_value=this.form_field.value,this.is_rtl=this.form_field.hasClassName("chzn-rtl")},r.prototype.finish_setup=function(){return this.form_field.addClassName("chzn-done")},r.prototype.set_default_values=function(){return r.__super__.set_default_values.call(this),this.single_temp=new Template('<a href="javascript:void(0)" class="chzn-single chzn-default" tabindex="-1"><span>#{default}</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.multi_temp=new Template('<ul class="chzn-choices"><li class="search-field"><input type="text" value="#{default}" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop" style="left:-9000px;"><ul class="chzn-results"></ul></div>'),this.choice_temp=new Template('<li class="search-choice" id="#{id}"><span>#{choice}</span><a href="javascript:void(0)" class="search-choice-close" rel="#{position}"></a></li>'),this.choice_noclose_temp=new Template('<li class="search-choice search-choice-disabled" id="#{id}"><span>#{choice}</span></li>'),this.no_results_temp=new Template('<li class="no-results">'+this.results_none_found+' "<span>#{terms}</span>"</li>')},r.prototype.set_up_html=function(){var e,n,r,i,s,o;return this.container_id=this.form_field.identify().replace(/[^\w]/g,"_")+"_chzn",n=["chzn-container"],n.push("chzn-container-"+(this.is_multiple?"multi":"single")),this.inherit_select_classes&&this.form_field.className&&n.push(this.form_field.className),this.is_rtl&&n.push("chzn-rtl"),this.f_width=this.form_field.getStyle("width")?parseInt(this.form_field.getStyle("width"),10):this.form_field.getWidth(),r={id:this.container_id,"class":n.join(" "),style:"width: "+this.f_width+"px",title:this.form_field.title},e=this.is_multiple?(new Element("div",r)).update(this.multi_temp.evaluate({"default":this.default_text})):(new Element("div",r)).update(this.single_temp.evaluate({"default":this.default_text})),this.form_field.hide().insert({after:e}),this.container=$(this.container_id),this.dropdown=this.container.down("div.chzn-drop"),i=this.container.getHeight(),s=this.f_width-t(this.dropdown),this.dropdown.setStyle({width:s+"px",top:i+"px"}),this.search_field=this.container.down("input"),this.search_results=this.container.down("ul.chzn-results"),this.search_field_scale(),this.search_no_results=this.container.down("li.no-results"),this.is_multiple?(this.search_choices=this.container.down("ul.chzn-choices"),this.search_container=this.container.down("li.search-field")):(this.search_container=this.container.down("div.chzn-search"),this.selected_item=this.container.down(".chzn-single"),o=s-t(this.search_container)-t(this.search_field),this.search_field.setStyle({width:o+"px"})),this.results_build(),this.set_tab_index(),this.form_field.fire("liszt:ready",{chosen:this})},r.prototype.register_observers=function(){var e=this;return this.container.observe("mousedown",function(t){return e.container_mousedown(t)}),this.container.observe("mouseup",function(t){return e.container_mouseup(t)}),this.container.observe("mouseenter",function(t){return e.mouse_enter(t)}),this.container.observe("mouseleave",function(t){return e.mouse_leave(t)}),this.search_results.observe("mouseup",function(t){return e.search_results_mouseup(t)}),this.search_results.observe("mouseover",function(t){return e.search_results_mouseover(t)}),this.search_results.observe("mouseout",function(t){return e.search_results_mouseout(t)}),this.form_field.observe("liszt:updated",function(t){return e.results_update_field(t)}),this.form_field.observe("liszt:activate",function(t){return e.activate_field(t)}),this.form_field.observe("liszt:open",function(t){return e.container_mousedown(t)}),this.search_field.observe("blur",function(t){return e.input_blur(t)}),this.search_field.observe("keyup",function(t){return e.keyup_checker(t)}),this.search_field.observe("keydown",function(t){return e.keydown_checker(t)}),this.search_field.observe("focus",function(t){return e.input_focus(t)}),this.is_multiple?this.search_choices.observe("click",function(t){return e.choices_click(t)}):this.container.observe("click",function(e){return e.preventDefault()})},r.prototype.search_field_disabled=function(){this.is_disabled=this.form_field.disabled;if(this.is_disabled)return this.container.addClassName("chzn-disabled"),this.search_field.disabled=!0,this.is_multiple||this.selected_item.stopObserving("focus",this.activate_action),this.close_field();this.container.removeClassName("chzn-disabled"),this.search_field.disabled=!1;if(!this.is_multiple)return this.selected_item.observe("focus",this.activate_action)},r.prototype.container_mousedown=function(e){var t;if(!this.is_disabled)return t=e!=null?e.target.hasClassName("search-choice-close"):!1,e&&e.type==="mousedown"&&!this.results_showing&&e.stop(),!this.pending_destroy_click&&!t?(this.active_field?!this.is_multiple&&e&&(e.target===this.selected_item||e.target.up("a.chzn-single"))&&this.results_toggle():(this.is_multiple&&this.search_field.clear(),document.observe("click",this.click_test_action),this.results_show()),this.activate_field()):this.pending_destroy_click=!1},r.prototype.container_mouseup=function(e){if(e.target.nodeName==="ABBR"&&!this.is_disabled)return this.results_reset(e)},r.prototype.blur_test=function(e){if(!this.active_field&&this.container.hasClassName("chzn-container-active"))return this.close_field()},r.prototype.close_field=function(){return document.stopObserving("click",this.click_test_action),this.active_field=!1,this.results_hide(),this.container.removeClassName("chzn-container-active"),this.winnow_results_clear(),this.clear_backstroke(),this.show_search_field_default(),this.search_field_scale()},r.prototype.activate_field=function(){return this.container.addClassName("chzn-container-active"),this.active_field=!0,this.search_field.value=this.search_field.value,this.search_field.focus()},r.prototype.test_active_click=function(e){return e.target.up("#"+this.container_id)?this.active_field=!0:this.close_field()},r.prototype.results_build=function(){var e,t,r,i,s;this.parsing=!0,this.results_data=n.SelectParser.select_to_array(this.form_field),this.is_multiple&&this.choices>0?(this.search_choices.select("li.search-choice").invoke("remove"),this.choices=0):this.is_multiple||(this.selected_item.addClassName("chzn-default").down("span").update(this.default_text),this.disable_search||this.form_field.options.length<=this.disable_search_threshold?this.container.addClassName("chzn-container-single-nosearch"):this.container.removeClassName("chzn-container-single-nosearch")),e="",s=this.results_data;for(r=0,i=s.length;r<i;r++)t=s[r],t.group?e+=this.result_add_group(t):t.empty||(e+=this.result_add_option(t),t.selected&&this.is_multiple?this.choice_build(t):t.selected&&!this.is_multiple&&(this.selected_item.removeClassName("chzn-default").down("span").update(t.html),this.allow_single_deselect&&this.single_deselect_control_build()));return this.search_field_disabled(),this.show_search_field_default(),this.search_field_scale(),this.search_results.update(e),this.parsing=!1},r.prototype.result_add_group=function(e){return e.disabled?"":(e.dom_id=this.container_id+"_g_"+e.array_index,'<li id="'+e.dom_id+'" class="group-result">'+e.label.escapeHTML()+"</li>")},r.prototype.result_do_highlight=function(e){var t,n,r,i,s;this.result_clear_highlight(),this.result_highlight=e,this.result_highlight.addClassName("highlighted"),r=parseInt(this.search_results.getStyle("maxHeight"),10),s=this.search_results.scrollTop,i=r+s,n=this.result_highlight.positionedOffset().top,t=n+this.result_highlight.getHeight();if(t>=i)return this.search_results.scrollTop=t-r>0?t-r:0;if(n<s)return this.search_results.scrollTop=n},r.prototype.result_clear_highlight=function(){return this.result_highlight&&this.result_highlight.removeClassName("highlighted"),this.result_highlight=null},r.prototype.results_show=function(){var e;if(!this.is_multiple)this.selected_item.addClassName("chzn-single-with-drop"),this.result_single_selected&&this.result_do_highlight(this.result_single_selected);else if(this.max_selected_options<=this.choices)return this.form_field.fire("liszt:maxselected",{chosen:this}),!1;return e=this.is_multiple?this.container.getHeight():this.container.getHeight()-1,this.form_field.fire("liszt:showing_dropdown",{chosen:this}),this.dropdown.setStyle({top:e+"px",left:0}),this.results_showing=!0,this.search_field.focus(),this.search_field.value=this.search_field.value,this.winnow_results()},r.prototype.results_hide=function(){return this.is_multiple||this.selected_item.removeClassName("chzn-single-with-drop"),this.result_clear_highlight(),this.form_field.fire("liszt:hiding_dropdown",{chosen:this}),this.dropdown.setStyle({left:"-9000px"}),this.results_showing=!1},r.prototype.set_tab_index=function(e){var t;if(this.form_field.tabIndex)return t=this.form_field.tabIndex,this.form_field.tabIndex=-1,this.search_field.tabIndex=t},r.prototype.show_search_field_default=function(){return this.is_multiple&&this.choices<1&&!this.active_field?(this.search_field.value=this.default_text,this.search_field.addClassName("default")):(this.search_field.value="",this.search_field.removeClassName("default"))},r.prototype.search_results_mouseup=function(e){var t;t=e.target.hasClassName("active-result")?e.target:e.target.up(".active-result");if(t)return this.result_highlight=t,this.result_select(e),this.search_field.focus()},r.prototype.search_results_mouseover=function(e){var t;t=e.target.hasClassName("active-result")?e.target:e.target.up(".active-result");if(t)return this.result_do_highlight(t)},r.prototype.search_results_mouseout=function(e){if(e.target.hasClassName("active-result")||e.target.up(".active-result"))return this.result_clear_highlight()},r.prototype.choices_click=function(e){e.preventDefault();if(this.active_field&&!e.target.hasClassName("search-choice")&&!e.target.up(".search-choice")&&!this.results_showing)return this.results_show()},r.prototype.choice_build=function(e){var t,n,r=this;if(this.is_multiple&&this.max_selected_options<=this.choices)return this.form_field.fire("liszt:maxselected",{chosen:this}),!1;t=this.container_id+"_c_"+e.array_index,this.choices+=1,this.search_container.insert({before:(e.disabled?this.choice_noclose_temp:this.choice_temp).evaluate({id:t,choice:e.html,position:e.array_index})});if(!e.disabled)return n=$(t).down("a"),n.observe("click",function(e){return r.choice_destroy_link_click(e)})},r.prototype.choice_destroy_link_click=function(e){e.preventDefault();if(!this.is_disabled)return this.pending_destroy_click=!0,this.choice_destroy(e.target)},r.prototype.choice_destroy=function(e){if(this.result_deselect(e.readAttribute("rel")))return this.choices-=1,this.show_search_field_default(),this.is_multiple&&this.choices>0&&this.search_field.value.length<1&&this.results_hide(),e.up("li").remove(),this.search_field_scale()},r.prototype.results_reset=function(){this.form_field.options[0].selected=!0,this.selected_item.down("span").update(this.default_text),this.is_multiple||this.selected_item.addClassName("chzn-default"),this.show_search_field_default(),this.results_reset_cleanup(),typeof Event.simulate=="function"&&this.form_field.simulate("change");if(this.active_field)return this.results_hide()},r.prototype.results_reset_cleanup=function(){var e;this.current_value=this.form_field.value,e=this.selected_item.down("abbr");if(e)return e.remove()},r.prototype.result_select=function(e){var t,n,r;if(this.result_highlight)return t=this.result_highlight,this.result_clear_highlight(),this.is_multiple?this.result_deactivate(t):(this.search_results.descendants(".result-selected").invoke("removeClassName","result-selected"),this.selected_item.removeClassName("chzn-default"),this.result_single_selected=t),t.addClassName("result-selected"),r=t.id.substr(t.id.lastIndexOf("_")+1),n=this.results_data[r],n.selected=!0,this.form_field.options[n.options_index].selected=!0,this.is_multiple?this.choice_build(n):(this.selected_item.down("span").update(n.html),this.allow_single_deselect&&this.single_deselect_control_build()),(!e.metaKey&&!e.ctrlKey||!this.is_multiple)&&this.results_hide(),this.search_field.value="",typeof Event.simulate=="function"&&(this.is_multiple||this.form_field.value!==this.current_value)&&this.form_field.simulate("change"),this.current_value=this.form_field.value,this.search_field_scale()},r.prototype.result_activate=function(e){return e.addClassName("active-result")},r.prototype.result_deactivate=function(e){return e.removeClassName("active-result")},r.prototype.result_deselect=function(e){var t,n;return n=this.results_data[e],this.form_field.options[n.options_index].disabled?!1:(n.selected=!1,this.form_field.options[n.options_index].selected=!1,t=$(this.container_id+"_o_"+e),t.removeClassName("result-selected").addClassName("active-result").show(),this.result_clear_highlight(),this.winnow_results(),typeof Event.simulate=="function"&&this.form_field.simulate("change"),this.search_field_scale(),!0)},r.prototype.single_deselect_control_build=function(){if(this.allow_single_deselect&&!this.selected_item.down("abbr"))return this.selected_item.down("span").insert({after:'<abbr class="search-choice-close"></abbr>'})},r.prototype.winnow_results=function(){var e,t,n,r,i,s,o,u,a,f,l,c,h,p,d,v,m;this.no_results_clear(),u=0,a=this.search_field.value===this.default_text?"":this.search_field.value.strip().escapeHTML(),s=this.search_contains?"":"^",i=new RegExp(s+a.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),c=new RegExp(a.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),m=this.results_data;for(h=0,d=m.length;h<d;h++){t=m[h];if(!t.disabled&&!t.empty)if(t.group)$(t.dom_id).hide();else if(!this.is_multiple||!t.selected){e=!1,o=t.dom_id;if(i.test(t.html))e=!0,u+=1;else if(this.enable_split_word_search&&(t.html.indexOf(" ")>=0||t.html.indexOf("[")===0)){r=t.html.replace(/\[|\]/g,"").split(" ");if(r.length)for(p=0,v=r.length;p<v;p++)n=r[p],i.test(n)&&(e=!0,u+=1)}e?(a.length?(f=t.html.search(c),l=t.html.substr(0,f+a.length)+"</em>"+t.html.substr(f+a.length),l=l.substr(0,f)+"<em>"+l.substr(f)):l=t.html,$(o).innerHTML!==l&&$(o).update(l),this.result_activate($(o)),t.group_array_index!=null&&$(this.results_data[t.group_array_index].dom_id).setStyle({display:"list-item"})):($(o)===this.result_highlight&&this.result_clear_highlight(),this.result_deactivate($(o)))}}return u<1&&a.length?this.no_results(a):this.winnow_results_set_highlight()},r.prototype.winnow_results_clear=function(){var e,t,n,r,i;this.search_field.clear(),t=this.search_results.select("li"),i=[];for(n=0,r=t.length;n<r;n++)e=t[n],e.hasClassName("group-result")?i.push(e.show()):!this.is_multiple||!e.hasClassName("result-selected")?i.push(this.result_activate(e)):i.push(void 0);return i},r.prototype.winnow_results_set_highlight=function(){var e;if(!this.result_highlight){this.is_multiple||(e=this.search_results.down(".result-selected.active-result")),e==null&&(e=this.search_results.down(".active-result"));if(e!=null)return this.result_do_highlight(e)}},r.prototype.no_results=function(e){return this.search_results.insert(this.no_results_temp.evaluate({terms:e}))},r.prototype.no_results_clear=function(){var e,t;e=null,t=[];while(e=this.search_results.down(".no-results"))t.push(e.remove());return t},r.prototype.keydown_arrow=function(){var e,t,n;e=this.search_results.select("li.active-result");if(e.length){this.result_highlight?this.results_showing&&(n=this.result_highlight.nextSiblings(),t=n.intersect(e),t.length&&this.result_do_highlight(t.first())):this.result_do_highlight(e.first());if(!this.results_showing)return this.results_show()}},r.prototype.keyup_arrow=function(){var e,t,n;if(!this.results_showing&&!this.is_multiple)return this.results_show();if(this.result_highlight)return n=this.result_highlight.previousSiblings(),e=this.search_results.select("li.active-result"),t=n.intersect(e),t.length?this.result_do_highlight(t.first()):(this.choices>0&&this.results_hide(),this.result_clear_highlight())},r.prototype.keydown_backstroke=function(){var e;if(this.pending_backstroke)return this.choice_destroy(this.pending_backstroke.down("a")),this.clear_backstroke();e=this.search_container.siblings().last();if(e&&e.hasClassName("search-choice")&&!e.hasClassName("search-choice-disabled"))return this.pending_backstroke=e,this.pending_backstroke&&this.pending_backstroke.addClassName("search-choice-focus"),this.single_backstroke_delete?this.keydown_backstroke():this.pending_backstroke.addClassName("search-choice-focus")},r.prototype.clear_backstroke=function(){return this.pending_backstroke&&this.pending_backstroke.removeClassName("search-choice-focus"),this.pending_backstroke=null},r.prototype.keydown_checker=function(e){var t,n;t=(n=e.which)!=null?n:e.keyCode,this.search_field_scale(),t!==8&&this.pending_backstroke&&this.clear_backstroke();switch(t){case 8:this.backstroke_length=this.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:e.preventDefault();break;case 38:e.preventDefault(),this.keyup_arrow();break;case 40:this.keydown_arrow()}},r.prototype.search_field_scale=function(){var e,t,n,r,i,s,o,u,a;if(this.is_multiple){n=0,o=0,i="position:absolute; left: -1000px; top: -1000px; display:none;",s=["font-size","font-style","font-weight","font-family","line-height","text-transform","letter-spacing"];for(u=0,a=s.length;u<a;u++)r=s[u],i+=r+":"+this.search_field.getStyle(r)+";";return t=(new Element("div",{style:i})).update(this.search_field.value.escapeHTML()),document.body.appendChild(t),o=Element.measure(t,"width")+25,t.remove(),o>this.f_width-10&&(o=this.f_width-10),this.search_field.setStyle({width:o+"px"}),e=this.container.getHeight(),this.dropdown.setStyle({top:e+"px"})}},r}(AbstractChosen),n.Chosen=e,Prototype.Browser.IE&&/MSIE (\d+\.\d+);/.test(navigator.userAgent)&&(Prototype.BrowserFeatures.Version=new Number(RegExp.$1)),t=function(e){var t,n;return t=new Element.Layout(e),n=t.get("border-left")+t.get("border-right")+t.get("padding-left")+t.get("padding-right")},n.get_side_border_padding=t}.call(this);
  10 +(function(){var e;e=function(){function e(){this.options_index=0,this.parsed=[]}return e.prototype.add_node=function(e){return e.nodeName.toUpperCase()==="OPTGROUP"?this.add_group(e):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:!0,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")return e.text!==""?(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===!0?n:e.disabled,group_array_index:t,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},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()}return e.prototype.set_default_values=function(){var e=this;return 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=!1,this.mouse_on_container=!1,this.results_showing=!1,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:!1,this.disable_search_threshold=this.options.disable_search_threshold||0,this.disable_search=this.options.disable_search||!1,this.enable_split_word_search=this.options.enable_split_word_search!=null?this.options.enable_split_word_search:!0,this.search_contains=this.options.search_contains||!1,this.choices=0,this.single_backstroke_delete=this.options.single_backstroke_delete||!1,this.max_selected_options=this.options.max_selected_options||Infinity,this.inherit_select_classes=this.options.inherit_select_classes||!1},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||"Select Some Options":this.default_text=this.options.placeholder_text_single||this.options.placeholder_text||"Select an Option",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=!0},e.prototype.mouse_leave=function(){return this.mouse_on_container=!1},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)return this.active_field=!1,setTimeout(function(){return t.blur_test()},100)},e.prototype.result_add_option=function(e){var t,n;return e.disabled?"":(e.dom_id=this.container_id+"_o_"+e.array_index,t=e.selected&&this.is_multiple?[]:["active-result"],e.selected&&t.push("result-selected"),e.group_array_index!=null&&t.push("group-option"),e.classes!==""&&t.push(e.classes),n=e.style.cssText!==""?' style="'+e.style+'"':"",'<li id="'+e.dom_id+'" class="'+t.join(" ")+'"'+n+">"+e.html+"</li>")},e.prototype.results_update_field=function(){return this.is_multiple||this.results_reset_cleanup(),this.result_clear_highlight(),this.result_single_selected=null,this.results_build()},e.prototype.results_toggle=function(){return this.results_showing?this.results_hide():this.results_show()},e.prototype.results_search=function(e){return this.results_showing?this.winnow_results():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();if(!this.pending_backstroke)return this.result_clear_highlight(),this.results_search();break;case 13:e.preventDefault();if(this.results_showing)return this.result_select(e);break;case 27:return this.results_showing&&this.results_hide(),!0;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;return e=this.generate_random_id(),this.form_field.id=e,e},e.prototype.generate_random_char=function(){var e,t,n;return e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",n=Math.floor(Math.random()*e.length),t=e.substring(n,n+1)},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)i.call(t,n)&&(e[n]=t[n]);return r.prototype=t.prototype,e.prototype=new r,e.__super__=t.prototype,e};n=this,e=function(e){function i(){return r=i.__super__.constructor.apply(this,arguments),r}return s(i,e),i.prototype.setup=function(){return this.current_value=this.form_field.value,this.is_rtl=this.form_field.hasClassName("chzn-rtl")},i.prototype.finish_setup=function(){return this.form_field.addClassName("chzn-done")},i.prototype.set_default_values=function(){return i.__super__.set_default_values.call(this),this.single_temp=new Template('<a href="javascript:void(0)" class="chzn-single chzn-default" tabindex="-1"><span>#{default}</span><div><b></b></div></a><div class="chzn-drop" style="left:'+(this.is_rtl?"":"-")+'9000px;"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>'),this.multi_temp=new Template('<ul class="chzn-choices"><li class="search-field"><input type="text" value="#{default}" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop" style="left:'+(this.is_rtl?"":"-")+'9000px;"><ul class="chzn-results"></ul></div>'),this.choice_temp=new Template('<li class="search-choice" id="#{id}"><span>#{choice}</span><a href="javascript:void(0)" class="search-choice-close" rel="#{position}"></a></li>'),this.choice_noclose_temp=new Template('<li class="search-choice search-choice-disabled" id="#{id}"><span>#{choice}</span></li>'),this.no_results_temp=new Template('<li class="no-results">'+this.results_none_found+' "<span>#{terms}</span>"</li>')},i.prototype.set_up_html=function(){var e,n,r,i,s,o;return this.container_id=this.form_field.identify().replace(/[^\w]/g,"_")+"_chzn",n=["chzn-container"],n.push("chzn-container-"+(this.is_multiple?"multi":"single")),this.inherit_select_classes&&this.form_field.className&&n.push(this.form_field.className),this.is_rtl&&n.push("chzn-rtl"),this.f_width=this.form_field.getStyle("width")?parseInt(this.form_field.getStyle("width"),10):this.form_field.getWidth(),r={id:this.container_id,"class":n.join(" "),style:"width: "+this.f_width+"px",title:this.form_field.title},e=this.is_multiple?(new Element("div",r)).update(this.multi_temp.evaluate({"default":this.default_text})):(new Element("div",r)).update(this.single_temp.evaluate({"default":this.default_text})),this.form_field.hide().insert({after:e}),this.container=$(this.container_id),this.dropdown=this.container.down("div.chzn-drop"),i=this.container.getHeight(),s=this.f_width-t(this.dropdown),this.dropdown.setStyle({width:s+"px",top:i+"px"}),this.search_field=this.container.down("input"),this.search_results=this.container.down("ul.chzn-results"),this.search_field_scale(),this.search_no_results=this.container.down("li.no-results"),this.is_multiple?(this.search_choices=this.container.down("ul.chzn-choices"),this.search_container=this.container.down("li.search-field")):(this.search_container=this.container.down("div.chzn-search"),this.selected_item=this.container.down(".chzn-single"),o=s-t(this.search_container)-t(this.search_field),this.search_field.setStyle({width:o+"px"})),this.results_build(),this.set_tab_index(),this.form_field.fire("liszt:ready",{chosen:this})},i.prototype.register_observers=function(){var e=this;return this.container.observe("mousedown",function(t){return e.container_mousedown(t)}),this.container.observe("mouseup",function(t){return e.container_mouseup(t)}),this.container.observe("mouseenter",function(t){return e.mouse_enter(t)}),this.container.observe("mouseleave",function(t){return e.mouse_leave(t)}),this.search_results.observe("mouseup",function(t){return e.search_results_mouseup(t)}),this.search_results.observe("mouseover",function(t){return e.search_results_mouseover(t)}),this.search_results.observe("mouseout",function(t){return e.search_results_mouseout(t)}),this.form_field.observe("liszt:updated",function(t){return e.results_update_field(t)}),this.form_field.observe("liszt:activate",function(t){return e.activate_field(t)}),this.form_field.observe("liszt:open",function(t){return e.container_mousedown(t)}),this.search_field.observe("blur",function(t){return e.input_blur(t)}),this.search_field.observe("keyup",function(t){return e.keyup_checker(t)}),this.search_field.observe("keydown",function(t){return e.keydown_checker(t)}),this.search_field.observe("focus",function(t){return e.input_focus(t)}),this.is_multiple?this.search_choices.observe("click",function(t){return e.choices_click(t)}):this.container.observe("click",function(e){return e.preventDefault()})},i.prototype.search_field_disabled=function(){this.is_disabled=this.form_field.disabled;if(this.is_disabled)return this.container.addClassName("chzn-disabled"),this.search_field.disabled=!0,this.is_multiple||this.selected_item.stopObserving("focus",this.activate_action),this.close_field();this.container.removeClassName("chzn-disabled"),this.search_field.disabled=!1;if(!this.is_multiple)return this.selected_item.observe("focus",this.activate_action)},i.prototype.container_mousedown=function(e){var t;if(!this.is_disabled)return t=e!=null?e.target.hasClassName("search-choice-close"):!1,e&&e.type==="mousedown"&&!this.results_showing&&e.stop(),!this.pending_destroy_click&&!t?(this.active_field?!this.is_multiple&&e&&(e.target===this.selected_item||e.target.up("a.chzn-single"))&&this.results_toggle():(this.is_multiple&&this.search_field.clear(),document.observe("click",this.click_test_action),this.results_show()),this.activate_field()):this.pending_destroy_click=!1},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.hasClassName("chzn-container-active"))return this.close_field()},i.prototype.close_field=function(){return document.stopObserving("click",this.click_test_action),this.active_field=!1,this.results_hide(),this.container.removeClassName("chzn-container-active"),this.winnow_results_clear(),this.clear_backstroke(),this.show_search_field_default(),this.search_field_scale()},i.prototype.activate_field=function(){return this.container.addClassName("chzn-container-active"),this.active_field=!0,this.search_field.value=this.search_field.value,this.search_field.focus()},i.prototype.test_active_click=function(e){return e.target.up("#"+this.container_id)?this.active_field=!0:this.close_field()},i.prototype.results_build=function(){var e,t,r,i,s;this.parsing=!0,this.results_data=n.SelectParser.select_to_array(this.form_field),this.is_multiple&&this.choices>0?(this.search_choices.select("li.search-choice").invoke("remove"),this.choices=0):this.is_multiple||(this.selected_item.addClassName("chzn-default").down("span").update(this.default_text),this.disable_search||this.form_field.options.length<=this.disable_search_threshold?this.container.addClassName("chzn-container-single-nosearch"):this.container.removeClassName("chzn-container-single-nosearch")),e="",s=this.results_data;for(r=0,i=s.length;r<i;r++)t=s[r],t.group?e+=this.result_add_group(t):t.empty||(e+=this.result_add_option(t),t.selected&&this.is_multiple?this.choice_build(t):t.selected&&!this.is_multiple&&(this.selected_item.removeClassName("chzn-default").down("span").update(t.html),this.allow_single_deselect&&this.single_deselect_control_build()));return this.search_field_disabled(),this.show_search_field_default(),this.search_field_scale(),this.search_results.update(e),this.parsing=!1},i.prototype.result_add_group=function(e){return e.disabled?"":(e.dom_id=this.container_id+"_g_"+e.array_index,'<li id="'+e.dom_id+'" class="group-result">'+e.label.escapeHTML()+"</li>")},i.prototype.result_do_highlight=function(e){var t,n,r,i,s;this.result_clear_highlight(),this.result_highlight=e,this.result_highlight.addClassName("highlighted"),r=parseInt(this.search_results.getStyle("maxHeight"),10),s=this.search_results.scrollTop,i=r+s,n=this.result_highlight.positionedOffset().top,t=n+this.result_highlight.getHeight();if(t>=i)return this.search_results.scrollTop=t-r>0?t-r:0;if(n<s)return this.search_results.scrollTop=n},i.prototype.result_clear_highlight=function(){return this.result_highlight&&this.result_highlight.removeClassName("highlighted"),this.result_highlight=null},i.prototype.results_show=function(){var e;if(!this.is_multiple)this.selected_item.addClassName("chzn-single-with-drop"),this.result_single_selected&&this.result_do_highlight(this.result_single_selected);else if(this.max_selected_options<=this.choices)return this.form_field.fire("liszt:maxselected",{chosen:this}),!1;return e=this.is_multiple?this.container.getHeight():this.container.getHeight()-1,this.form_field.fire("liszt:showing_dropdown",{chosen:this}),this.dropdown.setStyle({top:e+"px",left:0}),this.results_showing=!0,this.search_field.focus(),this.search_field.value=this.search_field.value,this.winnow_results()},i.prototype.results_hide=function(){return this.is_multiple||this.selected_item.removeClassName("chzn-single-with-drop"),this.result_clear_highlight(),this.form_field.fire("liszt:hiding_dropdown",{chosen:this}),this.dropdown.setStyle({left:(this.is_rtl?"":"-")+"9000px"}),this.results_showing=!1},i.prototype.set_tab_index=function(e){var t;if(this.form_field.tabIndex)return t=this.form_field.tabIndex,this.form_field.tabIndex=-1,this.search_field.tabIndex=t},i.prototype.show_search_field_default=function(){return this.is_multiple&&this.choices<1&&!this.active_field?(this.search_field.value=this.default_text,this.search_field.addClassName("default")):(this.search_field.value="",this.search_field.removeClassName("default"))},i.prototype.search_results_mouseup=function(e){var t;t=e.target.hasClassName("active-result")?e.target:e.target.up(".active-result");if(t)return this.result_highlight=t,this.result_select(e),this.search_field.focus()},i.prototype.search_results_mouseover=function(e){var t;t=e.target.hasClassName("active-result")?e.target:e.target.up(".active-result");if(t)return this.result_do_highlight(t)},i.prototype.search_results_mouseout=function(e){if(e.target.hasClassName("active-result")||e.target.up(".active-result"))return this.result_clear_highlight()},i.prototype.choices_click=function(e){e.preventDefault();if(this.active_field&&!e.target.hasClassName("search-choice")&&!e.target.up(".search-choice")&&!this.results_showing)return this.results_show()},i.prototype.choice_build=function(e){var t,n,r=this;if(this.is_multiple&&this.max_selected_options<=this.choices)return this.form_field.fire("liszt:maxselected",{chosen:this}),!1;t=this.container_id+"_c_"+e.array_index,this.choices+=1,this.search_container.insert({before:(e.disabled?this.choice_noclose_temp:this.choice_temp).evaluate({id:t,choice:e.html,position:e.array_index})});if(!e.disabled)return n=$(t).down("a"),n.observe("click",function(e){return r.choice_destroy_link_click(e)})},i.prototype.choice_destroy_link_click=function(e){e.preventDefault();if(!this.is_disabled)return this.pending_destroy_click=!0,this.choice_destroy(e.target)},i.prototype.choice_destroy=function(e){if(this.result_deselect(e.readAttribute("rel")))return this.choices-=1,this.show_search_field_default(),this.is_multiple&&this.choices>0&&this.search_field.value.length<1&&this.results_hide(),e.up("li").remove(),this.search_field_scale()},i.prototype.results_reset=function(){this.form_field.options[0].selected=!0,this.selected_item.down("span").update(this.default_text),this.is_multiple||this.selected_item.addClassName("chzn-default"),this.show_search_field_default(),this.results_reset_cleanup(),typeof Event.simulate=="function"&&this.form_field.simulate("change");if(this.active_field)return this.results_hide()},i.prototype.results_reset_cleanup=function(){var e;this.current_value=this.form_field.value,e=this.selected_item.down("abbr");if(e)return e.remove()},i.prototype.result_select=function(e){var t,n,r;if(this.result_highlight)return t=this.result_highlight,this.result_clear_highlight(),this.is_multiple?this.result_deactivate(t):(this.search_results.descendants(".result-selected").invoke("removeClassName","result-selected"),this.selected_item.removeClassName("chzn-default"),this.result_single_selected=t),t.addClassName("result-selected"),r=t.id.substr(t.id.lastIndexOf("_")+1),n=this.results_data[r],n.selected=!0,this.form_field.options[n.options_index].selected=!0,this.is_multiple?this.choice_build(n):(this.selected_item.down("span").update(n.html),this.allow_single_deselect&&this.single_deselect_control_build()),(!e.metaKey&&!e.ctrlKey||!this.is_multiple)&&this.results_hide(),this.search_field.value="",typeof Event.simulate=="function"&&(this.is_multiple||this.form_field.value!==this.current_value)&&this.form_field.simulate("change"),this.current_value=this.form_field.value,this.search_field_scale()},i.prototype.result_activate=function(e){return e.addClassName("active-result")},i.prototype.result_deactivate=function(e){return e.removeClassName("active-result")},i.prototype.result_deselect=function(e){var t,n;return n=this.results_data[e],this.form_field.options[n.options_index].disabled?!1:(n.selected=!1,this.form_field.options[n.options_index].selected=!1,t=$(this.container_id+"_o_"+e),t.removeClassName("result-selected").addClassName("active-result").show(),this.result_clear_highlight(),this.winnow_results(),typeof Event.simulate=="function"&&this.form_field.simulate("change"),this.search_field_scale(),!0)},i.prototype.single_deselect_control_build=function(){if(this.allow_single_deselect&&!this.selected_item.down("abbr"))return this.selected_item.down("span").insert({after:'<abbr class="search-choice-close"></abbr>'})},i.prototype.winnow_results=function(){var e,t,n,r,i,s,o,u,a,f,l,c,h,p,d,v,m;this.no_results_clear(),u=0,a=this.search_field.value===this.default_text?"":this.search_field.value.strip().escapeHTML(),s=this.search_contains?"":"^",i=new RegExp(s+a.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),c=new RegExp(a.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),m=this.results_data;for(h=0,d=m.length;h<d;h++){t=m[h];if(!t.disabled&&!t.empty)if(t.group)$(t.dom_id).hide();else if(!this.is_multiple||!t.selected){e=!1,o=t.dom_id;if(i.test(t.html))e=!0,u+=1;else if(this.enable_split_word_search&&(t.html.indexOf(" ")>=0||t.html.indexOf("[")===0)){r=t.html.replace(/\[|\]/g,"").split(" ");if(r.length)for(p=0,v=r.length;p<v;p++)n=r[p],i.test(n)&&(e=!0,u+=1)}e?(a.length?(f=t.html.search(c),l=t.html.substr(0,f+a.length)+"</em>"+t.html.substr(f+a.length),l=l.substr(0,f)+"<em>"+l.substr(f)):l=t.html,$(o).innerHTML!==l&&$(o).update(l),this.result_activate($(o)),t.group_array_index!=null&&$(this.results_data[t.group_array_index].dom_id).setStyle({display:"list-item"})):($(o)===this.result_highlight&&this.result_clear_highlight(),this.result_deactivate($(o)))}}return u<1&&a.length?this.no_results(a):this.winnow_results_set_highlight()},i.prototype.winnow_results_clear=function(){var e,t,n,r,i;this.search_field.clear(),t=this.search_results.select("li"),i=[];for(n=0,r=t.length;n<r;n++)e=t[n],e.hasClassName("group-result")?i.push(e.show()):!this.is_multiple||!e.hasClassName("result-selected")?i.push(this.result_activate(e)):i.push(void 0);return i},i.prototype.winnow_results_set_highlight=function(){var e;if(!this.result_highlight){this.is_multiple||(e=this.search_results.down(".result-selected.active-result")),e==null&&(e=this.search_results.down(".active-result"));if(e!=null)return this.result_do_highlight(e)}},i.prototype.no_results=function(e){return this.search_results.insert(this.no_results_temp.evaluate({terms:e}))},i.prototype.no_results_clear=function(){var e,t;e=null,t=[];while(e=this.search_results.down(".no-results"))t.push(e.remove());return t},i.prototype.keydown_arrow=function(){var e,t,n;e=this.search_results.select("li.active-result");if(e.length){this.result_highlight?this.results_showing&&(n=this.result_highlight.nextSiblings(),t=n.intersect(e),t.length&&this.result_do_highlight(t.first())):this.result_do_highlight(e.first());if(!this.results_showing)return this.results_show()}},i.prototype.keyup_arrow=function(){var e,t,n;if(!this.results_showing&&!this.is_multiple)return this.results_show();if(this.result_highlight)return n=this.result_highlight.previousSiblings(),e=this.search_results.select("li.active-result"),t=n.intersect(e),t.length?this.result_do_highlight(t.first()):(this.choices>0&&this.results_hide(),this.result_clear_highlight())},i.prototype.keydown_backstroke=function(){var e;if(this.pending_backstroke)return this.choice_destroy(this.pending_backstroke.down("a")),this.clear_backstroke();e=this.search_container.siblings().last();if(e&&e.hasClassName("search-choice")&&!e.hasClassName("search-choice-disabled"))return this.pending_backstroke=e,this.pending_backstroke&&this.pending_backstroke.addClassName("search-choice-focus"),this.single_backstroke_delete?this.keydown_backstroke():this.pending_backstroke.addClassName("search-choice-focus")},i.prototype.clear_backstroke=function(){return this.pending_backstroke&&this.pending_backstroke.removeClassName("search-choice-focus"),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(),t!==8&&this.pending_backstroke&&this.clear_backstroke();switch(t){case 8:this.backstroke_length=this.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:e.preventDefault();break;case 38:e.preventDefault(),this.keyup_arrow();break;case 40:this.keydown_arrow()}},i.prototype.search_field_scale=function(){var e,t,n,r,i,s,o,u,a;if(this.is_multiple){n=0,o=0,i="position:absolute; left: -1000px; top: -1000px; display:none;",s=["font-size","font-style","font-weight","font-family","line-height","text-transform","letter-spacing"];for(u=0,a=s.length;u<a;u++)r=s[u],i+=r+":"+this.search_field.getStyle(r)+";";return t=(new Element("div",{style:i})).update(this.search_field.value.escapeHTML()),document.body.appendChild(t),o=Element.measure(t,"width")+25,t.remove(),o>this.f_width-10&&(o=this.f_width-10),this.search_field.setStyle({width:o+"px"}),e=this.container.getHeight(),this.dropdown.setStyle({top:e+"px"})}},i}(AbstractChosen),n.Chosen=e,Prototype.Browser.IE&&/MSIE (\d+\.\d+);/.test(navigator.userAgent)&&(Prototype.BrowserFeatures.Version=new Number(RegExp.$1)),t=function(e){var t,n;return t=new Element.Layout(e),n=t.get("border-left")+t.get("border-right")+t.get("padding-left")+t.get("padding-right")},n.get_side_border_padding=t}.call(this);
6 coffee/chosen.jquery.coffee
@@ -54,9 +54,9 @@ class Chosen extends AbstractChosen
54 54 container_div = ($ "<div />", container_props)
55 55
56 56 if @is_multiple
57   - container_div.html '<ul class="chzn-choices"><li class="search-field"><input type="text" value="' + @default_text + '" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop" style="left:-9000px;"><ul class="chzn-results"></ul></div>'
  57 + container_div.html '<ul class="chzn-choices"><li class="search-field"><input type="text" value="' + @default_text + '" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop" style="left:' + (if @is_rtl then '' else '-') + '9000px;"><ul class="chzn-results"></ul></div>'
58 58 else
59   - container_div.html '<a href="javascript:void(0)" class="chzn-single chzn-default" tabindex="-1"><span>' + @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>'
  59 + container_div.html '<a href="javascript:void(0)" class="chzn-single chzn-default" tabindex="-1"><span>' + @default_text + '</span><div><b></b></div></a><div class="chzn-drop" style="left:' + (if @is_rtl then '' else '-') + '9000px;"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>'
60 60
61 61 @form_field_jq.hide().after container_div
62 62 @container = ($ '#' + @container_id)
@@ -261,7 +261,7 @@ class Chosen extends AbstractChosen
261 261 @selected_item.removeClass "chzn-single-with-drop" unless @is_multiple
262 262 this.result_clear_highlight()
263 263 @form_field_jq.trigger("liszt:hiding_dropdown", {chosen: this})
264   - @dropdown.css {"left":"-9000px"}
  264 + @dropdown.css {"left":(if @is_rtl then '' else '-') + "9000px"}
265 265 @results_showing = false
266 266
267 267
6 coffee/chosen.proto.coffee
@@ -17,8 +17,8 @@ class Chosen extends AbstractChosen
17 17 super()
18 18
19 19 # HTML Templates
20   - @single_temp = new Template('<a href="javascript:void(0)" class="chzn-single chzn-default" tabindex="-1"><span>#{default}</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>')
21   - @multi_temp = new Template('<ul class="chzn-choices"><li class="search-field"><input type="text" value="#{default}" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop" style="left:-9000px;"><ul class="chzn-results"></ul></div>')
  20 + @single_temp = new Template('<a href="javascript:void(0)" class="chzn-single chzn-default" tabindex="-1"><span>#{default}</span><div><b></b></div></a><div class="chzn-drop" style="left:' + (if @is_rtl then '' else '-') + '9000px;"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>')
  21 + @multi_temp = new Template('<ul class="chzn-choices"><li class="search-field"><input type="text" value="#{default}" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop" style="left:' + (if @is_rtl then '' else '-') + '9000px;"><ul class="chzn-results"></ul></div>')
22 22 @choice_temp = new Template('<li class="search-choice" id="#{id}"><span>#{choice}</span><a href="javascript:void(0)" class="search-choice-close" rel="#{position}"></a></li>')
23 23 @choice_noclose_temp = new Template('<li class="search-choice search-choice-disabled" id="#{id}"><span>#{choice}</span></li>')
24 24 @no_results_temp = new Template('<li class="no-results">' + @results_none_found + ' "<span>#{terms}</span>"</li>')
@@ -240,7 +240,7 @@ class Chosen extends AbstractChosen
240 240 @selected_item.removeClassName('chzn-single-with-drop') unless @is_multiple
241 241 this.result_clear_highlight()
242 242 @form_field.fire("liszt:hiding_dropdown", {chosen: this})
243   - @dropdown.setStyle({"left":"-9000px"})
  243 + @dropdown.setStyle({"left": (if @is_rtl then '' else '-') + "9000px"})
244 244 @results_showing = false
245 245
246 246

0 comments on commit 4628581

Please sign in to comment.
Something went wrong with that request. Please try again.