Changeset 113714 in spip-zone
- Timestamp:
-
Feb 1, 2019, 5:40:29 PM
(2 years ago)
- Author:
- marcimat@…
- Message:
-
Mise à jour le Chosen en version 1.8.7
Ça corrige un problème sur la recherche, qui ne trouvait jamais le premier mot des sélects…
- Location:
- _plugins_/chosen/trunk
-
Files:
-
- 7 added
- 1 deleted
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
r98557
|
r113714
|
|
3 | 3 | by Patrick Filler for Harvest, http://getharvest.com |
4 | 4 | |
5 | | Version 1.6.1 |
| 5 | Version 1.8.7 |
6 | 6 | Full source at https://github.com/harvesthq/chosen |
7 | | Copyright (c) 2011-2016 Harvest http://getharvest.com |
| 7 | Copyright (c) 2011-2018 Harvest http://getharvest.com |
8 | 8 | |
9 | 9 | MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md |
… |
… |
|
18 | 18 | font-size: 13px; |
19 | 19 | -webkit-user-select: none; |
20 | | -moz-user-select: none; |
21 | | user-select: none; |
22 | | } |
| 20 | -moz-user-select: none; |
| 21 | -ms-user-select: none; |
| 22 | user-select: none; |
| 23 | } |
| 24 | |
23 | 25 | .chosen-container * { |
24 | 26 | -webkit-box-sizing: border-box; |
25 | | -moz-box-sizing: border-box; |
26 | | box-sizing: border-box; |
27 | | } |
| 27 | box-sizing: border-box; |
| 28 | } |
| 29 | |
28 | 30 | .chosen-container .chosen-drop { |
29 | 31 | position: absolute; |
30 | 32 | top: 100%; |
31 | | left: -9999px; |
32 | 33 | z-index: 1010; |
33 | 34 | width: 100%; |
… |
… |
|
35 | 36 | border-top: 0; |
36 | 37 | background: #fff; |
37 | | box-shadow: 0 4px 5px rgba(0, 0, 0, 0.15); |
38 | | } |
| 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); |
| 40 | clip: rect(0, 0, 0, 0); |
| 41 | -webkit-clip-path: inset(100% 100%); |
| 42 | clip-path: inset(100% 100%); |
| 43 | } |
| 44 | |
39 | 45 | .chosen-container.chosen-with-drop .chosen-drop { |
40 | | left: 0; |
41 | | } |
| 46 | clip: auto; |
| 47 | -webkit-clip-path: none; |
| 48 | clip-path: none; |
| 49 | } |
| 50 | |
42 | 51 | .chosen-container a { |
43 | 52 | cursor: pointer; |
44 | 53 | } |
| 54 | |
45 | 55 | .chosen-container .search-choice .group-name, .chosen-container .chosen-single .group-name { |
46 | 56 | margin-right: 4px; |
… |
… |
|
51 | 61 | color: #999999; |
52 | 62 | } |
| 63 | |
53 | 64 | .chosen-container .search-choice .group-name:after, .chosen-container .chosen-single .group-name:after { |
54 | 65 | content: ":"; |
… |
… |
|
68 | 79 | border-radius: 5px; |
69 | 80 | background-color: #fff; |
70 | | background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(20%, #ffffff), color-stop(50%, #f6f6f6), color-stop(52%, #eeeeee), color-stop(100%, #f4f4f4)); |
71 | | background: -webkit-linear-gradient(#ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%); |
72 | | background: -moz-linear-gradient(#ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%); |
73 | | background: -o-linear-gradient(#ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%); |
74 | | background: linear-gradient(#ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%); |
| 81 | background: -webkit-gradient(linear, left top, left bottom, color-stop(20%, #fff), color-stop(50%, #f6f6f6), color-stop(52%, #eee), to(#f4f4f4)); |
| 82 | background: linear-gradient(#fff 20%, #f6f6f6 50%, #eee 52%, #f4f4f4 100%); |
75 | 83 | background-clip: padding-box; |
76 | | box-shadow: 0 0 3px white inset, 0 1px 1px rgba(0, 0, 0, 0.1); |
| 84 | -webkit-box-shadow: 0 0 3px #fff inset, 0 1px 1px rgba(0, 0, 0, 0.1); |
| 85 | box-shadow: 0 0 3px #fff inset, 0 1px 1px rgba(0, 0, 0, 0.1); |
77 | 86 | color: #444; |
78 | 87 | text-decoration: none; |
… |
… |
|
80 | 89 | line-height: 24px; |
81 | 90 | } |
| 91 | |
82 | 92 | .chosen-container-single .chosen-default { |
83 | 93 | color: #999; |
84 | 94 | } |
| 95 | |
85 | 96 | .chosen-container-single .chosen-single span { |
86 | 97 | display: block; |
… |
… |
|
90 | 101 | white-space: nowrap; |
91 | 102 | } |
| 103 | |
92 | 104 | .chosen-container-single .chosen-single-with-deselect span { |
93 | 105 | margin-right: 38px; |
94 | 106 | } |
| 107 | |
95 | 108 | .chosen-container-single .chosen-single abbr { |
96 | 109 | position: absolute; |
… |
… |
|
100 | 113 | width: 12px; |
101 | 114 | height: 12px; |
102 | | background: url('chosen-sprite.png') -42px 1px no-repeat; |
| 115 | background: url("chosen-sprite.png") -42px 1px no-repeat; |
103 | 116 | font-size: 1px; |
104 | 117 | } |
| 118 | |
105 | 119 | .chosen-container-single .chosen-single abbr:hover { |
106 | 120 | background-position: -42px -10px; |
107 | 121 | } |
| 122 | |
108 | 123 | .chosen-container-single.chosen-disabled .chosen-single abbr:hover { |
109 | 124 | background-position: -42px -10px; |
110 | 125 | } |
| 126 | |
111 | 127 | .chosen-container-single .chosen-single div { |
112 | 128 | position: absolute; |
… |
… |
|
117 | 133 | height: 100%; |
118 | 134 | } |
| 135 | |
119 | 136 | .chosen-container-single .chosen-single div b { |
120 | 137 | display: block; |
121 | 138 | width: 100%; |
122 | 139 | height: 100%; |
123 | | background: url('chosen-sprite.png') no-repeat 0px 2px; |
124 | | } |
| 140 | background: url("chosen-sprite.png") no-repeat 0px 2px; |
| 141 | } |
| 142 | |
125 | 143 | .chosen-container-single .chosen-search { |
126 | 144 | position: relative; |
… |
… |
|
130 | 148 | white-space: nowrap; |
131 | 149 | } |
| 150 | |
132 | 151 | .chosen-container-single .chosen-search input[type="text"] { |
133 | 152 | margin: 1px 0; |
… |
… |
|
137 | 156 | outline: 0; |
138 | 157 | border: 1px solid #aaa; |
139 | | background: white url('chosen-sprite.png') no-repeat 100% -20px; |
140 | | background: url('chosen-sprite.png') no-repeat 100% -20px; |
| 158 | background: url("chosen-sprite.png") no-repeat 100% -20px; |
141 | 159 | font-size: 1em; |
142 | 160 | font-family: sans-serif; |
… |
… |
|
144 | 162 | border-radius: 0; |
145 | 163 | } |
| 164 | |
146 | 165 | .chosen-container-single .chosen-drop { |
147 | 166 | margin-top: -1px; |
… |
… |
|
149 | 168 | background-clip: padding-box; |
150 | 169 | } |
| 170 | |
151 | 171 | .chosen-container-single.chosen-container-single-nosearch .chosen-search { |
152 | 172 | position: absolute; |
153 | | left: -9999px; |
| 173 | clip: rect(0, 0, 0, 0); |
| 174 | -webkit-clip-path: inset(100% 100%); |
| 175 | clip-path: inset(100% 100%); |
154 | 176 | } |
155 | 177 | |
… |
… |
|
166 | 188 | -webkit-overflow-scrolling: touch; |
167 | 189 | } |
| 190 | |
168 | 191 | .chosen-container .chosen-results li { |
169 | 192 | display: none; |
… |
… |
|
175 | 198 | -webkit-touch-callout: none; |
176 | 199 | } |
| 200 | |
177 | 201 | .chosen-container .chosen-results li.active-result { |
178 | 202 | display: list-item; |
179 | 203 | cursor: pointer; |
180 | 204 | } |
| 205 | |
181 | 206 | .chosen-container .chosen-results li.disabled-result { |
182 | 207 | display: list-item; |
… |
… |
|
184 | 209 | cursor: default; |
185 | 210 | } |
| 211 | |
186 | 212 | .chosen-container .chosen-results li.highlighted { |
187 | 213 | background-color: #3875d7; |
188 | | background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(20%, #3875d7), color-stop(90%, #2a62bc)); |
189 | | background-image: -webkit-linear-gradient(#3875d7 20%, #2a62bc 90%); |
190 | | background-image: -moz-linear-gradient(#3875d7 20%, #2a62bc 90%); |
191 | | background-image: -o-linear-gradient(#3875d7 20%, #2a62bc 90%); |
| 214 | background-image: -webkit-gradient(linear, left top, left bottom, color-stop(20%, #3875d7), color-stop(90%, #2a62bc)); |
192 | 215 | background-image: linear-gradient(#3875d7 20%, #2a62bc 90%); |
193 | 216 | color: #fff; |
194 | 217 | } |
| 218 | |
195 | 219 | .chosen-container .chosen-results li.no-results { |
196 | 220 | color: #777; |
… |
… |
|
198 | 222 | background: #f4f4f4; |
199 | 223 | } |
| 224 | |
200 | 225 | .chosen-container .chosen-results li.group-result { |
201 | 226 | display: list-item; |
… |
… |
|
203 | 228 | cursor: default; |
204 | 229 | } |
| 230 | |
205 | 231 | .chosen-container .chosen-results li.group-option { |
206 | 232 | padding-left: 15px; |
207 | 233 | } |
| 234 | |
208 | 235 | .chosen-container .chosen-results li em { |
209 | 236 | font-style: normal; |
… |
… |
|
222 | 249 | border: 1px solid #aaa; |
223 | 250 | background-color: #fff; |
224 | | background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff)); |
225 | | background-image: -webkit-linear-gradient(#eeeeee 1%, #ffffff 15%); |
226 | | background-image: -moz-linear-gradient(#eeeeee 1%, #ffffff 15%); |
227 | | background-image: -o-linear-gradient(#eeeeee 1%, #ffffff 15%); |
228 | | background-image: linear-gradient(#eeeeee 1%, #ffffff 15%); |
| 251 | background-image: -webkit-gradient(linear, left top, left bottom, color-stop(1%, #eee), color-stop(15%, #fff)); |
| 252 | background-image: linear-gradient(#eee 1%, #fff 15%); |
229 | 253 | cursor: text; |
230 | 254 | } |
| 255 | |
231 | 256 | .chosen-container-multi .chosen-choices li { |
232 | 257 | float: left; |
233 | 258 | list-style: none; |
234 | 259 | } |
| 260 | |
235 | 261 | .chosen-container-multi .chosen-choices li.search-field { |
236 | 262 | margin: 0; |
… |
… |
|
238 | 264 | white-space: nowrap; |
239 | 265 | } |
| 266 | |
240 | 267 | .chosen-container-multi .chosen-choices li.search-field input[type="text"] { |
241 | 268 | margin: 1px 0; |
… |
… |
|
245 | 272 | border: 0 !important; |
246 | 273 | background: transparent !important; |
247 | | box-shadow: none; |
| 274 | -webkit-box-shadow: none; |
| 275 | box-shadow: none; |
248 | 276 | color: #999; |
249 | 277 | font-size: 100%; |
… |
… |
|
251 | 279 | line-height: normal; |
252 | 280 | border-radius: 0; |
253 | | } |
| 281 | width: 25px; |
| 282 | } |
| 283 | |
254 | 284 | .chosen-container-multi .chosen-choices li.search-choice { |
255 | 285 | position: relative; |
… |
… |
|
260 | 290 | border-radius: 3px; |
261 | 291 | background-color: #eeeeee; |
262 | | background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eeeeee)); |
263 | | background-image: -webkit-linear-gradient(#f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%); |
264 | | background-image: -moz-linear-gradient(#f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%); |
265 | | background-image: -o-linear-gradient(#f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%); |
266 | | background-image: linear-gradient(#f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%); |
| 292 | background-image: -webkit-gradient(linear, left top, left bottom, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), to(#eee)); |
| 293 | background-image: linear-gradient(#f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%); |
267 | 294 | background-size: 100% 19px; |
268 | 295 | background-repeat: repeat-x; |
269 | 296 | background-clip: padding-box; |
270 | | box-shadow: 0 0 2px white inset, 0 1px 0 rgba(0, 0, 0, 0.05); |
| 297 | -webkit-box-shadow: 0 0 2px #fff inset, 0 1px 0 rgba(0, 0, 0, 0.05); |
| 298 | box-shadow: 0 0 2px #fff inset, 0 1px 0 rgba(0, 0, 0, 0.05); |
271 | 299 | color: #333; |
272 | 300 | line-height: 13px; |
273 | 301 | cursor: default; |
274 | 302 | } |
| 303 | |
275 | 304 | .chosen-container-multi .chosen-choices li.search-choice span { |
276 | 305 | word-wrap: break-word; |
277 | 306 | } |
| 307 | |
278 | 308 | .chosen-container-multi .chosen-choices li.search-choice .search-choice-close { |
279 | 309 | position: absolute; |
… |
… |
|
283 | 313 | width: 12px; |
284 | 314 | height: 12px; |
285 | | background: url('chosen-sprite.png') -42px 1px no-repeat; |
| 315 | background: url("chosen-sprite.png") -42px 1px no-repeat; |
286 | 316 | font-size: 1px; |
287 | 317 | } |
| 318 | |
288 | 319 | .chosen-container-multi .chosen-choices li.search-choice .search-choice-close:hover { |
289 | 320 | background-position: -42px -10px; |
290 | 321 | } |
| 322 | |
291 | 323 | .chosen-container-multi .chosen-choices li.search-choice-disabled { |
292 | 324 | padding-right: 5px; |
293 | 325 | border: 1px solid #ccc; |
294 | 326 | background-color: #e4e4e4; |
295 | | background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eeeeee)); |
296 | | background-image: -webkit-linear-gradient(#f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%); |
297 | | background-image: -moz-linear-gradient(#f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%); |
298 | | background-image: -o-linear-gradient(#f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%); |
299 | | background-image: linear-gradient(#f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%); |
| 327 | background-image: -webkit-gradient(linear, left top, left bottom, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), to(#eee)); |
| 328 | background-image: linear-gradient(#f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%); |
300 | 329 | color: #666; |
301 | 330 | } |
| 331 | |
302 | 332 | .chosen-container-multi .chosen-choices li.search-choice-focus { |
303 | 333 | background: #d4d4d4; |
304 | 334 | } |
| 335 | |
305 | 336 | .chosen-container-multi .chosen-choices li.search-choice-focus .search-choice-close { |
306 | 337 | background-position: -42px -10px; |
307 | 338 | } |
| 339 | |
308 | 340 | .chosen-container-multi .chosen-results { |
309 | 341 | margin: 0; |
310 | 342 | padding: 0; |
311 | 343 | } |
| 344 | |
312 | 345 | .chosen-container-multi .chosen-drop .result-selected { |
313 | 346 | display: list-item; |
… |
… |
|
320 | 353 | .chosen-container-active .chosen-single { |
321 | 354 | border: 1px solid #5897fb; |
322 | | box-shadow: 0 0 5px rgba(0, 0, 0, 0.3); |
323 | | } |
| 355 | -webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.3); |
| 356 | box-shadow: 0 0 5px rgba(0, 0, 0, 0.3); |
| 357 | } |
| 358 | |
324 | 359 | .chosen-container-active.chosen-with-drop .chosen-single { |
325 | 360 | border: 1px solid #aaa; |
326 | | -moz-border-radius-bottomright: 0; |
327 | 361 | border-bottom-right-radius: 0; |
328 | | -moz-border-radius-bottomleft: 0; |
329 | 362 | border-bottom-left-radius: 0; |
330 | | background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(20%, #eeeeee), color-stop(80%, #ffffff)); |
331 | | background-image: -webkit-linear-gradient(#eeeeee 20%, #ffffff 80%); |
332 | | background-image: -moz-linear-gradient(#eeeeee 20%, #ffffff 80%); |
333 | | background-image: -o-linear-gradient(#eeeeee 20%, #ffffff 80%); |
334 | | background-image: linear-gradient(#eeeeee 20%, #ffffff 80%); |
335 | | box-shadow: 0 1px 0 #fff inset; |
336 | | } |
| 363 | background-image: -webkit-gradient(linear, left top, left bottom, color-stop(20%, #eee), color-stop(80%, #fff)); |
| 364 | background-image: linear-gradient(#eee 20%, #fff 80%); |
| 365 | -webkit-box-shadow: 0 1px 0 #fff inset; |
| 366 | box-shadow: 0 1px 0 #fff inset; |
| 367 | } |
| 368 | |
337 | 369 | .chosen-container-active.chosen-with-drop .chosen-single div { |
338 | 370 | border-left: none; |
339 | 371 | background: transparent; |
340 | 372 | } |
| 373 | |
341 | 374 | .chosen-container-active.chosen-with-drop .chosen-single div b { |
342 | 375 | background-position: -18px 2px; |
343 | 376 | } |
| 377 | |
344 | 378 | .chosen-container-active .chosen-choices { |
345 | 379 | border: 1px solid #5897fb; |
346 | | box-shadow: 0 0 5px rgba(0, 0, 0, 0.3); |
347 | | } |
| 380 | -webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.3); |
| 381 | box-shadow: 0 0 5px rgba(0, 0, 0, 0.3); |
| 382 | } |
| 383 | |
348 | 384 | .chosen-container-active .chosen-choices li.search-field input[type="text"] { |
349 | 385 | color: #222 !important; |
… |
… |
|
356 | 392 | cursor: default; |
357 | 393 | } |
| 394 | |
358 | 395 | .chosen-disabled .chosen-single { |
359 | 396 | cursor: default; |
360 | 397 | } |
| 398 | |
361 | 399 | .chosen-disabled .chosen-choices .search-choice .search-choice-close { |
362 | 400 | cursor: default; |
… |
… |
|
368 | 406 | text-align: right; |
369 | 407 | } |
| 408 | |
370 | 409 | .chosen-rtl .chosen-single { |
371 | 410 | overflow: visible; |
372 | 411 | padding: 0 8px 0 0; |
373 | 412 | } |
| 413 | |
374 | 414 | .chosen-rtl .chosen-single span { |
375 | 415 | margin-right: 0; |
… |
… |
|
377 | 417 | direction: rtl; |
378 | 418 | } |
| 419 | |
379 | 420 | .chosen-rtl .chosen-single-with-deselect span { |
380 | 421 | margin-left: 38px; |
381 | 422 | } |
| 423 | |
382 | 424 | .chosen-rtl .chosen-single div { |
383 | 425 | right: auto; |
384 | 426 | left: 3px; |
385 | 427 | } |
| 428 | |
386 | 429 | .chosen-rtl .chosen-single abbr { |
387 | 430 | right: auto; |
388 | 431 | left: 26px; |
389 | 432 | } |
| 433 | |
390 | 434 | .chosen-rtl .chosen-choices li { |
391 | 435 | float: right; |
392 | 436 | } |
| 437 | |
393 | 438 | .chosen-rtl .chosen-choices li.search-field input[type="text"] { |
394 | 439 | direction: rtl; |
395 | 440 | } |
| 441 | |
396 | 442 | .chosen-rtl .chosen-choices li.search-choice { |
397 | 443 | margin: 3px 5px 3px 0; |
398 | 444 | padding: 3px 5px 3px 19px; |
399 | 445 | } |
| 446 | |
400 | 447 | .chosen-rtl .chosen-choices li.search-choice .search-choice-close { |
401 | 448 | right: auto; |
402 | 449 | left: 4px; |
403 | 450 | } |
404 | | .chosen-rtl.chosen-container-single-nosearch .chosen-search, |
405 | | .chosen-rtl .chosen-drop { |
406 | | left: 9999px; |
407 | | } |
| 451 | |
408 | 452 | .chosen-rtl.chosen-container-single .chosen-results { |
409 | 453 | margin: 0 0 4px 4px; |
410 | 454 | padding: 0 4px 0 0; |
411 | 455 | } |
| 456 | |
412 | 457 | .chosen-rtl .chosen-results li.group-option { |
413 | 458 | padding-right: 15px; |
414 | 459 | padding-left: 0; |
415 | 460 | } |
| 461 | |
416 | 462 | .chosen-rtl.chosen-container-active.chosen-with-drop .chosen-single div { |
417 | 463 | border-right: none; |
418 | 464 | } |
| 465 | |
419 | 466 | .chosen-rtl .chosen-search input[type="text"] { |
420 | 467 | padding: 4px 5px 4px 20px; |
421 | | background: white url('chosen-sprite.png') no-repeat -30px -20px; |
422 | | background: url('chosen-sprite.png') no-repeat -30px -20px; |
| 468 | background: url("chosen-sprite.png") no-repeat -30px -20px; |
423 | 469 | direction: rtl; |
424 | 470 | } |
| 471 | |
425 | 472 | .chosen-rtl.chosen-container-single .chosen-single div b { |
426 | 473 | background-position: 6px 2px; |
427 | 474 | } |
| 475 | |
428 | 476 | .chosen-rtl.chosen-container-single.chosen-with-drop .chosen-single div b { |
429 | 477 | background-position: -12px 2px; |
… |
… |
|
440 | 488 | .chosen-container .chosen-results-scroll-down span, |
441 | 489 | .chosen-container .chosen-results-scroll-up span { |
442 | | background-image: url('chosen-sprite@2x.png') !important; |
| 490 | background-image: url("chosen-sprite@2x.png") !important; |
443 | 491 | background-size: 52px 37px !important; |
444 | 492 | background-repeat: no-repeat !important; |
445 | 493 | } |
446 | 494 | } |
447 | | /* @end */ |
| 495 | |
| 496 | /* @end */ |
-
r98557
|
r113714
|
|
3 | 3 | by Patrick Filler for Harvest, http://getharvest.com |
4 | 4 | |
5 | | Version 1.6.1 |
| 5 | Version 1.8.7 |
6 | 6 | Full source at https://github.com/harvesthq/chosen |
7 | | Copyright (c) 2011-2016 Harvest http://getharvest.com |
| 7 | Copyright (c) 2011-2018 Harvest http://getharvest.com |
8 | 8 | |
9 | 9 | MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md |
… |
… |
|
12 | 12 | |
13 | 13 | (function() { |
14 | | var $, AbstractChosen, Chosen, SelectParser, _ref, |
15 | | __hasProp = {}.hasOwnProperty, |
16 | | __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; |
17 | 18 | |
18 | 19 | SelectParser = (function() { |
… |
… |
|
31 | 32 | |
32 | 33 | SelectParser.prototype.add_group = function(group) { |
33 | | var group_position, option, _i, _len, _ref, _results; |
| 34 | var group_position, i, len, option, ref, results1; |
34 | 35 | group_position = this.parsed.length; |
35 | 36 | this.parsed.push({ |
36 | 37 | array_index: group_position, |
37 | 38 | group: true, |
38 | | label: this.escapeExpression(group.label), |
| 39 | label: group.label, |
39 | 40 | title: group.title ? group.title : void 0, |
40 | 41 | children: 0, |
… |
… |
|
42 | 43 | classes: group.className |
43 | 44 | }); |
44 | | _ref = group.childNodes; |
45 | | _results = []; |
46 | | for (_i = 0, _len = _ref.length; _i < _len; _i++) { |
47 | | option = _ref[_i]; |
48 | | _results.push(this.add_option(option, group_position, group.disabled)); |
49 | | } |
50 | | return _results; |
| 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)); |
| 50 | } |
| 51 | return results1; |
51 | 52 | }; |
52 | 53 | |
… |
… |
|
82 | 83 | }; |
83 | 84 | |
84 | | SelectParser.prototype.escapeExpression = function(text) { |
85 | | var map, unsafe_chars; |
86 | | if ((text == null) || text === false) { |
87 | | return ""; |
88 | | } |
89 | | if (!/[\&\<\>\"\'\`]/.test(text)) { |
90 | | return text; |
91 | | } |
92 | | map = { |
93 | | "<": "<", |
94 | | ">": ">", |
95 | | '"': """, |
96 | | "'": "'", |
97 | | "`": "`" |
98 | | }; |
99 | | unsafe_chars = /&(?!\w+;)|[\<\>\"\'\`]/g; |
100 | | return text.replace(unsafe_chars, function(chr) { |
101 | | return map[chr] || "&"; |
102 | | }); |
103 | | }; |
104 | | |
105 | 85 | return SelectParser; |
106 | 86 | |
… |
… |
|
108 | 88 | |
109 | 89 | SelectParser.select_to_array = function(select) { |
110 | | var child, parser, _i, _len, _ref; |
| 90 | var child, i, len, parser, ref; |
111 | 91 | parser = new SelectParser(); |
112 | | _ref = select.childNodes; |
113 | | for (_i = 0, _len = _ref.length; _i < _len; _i++) { |
114 | | child = _ref[_i]; |
| 92 | ref = select.childNodes; |
| 93 | for (i = 0, len = ref.length; i < len; i++) { |
| 94 | child = ref[i]; |
115 | 95 | parser.add_node(child); |
116 | 96 | } |
… |
… |
|
119 | 99 | |
120 | 100 | AbstractChosen = (function() { |
121 | | function AbstractChosen(form_field, options) { |
| 101 | function AbstractChosen(form_field, options1) { |
122 | 102 | this.form_field = form_field; |
123 | | this.options = options != null ? options : {}; |
| 103 | this.options = options1 != null ? options1 : {}; |
| 104 | this.label_click_handler = bind(this.label_click_handler, this); |
124 | 105 | if (!AbstractChosen.browser_is_supported()) { |
125 | 106 | return; |
… |
… |
|
135 | 116 | |
136 | 117 | AbstractChosen.prototype.set_default_values = function() { |
137 | | var _this = this; |
138 | | this.click_test_action = function(evt) { |
139 | | return _this.test_active_click(evt); |
140 | | }; |
141 | | this.activate_action = function(evt) { |
142 | | return _this.activate_field(evt); |
143 | | }; |
| 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); |
144 | 128 | this.active_field = false; |
145 | 129 | this.mouse_on_container = false; |
146 | 130 | this.results_showing = false; |
147 | 131 | this.result_highlighted = null; |
| 132 | this.is_rtl = this.options.rtl || /\bchosen-rtl\b/.test(this.form_field.className); |
148 | 133 | 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; |
149 | 134 | this.disable_search_threshold = this.options.disable_search_threshold || 0; |
… |
… |
|
159 | 144 | this.include_group_label_in_selected = this.options.include_group_label_in_selected || false; |
160 | 145 | this.max_shown_results = this.options.max_shown_results || Number.POSITIVE_INFINITY; |
161 | | return this.case_sensitive_search = this.options.case_sensitive_search || false; |
| 146 | this.case_sensitive_search = this.options.case_sensitive_search || false; |
| 147 | return this.hide_results_on_select = this.options.hide_results_on_select != null ? this.options.hide_results_on_select : true; |
162 | 148 | }; |
163 | 149 | |
… |
… |
|
170 | 156 | this.default_text = this.options.placeholder_text_single || this.options.placeholder_text || AbstractChosen.default_single_text; |
171 | 157 | } |
| 158 | this.default_text = this.escape_html(this.default_text); |
172 | 159 | return this.results_none_found = this.form_field.getAttribute("data-no_results_text") || this.options.no_results_text || AbstractChosen.default_no_result_text; |
173 | 160 | }; |
… |
… |
|
175 | 162 | AbstractChosen.prototype.choice_label = function(item) { |
176 | 163 | if (this.include_group_label_in_selected && (item.group_label != null)) { |
177 | | return "<b class='group-name'>" + item.group_label + "</b>" + item.html; |
| 164 | return "<b class='group-name'>" + (this.escape_html(item.group_label)) + "</b>" + item.html; |
178 | 165 | } else { |
179 | 166 | return item.html; |
… |
… |
|
190 | 177 | |
191 | 178 | AbstractChosen.prototype.input_focus = function(evt) { |
192 | | var _this = this; |
193 | 179 | if (this.is_multiple) { |
194 | 180 | if (!this.active_field) { |
195 | | return setTimeout((function() { |
196 | | return _this.container_mousedown(); |
197 | | }), 50); |
| 181 | return setTimeout(((function(_this) { |
| 182 | return function() { |
| 183 | return _this.container_mousedown(); |
| 184 | }; |
| 185 | })(this)), 50); |
198 | 186 | } |
199 | 187 | } else { |
… |
… |
|
205 | 193 | |
206 | 194 | AbstractChosen.prototype.input_blur = function(evt) { |
207 | | var _this = this; |
208 | 195 | if (!this.mouse_on_container) { |
209 | 196 | this.active_field = false; |
210 | | return setTimeout((function() { |
211 | | return _this.blur_test(); |
212 | | }), 100); |
| 197 | return setTimeout(((function(_this) { |
| 198 | return function() { |
| 199 | return _this.blur_test(); |
| 200 | }; |
| 201 | })(this)), 100); |
| 202 | } |
| 203 | }; |
| 204 | |
| 205 | AbstractChosen.prototype.label_click_handler = function(evt) { |
| 206 | if (this.is_multiple) { |
| 207 | return this.container_mousedown(evt); |
| 208 | } else { |
| 209 | return this.activate_field(); |
213 | 210 | } |
214 | 211 | }; |
215 | 212 | |
216 | 213 | AbstractChosen.prototype.results_option_build = function(options) { |
217 | | var content, data, data_content, shown_results, _i, _len, _ref; |
| 214 | var content, data, data_content, i, len, ref, shown_results; |
218 | 215 | content = ''; |
219 | 216 | shown_results = 0; |
220 | | _ref = this.results_data; |
221 | | for (_i = 0, _len = _ref.length; _i < _len; _i++) { |
222 | | data = _ref[_i]; |
| 217 | ref = this.results_data; |
| 218 | for (i = 0, len = ref.length; i < len; i++) { |
| 219 | data = ref[i]; |
223 | 220 | data_content = ''; |
224 | 221 | if (data.group) { |
… |
… |
|
271 | 268 | option_el = document.createElement("li"); |
272 | 269 | option_el.className = classes.join(" "); |
273 | | option_el.style.cssText = option.style; |
| 270 | if (option.style) { |
| 271 | option_el.style.cssText = option.style; |
| 272 | } |
274 | 273 | option_el.setAttribute("data-option-array-index", option.array_index); |
275 | | option_el.innerHTML = option.search_text; |
| 274 | option_el.innerHTML = option.highlighted_html || option.html; |
276 | 275 | if (option.title) { |
277 | 276 | option_el.title = option.title; |
… |
… |
|
295 | 294 | group_el = document.createElement("li"); |
296 | 295 | group_el.className = classes.join(" "); |
297 | | group_el.innerHTML = group.search_text; |
| 296 | group_el.innerHTML = group.highlighted_html || this.escape_html(group.label); |
298 | 297 | if (group.title) { |
299 | 298 | group_el.title = group.title; |
… |
… |
|
315 | 314 | |
316 | 315 | AbstractChosen.prototype.reset_single_select_options = function() { |
317 | | var result, _i, _len, _ref, _results; |
318 | | _ref = this.results_data; |
319 | | _results = []; |
320 | | for (_i = 0, _len = _ref.length; _i < _len; _i++) { |
321 | | result = _ref[_i]; |
| 316 | var i, len, ref, result, results1; |
| 317 | ref = this.results_data; |
| 318 | results1 = []; |
| 319 | for (i = 0, len = ref.length; i < len; i++) { |
| 320 | result = ref[i]; |
322 | 321 | if (result.selected) { |
323 | | _results.push(result.selected = false); |
| 322 | results1.push(result.selected = false); |
324 | 323 | } else { |
325 | | _results.push(void 0); |
326 | | } |
327 | | } |
328 | | return _results; |
| 324 | results1.push(void 0); |
| 325 | } |
| 326 | } |
| 327 | return results1; |
329 | 328 | }; |
330 | 329 | |
… |
… |
|
345 | 344 | }; |
346 | 345 | |
347 | | AbstractChosen.prototype.winnow_results = function() { |
348 | | var escapedSearchText, option, regex, results, results_group, searchText, startpos, text, zregex, _i, _len, _ref; |
| 346 | AbstractChosen.prototype.winnow_results = function(options) { |
| 347 | var escapedQuery, fix, i, len, option, prefix, query, ref, regex, results, results_group, search_match, startpos, suffix, text; |
349 | 348 | this.no_results_clear(); |
350 | 349 | results = 0; |
351 | | searchText = this.get_search_text(); |
352 | | escapedSearchText = searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); |
353 | | zregex = new RegExp(escapedSearchText, 'i'); |
354 | | regex = this.get_search_regex(escapedSearchText); |
355 | | _ref = this.results_data; |
356 | | for (_i = 0, _len = _ref.length; _i < _len; _i++) { |
357 | | option = _ref[_i]; |
| 350 | query = this.get_search_text(); |
| 351 | escapedQuery = query.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); |
| 352 | regex = this.get_search_regex(escapedQuery); |
| 353 | ref = this.results_data; |
| 354 | for (i = 0, len = ref.length; i < len; i++) { |
| 355 | option = ref[i]; |
358 | 356 | option.search_match = false; |
359 | 357 | results_group = null; |
| 358 | search_match = null; |
| 359 | option.highlighted_html = ''; |
360 | 360 | if (this.include_option_in_results(option)) { |
361 | 361 | if (option.group) { |
… |
… |
|
370 | 370 | results_group.active_options += 1; |
371 | 371 | } |
372 | | option.search_text = option.group ? option.label : option.html; |
| 372 | text = option.group ? option.label : option.text; |
373 | 373 | if (!(option.group && !this.group_search)) { |
374 | | option.search_match = this.search_string_match(option.search_text, regex); |
| 374 | search_match = this.search_string_match(text, regex); |
| 375 | option.search_match = search_match != null; |
375 | 376 | if (option.search_match && !option.group) { |
376 | 377 | results += 1; |
377 | 378 | } |
378 | 379 | if (option.search_match) { |
379 | | if (searchText.length) { |
380 | | startpos = option.search_text.search(zregex); |
381 | | text = option.search_text.substr(0, startpos + searchText.length) + '</em>' + option.search_text.substr(startpos + searchText.length); |
382 | | option.search_text = text.substr(0, startpos) + '<em>' + text.substr(startpos); |
| 380 | if (query.length) { |
| 381 | startpos = search_match.index; |
| 382 | prefix = text.slice(0, startpos); |
| 383 | fix = text.slice(startpos, startpos + query.length); |
| 384 | suffix = text.slice(startpos + query.length); |
| 385 | option.highlighted_html = (this.escape_html(prefix)) + "<em>" + (this.escape_html(fix)) + "</em>" + (this.escape_html(suffix)); |
383 | 386 | } |
384 | 387 | if (results_group != null) { |
… |
… |
|
392 | 395 | } |
393 | 396 | this.result_clear_highlight(); |
394 | | if (results < 1 && searchText.length) { |
| 397 | if (results < 1 && query.length) { |
395 | 398 | this.update_results_content(""); |
396 | | return this.no_results(searchText); |
| 399 | return this.no_results(query); |
397 | 400 | } else { |
398 | 401 | this.update_results_content(this.results_option_build()); |
399 | | return this.winnow_results_set_highlight(); |
| 402 | if (!(options != null ? options.skip_highlight : void 0)) { |
| 403 | return this.winnow_results_set_highlight(); |
| 404 | } |
400 | 405 | } |
401 | 406 | }; |
402 | 407 | |
403 | 408 | AbstractChosen.prototype.get_search_regex = function(escaped_search_string) { |
404 | | var regex_anchor, regex_flag; |
405 | | regex_anchor = this.search_contains ? "" : "^"; |
| 409 | var regex_flag, regex_string; |
| 410 | regex_string = this.search_contains ? escaped_search_string : "(^|\\s|\\b)" + escaped_search_string + "[^\\s]*"; |
| 411 | if (!(this.enable_split_word_search || this.search_contains)) { |
| 412 | regex_string = "^" + regex_string; |
| 413 | } |
406 | 414 | regex_flag = this.case_sensitive_search ? "" : "i"; |
407 | | return new RegExp(regex_anchor + escaped_search_string, regex_flag); |
| 415 | return new RegExp(regex_string, regex_flag); |
408 | 416 | }; |
409 | 417 | |
410 | 418 | AbstractChosen.prototype.search_string_match = function(search_string, regex) { |
411 | | var part, parts, _i, _len; |
412 | | if (regex.test(search_string)) { |
413 | | return true; |
414 | | } else if (this.enable_split_word_search && (search_string.indexOf(" ") >= 0 || search_string.indexOf("[") === 0)) { |
415 | | parts = search_string.replace(/\[|\]/g, "").split(" "); |
416 | | if (parts.length) { |
417 | | for (_i = 0, _len = parts.length; _i < _len; _i++) { |
418 | | part = parts[_i]; |
419 | | if (regex.test(part)) { |
420 | | return true; |
421 | | } |
422 | | } |
423 | | } |
424 | | } |
| 419 | var match; |
| 420 | match = regex.exec(search_string); |
| 421 | if (!this.search_contains && (match != null ? match[1] : void 0)) { |
| 422 | match.index += 1; |
| 423 | } |
| 424 | return match; |
425 | 425 | }; |
426 | 426 | |
427 | 427 | AbstractChosen.prototype.choices_count = function() { |
428 | | var option, _i, _len, _ref; |
| 428 | var i, len, option, ref; |
429 | 429 | if (this.selected_option_count != null) { |
430 | 430 | return this.selected_option_count; |
431 | 431 | } |
432 | 432 | this.selected_option_count = 0; |
433 | | _ref = this.form_field.options; |
434 | | for (_i = 0, _len = _ref.length; _i < _len; _i++) { |
435 | | option = _ref[_i]; |
| 433 | ref = this.form_field.options; |
| 434 | for (i = 0, len = ref.length; i < len; i++) { |
| 435 | option = ref[i]; |
436 | 436 | if (option.selected) { |
437 | 437 | this.selected_option_count += 1; |
… |
… |
|
443 | 443 | AbstractChosen.prototype.choices_click = function(evt) { |
444 | 444 | evt.preventDefault(); |
| 445 | this.activate_field(); |
445 | 446 | if (!(this.results_showing || this.is_disabled)) { |
446 | 447 | return this.results_show(); |
… |
… |
|
448 | 449 | }; |
449 | 450 | |
| 451 | AbstractChosen.prototype.keydown_checker = function(evt) { |
| 452 | var ref, stroke; |
| 453 | stroke = (ref = evt.which) != null ? ref : evt.keyCode; |
| 454 | this.search_field_scale(); |
| 455 | if (stroke !== 8 && this.pending_backstroke) { |
| 456 | this.clear_backstroke(); |
| 457 | } |
| 458 | switch (stroke) { |
| 459 | case 8: |
| 460 | this.backstroke_length = this.get_search_field_value().length; |
| 461 | break; |
| 462 | case 9: |
| 463 | if (this.results_showing && !this.is_multiple) { |
| 464 | this.result_select(evt); |
| 465 | } |
| 466 | this.mouse_on_container = false; |
| 467 | break; |
| 468 | case 13: |
| 469 | if (this.results_showing) { |
| 470 | evt.preventDefault(); |
| 471 | } |
| 472 | break; |
| 473 | case 27: |
| 474 | if (this.results_showing) { |
| 475 | evt.preventDefault(); |
| 476 | } |
| 477 | break; |
| 478 | case 32: |
| 479 | if (this.disable_search) { |
| 480 | evt.preventDefault(); |
| 481 | } |
| 482 | break; |
| 483 | case 38: |
| 484 | evt.preventDefault(); |
| 485 | this.keyup_arrow(); |
| 486 | break; |
| 487 | case 40: |
| 488 | evt.preventDefault(); |
| 489 | this.keydown_arrow(); |
| 490 | break; |
| 491 | } |
| 492 | }; |
| 493 | |
450 | 494 | AbstractChosen.prototype.keyup_checker = function(evt) { |
451 | | var stroke, _ref; |
452 | | stroke = (_ref = evt.which) != null ? _ref : evt.keyCode; |
| 495 | var ref, stroke; |
| 496 | stroke = (ref = evt.which) != null ? ref : evt.keyCode; |
453 | 497 | this.search_field_scale(); |
454 | 498 | switch (stroke) { |
455 | 499 | case 8: |
456 | 500 | if (this.is_multiple && this.backstroke_length < 1 && this.choices_count() > 0) { |
457 | | return this.keydown_backstroke(); |
| 501 | this.keydown_backstroke(); |
458 | 502 | } else if (!this.pending_backstroke) { |
459 | 503 | this.result_clear_highlight(); |
460 | | return this.results_search(); |
| 504 | this.results_search(); |
461 | 505 | } |
462 | 506 | break; |
… |
… |
|
464 | 508 | evt.preventDefault(); |
465 | 509 | if (this.results_showing) { |
466 | | return this.result_select(evt); |
| 510 | this.result_select(evt); |
467 | 511 | } |
468 | 512 | break; |
… |
… |
|
471 | 515 | this.results_hide(); |
472 | 516 | } |
473 | | return true; |
| 517 | break; |
474 | 518 | case 9: |
| 519 | case 16: |
| 520 | case 17: |
| 521 | case 18: |
475 | 522 | case 38: |
476 | 523 | case 40: |
477 | | case 16: |
478 | 524 | case 91: |
479 | | case 17: |
480 | | case 18: |
481 | 525 | break; |
482 | 526 | default: |
483 | | return this.results_search(); |
| 527 | this.results_search(); |
| 528 | break; |
484 | 529 | } |
485 | 530 | }; |
486 | 531 | |
487 | 532 | AbstractChosen.prototype.clipboard_event_checker = function(evt) { |
488 | | var _this = this; |
489 | | return setTimeout((function() { |
490 | | return _this.results_search(); |
491 | | }), 50); |
| 533 | if (this.is_disabled) { |
| 534 | return; |
| 535 | } |
| 536 | return setTimeout(((function(_this) { |
| 537 | return function() { |
| 538 | return _this.results_search(); |
| 539 | }; |
| 540 | })(this)), 50); |
492 | 541 | }; |
493 | 542 | |
… |
… |
|
496 | 545 | return this.options.width; |
497 | 546 | } else { |
498 | | return "" + this.form_field.offsetWidth + "px"; |
| 547 | return this.form_field.offsetWidth + "px"; |
499 | 548 | } |
500 | 549 | }; |
… |
… |
|
537 | 586 | tmp.appendChild(element); |
538 | 587 | return tmp.innerHTML; |
| 588 | }; |
| 589 | |
| 590 | AbstractChosen.prototype.get_single_html = function() { |
| 591 | return "<a class=\"chosen-single chosen-default\">\n <span>" + this.default_text + "</span>\n <div><b></b></div>\n</a>\n<div class=\"chosen-drop\">\n <div class=\"chosen-search\">\n <input class=\"chosen-search-input\" type=\"text\" autocomplete=\"off\" />\n </div>\n <ul class=\"chosen-results\"></ul>\n</div>"; |
| 592 | }; |
| 593 | |
| 594 | AbstractChosen.prototype.get_multi_html = function() { |
| 595 | return "<ul class=\"chosen-choices\">\n <li class=\"search-field\">\n <input class=\"chosen-search-input\" type=\"text\" autocomplete=\"off\" value=\"" + this.default_text + "\" />\n </li>\n</ul>\n<div class=\"chosen-drop\">\n <ul class=\"chosen-results\"></ul>\n</div>"; |
| 596 | }; |
| 597 | |
| 598 | AbstractChosen.prototype.get_no_results_html = function(terms) { |
| 599 | return "<li class=\"no-results\">\n " + this.results_none_found + " <span>" + (this.escape_html(terms)) + "</span>\n</li>"; |
539 | 600 | }; |
540 | 601 | |
… |
… |
|
583 | 644 | }); |
584 | 645 | |
585 | | Chosen = (function(_super) { |
586 | | __extends(Chosen, _super); |
| 646 | Chosen = (function(superClass) { |
| 647 | extend(Chosen, superClass); |
587 | 648 | |
588 | 649 | function Chosen() { |
589 | | _ref = Chosen.__super__.constructor.apply(this, arguments); |
590 | | return _ref; |
| 650 | return Chosen.__super__.constructor.apply(this, arguments); |
591 | 651 | } |
592 | 652 | |
593 | 653 | Chosen.prototype.setup = function() { |
594 | 654 | this.form_field_jq = $(this.form_field); |