ad2games-ui_components 2.4.0 → 2.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 19244355dd4bc0e2c3555fe32649b945e98d8d63
4
- data.tar.gz: 5eb0d733152cf58f023166368eb2ccced815fae9
3
+ metadata.gz: 9f1c2ff6a39fb8b5b3c0924d041d367dba2561b1
4
+ data.tar.gz: b0cec954fc66503daf3a97ed5761ab36648f48c4
5
5
  SHA512:
6
- metadata.gz: 60bce326184a25270e43e1970fb333864ae2f76521f57cf72b25ee552607b42b6cc322dbd818d597fa930ebefcff6d59511295ace85c30b1a8eb8e5ce961bb78
7
- data.tar.gz: 27c73edec9231fb1f463c6fd81f3021cfe38d5c5470621ed66d854636c3789398823a76f7e5f189dd956f6d39dd78646665e9570cca70f5a22c3ce800fd92f80
6
+ metadata.gz: 06c214275e0fa2a1353e9232593c3ad78bd64e92a128a07e607e9ab49c65d5f3f59e0a921eb3487446adc3e9e7b972ec207a122c1fd23b55ab7822c03df49041
7
+ data.tar.gz: 59b450aa033e5f4be2515cddf0aaa586f2254623e4a291b0302a01db4b674705c68cf07b21a8defab28caa9c38b6c2bd62806eaa35d7afacd7c7daee365e820c
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UiComponents
4
- VERSION = '2.4.0'
4
+ VERSION = '2.4.1'
5
5
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Chosen is a library for making long, unwieldy select boxes more user friendly.
4
4
 
5
- - jQuery support: 1.4+
5
+ - jQuery support: 1.7+
6
6
  - Prototype support: 1.7+
7
7
 
8
8
  For **documentation**, usage, and examples, see:
@@ -32,9 +32,7 @@
32
32
  "dependencies": {},
33
33
  "main": [
34
34
  "chosen.jquery.js",
35
- "chosen.css",
36
- "chosen-sprite@2x.png",
37
- "chosen-sprite.png"
35
+ "chosen.css"
38
36
  ],
39
37
  "ignore": [],
40
38
  "repository": {
@@ -2,7 +2,7 @@
2
2
  Chosen, a Select Box Enhancer for jQuery and Prototype
3
3
  by Patrick Filler for Harvest, http://getharvest.com
4
4
 
5
- Version 1.7.0
5
+ Version 1.8.2
6
6
  Full source at https://github.com/harvesthq/chosen
7
7
  Copyright (c) 2011-2017 Harvest http://getharvest.com
8
8
 
@@ -23,7 +23,8 @@ This file is generated by `grunt build`, do not edit it by hand.
23
23
  }
24
24
 
25
25
  .chosen-container * {
26
- box-sizing: border-box;
26
+ -webkit-box-sizing: border-box;
27
+ box-sizing: border-box;
27
28
  }
28
29
 
29
30
  .chosen-container .chosen-drop {
@@ -34,7 +35,8 @@ This file is generated by `grunt build`, do not edit it by hand.
34
35
  border: 1px solid #aaa;
35
36
  border-top: 0;
36
37
  background: #fff;
37
- box-shadow: 0 4px 5px rgba(0, 0, 0, 0.15);
38
+ -webkit-box-shadow: 0 4px 5px rgba(0, 0, 0, 0.15);
39
+ box-shadow: 0 4px 5px rgba(0, 0, 0, 0.15);
38
40
  clip: rect(0, 0, 0, 0);
39
41
  }
40
42
 
@@ -72,9 +74,11 @@ This file is generated by `grunt build`, do not edit it by hand.
72
74
  border: 1px solid #aaa;
73
75
  border-radius: 5px;
74
76
  background-color: #fff;
77
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(20%, #fff), color-stop(50%, #f6f6f6), color-stop(52%, #eee), to(#f4f4f4));
75
78
  background: linear-gradient(#fff 20%, #f6f6f6 50%, #eee 52%, #f4f4f4 100%);
76
79
  background-clip: padding-box;
77
- box-shadow: 0 0 3px #fff inset, 0 1px 1px rgba(0, 0, 0, 0.1);
80
+ -webkit-box-shadow: 0 0 3px #fff inset, 0 1px 1px rgba(0, 0, 0, 0.1);
81
+ box-shadow: 0 0 3px #fff inset, 0 1px 1px rgba(0, 0, 0, 0.1);
78
82
  color: #444;
79
83
  text-decoration: none;
80
84
  white-space: nowrap;
@@ -201,6 +205,7 @@ This file is generated by `grunt build`, do not edit it by hand.
201
205
 
202
206
  .chosen-container .chosen-results li.highlighted {
203
207
  background-color: #3875d7;
208
+ background-image: -webkit-gradient(linear, left top, left bottom, color-stop(20%, #3875d7), color-stop(90%, #2a62bc));
204
209
  background-image: linear-gradient(#3875d7 20%, #2a62bc 90%);
205
210
  color: #fff;
206
211
  }
@@ -237,6 +242,7 @@ This file is generated by `grunt build`, do not edit it by hand.
237
242
  height: auto;
238
243
  border: 1px solid #aaa;
239
244
  background-color: #fff;
245
+ background-image: -webkit-gradient(linear, left top, left bottom, color-stop(1%, #eee), color-stop(15%, #fff));
240
246
  background-image: linear-gradient(#eee 1%, #fff 15%);
241
247
  cursor: text;
242
248
  }
@@ -259,7 +265,8 @@ This file is generated by `grunt build`, do not edit it by hand.
259
265
  outline: 0;
260
266
  border: 0 !important;
261
267
  background: transparent !important;
262
- box-shadow: none;
268
+ -webkit-box-shadow: none;
269
+ box-shadow: none;
263
270
  color: #999;
264
271
  font-size: 100%;
265
272
  font-family: sans-serif;
@@ -276,11 +283,13 @@ This file is generated by `grunt build`, do not edit it by hand.
276
283
  max-width: 100%;
277
284
  border-radius: 3px;
278
285
  background-color: #eeeeee;
286
+ background-image: -webkit-gradient(linear, left top, left bottom, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), to(#eee));
279
287
  background-image: linear-gradient(#f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
280
288
  background-size: 100% 19px;
281
289
  background-repeat: repeat-x;
282
290
  background-clip: padding-box;
283
- box-shadow: 0 0 2px #fff inset, 0 1px 0 rgba(0, 0, 0, 0.05);
291
+ -webkit-box-shadow: 0 0 2px #fff inset, 0 1px 0 rgba(0, 0, 0, 0.05);
292
+ box-shadow: 0 0 2px #fff inset, 0 1px 0 rgba(0, 0, 0, 0.05);
284
293
  color: #333;
285
294
  line-height: 13px;
286
295
  cursor: default;
@@ -309,6 +318,7 @@ This file is generated by `grunt build`, do not edit it by hand.
309
318
  padding-right: 5px;
310
319
  border: 1px solid #ccc;
311
320
  background-color: #e4e4e4;
321
+ background-image: -webkit-gradient(linear, left top, left bottom, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), to(#eee));
312
322
  background-image: linear-gradient(#f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
313
323
  color: #666;
314
324
  }
@@ -336,15 +346,18 @@ This file is generated by `grunt build`, do not edit it by hand.
336
346
  /* @group Active */
337
347
  .chosen-container-active .chosen-single {
338
348
  border: 1px solid #5897fb;
339
- box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
349
+ -webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
350
+ box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
340
351
  }
341
352
 
342
353
  .chosen-container-active.chosen-with-drop .chosen-single {
343
354
  border: 1px solid #aaa;
344
355
  border-bottom-right-radius: 0;
345
356
  border-bottom-left-radius: 0;
357
+ background-image: -webkit-gradient(linear, left top, left bottom, color-stop(20%, #eee), color-stop(80%, #fff));
346
358
  background-image: linear-gradient(#eee 20%, #fff 80%);
347
- box-shadow: 0 1px 0 #fff inset;
359
+ -webkit-box-shadow: 0 1px 0 #fff inset;
360
+ box-shadow: 0 1px 0 #fff inset;
348
361
  }
349
362
 
350
363
  .chosen-container-active.chosen-with-drop .chosen-single div {
@@ -358,7 +371,8 @@ This file is generated by `grunt build`, do not edit it by hand.
358
371
 
359
372
  .chosen-container-active .chosen-choices {
360
373
  border: 1px solid #5897fb;
361
- box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
374
+ -webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
375
+ box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
362
376
  }
363
377
 
364
378
  .chosen-container-active .chosen-choices li.search-field input[type="text"] {
@@ -1,8 +1,20 @@
1
+ /*!
2
+ Chosen, a Select Box Enhancer for jQuery and Prototype
3
+ by Patrick Filler for Harvest, http://getharvest.com
4
+
5
+ Version 1.8.2
6
+ Full source at https://github.com/harvesthq/chosen
7
+ Copyright (c) 2011-2017 Harvest http://getharvest.com
8
+
9
+ MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md
10
+ This file is generated by `grunt build`, do not edit it by hand.
11
+ */
12
+
1
13
  (function() {
2
- var $, AbstractChosen, Chosen, SelectParser, _ref,
3
- __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
4
- __hasProp = {}.hasOwnProperty,
5
- __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; };
14
+ var $, AbstractChosen, Chosen, SelectParser,
15
+ bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
16
+ extend = 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; },
17
+ hasProp = {}.hasOwnProperty;
6
18
 
7
19
  SelectParser = (function() {
8
20
  function SelectParser() {
@@ -19,24 +31,24 @@
19
31
  };
20
32
 
21
33
  SelectParser.prototype.add_group = function(group) {
22
- var group_position, option, _i, _len, _ref, _results;
34
+ var group_position, i, len, option, ref, results1;
23
35
  group_position = this.parsed.length;
24
36
  this.parsed.push({
25
37
  array_index: group_position,
26
38
  group: true,
27
- label: this.escapeExpression(group.label),
39
+ label: group.label,
28
40
  title: group.title ? group.title : void 0,
29
41
  children: 0,
30
42
  disabled: group.disabled,
31
43
  classes: group.className
32
44
  });
33
- _ref = group.childNodes;
34
- _results = [];
35
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
36
- option = _ref[_i];
37
- _results.push(this.add_option(option, group_position, group.disabled));
45
+ ref = group.childNodes;
46
+ results1 = [];
47
+ for (i = 0, len = ref.length; i < len; i++) {
48
+ option = ref[i];
49
+ results1.push(this.add_option(option, group_position, group.disabled));
38
50
  }
39
- return _results;
51
+ return results1;
40
52
  };
41
53
 
42
54
  SelectParser.prototype.add_option = function(option, group_position, group_disabled) {
@@ -70,47 +82,26 @@
70
82
  }
71
83
  };
72
84
 
73
- SelectParser.prototype.escapeExpression = function(text) {
74
- var map, unsafe_chars;
75
- if ((text == null) || text === false) {
76
- return "";
77
- }
78
- if (!/[\&\<\>\"\'\`]/.test(text)) {
79
- return text;
80
- }
81
- map = {
82
- "<": "&lt;",
83
- ">": "&gt;",
84
- '"': "&quot;",
85
- "'": "&#x27;",
86
- "`": "&#x60;"
87
- };
88
- unsafe_chars = /&(?!\w+;)|[\<\>\"\'\`]/g;
89
- return text.replace(unsafe_chars, function(chr) {
90
- return map[chr] || "&amp;";
91
- });
92
- };
93
-
94
85
  return SelectParser;
95
86
 
96
87
  })();
97
88
 
98
89
  SelectParser.select_to_array = function(select) {
99
- var child, parser, _i, _len, _ref;
90
+ var child, i, len, parser, ref;
100
91
  parser = new SelectParser();
101
- _ref = select.childNodes;
102
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
103
- child = _ref[_i];
92
+ ref = select.childNodes;
93
+ for (i = 0, len = ref.length; i < len; i++) {
94
+ child = ref[i];
104
95
  parser.add_node(child);
105
96
  }
106
97
  return parser.parsed;
107
98
  };
108
99
 
109
100
  AbstractChosen = (function() {
110
- function AbstractChosen(form_field, options) {
101
+ function AbstractChosen(form_field, options1) {
111
102
  this.form_field = form_field;
112
- this.options = options != null ? options : {};
113
- this.label_click_handler = __bind(this.label_click_handler, this);
103
+ this.options = options1 != null ? options1 : {};
104
+ this.label_click_handler = bind(this.label_click_handler, this);
114
105
  if (!AbstractChosen.browser_is_supported()) {
115
106
  return;
116
107
  }
@@ -124,13 +115,16 @@
124
115
  }
125
116
 
126
117
  AbstractChosen.prototype.set_default_values = function() {
127
- var _this = this;
128
- this.click_test_action = function(evt) {
129
- return _this.test_active_click(evt);
130
- };
131
- this.activate_action = function(evt) {
132
- return _this.activate_field(evt);
133
- };
118
+ this.click_test_action = (function(_this) {
119
+ return function(evt) {
120
+ return _this.test_active_click(evt);
121
+ };
122
+ })(this);
123
+ this.activate_action = (function(_this) {
124
+ return function(evt) {
125
+ return _this.activate_field(evt);
126
+ };
127
+ })(this);
134
128
  this.active_field = false;
135
129
  this.mouse_on_container = false;
136
130
  this.results_showing = false;
@@ -182,12 +176,13 @@
182
176
  };
183
177
 
184
178
  AbstractChosen.prototype.input_focus = function(evt) {
185
- var _this = this;
186
179
  if (this.is_multiple) {
187
180
  if (!this.active_field) {
188
- return setTimeout((function() {
189
- return _this.container_mousedown();
190
- }), 50);
181
+ return setTimeout(((function(_this) {
182
+ return function() {
183
+ return _this.container_mousedown();
184
+ };
185
+ })(this)), 50);
191
186
  }
192
187
  } else {
193
188
  if (!this.active_field) {
@@ -197,12 +192,13 @@
197
192
  };
198
193
 
199
194
  AbstractChosen.prototype.input_blur = function(evt) {
200
- var _this = this;
201
195
  if (!this.mouse_on_container) {
202
196
  this.active_field = false;
203
- return setTimeout((function() {
204
- return _this.blur_test();
205
- }), 100);
197
+ return setTimeout(((function(_this) {
198
+ return function() {
199
+ return _this.blur_test();
200
+ };
201
+ })(this)), 100);
206
202
  }
207
203
  };
208
204
 
@@ -215,12 +211,12 @@
215
211
  };
216
212
 
217
213
  AbstractChosen.prototype.results_option_build = function(options) {
218
- var content, data, data_content, shown_results, _i, _len, _ref;
214
+ var content, data, data_content, i, len, ref, shown_results;
219
215
  content = '';
220
216
  shown_results = 0;
221
- _ref = this.results_data;
222
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
223
- data = _ref[_i];
217
+ ref = this.results_data;
218
+ for (i = 0, len = ref.length; i < len; i++) {
219
+ data = ref[i];
224
220
  data_content = '';
225
221
  if (data.group) {
226
222
  data_content = this.result_add_group(data);
@@ -273,7 +269,7 @@
273
269
  option_el.className = classes.join(" ");
274
270
  option_el.style.cssText = option.style;
275
271
  option_el.setAttribute("data-option-array-index", option.array_index);
276
- option_el.innerHTML = option.search_text;
272
+ option_el.innerHTML = option.highlighted_html || option.html;
277
273
  if (option.title) {
278
274
  option_el.title = option.title;
279
275
  }
@@ -295,7 +291,7 @@
295
291
  }
296
292
  group_el = document.createElement("li");
297
293
  group_el.className = classes.join(" ");
298
- group_el.innerHTML = group.search_text;
294
+ group_el.innerHTML = group.highlighted_html || this.escape_html(group.label);
299
295
  if (group.title) {
300
296
  group_el.title = group.title;
301
297
  }
@@ -315,18 +311,18 @@
315
311
  };
316
312
 
317
313
  AbstractChosen.prototype.reset_single_select_options = function() {
318
- var result, _i, _len, _ref, _results;
319
- _ref = this.results_data;
320
- _results = [];
321
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
322
- result = _ref[_i];
314
+ var i, len, ref, result, results1;
315
+ ref = this.results_data;
316
+ results1 = [];
317
+ for (i = 0, len = ref.length; i < len; i++) {
318
+ result = ref[i];
323
319
  if (result.selected) {
324
- _results.push(result.selected = false);
320
+ results1.push(result.selected = false);
325
321
  } else {
326
- _results.push(void 0);
322
+ results1.push(void 0);
327
323
  }
328
324
  }
329
- return _results;
325
+ return results1;
330
326
  };
331
327
 
332
328
  AbstractChosen.prototype.results_toggle = function() {
@@ -346,18 +342,19 @@
346
342
  };
347
343
 
348
344
  AbstractChosen.prototype.winnow_results = function() {
349
- var escapedSearchText, highlightRegex, option, regex, results, results_group, searchText, startpos, text, _i, _len, _ref;
345
+ var escapedQuery, fix, i, len, option, prefix, query, ref, regex, results, results_group, search_match, startpos, suffix, text;
350
346
  this.no_results_clear();
351
347
  results = 0;
352
- searchText = this.get_search_text();
353
- escapedSearchText = searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
354
- regex = this.get_search_regex(escapedSearchText);
355
- highlightRegex = this.get_highlight_regex(escapedSearchText);
356
- _ref = this.results_data;
357
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
358
- option = _ref[_i];
348
+ query = this.get_search_text();
349
+ escapedQuery = query.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
350
+ regex = this.get_search_regex(escapedQuery);
351
+ ref = this.results_data;
352
+ for (i = 0, len = ref.length; i < len; i++) {
353
+ option = ref[i];
359
354
  option.search_match = false;
360
355
  results_group = null;
356
+ search_match = null;
357
+ option.highlighted_html = '';
361
358
  if (this.include_option_in_results(option)) {
362
359
  if (option.group) {
363
360
  option.group_match = false;
@@ -370,17 +367,20 @@
370
367
  }
371
368
  results_group.active_options += 1;
372
369
  }
373
- option.search_text = option.group ? option.label : option.html;
370
+ text = option.group ? option.label : option.text;
374
371
  if (!(option.group && !this.group_search)) {
375
- option.search_match = this.search_string_match(option.search_text, regex);
372
+ search_match = this.search_string_match(text, regex);
373
+ option.search_match = search_match != null;
376
374
  if (option.search_match && !option.group) {
377
375
  results += 1;
378
376
  }
379
377
  if (option.search_match) {
380
- if (searchText.length) {
381
- startpos = option.search_text.search(highlightRegex);
382
- text = option.search_text.substr(0, startpos + searchText.length) + '</em>' + option.search_text.substr(startpos + searchText.length);
383
- option.search_text = text.substr(0, startpos) + '<em>' + text.substr(startpos);
378
+ if (query.length) {
379
+ startpos = search_match.index;
380
+ prefix = text.slice(0, startpos);
381
+ fix = text.slice(startpos, startpos + query.length);
382
+ suffix = text.slice(startpos + query.length);
383
+ option.highlighted_html = (this.escape_html(prefix)) + "<em>" + (this.escape_html(fix)) + "</em>" + (this.escape_html(suffix));
384
384
  }
385
385
  if (results_group != null) {
386
386
  results_group.group_match = true;
@@ -392,9 +392,9 @@
392
392
  }
393
393
  }
394
394
  this.result_clear_highlight();
395
- if (results < 1 && searchText.length) {
395
+ if (results < 1 && query.length) {
396
396
  this.update_results_content("");
397
- return this.no_results(searchText);
397
+ return this.no_results(query);
398
398
  } else {
399
399
  this.update_results_content(this.results_option_build());
400
400
  return this.winnow_results_set_highlight();
@@ -402,45 +402,33 @@
402
402
  };
403
403
 
404
404
  AbstractChosen.prototype.get_search_regex = function(escaped_search_string) {
405
- var regex_anchor, regex_flag;
406
- regex_anchor = this.search_contains ? "" : "^";
407
- regex_flag = this.case_sensitive_search ? "" : "i";
408
- return new RegExp(regex_anchor + escaped_search_string, regex_flag);
409
- };
410
-
411
- AbstractChosen.prototype.get_highlight_regex = function(escaped_search_string) {
412
- var regex_anchor, regex_flag;
413
- regex_anchor = this.search_contains ? "" : "\\b";
405
+ var regex_flag, regex_string;
406
+ regex_string = this.search_contains ? escaped_search_string : "(^|\\s|\\b)" + escaped_search_string + "[^\\s]*";
407
+ if (!(this.enable_split_word_search || this.search_contains)) {
408
+ regex_string = "^" + regex_string;
409
+ }
414
410
  regex_flag = this.case_sensitive_search ? "" : "i";
415
- return new RegExp(regex_anchor + escaped_search_string, regex_flag);
411
+ return new RegExp(regex_string, regex_flag);
416
412
  };
417
413
 
418
414
  AbstractChosen.prototype.search_string_match = function(search_string, regex) {
419
- var part, parts, _i, _len;
420
- if (regex.test(search_string)) {
421
- return true;
422
- } else if (this.enable_split_word_search && (search_string.indexOf(" ") >= 0 || search_string.indexOf("[") === 0)) {
423
- parts = search_string.replace(/\[|\]/g, "").split(" ");
424
- if (parts.length) {
425
- for (_i = 0, _len = parts.length; _i < _len; _i++) {
426
- part = parts[_i];
427
- if (regex.test(part)) {
428
- return true;
429
- }
430
- }
431
- }
415
+ var match;
416
+ match = regex.exec(search_string);
417
+ if (!this.search_contains && (match != null ? match[1] : void 0)) {
418
+ match.index += 1;
432
419
  }
420
+ return match;
433
421
  };
434
422
 
435
423
  AbstractChosen.prototype.choices_count = function() {
436
- var option, _i, _len, _ref;
424
+ var i, len, option, ref;
437
425
  if (this.selected_option_count != null) {
438
426
  return this.selected_option_count;
439
427
  }
440
428
  this.selected_option_count = 0;
441
- _ref = this.form_field.options;
442
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
443
- option = _ref[_i];
429
+ ref = this.form_field.options;
430
+ for (i = 0, len = ref.length; i < len; i++) {
431
+ option = ref[i];
444
432
  if (option.selected) {
445
433
  this.selected_option_count += 1;
446
434
  }
@@ -457,8 +445,8 @@
457
445
  };
458
446
 
459
447
  AbstractChosen.prototype.keydown_checker = function(evt) {
460
- var stroke, _ref;
461
- stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
448
+ var ref, stroke;
449
+ stroke = (ref = evt.which) != null ? ref : evt.keyCode;
462
450
  this.search_field_scale();
463
451
  if (stroke !== 8 && this.pending_backstroke) {
464
452
  this.clear_backstroke();
@@ -500,8 +488,8 @@
500
488
  };
501
489
 
502
490
  AbstractChosen.prototype.keyup_checker = function(evt) {
503
- var stroke, _ref;
504
- stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
491
+ var ref, stroke;
492
+ stroke = (ref = evt.which) != null ? ref : evt.keyCode;
505
493
  this.search_field_scale();
506
494
  switch (stroke) {
507
495
  case 8:
@@ -538,20 +526,21 @@
538
526
  };
539
527
 
540
528
  AbstractChosen.prototype.clipboard_event_checker = function(evt) {
541
- var _this = this;
542
529
  if (this.is_disabled) {
543
530
  return;
544
531
  }
545
- return setTimeout((function() {
546
- return _this.results_search();
547
- }), 50);
532
+ return setTimeout(((function(_this) {
533
+ return function() {
534
+ return _this.results_search();
535
+ };
536
+ })(this)), 50);
548
537
  };
549
538
 
550
539
  AbstractChosen.prototype.container_width = function() {
551
540
  if (this.options.width != null) {
552
541
  return this.options.width;
553
542
  } else {
554
- return "" + this.form_field.offsetWidth + "px";
543
+ return this.form_field.offsetWidth + "px";
555
544
  }
556
545
  };
557
546
 
@@ -603,7 +592,7 @@
603
592
  };
604
593
 
605
594
  AbstractChosen.prototype.get_no_results_html = function(terms) {
606
- return "<li class=\"no-results\">\n " + this.results_none_found + " <span>" + terms + "</span>\n</li>";
595
+ return "<li class=\"no-results\">\n " + this.results_none_found + " <span>" + (this.escape_html(terms)) + "</span>\n</li>";
607
596
  };
608
597
 
609
598
  AbstractChosen.browser_is_supported = function() {
@@ -650,12 +639,11 @@
650
639
  }
651
640
  });
652
641
 
653
- Chosen = (function(_super) {
654
- __extends(Chosen, _super);
642
+ Chosen = (function(superClass) {
643
+ extend(Chosen, superClass);
655
644
 
656
645
  function Chosen() {
657
- _ref = Chosen.__super__.constructor.apply(this, arguments);
658
- return _ref;
646
+ return Chosen.__super__.constructor.apply(this, arguments);
659
647
  }
660
648
 
661
649
  Chosen.prototype.setup = function() {
@@ -712,91 +700,138 @@
712
700
  };
713
701
 
714
702
  Chosen.prototype.register_observers = function() {
715
- var _this = this;
716
- this.container.bind('touchstart.chosen', function(evt) {
717
- _this.container_mousedown(evt);
718
- });
719
- this.container.bind('touchend.chosen', function(evt) {
720
- _this.container_mouseup(evt);
721
- });
722
- this.container.bind('mousedown.chosen', function(evt) {
723
- _this.container_mousedown(evt);
724
- });
725
- this.container.bind('mouseup.chosen', function(evt) {
726
- _this.container_mouseup(evt);
727
- });
728
- this.container.bind('mouseenter.chosen', function(evt) {
729
- _this.mouse_enter(evt);
730
- });
731
- this.container.bind('mouseleave.chosen', function(evt) {
732
- _this.mouse_leave(evt);
733
- });
734
- this.search_results.bind('mouseup.chosen', function(evt) {
735
- _this.search_results_mouseup(evt);
736
- });
737
- this.search_results.bind('mouseover.chosen', function(evt) {
738
- _this.search_results_mouseover(evt);
739
- });
740
- this.search_results.bind('mouseout.chosen', function(evt) {
741
- _this.search_results_mouseout(evt);
742
- });
743
- this.search_results.bind('mousewheel.chosen DOMMouseScroll.chosen', function(evt) {
744
- _this.search_results_mousewheel(evt);
745
- });
746
- this.search_results.bind('touchstart.chosen', function(evt) {
747
- _this.search_results_touchstart(evt);
748
- });
749
- this.search_results.bind('touchmove.chosen', function(evt) {
750
- _this.search_results_touchmove(evt);
751
- });
752
- this.search_results.bind('touchend.chosen', function(evt) {
753
- _this.search_results_touchend(evt);
754
- });
755
- this.form_field_jq.bind("chosen:updated.chosen", function(evt) {
756
- _this.results_update_field(evt);
757
- });
758
- this.form_field_jq.bind("chosen:activate.chosen", function(evt) {
759
- _this.activate_field(evt);
760
- });
761
- this.form_field_jq.bind("chosen:open.chosen", function(evt) {
762
- _this.container_mousedown(evt);
763
- });
764
- this.form_field_jq.bind("chosen:close.chosen", function(evt) {
765
- _this.close_field(evt);
766
- });
767
- this.search_field.bind('blur.chosen', function(evt) {
768
- _this.input_blur(evt);
769
- });
770
- this.search_field.bind('keyup.chosen', function(evt) {
771
- _this.keyup_checker(evt);
772
- });
773
- this.search_field.bind('keydown.chosen', function(evt) {
774
- _this.keydown_checker(evt);
775
- });
776
- this.search_field.bind('focus.chosen', function(evt) {
777
- _this.input_focus(evt);
778
- });
779
- this.search_field.bind('cut.chosen', function(evt) {
780
- _this.clipboard_event_checker(evt);
781
- });
782
- this.search_field.bind('paste.chosen', function(evt) {
783
- _this.clipboard_event_checker(evt);
784
- });
703
+ this.container.on('touchstart.chosen', (function(_this) {
704
+ return function(evt) {
705
+ _this.container_mousedown(evt);
706
+ };
707
+ })(this));
708
+ this.container.on('touchend.chosen', (function(_this) {
709
+ return function(evt) {
710
+ _this.container_mouseup(evt);
711
+ };
712
+ })(this));
713
+ this.container.on('mousedown.chosen', (function(_this) {
714
+ return function(evt) {
715
+ _this.container_mousedown(evt);
716
+ };
717
+ })(this));
718
+ this.container.on('mouseup.chosen', (function(_this) {
719
+ return function(evt) {
720
+ _this.container_mouseup(evt);
721
+ };
722
+ })(this));
723
+ this.container.on('mouseenter.chosen', (function(_this) {
724
+ return function(evt) {
725
+ _this.mouse_enter(evt);
726
+ };
727
+ })(this));
728
+ this.container.on('mouseleave.chosen', (function(_this) {
729
+ return function(evt) {
730
+ _this.mouse_leave(evt);
731
+ };
732
+ })(this));
733
+ this.search_results.on('mouseup.chosen', (function(_this) {
734
+ return function(evt) {
735
+ _this.search_results_mouseup(evt);
736
+ };
737
+ })(this));
738
+ this.search_results.on('mouseover.chosen', (function(_this) {
739
+ return function(evt) {
740
+ _this.search_results_mouseover(evt);
741
+ };
742
+ })(this));
743
+ this.search_results.on('mouseout.chosen', (function(_this) {
744
+ return function(evt) {
745
+ _this.search_results_mouseout(evt);
746
+ };
747
+ })(this));
748
+ this.search_results.on('mousewheel.chosen DOMMouseScroll.chosen', (function(_this) {
749
+ return function(evt) {
750
+ _this.search_results_mousewheel(evt);
751
+ };
752
+ })(this));
753
+ this.search_results.on('touchstart.chosen', (function(_this) {
754
+ return function(evt) {
755
+ _this.search_results_touchstart(evt);
756
+ };
757
+ })(this));
758
+ this.search_results.on('touchmove.chosen', (function(_this) {
759
+ return function(evt) {
760
+ _this.search_results_touchmove(evt);
761
+ };
762
+ })(this));
763
+ this.search_results.on('touchend.chosen', (function(_this) {
764
+ return function(evt) {
765
+ _this.search_results_touchend(evt);
766
+ };
767
+ })(this));
768
+ this.form_field_jq.on("chosen:updated.chosen", (function(_this) {
769
+ return function(evt) {
770
+ _this.results_update_field(evt);
771
+ };
772
+ })(this));
773
+ this.form_field_jq.on("chosen:activate.chosen", (function(_this) {
774
+ return function(evt) {
775
+ _this.activate_field(evt);
776
+ };
777
+ })(this));
778
+ this.form_field_jq.on("chosen:open.chosen", (function(_this) {
779
+ return function(evt) {
780
+ _this.container_mousedown(evt);
781
+ };
782
+ })(this));
783
+ this.form_field_jq.on("chosen:close.chosen", (function(_this) {
784
+ return function(evt) {
785
+ _this.close_field(evt);
786
+ };
787
+ })(this));
788
+ this.search_field.on('blur.chosen', (function(_this) {
789
+ return function(evt) {
790
+ _this.input_blur(evt);
791
+ };
792
+ })(this));
793
+ this.search_field.on('keyup.chosen', (function(_this) {
794
+ return function(evt) {
795
+ _this.keyup_checker(evt);
796
+ };
797
+ })(this));
798
+ this.search_field.on('keydown.chosen', (function(_this) {
799
+ return function(evt) {
800
+ _this.keydown_checker(evt);
801
+ };
802
+ })(this));
803
+ this.search_field.on('focus.chosen', (function(_this) {
804
+ return function(evt) {
805
+ _this.input_focus(evt);
806
+ };
807
+ })(this));
808
+ this.search_field.on('cut.chosen', (function(_this) {
809
+ return function(evt) {
810
+ _this.clipboard_event_checker(evt);
811
+ };
812
+ })(this));
813
+ this.search_field.on('paste.chosen', (function(_this) {
814
+ return function(evt) {
815
+ _this.clipboard_event_checker(evt);
816
+ };
817
+ })(this));
785
818
  if (this.is_multiple) {
786
- return this.search_choices.bind('click.chosen', function(evt) {
787
- _this.choices_click(evt);
788
- });
819
+ return this.search_choices.on('click.chosen', (function(_this) {
820
+ return function(evt) {
821
+ _this.choices_click(evt);
822
+ };
823
+ })(this));
789
824
  } else {
790
- return this.container.bind('click.chosen', function(evt) {
825
+ return this.container.on('click.chosen', function(evt) {
791
826
  evt.preventDefault();
792
827
  });
793
828
  }
794
829
  };
795
830
 
796
831
  Chosen.prototype.destroy = function() {
797
- $(this.container[0].ownerDocument).unbind('click.chosen', this.click_test_action);
832
+ $(this.container[0].ownerDocument).off('click.chosen', this.click_test_action);
798
833
  if (this.form_field_label.length > 0) {
799
- this.form_field_label.unbind('click.chosen');
834
+ this.form_field_label.off('click.chosen');
800
835
  }
801
836
  if (this.search_field[0].tabIndex) {
802
837
  this.form_field_jq[0].tabIndex = this.search_field[0].tabIndex;
@@ -811,21 +846,21 @@
811
846
  this.container.toggleClass('chosen-disabled', this.is_disabled);
812
847
  this.search_field[0].disabled = this.is_disabled;
813
848
  if (!this.is_multiple) {
814
- this.selected_item.unbind('focus.chosen', this.activate_field);
849
+ this.selected_item.off('focus.chosen', this.activate_field);
815
850
  }
816
851
  if (this.is_disabled) {
817
852
  return this.close_field();
818
853
  } else if (!this.is_multiple) {
819
- return this.selected_item.bind('focus.chosen', this.activate_field);
854
+ return this.selected_item.on('focus.chosen', this.activate_field);
820
855
  }
821
856
  };
822
857
 
823
858
  Chosen.prototype.container_mousedown = function(evt) {
824
- var _ref1;
859
+ var ref;
825
860
  if (this.is_disabled) {
826
861
  return;
827
862
  }
828
- if (evt && ((_ref1 = evt.type) === 'mousedown' || _ref1 === 'touchstart') && !this.results_showing) {
863
+ if (evt && ((ref = evt.type) === 'mousedown' || ref === 'touchstart') && !this.results_showing) {
829
864
  evt.preventDefault();
830
865
  }
831
866
  if (!((evt != null) && ($(evt.target)).hasClass("search-choice-close"))) {
@@ -833,7 +868,7 @@
833
868
  if (this.is_multiple) {
834
869
  this.search_field.val("");
835
870
  }
836
- $(this.container[0].ownerDocument).bind('click.chosen', this.click_test_action);
871
+ $(this.container[0].ownerDocument).on('click.chosen', this.click_test_action);
837
872
  this.results_show();
838
873
  } else if (!this.is_multiple && evt && (($(evt.target)[0] === this.selected_item[0]) || $(evt.target).parents("a.chosen-single").length)) {
839
874
  evt.preventDefault();
@@ -870,7 +905,7 @@
870
905
  };
871
906
 
872
907
  Chosen.prototype.close_field = function() {
873
- $(this.container[0].ownerDocument).unbind("click.chosen", this.click_test_action);
908
+ $(this.container[0].ownerDocument).off("click.chosen", this.click_test_action);
874
909
  this.active_field = false;
875
910
  this.results_hide();
876
911
  this.container.removeClass("chosen-container-active");
@@ -998,7 +1033,7 @@
998
1033
  this.form_field_label = $("label[for='" + this.form_field.id + "']");
999
1034
  }
1000
1035
  if (this.form_field_label.length > 0) {
1001
- return this.form_field_label.bind('click.chosen', this.label_click_handler);
1036
+ return this.form_field_label.on('click.chosen', this.label_click_handler);
1002
1037
  }
1003
1038
  };
1004
1039
 
@@ -1031,14 +1066,13 @@
1031
1066
  };
1032
1067
 
1033
1068
  Chosen.prototype.search_results_mouseout = function(evt) {
1034
- if ($(evt.target).hasClass("active-result" || $(evt.target).parents('.active-result').first())) {
1069
+ if ($(evt.target).hasClass("active-result") || $(evt.target).parents('.active-result').first()) {
1035
1070
  return this.result_clear_highlight();
1036
1071
  }
1037
1072
  };
1038
1073
 
1039
1074
  Chosen.prototype.choice_build = function(item) {
1040
- var choice, close_link,
1041
- _this = this;
1075
+ var choice, close_link;
1042
1076
  choice = $('<li />', {
1043
1077
  "class": "search-choice"
1044
1078
  }).html("<span>" + (this.choice_label(item)) + "</span>");
@@ -1049,9 +1083,11 @@
1049
1083
  "class": 'search-choice-close',
1050
1084
  'data-option-array-index': item.array_index
1051
1085
  });
1052
- close_link.bind('click.chosen', function(evt) {
1053
- return _this.choice_destroy_link_click(evt);
1054
- });
1086
+ close_link.on('click.chosen', (function(_this) {
1087
+ return function(evt) {
1088
+ return _this.choice_destroy_link_click(evt);
1089
+ };
1090
+ })(this));
1055
1091
  choice.append(close_link);
1056
1092
  }
1057
1093
  return this.search_container.before(choice);
@@ -1118,12 +1154,15 @@
1118
1154
  item.selected = true;
1119
1155
  this.form_field.options[item.options_index].selected = true;
1120
1156
  this.selected_option_count = null;
1157
+ this.search_field.val("");
1121
1158
  if (this.is_multiple) {
1122
1159
  this.choice_build(item);
1123
1160
  } else {
1124
1161
  this.single_set_selected_text(this.choice_label(item));
1125
1162
  }
1126
- if (!(this.is_multiple && (!this.hide_results_on_select || (evt.metaKey || evt.ctrlKey)))) {
1163
+ if (this.is_multiple && (!this.hide_results_on_select || (evt.metaKey || evt.ctrlKey))) {
1164
+ this.winnow_results();
1165
+ } else {
1127
1166
  this.results_hide();
1128
1167
  this.show_search_field_default();
1129
1168
  }
@@ -1187,7 +1226,7 @@
1187
1226
  };
1188
1227
 
1189
1228
  Chosen.prototype.get_search_text = function() {
1190
- return this.escape_html($.trim(this.get_search_field_value()));
1229
+ return $.trim(this.get_search_field_value());
1191
1230
  };
1192
1231
 
1193
1232
  Chosen.prototype.escape_html = function(text) {
@@ -1271,7 +1310,7 @@
1271
1310
  };
1272
1311
 
1273
1312
  Chosen.prototype.search_field_scale = function() {
1274
- var container_width, div, style, style_block, styles, width, _i, _len;
1313
+ var div, i, len, style, style_block, styles, width;
1275
1314
  if (!this.is_multiple) {
1276
1315
  return;
1277
1316
  }
@@ -1283,8 +1322,8 @@
1283
1322
  whiteSpace: 'pre'
1284
1323
  };
1285
1324
  styles = ['fontSize', 'fontStyle', 'fontWeight', 'fontFamily', 'lineHeight', 'textTransform', 'letterSpacing'];
1286
- for (_i = 0, _len = styles.length; _i < _len; _i++) {
1287
- style = styles[_i];
1325
+ for (i = 0, len = styles.length; i < len; i++) {
1326
+ style = styles[i];
1288
1327
  style_block[style] = this.search_field.css(style);
1289
1328
  }
1290
1329
  div = $('<div />').css(style_block);
@@ -1292,8 +1331,9 @@
1292
1331
  $('body').append(div);
1293
1332
  width = div.width() + 25;
1294
1333
  div.remove();
1295
- container_width = this.container.outerWidth();
1296
- width = Math.min(container_width - 10, width);
1334
+ if (this.container.is(':visible')) {
1335
+ width = Math.min(this.container.outerWidth() - 10, width);
1336
+ }
1297
1337
  return this.search_field.width(width);
1298
1338
  };
1299
1339