chosen-add 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in chosen-add.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 ramin keene
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # Chosen::Add
2
+
3
+ Integrates the Koenpunt jquery.chosen fork which adds create_option ability to jquery
4
+ chosen with the rails asset pipeline.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ gem 'chosen-add'
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install chosen-add
19
+
20
+ ## Usage
21
+
22
+ TODO: Write usage instructions here
23
+
24
+ ## Contributing
25
+
26
+ 1. Fork it
27
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
28
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
29
+ 4. Push to the branch (`git push origin my-new-feature`)
30
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,21 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'chosen/add/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "chosen-add"
8
+ spec.version = Chosen::Add::VERSION
9
+ spec.authors = ["ramin keene"]
10
+ spec.email = ["raminkeene@gmail.com"]
11
+ spec.description = %q{Chosen is a javascript library of select box enhancer for jQuery and Protoype. This gem integrates the Koenpunt fork which adds create_option ability to Chosen with Rails asset pipeline for easy of use.}
12
+ spec.summary = %q{Integrate the Koenpunt / create_option Chosen fork javascript library fork which allows adding options with Rails asset pipeline}
13
+ spec.homepage = "https://github.com/ramin/chosen-add"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.require_paths = ["lib", "vendor"]
18
+
19
+ spec.add_development_dependency "bundler", "~> 1.3"
20
+ spec.add_development_dependency "rake"
21
+ end
data/lib/chosen/add.rb ADDED
@@ -0,0 +1,8 @@
1
+ require "chosen/add/version"
2
+
3
+ module Chosen
4
+ module Add
5
+ class Engine < ::Rails::Engine
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ module Chosen
2
+ module Add
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,1195 @@
1
+ // BEWARE
2
+ // _,.-------.,_
3
+ // ,;~' '~;,
4
+ // ,; ;,
5
+ // ; ;
6
+ // ,' ',
7
+ // ,; ;,
8
+ // ; ; . . ; ;
9
+ // | ; ______ ______ ; |
10
+ // | `/~" ~" . "~ "~\' |
11
+ // | ~ ,-~~~^~, | ,~^~~~-, ~ |
12
+ // | | }:{ | |
13
+ // | l / | \ ! |
14
+ // .~ (__,.--" .^. "--.,__) ~.
15
+ // | ---;' / | \ `;--- |
16
+ // \__. \/^\/ .__/
17
+ // V| \ / |V
18
+ // | |T~\___!___!___/~T| |
19
+ // | |`IIII_I_I_I_IIII'| |
20
+ // | \,III I I I III,/ |
21
+ // \ `~~~~~~~~~~' /
22
+ // \ . . /
23
+ // \. ^ ./
24
+ // ^~~~^~~~^
25
+ //
26
+ // THIS IS A FORK of chosen, from :
27
+ // https://github.com/koenpunt/chosen
28
+ // and https://github.com/harvesthq/chosen/issues/166
29
+ // THE FORK ADDS THE create_option functionality
30
+ (function() {
31
+ var SelectParser;
32
+
33
+ SelectParser = (function() {
34
+ function SelectParser() {
35
+ this.options_index = 0;
36
+ this.parsed = [];
37
+ }
38
+
39
+ SelectParser.prototype.add_node = function(child) {
40
+ if (child.nodeName.toUpperCase() === "OPTGROUP") {
41
+ return this.add_group(child);
42
+ } else {
43
+ return this.add_option(child);
44
+ }
45
+ };
46
+
47
+ SelectParser.prototype.add_group = function(group) {
48
+ var group_position, option, _i, _len, _ref, _results;
49
+
50
+ group_position = this.parsed.length;
51
+ this.parsed.push({
52
+ array_index: group_position,
53
+ group: true,
54
+ label: group.label,
55
+ children: 0,
56
+ disabled: group.disabled
57
+ });
58
+ _ref = group.childNodes;
59
+ _results = [];
60
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
61
+ option = _ref[_i];
62
+ _results.push(this.add_option(option, group_position, group.disabled));
63
+ }
64
+ return _results;
65
+ };
66
+
67
+ SelectParser.prototype.add_option = function(option, group_position, group_disabled) {
68
+ if (option.nodeName.toUpperCase() === "OPTION") {
69
+ if (option.text !== "") {
70
+ if (group_position != null) {
71
+ this.parsed[group_position].children += 1;
72
+ }
73
+ this.parsed.push({
74
+ array_index: this.parsed.length,
75
+ options_index: this.options_index,
76
+ value: option.value,
77
+ text: option.text,
78
+ html: option.innerHTML,
79
+ selected: option.selected,
80
+ disabled: group_disabled === true ? group_disabled : option.disabled,
81
+ group_array_index: group_position,
82
+ classes: option.className,
83
+ style: option.style.cssText
84
+ });
85
+ } else {
86
+ this.parsed.push({
87
+ array_index: this.parsed.length,
88
+ options_index: this.options_index,
89
+ empty: true
90
+ });
91
+ }
92
+ return this.options_index += 1;
93
+ }
94
+ };
95
+
96
+ return SelectParser;
97
+
98
+ })();
99
+
100
+ SelectParser.select_to_array = function(select) {
101
+ var child, parser, _i, _len, _ref;
102
+
103
+ parser = new SelectParser();
104
+ _ref = select.childNodes;
105
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
106
+ child = _ref[_i];
107
+ parser.add_node(child);
108
+ }
109
+ return parser.parsed;
110
+ };
111
+
112
+ this.SelectParser = SelectParser;
113
+
114
+ }).call(this);
115
+ /*
116
+ Chosen source: generate output using 'cake build'
117
+ Copyright (c) 2011 by Harvest
118
+ */
119
+
120
+
121
+ (function() {
122
+ var AbstractChosen, root;
123
+
124
+ root = this;
125
+
126
+ AbstractChosen = (function() {
127
+ function AbstractChosen(form_field, options) {
128
+ this.form_field = form_field;
129
+ this.options = options != null ? options : {};
130
+ this.is_multiple = this.form_field.multiple;
131
+ this.set_default_text();
132
+ this.set_default_values();
133
+ this.setup();
134
+ this.set_up_html();
135
+ this.register_observers();
136
+ this.finish_setup();
137
+ }
138
+
139
+ AbstractChosen.prototype.set_default_values = function() {
140
+ var _this = this;
141
+
142
+ this.click_test_action = function(evt) {
143
+ return _this.test_active_click(evt);
144
+ };
145
+ this.activate_action = function(evt) {
146
+ return _this.activate_field(evt);
147
+ };
148
+ this.active_field = false;
149
+ this.mouse_on_container = false;
150
+ this.results_showing = false;
151
+ this.result_highlighted = null;
152
+ this.result_single_selected = null;
153
+ this.allow_single_deselect = (this.options.allow_single_deselect != null) && (this.form_field.options[0] != null) && this.form_field.options[0].text === "" ? this.options.allow_single_deselect : false;
154
+ this.disable_search_threshold = this.options.disable_search_threshold || 0;
155
+ this.disable_search = this.options.disable_search || false;
156
+ this.enable_split_word_search = this.options.enable_split_word_search != null ? this.options.enable_split_word_search : true;
157
+ this.search_contains = this.options.search_contains || false;
158
+ this.choices = 0;
159
+ this.single_backstroke_delete = this.options.single_backstroke_delete || false;
160
+ this.max_selected_options = this.options.max_selected_options || Infinity;
161
+ this.inherit_select_classes = this.options.inherit_select_classes || false;
162
+ this.create_option = this.options.create_option || false;
163
+ return this.persistent_create_option = this.options.persistent_create_option || false;
164
+ };
165
+
166
+ AbstractChosen.prototype.set_default_text = function() {
167
+ if (this.form_field.getAttribute("data-placeholder")) {
168
+ this.default_text = this.form_field.getAttribute("data-placeholder");
169
+ } else if (this.is_multiple) {
170
+ this.default_text = this.options.placeholder_text_multiple || this.options.placeholder_text || "Select Some Options";
171
+ } else {
172
+ this.default_text = this.options.placeholder_text_single || this.options.placeholder_text || "Select an Option";
173
+ }
174
+ this.results_none_found = this.form_field.getAttribute("data-no_results_text") || this.options.no_results_text || "No results match";
175
+ return this.create_option_text = this.form_field.getAttribute("data-create_option_text") || this.options.create_option_text || "Add option";
176
+ };
177
+
178
+ AbstractChosen.prototype.mouse_enter = function() {
179
+ return this.mouse_on_container = true;
180
+ };
181
+
182
+ AbstractChosen.prototype.mouse_leave = function() {
183
+ return this.mouse_on_container = false;
184
+ };
185
+
186
+ AbstractChosen.prototype.input_focus = function(evt) {
187
+ var _this = this;
188
+
189
+ if (this.is_multiple) {
190
+ if (!this.active_field) {
191
+ return setTimeout((function() {
192
+ return _this.container_mousedown();
193
+ }), 50);
194
+ }
195
+ } else {
196
+ if (!this.active_field) {
197
+ return this.activate_field();
198
+ }
199
+ }
200
+ };
201
+
202
+ AbstractChosen.prototype.input_blur = function(evt) {
203
+ var _this = this;
204
+
205
+ if (!this.mouse_on_container) {
206
+ this.active_field = false;
207
+ return setTimeout((function() {
208
+ return _this.blur_test();
209
+ }), 100);
210
+ }
211
+ };
212
+
213
+ AbstractChosen.prototype.result_add_option = function(option) {
214
+ var classes, style;
215
+
216
+ if (!option.disabled) {
217
+ option.dom_id = this.container_id + "_o_" + option.array_index;
218
+ classes = option.selected && this.is_multiple ? [] : ["active-result"];
219
+ if (option.selected) {
220
+ classes.push("result-selected");
221
+ }
222
+ if (option.group_array_index != null) {
223
+ classes.push("group-option");
224
+ }
225
+ if (option.classes !== "") {
226
+ classes.push(option.classes);
227
+ }
228
+ style = option.style.cssText !== "" ? " style=\"" + option.style + "\"" : "";
229
+ return '<li id="' + option.dom_id + '" class="' + classes.join(' ') + '"' + style + '>' + option.html + '</li>';
230
+ } else {
231
+ return "";
232
+ }
233
+ };
234
+
235
+ AbstractChosen.prototype.append_option = function(option) {
236
+ return this.select_append_option(option);
237
+ };
238
+
239
+ AbstractChosen.prototype.results_update_field = function() {
240
+ if (!this.is_multiple) {
241
+ this.results_reset_cleanup();
242
+ }
243
+ this.result_clear_highlight();
244
+ this.result_single_selected = null;
245
+ return this.results_build();
246
+ };
247
+
248
+ AbstractChosen.prototype.results_toggle = function() {
249
+ if (this.results_showing) {
250
+ return this.results_hide();
251
+ } else {
252
+ return this.results_show();
253
+ }
254
+ };
255
+
256
+ AbstractChosen.prototype.results_search = function(evt) {
257
+ if (this.results_showing) {
258
+ return this.winnow_results();
259
+ } else {
260
+ return this.results_show();
261
+ }
262
+ };
263
+
264
+ AbstractChosen.prototype.keyup_checker = function(evt) {
265
+ var stroke, _ref;
266
+
267
+ stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
268
+ this.search_field_scale();
269
+ switch (stroke) {
270
+ case 8:
271
+ if (this.is_multiple && this.backstroke_length < 1 && this.choices > 0) {
272
+ return this.keydown_backstroke();
273
+ } else if (!this.pending_backstroke) {
274
+ this.result_clear_highlight();
275
+ return this.results_search();
276
+ }
277
+ break;
278
+ case 13:
279
+ evt.preventDefault();
280
+ if (this.results_showing) {
281
+ return this.result_select(evt);
282
+ }
283
+ break;
284
+ case 27:
285
+ if (this.results_showing) {
286
+ this.results_hide();
287
+ }
288
+ return true;
289
+ case 9:
290
+ case 38:
291
+ case 40:
292
+ case 16:
293
+ case 91:
294
+ case 17:
295
+ break;
296
+ default:
297
+ return this.results_search();
298
+ }
299
+ };
300
+
301
+ AbstractChosen.prototype.generate_field_id = function() {
302
+ var new_id;
303
+
304
+ new_id = this.generate_random_id();
305
+ this.form_field.id = new_id;
306
+ return new_id;
307
+ };
308
+
309
+ AbstractChosen.prototype.generate_random_char = function() {
310
+ var chars, newchar, rand;
311
+
312
+ chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
313
+ rand = Math.floor(Math.random() * chars.length);
314
+ return newchar = chars.substring(rand, rand + 1);
315
+ };
316
+
317
+ return AbstractChosen;
318
+
319
+ })();
320
+
321
+ root.AbstractChosen = AbstractChosen;
322
+
323
+ }).call(this);
324
+ /*
325
+ Chosen source: generate output using 'cake build'
326
+ Copyright (c) 2011 by Harvest
327
+ */
328
+
329
+
330
+ (function() {
331
+ var $, Chosen, get_side_border_padding, root, _ref,
332
+ __hasProp = {}.hasOwnProperty,
333
+ __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; };
334
+
335
+ root = this;
336
+
337
+ $ = jQuery;
338
+
339
+ $.fn.extend({
340
+ chosen: function(options) {
341
+ var browser, match, ua;
342
+
343
+ ua = navigator.userAgent.toLowerCase();
344
+ match = /(msie) ([\w.]+)/.exec(ua) || [];
345
+ browser = {
346
+ name: match[1] || "",
347
+ version: match[2] || "0"
348
+ };
349
+ if (browser.name === "msie" && (browser.version === "6.0" || (browser.version === "7.0" && document.documentMode === 7))) {
350
+ return this;
351
+ }
352
+ return this.each(function(input_field) {
353
+ var $this;
354
+
355
+ $this = $(this);
356
+ if (!$this.hasClass("chzn-done")) {
357
+ return $this.data('chosen', new Chosen(this, options));
358
+ }
359
+ });
360
+ }
361
+ });
362
+
363
+ Chosen = (function(_super) {
364
+ __extends(Chosen, _super);
365
+
366
+ function Chosen() {
367
+ _ref = Chosen.__super__.constructor.apply(this, arguments);
368
+ return _ref;
369
+ }
370
+
371
+ Chosen.prototype.setup = function() {
372
+ this.form_field_jq = $(this.form_field);
373
+ this.current_value = this.form_field_jq.val();
374
+ return this.is_rtl = this.form_field_jq.hasClass("chzn-rtl");
375
+ };
376
+
377
+ Chosen.prototype.finish_setup = function() {
378
+ return this.form_field_jq.addClass("chzn-done");
379
+ };
380
+
381
+ Chosen.prototype.set_up_html = function() {
382
+ var container_classes, container_div, container_props, dd_top, dd_width, sf_width;
383
+
384
+ this.container_id = this.form_field.id.length ? this.form_field.id.replace(/[^\w]/g, '_') : this.generate_field_id();
385
+ this.container_id += "_chzn";
386
+ container_classes = ["chzn-container"];
387
+ container_classes.push("chzn-container-" + (this.is_multiple ? "multi" : "single"));
388
+ if (this.inherit_select_classes && this.form_field.className) {
389
+ container_classes.push(this.form_field.className);
390
+ }
391
+ if (this.is_rtl) {
392
+ container_classes.push("chzn-rtl");
393
+ }
394
+ this.f_width = this.form_field_jq.outerWidth();
395
+ container_props = {
396
+ id: this.container_id,
397
+ "class": container_classes.join(' '),
398
+ style: 'width: ' + this.f_width + 'px;',
399
+ title: this.form_field.title
400
+ };
401
+ container_div = $("<div />", container_props);
402
+ if (this.is_multiple) {
403
+ 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>');
404
+ } else {
405
+ 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>');
406
+ }
407
+ this.form_field_jq.hide().after(container_div);
408
+ this.container = $('#' + this.container_id);
409
+ this.dropdown = this.container.find('div.chzn-drop').first();
410
+ dd_top = this.container.height();
411
+ dd_width = this.f_width - get_side_border_padding(this.dropdown);
412
+ this.dropdown.css({
413
+ "width": dd_width + "px",
414
+ "top": dd_top + "px"
415
+ });
416
+ this.search_field = this.container.find('input').first();
417
+ this.search_results = this.container.find('ul.chzn-results').first();
418
+ this.search_field_scale();
419
+ this.search_no_results = this.container.find('li.no-results').first();
420
+ if (this.is_multiple) {
421
+ this.search_choices = this.container.find('ul.chzn-choices').first();
422
+ this.search_container = this.container.find('li.search-field').first();
423
+ } else {
424
+ this.search_container = this.container.find('div.chzn-search').first();
425
+ this.selected_item = this.container.find('.chzn-single').first();
426
+ sf_width = dd_width - get_side_border_padding(this.search_container) - get_side_border_padding(this.search_field);
427
+ this.search_field.css({
428
+ "width": sf_width + "px"
429
+ });
430
+ }
431
+ this.results_build();
432
+ this.set_tab_index();
433
+ return this.form_field_jq.trigger("liszt:ready", {
434
+ chosen: this
435
+ });
436
+ };
437
+
438
+ Chosen.prototype.register_observers = function() {
439
+ var _this = this;
440
+
441
+ this.container.mousedown(function(evt) {
442
+ _this.container_mousedown(evt);
443
+ });
444
+ this.container.mouseup(function(evt) {
445
+ _this.container_mouseup(evt);
446
+ });
447
+ this.container.mouseenter(function(evt) {
448
+ _this.mouse_enter(evt);
449
+ });
450
+ this.container.mouseleave(function(evt) {
451
+ _this.mouse_leave(evt);
452
+ });
453
+ this.search_results.mouseup(function(evt) {
454
+ _this.search_results_mouseup(evt);
455
+ });
456
+ this.search_results.mouseover(function(evt) {
457
+ _this.search_results_mouseover(evt);
458
+ });
459
+ this.search_results.mouseout(function(evt) {
460
+ _this.search_results_mouseout(evt);
461
+ });
462
+ this.form_field_jq.bind("liszt:updated", function(evt) {
463
+ _this.results_update_field(evt);
464
+ });
465
+ this.form_field_jq.bind("liszt:activate", function(evt) {
466
+ _this.activate_field(evt);
467
+ });
468
+ this.form_field_jq.bind("liszt:open", function(evt) {
469
+ _this.container_mousedown(evt);
470
+ });
471
+ this.search_field.blur(function(evt) {
472
+ _this.input_blur(evt);
473
+ });
474
+ this.search_field.keyup(function(evt) {
475
+ _this.keyup_checker(evt);
476
+ });
477
+ this.search_field.keydown(function(evt) {
478
+ _this.keydown_checker(evt);
479
+ });
480
+ this.search_field.focus(function(evt) {
481
+ _this.input_focus(evt);
482
+ });
483
+ if (this.is_multiple) {
484
+ return this.search_choices.click(function(evt) {
485
+ _this.choices_click(evt);
486
+ });
487
+ } else {
488
+ return this.container.click(function(evt) {
489
+ evt.preventDefault();
490
+ });
491
+ }
492
+ };
493
+
494
+ Chosen.prototype.search_field_disabled = function() {
495
+ this.is_disabled = this.form_field_jq[0].disabled;
496
+ if (this.is_disabled) {
497
+ this.container.addClass('chzn-disabled');
498
+ this.search_field[0].disabled = true;
499
+ if (!this.is_multiple) {
500
+ this.selected_item.unbind("focus", this.activate_action);
501
+ }
502
+ return this.close_field();
503
+ } else {
504
+ this.container.removeClass('chzn-disabled');
505
+ this.search_field[0].disabled = false;
506
+ if (!this.is_multiple) {
507
+ return this.selected_item.bind("focus", this.activate_action);
508
+ }
509
+ }
510
+ };
511
+
512
+ Chosen.prototype.container_mousedown = function(evt) {
513
+ var target_closelink;
514
+
515
+ if (!this.is_disabled) {
516
+ target_closelink = evt != null ? ($(evt.target)).hasClass("search-choice-close") : false;
517
+ if (evt && evt.type === "mousedown" && !this.results_showing) {
518
+ evt.preventDefault();
519
+ }
520
+ if (!this.pending_destroy_click && !target_closelink) {
521
+ if (!this.active_field) {
522
+ if (this.is_multiple) {
523
+ this.search_field.val("");
524
+ }
525
+ $(document).click(this.click_test_action);
526
+ this.results_show();
527
+ } else if (!this.is_multiple && evt && (($(evt.target)[0] === this.selected_item[0]) || $(evt.target).parents("a.chzn-single").length)) {
528
+ evt.preventDefault();
529
+ this.results_toggle();
530
+ }
531
+ return this.activate_field();
532
+ } else {
533
+ return this.pending_destroy_click = false;
534
+ }
535
+ }
536
+ };
537
+
538
+ Chosen.prototype.container_mouseup = function(evt) {
539
+ if (evt.target.nodeName === "ABBR" && !this.is_disabled) {
540
+ return this.results_reset(evt);
541
+ }
542
+ };
543
+
544
+ Chosen.prototype.blur_test = function(evt) {
545
+ if (!this.active_field && this.container.hasClass("chzn-container-active")) {
546
+ return this.close_field();
547
+ }
548
+ };
549
+
550
+ Chosen.prototype.close_field = function() {
551
+ $(document).unbind("click", this.click_test_action);
552
+ this.active_field = false;
553
+ this.results_hide();
554
+ this.container.removeClass("chzn-container-active");
555
+ this.winnow_results_clear();
556
+ this.clear_backstroke();
557
+ this.show_search_field_default();
558
+ return this.search_field_scale();
559
+ };
560
+
561
+ Chosen.prototype.activate_field = function() {
562
+ this.container.addClass("chzn-container-active");
563
+ this.active_field = true;
564
+ this.search_field.val(this.search_field.val());
565
+ return this.search_field.focus();
566
+ };
567
+
568
+ Chosen.prototype.test_active_click = function(evt) {
569
+ if ($(evt.target).parents('#' + this.container_id).length) {
570
+ return this.active_field = true;
571
+ } else {
572
+ return this.close_field();
573
+ }
574
+ };
575
+
576
+ Chosen.prototype.results_build = function() {
577
+ var content, data, _i, _len, _ref1;
578
+
579
+ this.parsing = true;
580
+ this.results_data = root.SelectParser.select_to_array(this.form_field);
581
+ if (this.is_multiple && this.choices > 0) {
582
+ this.search_choices.find("li.search-choice").remove();
583
+ this.choices = 0;
584
+ } else if (!this.is_multiple) {
585
+ this.selected_item.addClass("chzn-default").find("span").text(this.default_text);
586
+ if (this.create_option && !this.disable_search) {
587
+ this.container.removeClass("chzn-container-single-nosearch");
588
+ } else if (this.disable_search || this.form_field.options.length <= this.disable_search_threshold) {
589
+ this.container.addClass("chzn-container-single-nosearch");
590
+ }
591
+ }
592
+ content = '';
593
+ _ref1 = this.results_data;
594
+ for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
595
+ data = _ref1[_i];
596
+ if (data.group) {
597
+ content += this.result_add_group(data);
598
+ } else if (!data.empty) {
599
+ content += this.result_add_option(data);
600
+ if (data.selected && this.is_multiple) {
601
+ this.choice_build(data);
602
+ } else if (data.selected && !this.is_multiple) {
603
+ this.selected_item.removeClass("chzn-default").find("span").text(data.text);
604
+ if (this.allow_single_deselect) {
605
+ this.single_deselect_control_build();
606
+ }
607
+ }
608
+ }
609
+ }
610
+ this.search_field_disabled();
611
+ this.show_search_field_default();
612
+ this.search_field_scale();
613
+ this.search_results.html(content);
614
+ return this.parsing = false;
615
+ };
616
+
617
+ Chosen.prototype.result_add_group = function(group) {
618
+ if (!group.disabled) {
619
+ group.dom_id = this.container_id + "_g_" + group.array_index;
620
+ return '<li id="' + group.dom_id + '" class="group-result">' + $("<div />").text(group.label).html() + '</li>';
621
+ } else {
622
+ return "";
623
+ }
624
+ };
625
+
626
+ Chosen.prototype.result_do_highlight = function(el) {
627
+ var high_bottom, high_top, maxHeight, visible_bottom, visible_top;
628
+
629
+ if (el.length) {
630
+ this.result_clear_highlight();
631
+ this.result_highlight = el;
632
+ this.result_highlight.addClass("highlighted");
633
+ maxHeight = parseInt(this.search_results.css("maxHeight"), 10);
634
+ visible_top = this.search_results.scrollTop();
635
+ visible_bottom = maxHeight + visible_top;
636
+ high_top = this.result_highlight.position().top + this.search_results.scrollTop();
637
+ high_bottom = high_top + this.result_highlight.outerHeight();
638
+ if (high_bottom >= visible_bottom) {
639
+ return this.search_results.scrollTop((high_bottom - maxHeight) > 0 ? high_bottom - maxHeight : 0);
640
+ } else if (high_top < visible_top) {
641
+ return this.search_results.scrollTop(high_top);
642
+ }
643
+ }
644
+ };
645
+
646
+ Chosen.prototype.result_clear_highlight = function() {
647
+ if (this.result_highlight) {
648
+ this.result_highlight.removeClass("highlighted");
649
+ }
650
+ return this.result_highlight = null;
651
+ };
652
+
653
+ Chosen.prototype.results_show = function() {
654
+ var dd_top;
655
+
656
+ if (!this.is_multiple) {
657
+ this.selected_item.addClass("chzn-single-with-drop");
658
+ if (this.result_single_selected) {
659
+ this.result_do_highlight(this.result_single_selected);
660
+ }
661
+ } else if (this.max_selected_options <= this.choices) {
662
+ this.form_field_jq.trigger("liszt:maxselected", {
663
+ chosen: this
664
+ });
665
+ return false;
666
+ }
667
+ dd_top = this.is_multiple ? this.container.height() : this.container.height() - 1;
668
+ this.form_field_jq.trigger("liszt:showing_dropdown", {
669
+ chosen: this
670
+ });
671
+ this.dropdown.css({
672
+ "top": dd_top + "px",
673
+ "left": 0
674
+ });
675
+ this.results_showing = true;
676
+ this.search_field.focus();
677
+ this.search_field.val(this.search_field.val());
678
+ return this.winnow_results();
679
+ };
680
+
681
+ Chosen.prototype.results_hide = function() {
682
+ if (!this.is_multiple) {
683
+ this.selected_item.removeClass("chzn-single-with-drop");
684
+ }
685
+ this.result_clear_highlight();
686
+ this.form_field_jq.trigger("liszt:hiding_dropdown", {
687
+ chosen: this
688
+ });
689
+ this.dropdown.css({
690
+ "left": "-9000px"
691
+ });
692
+ return this.results_showing = false;
693
+ };
694
+
695
+ Chosen.prototype.set_tab_index = function(el) {
696
+ var ti;
697
+
698
+ if (this.form_field_jq.attr("tabindex")) {
699
+ ti = this.form_field_jq.attr("tabindex");
700
+ this.form_field_jq.attr("tabindex", -1);
701
+ return this.search_field.attr("tabindex", ti);
702
+ }
703
+ };
704
+
705
+ Chosen.prototype.show_search_field_default = function() {
706
+ if (this.is_multiple && this.choices < 1 && !this.active_field) {
707
+ this.search_field.val(this.default_text);
708
+ return this.search_field.addClass("default");
709
+ } else {
710
+ this.search_field.val("");
711
+ return this.search_field.removeClass("default");
712
+ }
713
+ };
714
+
715
+ Chosen.prototype.search_results_mouseup = function(evt) {
716
+ var target;
717
+
718
+ target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
719
+ if (target.length) {
720
+ this.result_highlight = target;
721
+ this.result_select(evt);
722
+ return this.search_field.focus();
723
+ }
724
+ };
725
+
726
+ Chosen.prototype.search_results_mouseover = function(evt) {
727
+ var target;
728
+
729
+ target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
730
+ if (target) {
731
+ return this.result_do_highlight(target);
732
+ }
733
+ };
734
+
735
+ Chosen.prototype.search_results_mouseout = function(evt) {
736
+ if ($(evt.target).hasClass("active-result" || $(evt.target).parents('.active-result').first())) {
737
+ return this.result_clear_highlight();
738
+ }
739
+ };
740
+
741
+ Chosen.prototype.choices_click = function(evt) {
742
+ evt.preventDefault();
743
+ if (this.active_field && !($(evt.target).hasClass("search-choice" || $(evt.target).parents('.search-choice').first)) && !this.results_showing) {
744
+ return this.results_show();
745
+ }
746
+ };
747
+
748
+ Chosen.prototype.choice_build = function(item) {
749
+ var choice_id, html, link,
750
+ _this = this;
751
+
752
+ if (this.is_multiple && this.max_selected_options <= this.choices) {
753
+ this.form_field_jq.trigger("liszt:maxselected", {
754
+ chosen: this
755
+ });
756
+ return false;
757
+ }
758
+ choice_id = this.container_id + "_c_" + item.array_index;
759
+ this.choices += 1;
760
+ if (item.disabled) {
761
+ html = '<li class="search-choice search-choice-disabled" id="' + choice_id + '"><span>' + item.html + '</span></li>';
762
+ } else {
763
+ html = '<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>';
764
+ }
765
+ this.search_container.before(html);
766
+ link = $('#' + choice_id).find("a").first();
767
+ return link.click(function(evt) {
768
+ return _this.choice_destroy_link_click(evt);
769
+ });
770
+ };
771
+
772
+ Chosen.prototype.choice_destroy_link_click = function(evt) {
773
+ evt.preventDefault();
774
+ if (!this.is_disabled) {
775
+ this.pending_destroy_click = true;
776
+ return this.choice_destroy($(evt.target));
777
+ } else {
778
+ return evt.stopPropagation;
779
+ }
780
+ };
781
+
782
+ Chosen.prototype.choice_destroy = function(link) {
783
+ if (this.result_deselect(link.attr("rel"))) {
784
+ this.choices -= 1;
785
+ this.show_search_field_default();
786
+ if (this.is_multiple && this.choices > 0 && this.search_field.val().length < 1) {
787
+ this.results_hide();
788
+ }
789
+ link.parents('li').first().remove();
790
+ return this.search_field_scale();
791
+ }
792
+ };
793
+
794
+ Chosen.prototype.results_reset = function() {
795
+ this.form_field.options[0].selected = true;
796
+ this.selected_item.find("span").text(this.default_text);
797
+ if (!this.is_multiple) {
798
+ this.selected_item.addClass("chzn-default");
799
+ }
800
+ this.show_search_field_default();
801
+ this.results_reset_cleanup();
802
+ this.form_field_jq.trigger("change");
803
+ if (this.active_field) {
804
+ return this.results_hide();
805
+ }
806
+ };
807
+
808
+ Chosen.prototype.results_reset_cleanup = function() {
809
+ this.current_value = this.form_field_jq.val();
810
+ return this.selected_item.find("abbr").remove();
811
+ };
812
+
813
+ Chosen.prototype.result_select = function(evt) {
814
+ var high, high_id, item, position;
815
+
816
+ if (this.result_highlight) {
817
+ high = this.result_highlight;
818
+ if (high.hasClass('create-option')) {
819
+ this.select_create_option(this.search_field.val());
820
+ return this.results_hide();
821
+ }
822
+ high_id = high.attr("id");
823
+ this.result_clear_highlight();
824
+ if (this.is_multiple) {
825
+ this.result_deactivate(high);
826
+ } else {
827
+ this.search_results.find(".result-selected").removeClass("result-selected");
828
+ this.result_single_selected = high;
829
+ this.selected_item.removeClass("chzn-default");
830
+ }
831
+ high.addClass("result-selected");
832
+ position = high_id.substr(high_id.lastIndexOf("_") + 1);
833
+ item = this.results_data[position];
834
+ item.selected = true;
835
+ this.form_field.options[item.options_index].selected = true;
836
+ if (this.is_multiple) {
837
+ this.choice_build(item);
838
+ } else {
839
+ this.selected_item.find("span").first().text(item.text);
840
+ if (this.allow_single_deselect) {
841
+ this.single_deselect_control_build();
842
+ }
843
+ }
844
+ if (!((evt.metaKey || evt.ctrlKey) && this.is_multiple)) {
845
+ this.results_hide();
846
+ }
847
+ this.search_field.val("");
848
+ if (this.is_multiple || this.form_field_jq.val() !== this.current_value) {
849
+ this.form_field_jq.trigger("change", {
850
+ 'selected': this.form_field.options[item.options_index].value
851
+ });
852
+ }
853
+ this.current_value = this.form_field_jq.val();
854
+ return this.search_field_scale();
855
+ }
856
+ };
857
+
858
+ Chosen.prototype.result_activate = function(el) {
859
+ return el.addClass("active-result");
860
+ };
861
+
862
+ Chosen.prototype.result_deactivate = function(el) {
863
+ return el.removeClass("active-result");
864
+ };
865
+
866
+ Chosen.prototype.result_deselect = function(pos) {
867
+ var result, result_data;
868
+
869
+ result_data = this.results_data[pos];
870
+ if (!this.form_field.options[result_data.options_index].disabled) {
871
+ result_data.selected = false;
872
+ this.form_field.options[result_data.options_index].selected = false;
873
+ result = $("#" + this.container_id + "_o_" + pos);
874
+ result.removeClass("result-selected").addClass("active-result").show();
875
+ this.result_clear_highlight();
876
+ this.winnow_results();
877
+ this.form_field_jq.trigger("change", {
878
+ deselected: this.form_field.options[result_data.options_index].value
879
+ });
880
+ this.search_field_scale();
881
+ return true;
882
+ } else {
883
+ return false;
884
+ }
885
+ };
886
+
887
+ Chosen.prototype.single_deselect_control_build = function() {
888
+ if (this.allow_single_deselect && this.selected_item.find("abbr").length < 1) {
889
+ return this.selected_item.find("span").first().after("<abbr class=\"search-choice-close\"></abbr>");
890
+ }
891
+ };
892
+
893
+ Chosen.prototype.winnow_results = function() {
894
+ var eregex, exact_result, found, option, part, parts, regex, regexAnchor, result, result_id, results, searchText, startpos, text, zregex, _i, _j, _len, _len1, _ref1;
895
+
896
+ this.no_results_clear();
897
+ this.create_option_clear();
898
+ results = 0;
899
+ searchText = this.search_field.val() === this.default_text ? "" : $('<div/>').text($.trim(this.search_field.val())).html();
900
+ regexAnchor = this.search_contains ? "" : "^";
901
+ regex = new RegExp(regexAnchor + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
902
+ zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
903
+ eregex = new RegExp('^' + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&") + '$', 'i');
904
+ exact_result = false;
905
+ _ref1 = this.results_data;
906
+ for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
907
+ option = _ref1[_i];
908
+ if (!option.disabled && !option.empty) {
909
+ if (option.group) {
910
+ $('#' + option.dom_id).css('display', 'none');
911
+ } else if (!(this.is_multiple && option.selected)) {
912
+ found = false;
913
+ result_id = option.dom_id;
914
+ result = $("#" + result_id);
915
+ if (regex.test(option.html)) {
916
+ found = true;
917
+ results += 1;
918
+ if (eregex.test(option.html)) {
919
+ exact_result = true;
920
+ }
921
+ } else if (this.enable_split_word_search && (option.html.indexOf(" ") >= 0 || option.html.indexOf("[") === 0)) {
922
+ parts = option.html.replace(/\[|\]/g, "").split(" ");
923
+ if (parts.length) {
924
+ for (_j = 0, _len1 = parts.length; _j < _len1; _j++) {
925
+ part = parts[_j];
926
+ if (regex.test(part)) {
927
+ found = true;
928
+ results += 1;
929
+ }
930
+ }
931
+ }
932
+ }
933
+ if (found) {
934
+ if (searchText.length) {
935
+ startpos = option.html.search(zregex);
936
+ text = option.html.substr(0, startpos + searchText.length) + '</em>' + option.html.substr(startpos + searchText.length);
937
+ text = text.substr(0, startpos) + '<em>' + text.substr(startpos);
938
+ } else {
939
+ text = option.html;
940
+ }
941
+ result.html(text);
942
+ this.result_activate(result);
943
+ if (option.group_array_index != null) {
944
+ $("#" + this.results_data[option.group_array_index].dom_id).css('display', 'list-item');
945
+ }
946
+ } else {
947
+ if (this.result_highlight && result_id === this.result_highlight.attr('id')) {
948
+ this.result_clear_highlight();
949
+ }
950
+ this.result_deactivate(result);
951
+ }
952
+ }
953
+ }
954
+ }
955
+ if (results < 1 && searchText.length) {
956
+ return this.no_results(searchText);
957
+ } else {
958
+ if (this.create_option && !exact_result && this.persistent_create_option && searchText.length) {
959
+ this.show_create_option(searchText);
960
+ }
961
+ return this.winnow_results_set_highlight();
962
+ }
963
+ };
964
+
965
+ Chosen.prototype.winnow_results_clear = function() {
966
+ var li, lis, _i, _len, _results;
967
+
968
+ this.search_field.val("");
969
+ lis = this.search_results.find("li");
970
+ _results = [];
971
+ for (_i = 0, _len = lis.length; _i < _len; _i++) {
972
+ li = lis[_i];
973
+ li = $(li);
974
+ if (li.hasClass("group-result")) {
975
+ _results.push(li.css('display', 'auto'));
976
+ } else if (!this.is_multiple || !li.hasClass("result-selected")) {
977
+ _results.push(this.result_activate(li));
978
+ } else {
979
+ _results.push(void 0);
980
+ }
981
+ }
982
+ return _results;
983
+ };
984
+
985
+ Chosen.prototype.winnow_results_set_highlight = function() {
986
+ var do_high, selected_results;
987
+
988
+ if (!this.result_highlight) {
989
+ selected_results = !this.is_multiple ? this.search_results.find(".result-selected.active-result") : [];
990
+ do_high = selected_results.length ? selected_results.first() : this.search_results.find(".active-result").first();
991
+ if (do_high != null) {
992
+ return this.result_do_highlight(do_high);
993
+ }
994
+ }
995
+ };
996
+
997
+ Chosen.prototype.no_results = function(terms) {
998
+ var no_results_html;
999
+
1000
+ no_results_html = $('<li class="no-results">' + this.results_none_found + ' "<span></span>"</li>');
1001
+ no_results_html.find("span").first().html(terms);
1002
+ this.search_results.append(no_results_html);
1003
+ if (this.create_option) {
1004
+ return this.show_create_option(terms);
1005
+ }
1006
+ };
1007
+
1008
+ Chosen.prototype.show_create_option = function(terms) {
1009
+ var create_option_html;
1010
+
1011
+ create_option_html = $('<li class="create-option active-result"><a href="javascript:void(0);">' + this.create_option_text + '</a>: "' + terms + '"</li>');
1012
+ return this.search_results.append(create_option_html);
1013
+ };
1014
+
1015
+ Chosen.prototype.create_option_clear = function() {
1016
+ return this.search_results.find(".create-option").remove();
1017
+ };
1018
+
1019
+ Chosen.prototype.select_create_option = function(terms) {
1020
+ if ($.isFunction(this.create_option)) {
1021
+ return this.create_option.call(this, terms);
1022
+ } else {
1023
+ return this.select_append_option({
1024
+ value: terms,
1025
+ text: terms
1026
+ });
1027
+ }
1028
+ };
1029
+
1030
+ Chosen.prototype.select_append_option = function(options) {
1031
+ var attributes, option;
1032
+
1033
+ attributes = $.extend({}, options, {
1034
+ selected: 1
1035
+ });
1036
+ option = $('<option />', attributes);
1037
+ this.form_field_jq.append(option);
1038
+ return this.form_field_jq.trigger("liszt:updated");
1039
+ };
1040
+
1041
+ Chosen.prototype.no_results_clear = function() {
1042
+ return this.search_results.find(".no-results").remove();
1043
+ };
1044
+
1045
+ Chosen.prototype.keydown_arrow = function() {
1046
+ var first_active, next_sib;
1047
+
1048
+ if (!this.result_highlight) {
1049
+ first_active = this.search_results.find("li.active-result").first();
1050
+ if (first_active) {
1051
+ this.result_do_highlight($(first_active));
1052
+ }
1053
+ } else if (this.results_showing) {
1054
+ next_sib = this.result_highlight.nextAll("li.active-result").first();
1055
+ if (next_sib) {
1056
+ this.result_do_highlight(next_sib);
1057
+ }
1058
+ }
1059
+ if (!this.results_showing) {
1060
+ return this.results_show();
1061
+ }
1062
+ };
1063
+
1064
+ Chosen.prototype.keyup_arrow = function() {
1065
+ var prev_sibs;
1066
+
1067
+ if (!this.results_showing && !this.is_multiple) {
1068
+ return this.results_show();
1069
+ } else if (this.result_highlight) {
1070
+ prev_sibs = this.result_highlight.prevAll("li.active-result");
1071
+ if (prev_sibs.length) {
1072
+ return this.result_do_highlight(prev_sibs.first());
1073
+ } else {
1074
+ if (this.choices > 0) {
1075
+ this.results_hide();
1076
+ }
1077
+ return this.result_clear_highlight();
1078
+ }
1079
+ }
1080
+ };
1081
+
1082
+ Chosen.prototype.keydown_backstroke = function() {
1083
+ var next_available_destroy;
1084
+
1085
+ if (this.pending_backstroke) {
1086
+ this.choice_destroy(this.pending_backstroke.find("a").first());
1087
+ return this.clear_backstroke();
1088
+ } else {
1089
+ next_available_destroy = this.search_container.siblings("li.search-choice").last();
1090
+ if (next_available_destroy.length && !next_available_destroy.hasClass("search-choice-disabled")) {
1091
+ this.pending_backstroke = next_available_destroy;
1092
+ if (this.single_backstroke_delete) {
1093
+ return this.keydown_backstroke();
1094
+ } else {
1095
+ return this.pending_backstroke.addClass("search-choice-focus");
1096
+ }
1097
+ }
1098
+ }
1099
+ };
1100
+
1101
+ Chosen.prototype.clear_backstroke = function() {
1102
+ if (this.pending_backstroke) {
1103
+ this.pending_backstroke.removeClass("search-choice-focus");
1104
+ }
1105
+ return this.pending_backstroke = null;
1106
+ };
1107
+
1108
+ Chosen.prototype.keydown_checker = function(evt) {
1109
+ var stroke, _ref1;
1110
+
1111
+ stroke = (_ref1 = evt.which) != null ? _ref1 : evt.keyCode;
1112
+ this.search_field_scale();
1113
+ if (stroke !== 8 && this.pending_backstroke) {
1114
+ this.clear_backstroke();
1115
+ }
1116
+ switch (stroke) {
1117
+ case 8:
1118
+ this.backstroke_length = this.search_field.val().length;
1119
+ break;
1120
+ case 9:
1121
+ if (this.results_showing && !this.is_multiple) {
1122
+ this.result_select(evt);
1123
+ }
1124
+ this.mouse_on_container = false;
1125
+ break;
1126
+ case 13:
1127
+ evt.preventDefault();
1128
+ break;
1129
+ case 38:
1130
+ evt.preventDefault();
1131
+ this.keyup_arrow();
1132
+ break;
1133
+ case 40:
1134
+ this.keydown_arrow();
1135
+ break;
1136
+ }
1137
+ };
1138
+
1139
+ Chosen.prototype.search_field_scale = function() {
1140
+ var dd_top, div, h, style, style_block, styles, w, _i, _len;
1141
+
1142
+ if (this.is_multiple) {
1143
+ h = 0;
1144
+ w = 0;
1145
+ style_block = "position:absolute; left: -1000px; top: -1000px; display:none;";
1146
+ styles = ['font-size', 'font-style', 'font-weight', 'font-family', 'line-height', 'text-transform', 'letter-spacing'];
1147
+ for (_i = 0, _len = styles.length; _i < _len; _i++) {
1148
+ style = styles[_i];
1149
+ style_block += style + ":" + this.search_field.css(style) + ";";
1150
+ }
1151
+ div = $('<div />', {
1152
+ 'style': style_block
1153
+ });
1154
+ div.text(this.search_field.val());
1155
+ $('body').append(div);
1156
+ w = div.width() + 25;
1157
+ div.remove();
1158
+ if (w > this.f_width - 10) {
1159
+ w = this.f_width - 10;
1160
+ }
1161
+ this.search_field.css({
1162
+ 'width': w + 'px'
1163
+ });
1164
+ dd_top = this.container.height();
1165
+ return this.dropdown.css({
1166
+ "top": dd_top + "px"
1167
+ });
1168
+ }
1169
+ };
1170
+
1171
+ Chosen.prototype.generate_random_id = function() {
1172
+ var string;
1173
+
1174
+ string = "sel" + this.generate_random_char() + this.generate_random_char() + this.generate_random_char();
1175
+ while ($("#" + string).length > 0) {
1176
+ string += this.generate_random_char();
1177
+ }
1178
+ return string;
1179
+ };
1180
+
1181
+ return Chosen;
1182
+
1183
+ })(AbstractChosen);
1184
+
1185
+ root.Chosen = Chosen;
1186
+
1187
+ get_side_border_padding = function(elmt) {
1188
+ var side_border_padding;
1189
+
1190
+ return side_border_padding = elmt.outerWidth() - elmt.width();
1191
+ };
1192
+
1193
+ root.get_side_border_padding = get_side_border_padding;
1194
+
1195
+ }).call(this);