Skip to content
This repository
Browse code

Updating version numbers.

  • Loading branch information...
commit 5175cb809e36abe1b7469d3e57d426cb6594f61a 1 parent c93a52b
Patrick Filler pfiller authored
348 chosen/chosen.jquery.js
... ... @@ -1,7 +1,7 @@
1 1 // Chosen, a Select Box Enhancer for jQuery and Protoype
2 2 // by Patrick Filler for Harvest, http://getharvest.com
3 3 //
4   -// Version 0.9.6
  4 +// Version 0.9.7
5 5 // Full source at https://github.com/harvesthq/chosen
6 6 // Copyright (c) 2011 Harvest http://getharvest.com
7 7
@@ -9,11 +9,14 @@
9 9 // This file is generated by `cake build`, do not edit it by hand.
10 10 (function() {
11 11 var SelectParser;
  12 +
12 13 SelectParser = (function() {
  14 +
13 15 function SelectParser() {
14 16 this.options_index = 0;
15 17 this.parsed = [];
16 18 }
  19 +
17 20 SelectParser.prototype.add_node = function(child) {
18 21 if (child.nodeName === "OPTGROUP") {
19 22 return this.add_group(child);
@@ -21,6 +24,7 @@
21 24 return this.add_option(child);
22 25 }
23 26 };
  27 +
24 28 SelectParser.prototype.add_group = function(group) {
25 29 var group_position, option, _i, _len, _ref, _results;
26 30 group_position = this.parsed.length;
@@ -39,12 +43,11 @@
39 43 }
40 44 return _results;
41 45 };
  46 +
42 47 SelectParser.prototype.add_option = function(option, group_position, group_disabled) {
43 48 if (option.nodeName === "OPTION") {
44 49 if (option.text !== "") {
45   - if (group_position != null) {
46   - this.parsed[group_position].children += 1;
47   - }
  50 + if (group_position != null) this.parsed[group_position].children += 1;
48 51 this.parsed.push({
49 52 array_index: this.parsed.length,
50 53 options_index: this.options_index,
@@ -67,8 +70,11 @@
67 70 return this.options_index += 1;
68 71 }
69 72 };
  73 +
70 74 return SelectParser;
  75 +
71 76 })();
  77 +
72 78 SelectParser.select_to_array = function(select) {
73 79 var child, parser, _i, _len, _ref;
74 80 parser = new SelectParser();
@@ -79,17 +85,23 @@
79 85 }
80 86 return parser.parsed;
81 87 };
  88 +
82 89 this.SelectParser = SelectParser;
  90 +
83 91 }).call(this);
  92 +
  93 +/*
  94 +Chosen source: generate output using 'cake build'
  95 +Copyright (c) 2011 by Harvest
  96 +*/
  97 +
84 98 (function() {
85   - /*
86   - Chosen source: generate output using 'cake build'
87   - Copyright (c) 2011 by Harvest
88   - */
89 99 var AbstractChosen, root;
90   - var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
  100 +
91 101 root = this;
  102 +
92 103 AbstractChosen = (function() {
  104 +
93 105 function AbstractChosen(form_field, options) {
94 106 this.form_field = form_field;
95 107 this.options = options != null ? options : {};
@@ -101,13 +113,15 @@
101 113 this.register_observers();
102 114 this.finish_setup();
103 115 }
  116 +
104 117 AbstractChosen.prototype.set_default_values = function() {
105   - this.click_test_action = __bind(function(evt) {
106   - return this.test_active_click(evt);
107   - }, this);
108   - this.activate_action = __bind(function(evt) {
109   - return this.activate_field(evt);
110   - }, this);
  118 + var _this = this;
  119 + this.click_test_action = function(evt) {
  120 + return _this.test_active_click(evt);
  121 + };
  122 + this.activate_action = function(evt) {
  123 + return _this.activate_field(evt);
  124 + };
111 125 this.active_field = false;
112 126 this.mouse_on_container = false;
113 127 this.results_showing = false;
@@ -118,52 +132,55 @@
118 132 this.choices = 0;
119 133 return this.results_none_found = this.options.no_results_text || "No results match";
120 134 };
  135 +
121 136 AbstractChosen.prototype.mouse_enter = function() {
122 137 return this.mouse_on_container = true;
123 138 };
  139 +
124 140 AbstractChosen.prototype.mouse_leave = function() {
125 141 return this.mouse_on_container = false;
126 142 };
  143 +
127 144 AbstractChosen.prototype.input_focus = function(evt) {
  145 + var _this = this;
128 146 if (!this.active_field) {
129   - return setTimeout((__bind(function() {
130   - return this.container_mousedown();
131   - }, this)), 50);
  147 + return setTimeout((function() {
  148 + return _this.container_mousedown();
  149 + }), 50);
132 150 }
133 151 };
  152 +
134 153 AbstractChosen.prototype.input_blur = function(evt) {
  154 + var _this = this;
135 155 if (!this.mouse_on_container) {
136 156 this.active_field = false;
137   - return setTimeout((__bind(function() {
138   - return this.blur_test();
139   - }, this)), 100);
  157 + return setTimeout((function() {
  158 + return _this.blur_test();
  159 + }), 100);
140 160 }
141 161 };
  162 +
142 163 AbstractChosen.prototype.result_add_option = function(option) {
143 164 var classes, style;
144 165 if (!option.disabled) {
145 166 option.dom_id = this.container_id + "_o_" + option.array_index;
146 167 classes = option.selected && this.is_multiple ? [] : ["active-result"];
147   - if (option.selected) {
148   - classes.push("result-selected");
149   - }
150   - if (option.group_array_index != null) {
151   - classes.push("group-option");
152   - }
153   - if (option.classes !== "") {
154   - classes.push(option.classes);
155   - }
  168 + if (option.selected) classes.push("result-selected");
  169 + if (option.group_array_index != null) classes.push("group-option");
  170 + if (option.classes !== "") classes.push(option.classes);
156 171 style = option.style.cssText !== "" ? " style=\"" + option.style + "\"" : "";
157 172 return '<li id="' + option.dom_id + '" class="' + classes.join(' ') + '"' + style + '>' + option.html + '</li>';
158 173 } else {
159 174 return "";
160 175 }
161 176 };
  177 +
162 178 AbstractChosen.prototype.results_update_field = function() {
163 179 this.result_clear_highlight();
164 180 this.result_single_selected = null;
165 181 return this.results_build();
166 182 };
  183 +
167 184 AbstractChosen.prototype.results_toggle = function() {
168 185 if (this.results_showing) {
169 186 return this.results_hide();
@@ -171,6 +188,7 @@
171 188 return this.results_show();
172 189 }
173 190 };
  191 +
174 192 AbstractChosen.prototype.results_search = function(evt) {
175 193 if (this.results_showing) {
176 194 return this.winnow_results();
@@ -178,6 +196,7 @@
178 196 return this.results_show();
179 197 }
180 198 };
  199 +
181 200 AbstractChosen.prototype.keyup_checker = function(evt) {
182 201 var stroke, _ref;
183 202 stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
@@ -193,14 +212,10 @@
193 212 break;
194 213 case 13:
195 214 evt.preventDefault();
196   - if (this.results_showing) {
197   - return this.result_select(evt);
198   - }
  215 + if (this.results_showing) return this.result_select(evt);
199 216 break;
200 217 case 27:
201   - if (this.results_showing) {
202   - this.results_hide();
203   - }
  218 + if (this.results_showing) this.results_hide();
204 219 return true;
205 220 case 9:
206 221 case 38:
@@ -213,62 +228,71 @@
213 228 return this.results_search();
214 229 }
215 230 };
  231 +
216 232 AbstractChosen.prototype.generate_field_id = function() {
217 233 var new_id;
218 234 new_id = this.generate_random_id();
219 235 this.form_field.id = new_id;
220 236 return new_id;
221 237 };
  238 +
222 239 AbstractChosen.prototype.generate_random_char = function() {
223 240 var chars, newchar, rand;
224 241 chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZ";
225 242 rand = Math.floor(Math.random() * chars.length);
226 243 return newchar = chars.substring(rand, rand + 1);
227 244 };
  245 +
228 246 return AbstractChosen;
  247 +
229 248 })();
  249 +
230 250 root.AbstractChosen = AbstractChosen;
  251 +
231 252 }).call(this);
  253 +
  254 +/*
  255 +Chosen source: generate output using 'cake build'
  256 +Copyright (c) 2011 by Harvest
  257 +*/
  258 +
232 259 (function() {
233   - /*
234   - Chosen source: generate output using 'cake build'
235   - Copyright (c) 2011 by Harvest
236   - */
237   - var $, Chosen, get_side_border_padding, root;
238   - var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
239   - for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
240   - function ctor() { this.constructor = child; }
241   - ctor.prototype = parent.prototype;
242   - child.prototype = new ctor;
243   - child.__super__ = parent.prototype;
244   - return child;
245   - }, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
  260 + var $, Chosen, get_side_border_padding, root,
  261 + __hasProp = Object.prototype.hasOwnProperty,
  262 + __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; };
  263 +
246 264 root = this;
  265 +
247 266 $ = jQuery;
  267 +
248 268 $.fn.extend({
249 269 chosen: function(options) {
250 270 if ($.browser.msie && ($.browser.version === "6.0" || $.browser.version === "7.0")) {
251 271 return this;
252 272 }
253 273 return $(this).each(function(input_field) {
254   - if (!($(this)).hasClass("chzn-done")) {
255   - return new Chosen(this, options);
256   - }
  274 + if (!($(this)).hasClass("chzn-done")) return new Chosen(this, options);
257 275 });
258 276 }
259 277 });
260   - Chosen = (function() {
261   - __extends(Chosen, AbstractChosen);
  278 +
  279 + Chosen = (function(_super) {
  280 +
  281 + __extends(Chosen, _super);
  282 +
262 283 function Chosen() {
263 284 Chosen.__super__.constructor.apply(this, arguments);
264 285 }
  286 +
265 287 Chosen.prototype.setup = function() {
266 288 this.form_field_jq = $(this.form_field);
267 289 return this.is_rtl = this.form_field_jq.hasClass("chzn-rtl");
268 290 };
  291 +
269 292 Chosen.prototype.finish_setup = function() {
270 293 return this.form_field_jq.addClass("chzn-done");
271 294 };
  295 +
272 296 Chosen.prototype.set_up_html = function() {
273 297 var container_div, dd_top, dd_width, sf_width;
274 298 this.container_id = this.form_field.id.length ? this.form_field.id.replace(/(:|\.)/g, '_') : this.generate_field_id();
@@ -316,53 +340,56 @@
316 340 chosen: this
317 341 });
318 342 };
  343 +
319 344 Chosen.prototype.register_observers = function() {
320   - this.container.mousedown(__bind(function(evt) {
321   - return this.container_mousedown(evt);
322   - }, this));
323   - this.container.mouseup(__bind(function(evt) {
324   - return this.container_mouseup(evt);
325   - }, this));
326   - this.container.mouseenter(__bind(function(evt) {
327   - return this.mouse_enter(evt);
328   - }, this));
329   - this.container.mouseleave(__bind(function(evt) {
330   - return this.mouse_leave(evt);
331   - }, this));
332   - this.search_results.mouseup(__bind(function(evt) {
333   - return this.search_results_mouseup(evt);
334   - }, this));
335   - this.search_results.mouseover(__bind(function(evt) {
336   - return this.search_results_mouseover(evt);
337   - }, this));
338   - this.search_results.mouseout(__bind(function(evt) {
339   - return this.search_results_mouseout(evt);
340   - }, this));
341   - this.form_field_jq.bind("liszt:updated", __bind(function(evt) {
342   - return this.results_update_field(evt);
343   - }, this));
344   - this.search_field.blur(__bind(function(evt) {
345   - return this.input_blur(evt);
346   - }, this));
347   - this.search_field.keyup(__bind(function(evt) {
348   - return this.keyup_checker(evt);
349   - }, this));
350   - this.search_field.keydown(__bind(function(evt) {
351   - return this.keydown_checker(evt);
352   - }, this));
  345 + var _this = this;
  346 + this.container.mousedown(function(evt) {
  347 + return _this.container_mousedown(evt);
  348 + });
  349 + this.container.mouseup(function(evt) {
  350 + return _this.container_mouseup(evt);
  351 + });
  352 + this.container.mouseenter(function(evt) {
  353 + return _this.mouse_enter(evt);
  354 + });
  355 + this.container.mouseleave(function(evt) {
  356 + return _this.mouse_leave(evt);
  357 + });
  358 + this.search_results.mouseup(function(evt) {
  359 + return _this.search_results_mouseup(evt);
  360 + });
  361 + this.search_results.mouseover(function(evt) {
  362 + return _this.search_results_mouseover(evt);
  363 + });
  364 + this.search_results.mouseout(function(evt) {
  365 + return _this.search_results_mouseout(evt);
  366 + });
  367 + this.form_field_jq.bind("liszt:updated", function(evt) {
  368 + return _this.results_update_field(evt);
  369 + });
  370 + this.search_field.blur(function(evt) {
  371 + return _this.input_blur(evt);
  372 + });
  373 + this.search_field.keyup(function(evt) {
  374 + return _this.keyup_checker(evt);
  375 + });
  376 + this.search_field.keydown(function(evt) {
  377 + return _this.keydown_checker(evt);
  378 + });
353 379 if (this.is_multiple) {
354   - this.search_choices.click(__bind(function(evt) {
355   - return this.choices_click(evt);
356   - }, this));
357   - return this.search_field.focus(__bind(function(evt) {
358   - return this.input_focus(evt);
359   - }, this));
  380 + this.search_choices.click(function(evt) {
  381 + return _this.choices_click(evt);
  382 + });
  383 + return this.search_field.focus(function(evt) {
  384 + return _this.input_focus(evt);
  385 + });
360 386 } else {
361   - return this.container.click(__bind(function(evt) {
  387 + return this.container.click(function(evt) {
362 388 return evt.preventDefault();
363   - }, this));
  389 + });
364 390 }
365 391 };
  392 +
366 393 Chosen.prototype.search_field_disabled = function() {
367 394 this.is_disabled = this.form_field_jq[0].disabled;
368 395 if (this.is_disabled) {
@@ -380,18 +407,15 @@
380 407 }
381 408 }
382 409 };
  410 +
383 411 Chosen.prototype.container_mousedown = function(evt) {
384 412 var target_closelink;
385 413 if (!this.is_disabled) {
386 414 target_closelink = evt != null ? ($(evt.target)).hasClass("search-choice-close") : false;
387   - if (evt && evt.type === "mousedown") {
388   - evt.stopPropagation();
389   - }
  415 + if (evt && evt.type === "mousedown") evt.stopPropagation();
390 416 if (!this.pending_destroy_click && !target_closelink) {
391 417 if (!this.active_field) {
392   - if (this.is_multiple) {
393   - this.search_field.val("");
394   - }
  418 + if (this.is_multiple) this.search_field.val("");
395 419 $(document).click(this.click_test_action);
396 420 this.results_show();
397 421 } else if (!this.is_multiple && evt && (($(evt.target)[0] === this.selected_item[0]) || $(evt.target).parents("a.chzn-single").length)) {
@@ -404,16 +428,17 @@
404 428 }
405 429 }
406 430 };
  431 +
407 432 Chosen.prototype.container_mouseup = function(evt) {
408   - if (evt.target.nodeName === "ABBR") {
409   - return this.results_reset(evt);
410   - }
  433 + if (evt.target.nodeName === "ABBR") return this.results_reset(evt);
411 434 };
  435 +
412 436 Chosen.prototype.blur_test = function(evt) {
413 437 if (!this.active_field && this.container.hasClass("chzn-container-active")) {
414 438 return this.close_field();
415 439 }
416 440 };
  441 +
417 442 Chosen.prototype.close_field = function() {
418 443 $(document).unbind("click", this.click_test_action);
419 444 if (!this.is_multiple) {
@@ -428,6 +453,7 @@
428 453 this.show_search_field_default();
429 454 return this.search_field_scale();
430 455 };
  456 +
431 457 Chosen.prototype.activate_field = function() {
432 458 if (!this.is_multiple && !this.active_field) {
433 459 this.search_field.attr("tabindex", this.selected_item.attr("tabindex"));
@@ -438,6 +464,7 @@
438 464 this.search_field.val(this.search_field.val());
439 465 return this.search_field.focus();
440 466 };
  467 +
441 468 Chosen.prototype.test_active_click = function(evt) {
442 469 if ($(evt.target).parents('#' + this.container_id).length) {
443 470 return this.active_field = true;
@@ -445,6 +472,7 @@
445 472 return this.close_field();
446 473 }
447 474 };
  475 +
448 476 Chosen.prototype.results_build = function() {
449 477 var content, data, _i, _len, _ref;
450 478 this.parsing = true;
@@ -472,9 +500,7 @@
472 500 this.choice_build(data);
473 501 } else if (data.selected && !this.is_multiple) {
474 502 this.selected_item.find("span").text(data.text);
475   - if (this.allow_single_deselect) {
476   - this.single_deselect_control_build();
477   - }
  503 + if (this.allow_single_deselect) this.single_deselect_control_build();
478 504 }
479 505 }
480 506 }
@@ -484,6 +510,7 @@
484 510 this.search_results.html(content);
485 511 return this.parsing = false;
486 512 };
  513 +
487 514 Chosen.prototype.result_add_group = function(group) {
488 515 if (!group.disabled) {
489 516 group.dom_id = this.container_id + "_g_" + group.array_index;
@@ -492,6 +519,7 @@
492 519 return "";
493 520 }
494 521 };
  522 +
495 523 Chosen.prototype.result_do_highlight = function(el) {
496 524 var high_bottom, high_top, maxHeight, visible_bottom, visible_top;
497 525 if (el.length) {
@@ -510,12 +538,12 @@
510 538 }
511 539 }
512 540 };
  541 +
513 542 Chosen.prototype.result_clear_highlight = function() {
514   - if (this.result_highlight) {
515   - this.result_highlight.removeClass("highlighted");
516   - }
  543 + if (this.result_highlight) this.result_highlight.removeClass("highlighted");
517 544 return this.result_highlight = null;
518 545 };
  546 +
519 547 Chosen.prototype.results_show = function() {
520 548 var dd_top;
521 549 if (!this.is_multiple) {
@@ -534,6 +562,7 @@
534 562 this.search_field.val(this.search_field.val());
535 563 return this.winnow_results();
536 564 };
  565 +
537 566 Chosen.prototype.results_hide = function() {
538 567 if (!this.is_multiple) {
539 568 this.selected_item.removeClass("chzn-single-with-drop");
@@ -544,6 +573,7 @@
544 573 });
545 574 return this.results_showing = false;
546 575 };
  576 +
547 577 Chosen.prototype.set_tab_index = function(el) {
548 578 var ti;
549 579 if (this.form_field_jq.attr("tabindex")) {
@@ -557,6 +587,7 @@
557 587 }
558 588 }
559 589 };
  590 +
560 591 Chosen.prototype.show_search_field_default = function() {
561 592 if (this.is_multiple && this.choices < 1 && !this.active_field) {
562 593 this.search_field.val(this.default_text);
@@ -566,6 +597,7 @@
566 597 return this.search_field.removeClass("default");
567 598 }
568 599 };
  600 +
569 601 Chosen.prototype.search_results_mouseup = function(evt) {
570 602 var target;
571 603 target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
@@ -574,34 +606,38 @@
574 606 return this.result_select(evt);
575 607 }
576 608 };
  609 +
577 610 Chosen.prototype.search_results_mouseover = function(evt) {
578 611 var target;
579 612 target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
580   - if (target) {
581   - return this.result_do_highlight(target);
582   - }
  613 + if (target) return this.result_do_highlight(target);
583 614 };
  615 +
584 616 Chosen.prototype.search_results_mouseout = function(evt) {
585 617 if ($(evt.target).hasClass("active-result" || $(evt.target).parents('.active-result').first())) {
586 618 return this.result_clear_highlight();
587 619 }
588 620 };
  621 +
589 622 Chosen.prototype.choices_click = function(evt) {
590 623 evt.preventDefault();
591 624 if (this.active_field && !($(evt.target).hasClass("search-choice" || $(evt.target).parents('.search-choice').first)) && !this.results_showing) {
592 625 return this.results_show();
593 626 }
594 627 };
  628 +
595 629 Chosen.prototype.choice_build = function(item) {
596   - var choice_id, link;
  630 + var choice_id, link,
  631 + _this = this;
597 632 choice_id = this.container_id + "_c_" + item.array_index;
598 633 this.choices += 1;
599 634 this.search_container.before('<li class="search-choice" id="' + choice_id + '"><span>' + item.html + '</span><a href="javascript:void(0)" class="search-choice-close" rel="' + item.array_index + '"></a></li>');
600 635 link = $('#' + choice_id).find("a").first();
601   - return link.click(__bind(function(evt) {
602   - return this.choice_destroy_link_click(evt);
603   - }, this));
  636 + return link.click(function(evt) {
  637 + return _this.choice_destroy_link_click(evt);
  638 + });
604 639 };
  640 +
605 641 Chosen.prototype.choice_destroy_link_click = function(evt) {
606 642 evt.preventDefault();
607 643 if (!this.is_disabled) {
@@ -611,6 +647,7 @@
611 647 return evt.stopPropagation;
612 648 }
613 649 };
  650 +
614 651 Chosen.prototype.choice_destroy = function(link) {
615 652 this.choices -= 1;
616 653 this.show_search_field_default();
@@ -620,16 +657,16 @@
620 657 this.result_deselect(link.attr("rel"));
621 658 return link.parents('li').first().remove();
622 659 };
  660 +
623 661 Chosen.prototype.results_reset = function(evt) {
624 662 this.form_field.options[0].selected = true;
625 663 this.selected_item.find("span").text(this.default_text);
626 664 this.show_search_field_default();
627 665 $(evt.target).remove();
628 666 this.form_field_jq.trigger("change");
629   - if (this.active_field) {
630   - return this.results_hide();
631   - }
  667 + if (this.active_field) return this.results_hide();
632 668 };
  669 +
633 670 Chosen.prototype.result_select = function(evt) {
634 671 var high, high_id, item, position;
635 672 if (this.result_highlight) {
@@ -651,24 +688,23 @@
651 688 this.choice_build(item);
652 689 } else {
653 690 this.selected_item.find("span").first().text(item.text);
654   - if (this.allow_single_deselect) {
655   - this.single_deselect_control_build();
656   - }
657   - }
658   - if (!(evt.metaKey && this.is_multiple)) {
659   - this.results_hide();
  691 + if (this.allow_single_deselect) this.single_deselect_control_build();
660 692 }
  693 + if (!(evt.metaKey && this.is_multiple)) this.results_hide();
661 694 this.search_field.val("");
662 695 this.form_field_jq.trigger("change");
663 696 return this.search_field_scale();
664 697 }
665 698 };
  699 +
666 700 Chosen.prototype.result_activate = function(el) {
667 701 return el.addClass("active-result");
668 702 };
  703 +
669 704 Chosen.prototype.result_deactivate = function(el) {
670 705 return el.removeClass("active-result");
671 706 };
  707 +
672 708 Chosen.prototype.result_deselect = function(pos) {
673 709 var result, result_data;
674 710 result_data = this.results_data[pos];
@@ -681,11 +717,13 @@
681 717 this.form_field_jq.trigger("change");
682 718 return this.search_field_scale();
683 719 };
  720 +
684 721 Chosen.prototype.single_deselect_control_build = function() {
685 722 if (this.allow_single_deselect && this.selected_item.find("abbr").length < 1) {
686 723 return this.selected_item.find("span").first().after("<abbr class=\"search-choice-close\"></abbr>");
687 724 }
688 725 };
  726 +
689 727 Chosen.prototype.winnow_results = function() {
690 728 var found, option, part, parts, regex, result, result_id, results, searchText, startpos, text, zregex, _i, _j, _len, _len2, _ref;
691 729 this.no_results_clear();
@@ -746,6 +784,7 @@
746 784 return this.winnow_results_set_highlight();
747 785 }
748 786 };
  787 +
749 788 Chosen.prototype.winnow_results_clear = function() {
750 789 var li, lis, _i, _len, _results;
751 790 this.search_field.val("");
@@ -754,46 +793,49 @@
754 793 for (_i = 0, _len = lis.length; _i < _len; _i++) {
755 794 li = lis[_i];
756 795 li = $(li);
757   - _results.push(li.hasClass("group-result") ? li.css('display', 'auto') : !this.is_multiple || !li.hasClass("result-selected") ? this.result_activate(li) : void 0);
  796 + if (li.hasClass("group-result")) {
  797 + _results.push(li.css('display', 'auto'));
  798 + } else if (!this.is_multiple || !li.hasClass("result-selected")) {
  799 + _results.push(this.result_activate(li));
  800 + } else {
  801 + _results.push(void 0);
  802 + }
758 803 }
759 804 return _results;
760 805 };
  806 +
761 807 Chosen.prototype.winnow_results_set_highlight = function() {
762 808 var do_high, selected_results;
763 809 if (!this.result_highlight) {
764 810 selected_results = !this.is_multiple ? this.search_results.find(".result-selected.active-result") : [];
765 811 do_high = selected_results.length ? selected_results.first() : this.search_results.find(".active-result").first();
766   - if (do_high != null) {
767   - return this.result_do_highlight(do_high);
768   - }
  812 + if (do_high != null) return this.result_do_highlight(do_high);
769 813 }
770 814 };
  815 +
771 816 Chosen.prototype.no_results = function(terms) {
772 817 var no_results_html;
773 818 no_results_html = $('<li class="no-results">' + this.results_none_found + ' "<span></span>"</li>');
774 819 no_results_html.find("span").first().html(terms);
775 820 return this.search_results.append(no_results_html);
776 821 };
  822 +
777 823 Chosen.prototype.no_results_clear = function() {
778 824 return this.search_results.find(".no-results").remove();
779 825 };
  826 +
780 827 Chosen.prototype.keydown_arrow = function() {
781 828 var first_active, next_sib;
782 829 if (!this.result_highlight) {
783 830 first_active = this.search_results.find("li.active-result").first();
784   - if (first_active) {
785   - this.result_do_highlight($(first_active));
786   - }
  831 + if (first_active) this.result_do_highlight($(first_active));
787 832 } else if (this.results_showing) {
788 833 next_sib = this.result_highlight.nextAll("li.active-result").first();
789   - if (next_sib) {
790   - this.result_do_highlight(next_sib);
791   - }
792   - }
793   - if (!this.results_showing) {
794   - return this.results_show();
  834 + if (next_sib) this.result_do_highlight(next_sib);
795 835 }
  836 + if (!this.results_showing) return this.results_show();
796 837 };
  838 +
797 839 Chosen.prototype.keyup_arrow = function() {
798 840 var prev_sibs;
799 841 if (!this.results_showing && !this.is_multiple) {
@@ -803,13 +845,12 @@
803 845 if (prev_sibs.length) {
804 846 return this.result_do_highlight(prev_sibs.first());
805 847 } else {
806   - if (this.choices > 0) {
807   - this.results_hide();
808   - }
  848 + if (this.choices > 0) this.results_hide();
809 849 return this.result_clear_highlight();
810 850 }
811 851 }
812 852 };
  853 +
813 854 Chosen.prototype.keydown_backstroke = function() {
814 855 if (this.pending_backstroke) {
815 856 this.choice_destroy(this.pending_backstroke.find("a").first());
@@ -819,27 +860,25 @@
819 860 return this.pending_backstroke.addClass("search-choice-focus");
820 861 }
821 862 };
  863 +
822 864 Chosen.prototype.clear_backstroke = function() {
823 865 if (this.pending_backstroke) {
824 866 this.pending_backstroke.removeClass("search-choice-focus");
825 867 }
826 868 return this.pending_backstroke = null;
827 869 };
  870 +
828 871 Chosen.prototype.keydown_checker = function(evt) {
829 872 var stroke, _ref;
830 873 stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
831 874 this.search_field_scale();
832   - if (stroke !== 8 && this.pending_backstroke) {
833   - this.clear_backstroke();
834   - }
  875 + if (stroke !== 8 && this.pending_backstroke) this.clear_backstroke();
835 876 switch (stroke) {
836 877 case 8:
837 878 this.backstroke_length = this.search_field.val().length;
838 879 break;
839 880 case 9:
840   - if (this.results_showing && !this.is_multiple) {
841   - this.result_select(evt);
842   - }
  881 + if (this.results_showing && !this.is_multiple) this.result_select(evt);
843 882 this.mouse_on_container = false;
844 883 break;
845 884 case 13:
@@ -854,6 +893,7 @@
854 893 break;
855 894 }
856 895 };
  896 +
857 897 Chosen.prototype.search_field_scale = function() {
858 898 var dd_top, div, h, style, style_block, styles, w, _i, _len;
859 899 if (this.is_multiple) {
@@ -872,9 +912,7 @@
872 912 $('body').append(div);
873 913 w = div.width() + 25;
874 914 div.remove();
875   - if (w > this.f_width - 10) {
876   - w = this.f_width - 10;
877   - }
  915 + if (w > this.f_width - 10) w = this.f_width - 10;
878 916 this.search_field.css({
879 917 'width': w + 'px'
880 918 });
@@ -884,6 +922,7 @@
884 922 });
885 923 }
886 924 };
  925 +
887 926 Chosen.prototype.generate_random_id = function() {
888 927 var string;
889 928 string = "sel" + this.generate_random_char() + this.generate_random_char() + this.generate_random_char();
@@ -892,11 +931,16 @@
892 931 }
893 932 return string;
894 933 };
  934 +
895 935 return Chosen;
896   - })();
  936 +
  937 + })(AbstractChosen);
  938 +
897 939 get_side_border_padding = function(elmt) {
898 940 var side_border_padding;
899 941 return side_border_padding = elmt.outerWidth() - elmt.width();
900 942 };
  943 +
901 944 root.get_side_border_padding = get_side_border_padding;
  945 +
902 946 }).call(this);
4 chosen/chosen.jquery.min.js
... ... @@ -1,10 +1,10 @@
1 1 // Chosen, a Select Box Enhancer for jQuery and Protoype
2 2 // by Patrick Filler for Harvest, http://getharvest.com
3 3 //
4   -// Version 0.9.6
  4 +// Version 0.9.7
5 5 // Full source at https://github.com/harvesthq/chosen
6 6 // Copyright (c) 2011 Harvest http://getharvest.com
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 a;a=function(){function a(){this.options_index=0,this.parsed=[]}return a.prototype.add_node=function(a){return a.nodeName==="OPTGROUP"?this.add_group(a):this.add_option(a)},a.prototype.add_group=function(a){var b,c,d,e,f,g;b=this.parsed.length,this.parsed.push({array_index:b,group:!0,label:a.label,children:0,disabled:a.disabled}),f=a.childNodes,g=[];for(d=0,e=f.length;d<e;d++)c=f[d],g.push(this.add_option(c,b,a.disabled));return g},a.prototype.add_option=function(a,b,c){if(a.nodeName==="OPTION")return a.text!==""?(b!=null&&(this.parsed[b].children+=1),this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,value:a.value,text:a.text,html:a.innerHTML,selected:a.selected,disabled:c===!0?c:a.disabled,group_array_index:b,classes:a.className,style:a.style.cssText})):this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,empty:!0}),this.options_index+=1},a}(),a.select_to_array=function(b){var c,d,e,f,g;d=new a,g=b.childNodes;for(e=0,f=g.length;e<f;e++)c=g[e],d.add_node(c);return d.parsed},this.SelectParser=a}).call(this),function(){var a,b,c=function(a,b){return function(){return a.apply(b,arguments)}};b=this,a=function(){function a(a,b){this.form_field=a,this.options=b!=null?b:{},this.set_default_values(),this.is_multiple=this.form_field.multiple,this.default_text_default=this.is_multiple?"Select Some Options":"Select an Option",this.setup(),this.set_up_html(),this.register_observers(),this.finish_setup()}return a.prototype.set_default_values=function(){return this.click_test_action=c(function(a){return this.test_active_click(a)},this),this.activate_action=c(function(a){return this.activate_field(a)},this),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.choices=0,this.results_none_found=this.options.no_results_text||"No results match"},a.prototype.mouse_enter=function(){return this.mouse_on_container=!0},a.prototype.mouse_leave=function(){return this.mouse_on_container=!1},a.prototype.input_focus=function(a){if(!this.active_field)return setTimeout(c(function(){return this.container_mousedown()},this),50)},a.prototype.input_blur=function(a){if(!this.mouse_on_container)return this.active_field=!1,setTimeout(c(function(){return this.blur_test()},this),100)},a.prototype.result_add_option=function(a){var b,c;return a.disabled?"":(a.dom_id=this.container_id+"_o_"+a.array_index,b=a.selected&&this.is_multiple?[]:["active-result"],a.selected&&b.push("result-selected"),a.group_array_index!=null&&b.push("group-option"),a.classes!==""&&b.push(a.classes),c=a.style.cssText!==""?' style="'+a.style+'"':"",'<li id="'+a.dom_id+'" class="'+b.join(" ")+'"'+c+">"+a.html+"</li>")},a.prototype.results_update_field=function(){return this.result_clear_highlight(),this.result_single_selected=null,this.results_build()},a.prototype.results_toggle=function(){return this.results_showing?this.results_hide():this.results_show()},a.prototype.results_search=function(a){return this.results_showing?this.winnow_results():this.results_show()},a.prototype.keyup_checker=function(a){var b,c;b=(c=a.which)!=null?c:a.keyCode,this.search_field_scale();switch(b){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:a.preventDefault();if(this.results_showing)return this.result_select(a);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()}},a.prototype.generate_field_id=function(){var a;return a=this.generate_random_id(),this.form_field.id=a,a},a.prototype.generate_random_char=function(){var a,b,c;return a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZ",c=Math.floor(Math.random()*a.length),b=a.substring(c,c+1)},a}(),b.AbstractChosen=a}.call(this),function(){var a,b,c,d,e=Object.prototype.hasOwnProperty,f=function(a,b){function d(){this.constructor=a}for(var c in b)e.call(b,c)&&(a[c]=b[c]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a},g=function(a,b){return function(){return a.apply(b,arguments)}};d=this,a=jQuery,a.fn.extend({chosen:function(c){return!a.browser.msie||a.browser.version!=="6.0"&&a.browser.version!=="7.0"?a(this).each(function(d){if(!a(this).hasClass("chzn-done"))return new b(this,c)}):this}}),b=function(){function b(){b.__super__.constructor.apply(this,arguments)}return f(b,AbstractChosen),b.prototype.setup=function(){return this.form_field_jq=a(this.form_field),this.is_rtl=this.form_field_jq.hasClass("chzn-rtl")},b.prototype.finish_setup=function(){return this.form_field_jq.addClass("chzn-done")},b.prototype.set_up_html=function(){var b,d,e,f;return this.container_id=this.form_field.id.length?this.form_field.id.replace(/(:|\.)/g,"_"):this.generate_field_id(),this.container_id+="_chzn",this.f_width=this.form_field_jq.outerWidth(),this.default_text=this.form_field_jq.data("placeholder")?this.form_field_jq.data("placeholder"):this.default_text_default,b=a("<div />",{id:this.container_id,"class":"chzn-container"+(this.is_rtl?" chzn-rtl":""),style:"width: "+this.f_width+"px;"}),this.is_multiple?b.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>'):b.html('<a href="javascript:void(0)" class="chzn-single"><span>'+this.default_text+'</span><div><b></b></div></a><div class="chzn-drop" style="left:-9000px;"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>'),this.form_field_jq.hide().after(b),this.container=a("#"+this.container_id),this.container.addClass("chzn-container-"+(this.is_multiple?"multi":"single")),this.dropdown=this.container.find("div.chzn-drop").first(),d=this.container.height(),e=this.f_width-c(this.dropdown),this.dropdown.css({width:e+"px",top:d+"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(),f=e-c(this.search_container)-c(this.search_field),this.search_field.css({width:f+"px"})),this.results_build(),this.set_tab_index(),this.form_field_jq.trigger("liszt:ready",{chosen:this})},b.prototype.register_observers=function(){return this.container.mousedown(g(function(a){return this.container_mousedown(a)},this)),this.container.mouseup(g(function(a){return this.container_mouseup(a)},this)),this.container.mouseenter(g(function(a){return this.mouse_enter(a)},this)),this.container.mouseleave(g(function(a){return this.mouse_leave(a)},this)),this.search_results.mouseup(g(function(a){return this.search_results_mouseup(a)},this)),this.search_results.mouseover(g(function(a){return this.search_results_mouseover(a)},this)),this.search_results.mouseout(g(function(a){return this.search_results_mouseout(a)},this)),this.form_field_jq.bind("liszt:updated",g(function(a){return this.results_update_field(a)},this)),this.search_field.blur(g(function(a){return this.input_blur(a)},this)),this.search_field.keyup(g(function(a){return this.keyup_checker(a)},this)),this.search_field.keydown(g(function(a){return this.keydown_checker(a)},this)),this.is_multiple?(this.search_choices.click(g(function(a){return this.choices_click(a)},this)),this.search_field.focus(g(function(a){return this.input_focus(a)},this))):this.container.click(g(function(a){return a.preventDefault()},this))},b.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)},b.prototype.container_mousedown=function(b){var c;if(!this.is_disabled)return c=b!=null?a(b.target).hasClass("search-choice-close"):!1,b&&b.type==="mousedown"&&b.stopPropagation(),!this.pending_destroy_click&&!c?(this.active_field?!this.is_multiple&&b&&(a(b.target)[0]===this.selected_item[0]||a(b.target).parents("a.chzn-single").length)&&(b.preventDefault(),this.results_toggle()):(this.is_multiple&&this.search_field.val(""),a(document).click(this.click_test_action),this.results_show()),this.activate_field()):this.pending_destroy_click=!1},b.prototype.container_mouseup=function(a){if(a.target.nodeName==="ABBR")return this.results_reset(a)},b.prototype.blur_test=function(a){if(!this.active_field&&this.container.hasClass("chzn-container-active"))return this.close_field()},b.prototype.close_field=function(){return a(document).unbind("click",this.click_test_action),this.is_multiple||(this.selected_item.attr("tabindex",this.search_field.attr("tabindex")),this.search_field.attr("tabindex",-1)),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()},b.prototype.activate_field=function(){return!this.is_multiple&&!this.active_field&&(this.search_field.attr("tabindex",this.selected_item.attr("tabindex")),this.selected_item.attr("tabindex",-1)),this.container.addClass("chzn-container-active"),this.active_field=!0,this.search_field.val(this.search_field.val()),this.search_field.focus()},b.prototype.test_active_click=function(b){return a(b.target).parents("#"+this.container_id).length?this.active_field=!0:this.close_field()},b.prototype.results_build=function(){var a,b,c,e,f;this.parsing=!0,this.results_data=d.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.find("span").text(this.default_text),this.form_field.options.length>this.disable_search_threshold?this.container.removeClass("chzn-container-single-nosearch"):this.container.addClass("chzn-container-single-nosearch")),a="",f=this.results_data;for(c=0,e=f.length;c<e;c++)b=f[c],b.group?a+=this.result_add_group(b):b.empty||(a+=this.result_add_option(b),b.selected&&this.is_multiple?this.choice_build(b):b.selected&&!this.is_multiple&&(this.selected_item.find("span").text(b.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(a),this.parsing=!1},b.prototype.result_add_group=function(b){return b.disabled?"":(b.dom_id=this.container_id+"_g_"+b.array_index,'<li id="'+b.dom_id+'" class="group-result">'+a("<div />").text(b.label).html()+"</li>")},b.prototype.result_do_highlight=function(a){var b,c,d,e,f;if(a.length){this.result_clear_highlight(),this.result_highlight=a,this.result_highlight.addClass("highlighted"),d=parseInt(this.search_results.css("maxHeight"),10),f=this.search_results.scrollTop(),e=d+f,c=this.result_highlight.position().top+this.search_results.scrollTop(),b=c+this.result_highlight.outerHeight();if(b>=e)return this.search_results.scrollTop(b-d>0?b-d:0);if(c<f)return this.search_results.scrollTop(c)}},b.prototype.result_clear_highlight=function(){return this.result_highlight&&this.result_highlight.removeClass("highlighted"),this.result_highlight=null},b.prototype.results_show=function(){var a;return this.is_multiple||(this.selected_item.addClass("chzn-single-with-drop"),this.result_single_selected&&this.result_do_highlight(this.result_single_selected)),a=this.is_multiple?this.container.height():this.container.height()-1,this.dropdown.css({top:a+"px",left:0}),this.results_showing=!0,this.search_field.focus(),this.search_field.val(this.search_field.val()),this.winnow_results()},b.prototype.results_hide=function(){return this.is_multiple||this.selected_item.removeClass("chzn-single-with-drop"),this.result_clear_highlight(),this.dropdown.css({left:"-9000px"}),this.results_showing=!1},b.prototype.set_tab_index=function(a){var b;if(this.form_field_jq.attr("tabindex"))return b=this.form_field_jq.attr("tabindex"),this.form_field_jq.attr("tabindex",-1),this.is_multiple?this.search_field.attr("tabindex",b):(this.selected_item.attr("tabindex",b),this.search_field.attr("tabindex",-1))},b.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"))},b.prototype.search_results_mouseup=function(b){var c;c=a(b.target).hasClass("active-result")?a(b.target):a(b.target).parents(".active-result").first();if(c.length)return this.result_highlight=c,this.result_select(b)},b.prototype.search_results_mouseover=function(b){var c;c=a(b.target).hasClass("active-result")?a(b.target):a(b.target).parents(".active-result").first();if(c)return this.result_do_highlight(c)},b.prototype.search_results_mouseout=function(b){if(a(b.target).hasClass("active-result"))return this.result_clear_highlight()},b.prototype.choices_click=function(b){b.preventDefault();if(this.active_field&&!a(b.target).hasClass("search-choice")&&!this.results_showing)return this.results_show()},b.prototype.choice_build=function(b){var c,d;return c=this.container_id+"_c_"+b.array_index,this.choices+=1,this.search_container.before('<li class="search-choice" id="'+c+'"><span>'+b.html+'</span><a href="javascript:void(0)" class="search-choice-close" rel="'+b.array_index+'"></a></li>'),d=a("#"+c).find("a").first(),d.click(g(function(a){return this.choice_destroy_link_click(a)},this))},b.prototype.choice_destroy_link_click=function(b){return b.preventDefault(),this.is_disabled?b.stopPropagation:(this.pending_destroy_click=!0,this.choice_destroy(a(b.target)))},b.prototype.choice_destroy=function(a){return this.choices-=1,this.show_search_field_default(),this.is_multiple&&this.choices>0&&this.search_field.val().length<1&&this.results_hide(),this.result_deselect(a.attr("rel")),a.parents("li").first().remove()},b.prototype.results_reset=function(b){this.form_field.options[0].selected=!0,this.selected_item.find("span").text(this.default_text),this.show_search_field_default(),a(b.target).remove(),this.form_field_jq.trigger("change");if(this.active_field)return this.results_hide()},b.prototype.result_select=function(a){var b,c,d,e;if(this.result_highlight)return b=this.result_highlight,c=b.attr("id"),this.result_clear_highlight(),this.is_multiple?this.result_deactivate(b):(this.search_results.find(".result-selected").removeClass("result-selected"),this.result_single_selected=b),b.addClass("result-selected"),e=c.substr(c.lastIndexOf("_")+1),d=this.results_data[e],d.selected=!0,this.form_field.options[d.options_index].selected=!0,this.is_multiple?this.choice_build(d):(this.selected_item.find("span").first().text(d.text),this.allow_single_deselect&&this.single_deselect_control_build()),(!a.metaKey||!this.is_multiple)&&this.results_hide(),this.search_field.val(""),this.form_field_jq.trigger("change"),this.search_field_scale()},b.prototype.result_activate=function(a){return a.addClass("active-result")},b.prototype.result_deactivate=function(a){return a.removeClass("active-result")},b.prototype.result_deselect=function(b){var c,d;return d=this.results_data[b],d.selected=!1,this.form_field.options[d.options_index].selected=!1,c=a("#"+this.container_id+"_o_"+b),c.removeClass("result-selected").addClass("active-result").show(),this.result_clear_highlight(),this.winnow_results(),this.form_field_jq.trigger("change"),this.search_field_scale()},b.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>')},b.prototype.winnow_results=function(){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r;this.no_results_clear(),i=0,j=this.search_field.val()===this.default_text?"":a("<div/>").text(a.trim(this.search_field.val())).html(),f=new RegExp("^"+j.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),m=new RegExp(j.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),r=this.results_data;for(n=0,p=r.length;n<p;n++){c=r[n];if(!c.disabled&&!c.empty)if(c.group)a("#"+c.dom_id).css("display","none");else if(!this.is_multiple||!c.selected){b=!1,h=c.dom_id,g=a("#"+h);if(f.test(c.html))b=!0,i+=1;else if(c.html.indexOf(" ")>=0||c.html.indexOf("[")===0){e=c.html.replace(/\[|\]/g,"").split(" ");if(e.length)for(o=0,q=e.length;o<q;o++)d=e[o],f.test(d)&&(b=!0,i+=1)}b?(j.length?(k=c.html.search(m),l=c.html.substr(0,k+j.length)+"</em>"+c.html.substr(k+j.length),l=l.substr(0,k)+"<em>"+l.substr(k)):l=c.html,g.html(l),this.result_activate(g),c.group_array_index!=null&&a("#"+this.results_data[c.group_array_index].dom_id).css("display","list-item")):(this.result_highlight&&h===this.result_highlight.attr("id")&&this.result_clear_highlight(),this.result_deactivate(g))}}return i<1&&j.length?this.no_results(j):this.winnow_results_set_highlight()},b.prototype.winnow_results_clear=function(){var b,c,d,e,f;this.search_field.val(""),c=this.search_results.find("li"),f=[];for(d=0,e=c.length;d<e;d++)b=c[d],b=a(b),f.push(b.hasClass("group-result")?b.css("display","auto"):!this.is_multiple||!b.hasClass("result-selected")?this.result_activate(b):void 0);return f},b.prototype.winnow_results_set_highlight=function(){var a,b;if(!this.result_highlight){b=this.is_multiple?[]:this.search_results.find(".result-selected.active-result"),a=b.length?b.first():this.search_results.find(".active-result").first();if(a!=null)return this.result_do_highlight(a)}},b.prototype.no_results=function(b){var c;return c=a('<li class="no-results">'+this.results_none_found+' "<span></span>"</li>'),c.find("span").first().html(b),this.search_results.append(c)},b.prototype.no_results_clear=function(){return this.search_results.find(".no-results").remove()},b.prototype.keydown_arrow=function(){var b,c;this.result_highlight?this.results_showing&&(c=this.result_highlight.nextAll("li.active-result").first(),c&&this.result_do_highlight(c)):(b=this.search_results.find("li.active-result").first(),b&&this.result_do_highlight(a(b)));if(!this.results_showing)return this.results_show()},b.prototype.keyup_arrow=function(){var a;if(!this.results_showing&&!this.is_multiple)return this.results_show();if(this.result_highlight)return a=this.result_highlight.prevAll("li.active-result"),a.length?this.result_do_highlight(a.first()):(this.choices>0&&this.results_hide(),this.result_clear_highlight())},b.prototype.keydown_backstroke=function(){return this.pending_backstroke?(this.choice_destroy(this.pending_backstroke.find("a").first()),this.clear_backstroke()):(this.pending_backstroke=this.search_container.siblings("li.search-choice").last(),this.pending_backstroke.addClass("search-choice-focus"))},b.prototype.clear_backstroke=function(){return this.pending_backstroke&&this.pending_backstroke.removeClass("search-choice-focus"),this.pending_backstroke=null},b.prototype.keydown_checker=function(a){var b,c;b=(c=a.which)!=null?c:a.keyCode,this.search_field_scale(),b!==8&&this.pending_backstroke&&this.clear_backstroke();switch(b){case 8:this.backstroke_length=this.search_field.val().length;break;case 9:this.results_showing&&!this.is_multiple&&this.result_select(a),this.mouse_on_container=!1;break;case 13:a.preventDefault();break;case 38:a.preventDefault(),this.keyup_arrow();break;case 40:this.keydown_arrow()}},b.prototype.search_field_scale=function(){var b,c,d,e,f,g,h,i,j;if(this.is_multiple){d=0,h=0,f="position:absolute; left: -1000px; top: -1000px; display:none;",g=["font-size","font-style","font-weight","font-family","line-height","text-transform","letter-spacing"];for(i=0,j=g.length;i<j;i++)e=g[i],f+=e+":"+this.search_field.css(e)+";";return c=a("<div />",{style:f}),c.text(this.search_field.val()),a("body").append(c),h=c.width()+25,c.remove(),h>this.f_width-10&&(h=this.f_width-10),this.search_field.css({width:h+"px"}),b=this.container.height(),this.dropdown.css({top:b+"px"})}},b.prototype.generate_random_id=function(){var b;b="sel"+this.generate_random_char()+this.generate_random_char()+this.generate_random_char();while(a("#"+b).length>0)b+=this.generate_random_char();return b},b}(),c=function(a){var b;return b=a.outerWidth()-a.width()},d.get_side_border_padding=c}.call(this)
  10 +((function(){var a;a=function(){function a(){this.options_index=0,this.parsed=[]}return a.prototype.add_node=function(a){return a.nodeName==="OPTGROUP"?this.add_group(a):this.add_option(a)},a.prototype.add_group=function(a){var b,c,d,e,f,g;b=this.parsed.length,this.parsed.push({array_index:b,group:!0,label:a.label,children:0,disabled:a.disabled}),f=a.childNodes,g=[];for(d=0,e=f.length;d<e;d++)c=f[d],g.push(this.add_option(c,b,a.disabled));return g},a.prototype.add_option=function(a,b,c){if(a.nodeName==="OPTION")return a.text!==""?(b!=null&&(this.parsed[b].children+=1),this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,value:a.value,text:a.text,html:a.innerHTML,selected:a.selected,disabled:c===!0?c:a.disabled,group_array_index:b,classes:a.className,style:a.style.cssText})):this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,empty:!0}),this.options_index+=1},a}(),a.select_to_array=function(b){var c,d,e,f,g;d=new a,g=b.childNodes;for(e=0,f=g.length;e<f;e++)c=g[e],d.add_node(c);return d.parsed},this.SelectParser=a})).call(this),function(){var a,b;b=this,a=function(){function a(a,b){this.form_field=a,this.options=b!=null?b:{},this.set_default_values(),this.is_multiple=this.form_field.multiple,this.default_text_default=this.is_multiple?"Select Some Options":"Select an Option",this.setup(),this.set_up_html(),this.register_observers(),this.finish_setup()}return a.prototype.set_default_values=function(){var a=this;return this.click_test_action=function(b){return a.test_active_click(b)},this.activate_action=function(b){return a.activate_field(b)},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.choices=0,this.results_none_found=this.options.no_results_text||"No results match"},a.prototype.mouse_enter=function(){return this.mouse_on_container=!0},a.prototype.mouse_leave=function(){return this.mouse_on_container=!1},a.prototype.input_focus=function(a){var b=this;if(!this.active_field)return setTimeout(function(){return b.container_mousedown()},50)},a.prototype.input_blur=function(a){var b=this;if(!this.mouse_on_container)return this.active_field=!1,setTimeout(function(){return b.blur_test()},100)},a.prototype.result_add_option=function(a){var b,c;return a.disabled?"":(a.dom_id=this.container_id+"_o_"+a.array_index,b=a.selected&&this.is_multiple?[]:["active-result"],a.selected&&b.push("result-selected"),a.group_array_index!=null&&b.push("group-option"),a.classes!==""&&b.push(a.classes),c=a.style.cssText!==""?' style="'+a.style+'"':"",'<li id="'+a.dom_id+'" class="'+b.join(" ")+'"'+c+">"+a.html+"</li>")},a.prototype.results_update_field=function(){return this.result_clear_highlight(),this.result_single_selected=null,this.results_build()},a.prototype.results_toggle=function(){return this.results_showing?this.results_hide():this.results_show()},a.prototype.results_search=function(a){return this.results_showing?this.winnow_results():this.results_show()},a.prototype.keyup_checker=function(a){var b,c;b=(c=a.which)!=null?c:a.keyCode,this.search_field_scale();switch(b){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:a.preventDefault();if(this.results_showing)return this.result_select(a);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()}},a.prototype.generate_field_id=function(){var a;return a=this.generate_random_id(),this.form_field.id=a,a},a.prototype.generate_random_char=function(){var a,b,c;return a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZ",c=Math.floor(Math.random()*a.length),b=a.substring(c,c+1)},a}(),b.AbstractChosen=a}.call(this),function(){var a,b,c,d,e=Object.prototype.hasOwnProperty,f=function(a,b){function d(){this.constructor=a}for(var c in b)e.call(b,c)&&(a[c]=b[c]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};d=this,a=jQuery,a.fn.extend({chosen:function(c){return!a.browser.msie||a.browser.version!=="6.0"&&a.browser.version!=="7.0"?a(this).each(function(d){if(!a(this).hasClass("chzn-done"))return new b(this,c)}):this}}),b=function(b){function e(){e.__super__.constructor.apply(this,arguments)}return f(e,b),e.prototype.setup=function(){return this.form_field_jq=a(this.form_field),this.is_rtl=this.form_field_jq.hasClass("chzn-rtl")},e.prototype.finish_setup=function(){return this.form_field_jq.addClass("chzn-done")},e.prototype.set_up_html=function(){var b,d,e,f;return this.container_id=this.form_field.id.length?this.form_field.id.replace(/(:|\.)/g,"_"):this.generate_field_id(),this.container_id+="_chzn",this.f_width=this.form_field_jq.outerWidth(),this.default_text=this.form_field_jq.data("placeholder")?this.form_field_jq.data("placeholder"):this.default_text_default,b=a("<div />",{id:this.container_id,"class":"chzn-container"+(this.is_rtl?" chzn-rtl":""),style:"width: "+this.f_width+"px;"}),this.is_multiple?b.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>'):b.html('<a href="javascript:void(0)" class="chzn-single"><span>'+this.default_text+'</span><div><b></b></div></a><div class="chzn-drop" style="left:-9000px;"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>'),this.form_field_jq.hide().after(b),this.container=a("#"+this.container_id),this.container.addClass("chzn-container-"+(this.is_multiple?"multi":"single")),this.dropdown=this.container.find("div.chzn-drop").first(),d=this.container.height(),e=this.f_width-c(this.dropdown),this.dropdown.css({width:e+"px",top:d+"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(),f=e-c(this.search_container)-c(this.search_field),this.search_field.css({width:f+"px"})),this.results_build(),this.set_tab_index(),this.form_field_jq.trigger("liszt:ready",{chosen:this})},e.prototype.register_observers=function(){var a=this;return this.container.mousedown(function(b){return a.container_mousedown(b)}),this.container.mouseup(function(b){return a.container_mouseup(b)}),this.container.mouseenter(function(b){return a.mouse_enter(b)}),this.container.mouseleave(function(b){return a.mouse_leave(b)}),this.search_results.mouseup(function(b){return a.search_results_mouseup(b)}),this.search_results.mouseover(function(b){return a.search_results_mouseover(b)}),this.search_results.mouseout(function(b){return a.search_results_mouseout(b)}),this.form_field_jq.bind("liszt:updated",function(b){return a.results_update_field(b)}),this.search_field.blur(function(b){return a.input_blur(b)}),this.search_field.keyup(function(b){return a.keyup_checker(b)}),this.search_field.keydown(function(b){return a.keydown_checker(b)}),this.is_multiple?(this.search_choices.click(function(b){return a.choices_click(b)}),this.search_field.focus(function(b){return a.input_focus(b)})):this.container.click(function(a){return a.preventDefault()})},e.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)},e.prototype.container_mousedown=function(b){var c;if(!this.is_disabled)return c=b!=null?a(b.target).hasClass("search-choice-close"):!1,b&&b.type==="mousedown"&&b.stopPropagation(),!this.pending_destroy_click&&!c?(this.active_field?!this.is_multiple&&b&&(a(b.target)[0]===this.selected_item[0]||a(b.target).parents("a.chzn-single").length)&&(b.preventDefault(),this.results_toggle()):(this.is_multiple&&this.search_field.val(""),a(document).click(this.click_test_action),this.results_show()),this.activate_field()):this.pending_destroy_click=!1},e.prototype.container_mouseup=function(a){if(a.target.nodeName==="ABBR")return this.results_reset(a)},e.prototype.blur_test=function(a){if(!this.active_field&&this.container.hasClass("chzn-container-active"))return this.close_field()},e.prototype.close_field=function(){return a(document).unbind("click",this.click_test_action),this.is_multiple||(this.selected_item.attr("tabindex",this.search_field.attr("tabindex")),this.search_field.attr("tabindex",-1)),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()},e.prototype.activate_field=function(){return!this.is_multiple&&!this.active_field&&(this.search_field.attr("tabindex",this.selected_item.attr("tabindex")),this.selected_item.attr("tabindex",-1)),this.container.addClass("chzn-container-active"),this.active_field=!0,this.search_field.val(this.search_field.val()),this.search_field.focus()},e.prototype.test_active_click=function(b){return a(b.target).parents("#"+this.container_id).length?this.active_field=!0:this.close_field()},e.prototype.results_build=function(){var a,b,c,e,f;this.parsing=!0,this.results_data=d.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.find("span").text(this.default_text),this.form_field.options.length<=this.disable_search_threshold?this.container.addClass("chzn-container-single-nosearch"):this.container.removeClass("chzn-container-single-nosearch")),a="",f=this.results_data;for(c=0,e=f.length;c<e;c++)b=f[c],b.group?a+=this.result_add_group(b):b.empty||(a+=this.result_add_option(b),b.selected&&this.is_multiple?this.choice_build(b):b.selected&&!this.is_multiple&&(this.selected_item.find("span").text(b.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(a),this.parsing=!1},e.prototype.result_add_group=function(b){return b.disabled?"":(b.dom_id=this.container_id+"_g_"+b.array_index,'<li id="'+b.dom_id+'" class="group-result">'+a("<div />").text(b.label).html()+"</li>")},e.prototype.result_do_highlight=function(a){var b,c,d,e,f;if(a.length){this.result_clear_highlight(),this.result_highlight=a,this.result_highlight.addClass("highlighted"),d=parseInt(this.search_results.css("maxHeight"),10),f=this.search_results.scrollTop(),e=d+f,c=this.result_highlight.position().top+this.search_results.scrollTop(),b=c+this.result_highlight.outerHeight();if(b>=e)return this.search_results.scrollTop(b-d>0?b-d:0);if(c<f)return this.search_results.scrollTop(c)}},e.prototype.result_clear_highlight=function(){return this.result_highlight&&this.result_highlight.removeClass("highlighted"),this.result_highlight=null},e.prototype.results_show=function(){var a;return this.is_multiple||(this.selected_item.addClass("chzn-single-with-drop"),this.result_single_selected&&this.result_do_highlight(this.result_single_selected)),a=this.is_multiple?this.container.height():this.container.height()-1,this.dropdown.css({top:a+"px",left:0}),this.results_showing=!0,this.search_field.focus(),this.search_field.val(this.search_field.val()),this.winnow_results()},e.prototype.results_hide=function(){return this.is_multiple||this.selected_item.removeClass("chzn-single-with-drop"),this.result_clear_highlight(),this.dropdown.css({left:"-9000px"}),this.results_showing=!1},e.prototype.set_tab_index=function(a){var b;if(this.form_field_jq.attr("tabindex"))return b=this.form_field_jq.attr("tabindex"),this.form_field_jq.attr("tabindex",-1),this.is_multiple?this.search_field.attr("tabindex",b):(this.selected_item.attr("tabindex",b),this.search_field.attr("tabindex",-1))},e.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"))},e.prototype.search_results_mouseup=function(b){var c;c=a(b.target).hasClass("active-result")?a(b.target):a(b.target).parents(".active-result").first();if(c.length)return this.result_highlight=c,this.result_select(b)},e.prototype.search_results_mouseover=function(b){var c;c=a(b.target).hasClass("active-result")?a(b.target):a(b.target).parents(".active-result").first();if(c)return this.result_do_highlight(c)},e.prototype.search_results_mouseout=function(b){if(a(b.target).hasClass("active-result"))return this.result_clear_highlight()},e.prototype.choices_click=function(b){b.preventDefault();if(this.active_field&&!a(b.target).hasClass("search-choice")&&!this.results_showing)return this.results_show()},e.prototype.choice_build=function(b){var c,d,e=this;return c=this.container_id+"_c_"+b.array_index,this.choices+=1,this.search_container.before('<li class="search-choice" id="'+c+'"><span>'+b.html+'</span><a href="javascript:void(0)" class="search-choice-close" rel="'+b.array_index+'"></a></li>'),d=a("#"+c).find("a").first(),d.click(function(a){return e.choice_destroy_link_click(a)})},e.prototype.choice_destroy_link_click=function(b){return b.preventDefault(),this.is_disabled?b.stopPropagation:(this.pending_destroy_click=!0,this.choice_destroy(a(b.target)))},e.prototype.choice_destroy=function(a){return this.choices-=1,this.show_search_field_default(),this.is_multiple&&this.choices>0&&this.search_field.val().length<1&&this.results_hide(),this.result_deselect(a.attr("rel")),a.parents("li").first().remove()},e.prototype.results_reset=function(b){this.form_field.options[0].selected=!0,this.selected_item.find("span").text(this.default_text),this.show_search_field_default(),a(b.target).remove(),this.form_field_jq.trigger("change");if(this.active_field)return this.results_hide()},e.prototype.result_select=function(a){var b,c,d,e;if(this.result_highlight)return b=this.result_highlight,c=b.attr("id"),this.result_clear_highlight(),this.is_multiple?this.result_deactivate(b):(this.search_results.find(".result-selected").removeClass("result-selected"),this.result_single_selected=b),b.addClass("result-selected"),e=c.substr(c.lastIndexOf("_")+1),d=this.results_data[e],d.selected=!0,this.form_field.options[d.options_index].selected=!0,this.is_multiple?this.choice_build(d):(this.selected_item.find("span").first().text(d.text),this.allow_single_deselect&&this.single_deselect_control_build()),(!a.metaKey||!this.is_multiple)&&this.results_hide(),this.search_field.val(""),this.form_field_jq.trigger("change"),this.search_field_scale()},e.prototype.result_activate=function(a){return a.addClass("active-result")},e.prototype.result_deactivate=function(a){return a.removeClass("active-result")},e.prototype.result_deselect=function(b){var c,d;return d=this.results_data[b],d.selected=!1,this.form_field.options[d.options_index].selected=!1,c=a("#"+this.container_id+"_o_"+b),c.removeClass("result-selected").addClass("active-result").show(),this.result_clear_highlight(),this.winnow_results(),this.form_field_jq.trigger("change"),this.search_field_scale()},e.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>')},e.prototype.winnow_results=function(){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r;this.no_results_clear(),i=0,j=this.search_field.val()===this.default_text?"":a("<div/>").text(a.trim(this.search_field.val())).html(),f=new RegExp("^"+j.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),m=new RegExp(j.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),r=this.results_data;for(n=0,p=r.length;n<p;n++){c=r[n];if(!c.disabled&&!c.empty)if(c.group)a("#"+c.dom_id).css("display","none");else if(!this.is_multiple||!c.selected){b=!1,h=c.dom_id,g=a("#"+h);if(f.test(c.html))b=!0,i+=1;else if(c.html.indexOf(" ")>=0||c.html.indexOf("[")===0){e=c.html.replace(/\[|\]/g,"").split(" ");if(e.length)for(o=0,q=e.length;o<q;o++)d=e[o],f.test(d)&&(b=!0,i+=1)}b?(j.length?(k=c.html.search(m),l=c.html.substr(0,k+j.length)+"</em>"+c.html.substr(k+j.length),l=l.substr(0,k)+"<em>"+l.substr(k)):l=c.html,g.html(l),this.result_activate(g),c.group_array_index!=null&&a("#"+this.results_data[c.group_array_index].dom_id).css("display","list-item")):(this.result_highlight&&h===this.result_highlight.attr("id")&&this.result_clear_highlight(),this.result_deactivate(g))}}return i<1&&j.length?this.no_results(j):this.winnow_results_set_highlight()},e.prototype.winnow_results_clear=function(){var b,c,d,e,f;this.search_field.val(""),c=this.search_results.find("li"),f=[];for(d=0,e=c.length;d<e;d++)b=c[d],b=a(b),b.hasClass("group-result")?f.push(b.css("display","auto")):!this.is_multiple||!b.hasClass("result-selected")?f.push(this.result_activate(b)):f.push(void 0);return f},e.prototype.winnow_results_set_highlight=function(){var a,b;if(!this.result_highlight){b=this.is_multiple?[]:this.search_results.find(".result-selected.active-result"),a=b.length?b.first():this.search_results.find(".active-result").first();if(a!=null)return this.result_do_highlight(a)}},e.prototype.no_results=function(b){var c;return c=a('<li class="no-results">'+this.results_none_found+' "<span></span>"</li>'),c.find("span").first().html(b),this.search_results.append(c)},e.prototype.no_results_clear=function(){return this.search_results.find(".no-results").remove()},e.prototype.keydown_arrow=function(){var b,c;this.result_highlight?this.results_showing&&(c=this.result_highlight.nextAll("li.active-result").first(),c&&this.result_do_highlight(c)):(b=this.search_results.find("li.active-result").first(),b&&this.result_do_highlight(a(b)));if(!this.results_showing)return this.results_show()},e.prototype.keyup_arrow=function(){var a;if(!this.results_showing&&!this.is_multiple)return this.results_show();if(this.result_highlight)return a=this.result_highlight.prevAll("li.active-result"),a.length?this.result_do_highlight(a.first()):(this.choices>0&&this.results_hide(),this.result_clear_highlight())},e.prototype.keydown_backstroke=function(){return this.pending_backstroke?(this.choice_destroy(this.pending_backstroke.find("a").first()),this.clear_backstroke()):(this.pending_backstroke=this.search_container.siblings("li.search-choice").last(),this.pending_backstroke.addClass("search-choice-focus"))},e.prototype.clear_backstroke=function(){return this.pending_backstroke&&this.pending_backstroke.removeClass("search-choice-focus"),this.pending_backstroke=null},e.prototype.keydown_checker=function(a){var b,c;b=(c=a.which)!=null?c:a.keyCode,this.search_field_scale(),b!==8&&this.pending_backstroke&&this.clear_backstroke();switch(b){case 8:this.backstroke_length=this.search_field.val().length;break;case 9:this.results_showing&&!this.is_multiple&&this.result_select(a),this.mouse_on_container=!1;break;case 13:a.preventDefault();break;case 38:a.preventDefault(),this.keyup_arrow();break;case 40:this.keydown_arrow()}},e.prototype.search_field_scale=function(){var b,c,d,e,f,g,h,i,j;if(this.is_multiple){d=0,h=0,f="position:absolute; left: -1000px; top: -1000px; display:none;",g=["font-size","font-style","font-weight","font-family","line-height","text-transform","letter-spacing"];for(i=0,j=g.length;i<j;i++)e=g[i],f+=e+":"+this.search_field.css(e)+";";return c=a("<div />",{style:f}),c.text(this.search_field.val()),a("body").append(c),h=c.width()+25,c.remove(),h>this.f_width-10&&(h=this.f_width-10),this.search_field.css({width:h+"px"}),b=this.container.height(),this.dropdown.css({top:b+"px"})}},e.prototype.generate_random_id=function(){var b;b="sel"+this.generate_random_char()+this.generate_random_char()+this.generate_random_char();while(a("#"+b).length>0)b+=this.generate_random_char();return b},e}(AbstractChosen),c=function(a){var b;return b=a.outerWidth()-a.width()},d.get_side_border_padding=c}.call(this)
348 chosen/chosen.proto.js
... ... @@ -1,7 +1,7 @@
1 1 // Chosen, a Select Box Enhancer for jQuery and Protoype
2 2 // by Patrick Filler for Harvest, http://getharvest.com
3 3 //
4   -// Version 0.9.6
  4 +// Version 0.9.7
5 5 // Full source at https://github.com/harvesthq/chosen
6 6 // Copyright (c) 2011 Harvest http://getharvest.com
7 7
@@ -9,11 +9,14 @@
9 9 // This file is generated by `cake build`, do not edit it by hand.
10 10 (function() {
11 11 var SelectParser;
  12 +
12 13 SelectParser = (function() {
  14 +
13 15 function SelectParser() {
14 16 this.options_index = 0;
15 17 this.parsed = [];
16 18 }
  19 +
17 20 SelectParser.prototype.add_node = function(child) {
18 21 if (child.nodeName === "OPTGROUP") {
19 22 return this.add_group(child);
@@ -21,6 +24,7 @@
21 24 return this.add_option(child);
22 25 }
23 26 };
  27 +
24 28 SelectParser.prototype.add_group = function(group) {
25 29 var group_position, option, _i, _len, _ref, _results;
26 30 group_position = this.parsed.length;
@@ -39,12 +43,11 @@
39 43 }
40 44 return _results;
41 45 };
  46 +
42 47 SelectParser.prototype.add_option = function(option, group_position, group_disabled) {
43 48 if (option.nodeName === "OPTION") {
44 49 if (option.text !== "") {
45   - if (group_position != null) {
46   - this.parsed[group_position].children += 1;
47   - }
  50 + if (group_position != null) this.parsed[group_position].children += 1;
48 51 this.parsed.push({
49 52 array_index: this.parsed.length,
50 53 options_index: this.options_index,
@@ -67,8 +70,11 @@
67 70 return this.options_index += 1;
68 71 }
69 72 };
  73 +
70 74 return SelectParser;
  75 +
71 76 })();
  77 +
72 78 SelectParser.select_to_array = function(select) {
73 79 var child, parser, _i, _len, _ref;
74 80 parser = new SelectParser();
@@ -79,17 +85,23 @@
79 85 }
80 86 return parser.parsed;
81 87 };
  88 +
82 89 this.SelectParser = SelectParser;
  90 +
83 91 }).call(this);
  92 +
  93 +/*
  94 +Chosen source: generate output using 'cake build'
  95 +Copyright (c) 2011 by Harvest
  96 +*/
  97 +
84 98 (function() {
85   - /*
86   - Chosen source: generate output using 'cake build'
87   - Copyright (c) 2011 by Harvest
88   - */
89 99 var AbstractChosen, root;
90   - var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
  100 +
91 101 root = this;
  102 +
92 103 AbstractChosen = (function() {
  104 +
93 105 function AbstractChosen(form_field, options) {
94 106 this.form_field = form_field;
95 107 this.options = options != null ? options : {};
@@ -101,13 +113,15 @@
101 113 this.register_observers();
102 114 this.finish_setup();
103 115 }
  116 +
104 117 AbstractChosen.prototype.set_default_values = function() {
105   - this.click_test_action = __bind(function(evt) {
106   - return this.test_active_click(evt);
107   - }, this);
108   - this.activate_action = __bind(function(evt) {
109   - return this.activate_field(evt);
110   - }, this);
  118 + var _this = this;
  119 + this.click_test_action = function(evt) {
  120 + return _this.test_active_click(evt);
  121 + };
  122 + this.activate_action = function(evt) {
  123 + return _this.activate_field(evt);
  124 + };
111 125 this.active_field = false;
112 126 this.mouse_on_container = false;
113 127 this.results_showing = false;
@@ -118,52 +132,55 @@
118 132 this.choices = 0;
119 133 return this.results_none_found = this.options.no_results_text || "No results match";
120 134 };
  135 +
121 136 AbstractChosen.prototype.mouse_enter = function() {
122 137 return this.mouse_on_container = true;
123 138 };
  139 +
124 140 AbstractChosen.prototype.mouse_leave = function() {
125 141 return this.mouse_on_container = false;
126 142 };
  143 +
127 144 AbstractChosen.prototype.input_focus = function(evt) {
  145 + var _this = this;
128 146 if (!this.active_field) {
129   - return setTimeout((__bind(function() {
130   - return this.container_mousedown();
131   - }, this)), 50);
  147 + return setTimeout((function() {
  148 + return _this.container_mousedown();
  149 + }), 50);
132 150 }
133 151 };
  152 +
134 153 AbstractChosen.prototype.input_blur = function(evt) {
  154 + var _this = this;
135 155 if (!this.mouse_on_container) {
136 156 this.active_field = false;
137   - return setTimeout((__bind(function() {
138   - return this.blur_test();
139   - }, this)), 100);
  157 + return setTimeout((function() {
  158 + return _this.blur_test();
  159 + }), 100);
140 160 }
141 161 };
  162 +
142 163 AbstractChosen.prototype.result_add_option = function(option) {
143 164 var classes, style;
144 165 if (!option.disabled) {
145 166 option.dom_id = this.container_id + "_o_" + option.array_index;
146 167 classes = option.selected && this.is_multiple ? [] : ["active-result"];
147   - if (option.selected) {
148   - classes.push("result-selected");
149   - }
150   - if (option.group_array_index != null) {
151   - classes.push("group-option");
152   - }
153   - if (option.classes !== "") {
154   - classes.push(option.classes);
155   - }
  168 + if (option.selected) classes.push("result-selected");
  169 + if (option.group_array_index != null) classes.push("group-option");
  170 + if (option.classes !== "") classes.push(option.classes);
156 171 style = option.style.cssText !== "" ? " style=\"" + option.style + "\"" : "";
157 172 return '<li id="' + option.dom_id + '" class="' + classes.join(' ') + '"' + style + '>' + option.html + '</li>';
158 173 } else {
159 174 return "";
160 175 }
161 176 };
  177 +
162 178 AbstractChosen.prototype.results_update_field = function() {
163 179 this.result_clear_highlight();
164 180 this.result_single_selected = null;
165 181 return this.results_build();
166 182 };
  183 +
167 184 AbstractChosen.prototype.results_toggle = function() {
168 185 if (this.results_showing) {
169 186 return this.results_hide();
@@ -171,6 +188,7 @@
171 188 return this.results_show();
172 189 }
173 190 };
  191 +
174 192 AbstractChosen.prototype.results_search = function(evt) {
175 193 if (this.results_showing) {
176 194 return this.winnow_results();
@@ -178,6 +196,7 @@
178 196 return this.results_show();
179 197 }
180 198 };
  199 +
181 200 AbstractChosen.prototype.keyup_checker = function(evt) {
182 201 var stroke, _ref;
183 202 stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
@@ -193,14 +212,10 @@
193 212 break;
194 213 case 13:
195 214 evt.preventDefault();
196   - if (this.results_showing) {
197   - return this.result_select(evt);
198   - }
  215 + if (this.results_showing) return this.result_select(evt);
199 216 break;
200 217 case 27:
201   - if (this.results_showing) {
202   - this.results_hide();
203   - }
  218 + if (this.results_showing) this.results_hide();
204 219 return true;
205 220 case 9:
206 221 case 38:
@@ -213,48 +228,57 @@
213 228 return this.results_search();
214 229 }
215 230 };
  231 +
216 232 AbstractChosen.prototype.generate_field_id = function() {
217 233 var new_id;
218 234 new_id = this.generate_random_id();
219 235 this.form_field.id = new_id;
220 236 return new_id;
221 237 };
  238 +
222 239 AbstractChosen.prototype.generate_random_char = function() {
223 240 var chars, newchar, rand;
224 241 chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZ";
225 242 rand = Math.floor(Math.random() * chars.length);
226 243 return newchar = chars.substring(rand, rand + 1);
227 244 };
  245 +
228 246 return AbstractChosen;
  247 +
229 248 })();
  249 +
230 250 root.AbstractChosen = AbstractChosen;
  251 +
231 252 }).call(this);
  253 +
  254 +/*
  255 +Chosen source: generate output using 'cake build'
  256 +Copyright (c) 2011 by Harvest
  257 +*/
  258 +
232 259 (function() {
233   - /*
234   - Chosen source: generate output using 'cake build'
235   - Copyright (c) 2011 by Harvest
236   - */
237   - var Chosen, get_side_border_padding, root;
238   - var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
239   - for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
240   - function ctor() { this.constructor = child; }
241   - ctor.prototype = parent.prototype;
242   - child.prototype = new ctor;
243   - child.__super__ = parent.prototype;
244   - return child;
245   - }, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
  260 + var Chosen, get_side_border_padding, root,
  261 + __hasProp = Object.prototype.hasOwnProperty,
  262 + __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; };
  263 +
246 264 root = this;
247   - Chosen = (function() {
248   - __extends(Chosen, AbstractChosen);
  265 +
  266 + Chosen = (function(_super) {
  267 +
  268 + __extends(Chosen, _super);
  269 +
249 270 function Chosen() {
250 271 Chosen.__super__.constructor.apply(this, arguments);
251 272 }
  273 +
252 274 Chosen.prototype.setup = function() {
253 275 return this.is_rtl = this.form_field.hasClassName("chzn-rtl");
254 276 };
  277 +
255 278 Chosen.prototype.finish_setup = function() {
256 279 return this.form_field.addClassName("chzn-done");
257 280 };
  281 +
258 282 Chosen.prototype.set_default_values = function() {