Commit 43409ee5a963d6c3c302258bf0954e79b2245481

Authored by Андрей Ларионов
Exists in master

Merge branch 'master' of http://gitlab.nologostudio.ru/alarionov/rekamore-su

Showing 13 changed files Side-by-side Diff

app/Enums/DbExportColumns.php
... ... @@ -0,0 +1,17 @@
  1 +<?php
  2 +
  3 +namespace App\Enums;
  4 +
  5 +use App\Enums\EnumTraits\EnumToArray;
  6 +
  7 +enum DbExportColumns: string
  8 +{
  9 + use EnumToArray;
  10 +
  11 + case job_title = ['column' => 'job_titles.name', 'title' => 'Должность'];
  12 + case surname = ['column' => 'users.surname', 'title' => 'Фамилия'];
  13 + case name_man = ['column' => 'users.name_man', 'title' => 'Имя'];
  14 + case surname2 = ['column' => 'users.surname2', 'title' => 'Отчетство'];
  15 + case email = ['column' => 'users.email', 'title' => 'Почта'];
  16 + case telephone = ['column' => 'users.telephone', 'title' => 'Телефон'];
  17 +}
app/Enums/EnumTraits/EnumToArray.php
... ... @@ -8,4 +8,14 @@ trait EnumToArray
8 8 {
9 9 return array_column(self::cases(), 'value');
10 10 }
  11 +
  12 + public static function names(): array
  13 + {
  14 + return array_column(self::cases(), 'name');
  15 + }
  16 +
  17 + public static function toArray(): array
  18 + {
  19 + return array_combine(self::names(), self::values());
  20 + }
11 21 }
app/Http/Controllers/EmployerController.php
... ... @@ -5,34 +5,24 @@ namespace App\Http\Controllers;
5 5 use App\Classes\RusDate;
6 6 use App\Classes\Tools;
7 7 use App\Http\Requests\BaseUser_min_Request;
8   -use App\Http\Requests\BaseUserRequest;
9 8 use App\Http\Requests\FlotRequest;
10 9 use App\Http\Requests\MessagesRequiest;
11 10 use App\Http\Requests\VacancyRequestEdit;
12   -use App\Http\Requests\VacansiaRequiest;
13   -use App\Mail\MailAdminy;
14 11 use App\Mail\MailCreateEmployer;
15 12 use App\Mail\MailSotrudnichestvo;
16 13 use App\Mail\SendAllMessages;
17 14 use App\Models\Ad_employer;
18   -use App\Models\Ad_jobs;
19 15 use App\Models\ad_response;
20 16 use App\Models\Category;
21   -use App\Models\Education;
22 17 use App\Models\Employer;
23   -use App\Models\employers_main;
24 18 use App\Models\Flot;
25 19 use App\Models\Job_title;
26   -use App\Models\Like_vacancy;
27 20 use App\Models\Like_worker;
28 21 use App\Models\Message;
29   -use App\Models\Positions;
30 22 use App\Models\Worker;
31 23 use Carbon\Carbon;
32 24 use Illuminate\Auth\Events\Registered;
33 25 use Illuminate\Database\Eloquent\Builder;
34   -use Illuminate\Database\Eloquent\Model;
35   -use Illuminate\Foundation\Auth\User;
36 26 use Illuminate\Http\Request;
37 27 use Illuminate\Support\Facades\Auth;
38 28 use Illuminate\Support\Facades\Hash;
... ... @@ -40,6 +30,7 @@ use Illuminate\Support\Facades\Mail;
40 30 use Illuminate\Support\Facades\Storage;
41 31 use App\Models\User as User_Model;
42 32 use Illuminate\Support\Facades\Validator;
  33 +use App\Enums\DbExportColumns;
43 34  
44 35 class EmployerController extends Controller
45 36 {
... ... @@ -614,17 +605,6 @@ class EmployerController extends Controller
614 605  
615 606 // База данных
616 607 public function bd(Request $request) {
617   - // для типа BelongsTo
618   - //$documents = Document::query()->orderBy(Location::select('name')
619   - // ->whereColumn('locations.id', 'documents.location_id')
620   - //);
621   -
622   - // для типа HasOne/Many
623   - // $documents = Document::::query()->orderBy(Location::select('name')
624   - // ->whereColumn('locations.document_id', 'documents.id')
625   - //);
626   -
627   -
628 608 $users = User_Model::query()->with('workers');
629 609  
630 610 if ($request->has('search')) {
... ... @@ -642,8 +622,11 @@ class EmployerController extends Controller
642 622 $count_users = $users;
643 623 $users = $users->paginate(5);
644 624  
  625 + $export_options = DbExportColumns::toArray();
  626 +
  627 + $jobs_titles = Job_title::select('id', 'name')->orderBy('name', 'asc')->get()->toArray();
645 628  
646   - return view('employers.bd', compact('users', 'count_users'));
  629 + return view('employers.bd', compact('users', 'count_users', 'export_options', 'jobs_titles'));
647 630 }
648 631  
649 632 //Настройка уведомлений
app/Http/Controllers/WorkerController.php
... ... @@ -3,6 +3,7 @@
3 3 namespace App\Http\Controllers;
4 4  
5 5 use App\Classes\RusDate;
  6 +use App\Http\Requests\BaseUserRequest;
6 7 use App\Http\Requests\DocumentsRequest;
7 8 use App\Http\Requests\PrevCompanyRequest;
8 9 use App\Http\Requests\SertificationRequest;
... ... @@ -37,6 +38,10 @@ use Illuminate\Support\Facades\Auth;
37 38 use Illuminate\Support\Facades\Hash;
38 39 use Illuminate\Support\Facades\Storage;
39 40 use Illuminate\Support\Facades\Validator;
  41 +use PhpOffice\PhpSpreadsheet\Spreadsheet;
  42 +use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
  43 +use Symfony\Component\HttpFoundation\StreamedResponse;
  44 +use App\Enums\DbExportColumns;
40 45  
41 46 class WorkerController extends Controller
42 47 {
... ... @@ -215,23 +220,58 @@ class WorkerController extends Controller
215 220 return $pdf->stream();
216 221 }
217 222  
218   - public function resume_download_all() {
219   - $status_work = $this->status_work;
220   - $Query = Worker::query()->with('users')->with('job_titles')
221   - ->with('place_worker')->with('sertificate')->with('prev_company')
222   - ->with('infobloks')->
223   - whereHas('users', function (Builder $query) {
224   - $query->Where('is_worker', '=', '1')
225   - ->Where('is_bd', '=', '1');
226   - });
227   - //$Query = $Query->where('id', '=', $worker->id);
228   - $Query = $Query->get()->toArray();
  223 + public function resume_download_all(Request $request) {
  224 + $spreadsheet = new Spreadsheet();
  225 + $sheet = $spreadsheet->getActiveSheet();
229 226  
230   - view()->share('Query',$Query);
  227 + $columnMap = range('A', 'Z');
  228 + $columns = [];
231 229  
232   - $pdf = PDF::loadView('layout.pdf-list-people', $Query); //->setPaper('a4', 'landscape');
  230 + foreach (DbExportColumns::toArray() as $key => $value){
  231 + if ($request->input($key, 0)){
  232 + $sheet->setCellValue("{$columnMap[count($columns)]}1", ucfirst($value['title']));
  233 + $columns[] = $value['column'];
  234 + }
  235 + }
233 236  
234   - return $pdf->stream();
  237 + if (empty($columns)) {
  238 + return redirect()->back()->with('error', 'Пожалуйста выберите хотя бы 1 колонку для экспорта.');
  239 + }
  240 +
  241 + $query = User::select($columns)
  242 + ->leftJoin('workers', 'users.id', '=', 'workers.user_id')
  243 + ->leftJoin('job_titles', 'workers.position_work', '=', 'job_titles.id')
  244 + ->where('users.is_bd', '=', 1)
  245 + ;
  246 +
  247 + $job_title_list = $request->input('job_title_list', []);
  248 + if (!empty($job_title_list)){
  249 + $query->whereIn('job_titles.id', $job_title_list);
  250 + }
  251 +
  252 + $users = $query->get();
  253 + if ($users->count()){
  254 + $i = 2;
  255 + foreach ($users->toArray() as $user){
  256 + $j = 0;
  257 + foreach ($user as $field){
  258 + $sheet->setCellValue("{$columnMap[$j++]}$i", $field);
  259 + }
  260 + $i++;
  261 + }
  262 + }
  263 + $writer = new Xlsx($spreadsheet);
  264 + $fileName = 'DB.xlsx';
  265 +
  266 + $response = new StreamedResponse(function() use ($writer) {
  267 + $writer->save('php://output');
  268 + });
  269 +
  270 + $response->headers->set('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  271 + $response->headers->set('Content-Disposition', 'attachment;filename="' . $fileName . '"');
  272 + $response->headers->set('Cache-Control', 'max-age=0');
  273 +
  274 + return $response;
235 275 }
236 276  
237 277 // Кабинет работника
public/css/style_may2024.css
... ... @@ -8407,6 +8407,26 @@ main + .news {
8407 8407 flex-direction: column;
8408 8408 gap: 10px;
8409 8409 }
  8410 +.cabinet__export-wrap{
  8411 + padding: 10px;
  8412 + border: 1px #cecece solid;
  8413 + border-radius: 8px;
  8414 + width: 100%;
  8415 +}
  8416 +.cabinet__export-button-wrap{
  8417 + max-width: 200px;
  8418 + margin-bottom: 10px;
  8419 +}
  8420 +.cabinet__export-options-wrap{
  8421 + display: flex;
  8422 + justify-content: space-between;
  8423 +}
  8424 +.job-title-list-wrap{
  8425 + margin-top: 5px;
  8426 +}
  8427 +.cabinet__export-error{
  8428 + color: red;
  8429 +}
8410 8430 @media (min-width: 768px) {
8411 8431 .cabinet__filters {
8412 8432 gap: 20px;
public/js/chosen/chosen.css
... ... @@ -0,0 +1,496 @@
  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.7
  6 +Full source at https://github.com/harvesthq/chosen
  7 +Copyright (c) 2011-2018 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 +
  13 +/* @group Base */
  14 +.chosen-container {
  15 + position: relative;
  16 + display: inline-block;
  17 + vertical-align: middle;
  18 + font-size: 13px;
  19 + -webkit-user-select: none;
  20 + -moz-user-select: none;
  21 + -ms-user-select: none;
  22 + user-select: none;
  23 +}
  24 +
  25 +.chosen-container * {
  26 + -webkit-box-sizing: border-box;
  27 + box-sizing: border-box;
  28 +}
  29 +
  30 +.chosen-container .chosen-drop {
  31 + position: absolute;
  32 + top: 100%;
  33 + z-index: 1010;
  34 + width: 100%;
  35 + border: 1px solid #aaa;
  36 + border-top: 0;
  37 + background: #fff;
  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 +
  45 +.chosen-container.chosen-with-drop .chosen-drop {
  46 + clip: auto;
  47 + -webkit-clip-path: none;
  48 + clip-path: none;
  49 +}
  50 +
  51 +.chosen-container a {
  52 + cursor: pointer;
  53 +}
  54 +
  55 +.chosen-container .search-choice .group-name, .chosen-container .chosen-single .group-name {
  56 + margin-right: 4px;
  57 + overflow: hidden;
  58 + white-space: nowrap;
  59 + text-overflow: ellipsis;
  60 + font-weight: normal;
  61 + color: #999999;
  62 +}
  63 +
  64 +.chosen-container .search-choice .group-name:after, .chosen-container .chosen-single .group-name:after {
  65 + content: ":";
  66 + padding-left: 2px;
  67 + vertical-align: top;
  68 +}
  69 +
  70 +/* @end */
  71 +/* @group Single Chosen */
  72 +.chosen-container-single .chosen-single {
  73 + position: relative;
  74 + display: block;
  75 + overflow: hidden;
  76 + padding: 0 0 0 8px;
  77 + height: 25px;
  78 + border: 1px solid #aaa;
  79 + border-radius: 5px;
  80 + background-color: #fff;
  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%);
  83 + background-clip: padding-box;
  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);
  86 + color: #444;
  87 + text-decoration: none;
  88 + white-space: nowrap;
  89 + line-height: 24px;
  90 +}
  91 +
  92 +.chosen-container-single .chosen-default {
  93 + color: #999;
  94 +}
  95 +
  96 +.chosen-container-single .chosen-single span {
  97 + display: block;
  98 + overflow: hidden;
  99 + margin-right: 26px;
  100 + text-overflow: ellipsis;
  101 + white-space: nowrap;
  102 +}
  103 +
  104 +.chosen-container-single .chosen-single-with-deselect span {
  105 + margin-right: 38px;
  106 +}
  107 +
  108 +.chosen-container-single .chosen-single abbr {
  109 + position: absolute;
  110 + top: 6px;
  111 + right: 26px;
  112 + display: block;
  113 + width: 12px;
  114 + height: 12px;
  115 + background: url("chosen-sprite.png") -42px 1px no-repeat;
  116 + font-size: 1px;
  117 +}
  118 +
  119 +.chosen-container-single .chosen-single abbr:hover {
  120 + background-position: -42px -10px;
  121 +}
  122 +
  123 +.chosen-container-single.chosen-disabled .chosen-single abbr:hover {
  124 + background-position: -42px -10px;
  125 +}
  126 +
  127 +.chosen-container-single .chosen-single div {
  128 + position: absolute;
  129 + top: 0;
  130 + right: 0;
  131 + display: block;
  132 + width: 18px;
  133 + height: 100%;
  134 +}
  135 +
  136 +.chosen-container-single .chosen-single div b {
  137 + display: block;
  138 + width: 100%;
  139 + height: 100%;
  140 + background: url("chosen-sprite.png") no-repeat 0px 2px;
  141 +}
  142 +
  143 +.chosen-container-single .chosen-search {
  144 + position: relative;
  145 + z-index: 1010;
  146 + margin: 0;
  147 + padding: 3px 4px;
  148 + white-space: nowrap;
  149 +}
  150 +
  151 +.chosen-container-single .chosen-search input[type="text"] {
  152 + margin: 1px 0;
  153 + padding: 4px 20px 4px 5px;
  154 + width: 100%;
  155 + height: auto;
  156 + outline: 0;
  157 + border: 1px solid #aaa;
  158 + background: url("chosen-sprite.png") no-repeat 100% -20px;
  159 + font-size: 1em;
  160 + font-family: sans-serif;
  161 + line-height: normal;
  162 + border-radius: 0;
  163 +}
  164 +
  165 +.chosen-container-single .chosen-drop {
  166 + margin-top: -1px;
  167 + border-radius: 0 0 4px 4px;
  168 + background-clip: padding-box;
  169 +}
  170 +
  171 +.chosen-container-single.chosen-container-single-nosearch .chosen-search {
  172 + position: absolute;
  173 + clip: rect(0, 0, 0, 0);
  174 + -webkit-clip-path: inset(100% 100%);
  175 + clip-path: inset(100% 100%);
  176 +}
  177 +
  178 +/* @end */
  179 +/* @group Results */
  180 +.chosen-container .chosen-results {
  181 + color: #444;
  182 + position: relative;
  183 + overflow-x: hidden;
  184 + overflow-y: auto;
  185 + margin: 0 4px 4px 0;
  186 + padding: 0 0 0 4px;
  187 + max-height: 240px;
  188 + -webkit-overflow-scrolling: touch;
  189 +}
  190 +
  191 +.chosen-container .chosen-results li {
  192 + display: none;
  193 + margin: 0;
  194 + padding: 5px 6px;
  195 + list-style: none;
  196 + line-height: 15px;
  197 + word-wrap: break-word;
  198 + -webkit-touch-callout: none;
  199 +}
  200 +
  201 +.chosen-container .chosen-results li.active-result {
  202 + display: list-item;
  203 + cursor: pointer;
  204 +}
  205 +
  206 +.chosen-container .chosen-results li.disabled-result {
  207 + display: list-item;
  208 + color: #ccc;
  209 + cursor: default;
  210 +}
  211 +
  212 +.chosen-container .chosen-results li.highlighted {
  213 + background-color: #3875d7;
  214 + background-image: -webkit-gradient(linear, left top, left bottom, color-stop(20%, #3875d7), color-stop(90%, #2a62bc));
  215 + background-image: linear-gradient(#3875d7 20%, #2a62bc 90%);
  216 + color: #fff;
  217 +}
  218 +
  219 +.chosen-container .chosen-results li.no-results {
  220 + color: #777;
  221 + display: list-item;
  222 + background: #f4f4f4;
  223 +}
  224 +
  225 +.chosen-container .chosen-results li.group-result {
  226 + display: list-item;
  227 + font-weight: bold;
  228 + cursor: default;
  229 +}
  230 +
  231 +.chosen-container .chosen-results li.group-option {
  232 + padding-left: 15px;
  233 +}
  234 +
  235 +.chosen-container .chosen-results li em {
  236 + font-style: normal;
  237 + text-decoration: underline;
  238 +}
  239 +
  240 +/* @end */
  241 +/* @group Multi Chosen */
  242 +.chosen-container-multi .chosen-choices {
  243 + position: relative;
  244 + overflow: hidden;
  245 + margin: 0;
  246 + padding: 0 5px;
  247 + width: 100%;
  248 + height: auto;
  249 + border: 1px solid #aaa;
  250 + background-color: #fff;
  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%);
  253 + cursor: text;
  254 +}
  255 +
  256 +.chosen-container-multi .chosen-choices li {
  257 + float: left;
  258 + list-style: none;
  259 +}
  260 +
  261 +.chosen-container-multi .chosen-choices li.search-field {
  262 + margin: 0;
  263 + padding: 0;
  264 + white-space: nowrap;
  265 +}
  266 +
  267 +.chosen-container-multi .chosen-choices li.search-field input[type="text"] {
  268 + margin: 1px 0;
  269 + padding: 0;
  270 + height: 25px;
  271 + outline: 0;
  272 + border: 0 !important;
  273 + background: transparent !important;
  274 + -webkit-box-shadow: none;
  275 + box-shadow: none;
  276 + color: #999;
  277 + font-size: 100%;
  278 + font-family: sans-serif;
  279 + line-height: normal;
  280 + border-radius: 0;
  281 + width: 25px;
  282 +}
  283 +
  284 +.chosen-container-multi .chosen-choices li.search-choice {
  285 + position: relative;
  286 + margin: 3px 5px 3px 0;
  287 + padding: 3px 20px 3px 5px;
  288 + border: 1px solid #aaa;
  289 + max-width: 100%;
  290 + border-radius: 3px;
  291 + background-color: #eeeeee;
  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%);
  294 + background-size: 100% 19px;
  295 + background-repeat: repeat-x;
  296 + background-clip: padding-box;
  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);
  299 + color: #333;
  300 + line-height: 13px;
  301 + cursor: default;
  302 +}
  303 +
  304 +.chosen-container-multi .chosen-choices li.search-choice span {
  305 + word-wrap: break-word;
  306 +}
  307 +
  308 +.chosen-container-multi .chosen-choices li.search-choice .search-choice-close {
  309 + position: absolute;
  310 + top: 4px;
  311 + right: 3px;
  312 + display: block;
  313 + width: 12px;
  314 + height: 12px;
  315 + background: url("chosen-sprite.png") -42px 1px no-repeat;
  316 + font-size: 1px;
  317 +}
  318 +
  319 +.chosen-container-multi .chosen-choices li.search-choice .search-choice-close:hover {
  320 + background-position: -42px -10px;
  321 +}
  322 +
  323 +.chosen-container-multi .chosen-choices li.search-choice-disabled {
  324 + padding-right: 5px;
  325 + border: 1px solid #ccc;
  326 + background-color: #e4e4e4;
  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%);
  329 + color: #666;
  330 +}
  331 +
  332 +.chosen-container-multi .chosen-choices li.search-choice-focus {
  333 + background: #d4d4d4;
  334 +}
  335 +
  336 +.chosen-container-multi .chosen-choices li.search-choice-focus .search-choice-close {
  337 + background-position: -42px -10px;
  338 +}
  339 +
  340 +.chosen-container-multi .chosen-results {
  341 + margin: 0;
  342 + padding: 0;
  343 +}
  344 +
  345 +.chosen-container-multi .chosen-drop .result-selected {
  346 + display: list-item;
  347 + color: #ccc;
  348 + cursor: default;
  349 +}
  350 +
  351 +/* @end */
  352 +/* @group Active */
  353 +.chosen-container-active .chosen-single {
  354 + border: 1px solid #5897fb;
  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 +
  359 +.chosen-container-active.chosen-with-drop .chosen-single {
  360 + border: 1px solid #aaa;
  361 + border-bottom-right-radius: 0;
  362 + border-bottom-left-radius: 0;
  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 +
  369 +.chosen-container-active.chosen-with-drop .chosen-single div {
  370 + border-left: none;
  371 + background: transparent;
  372 +}
  373 +
  374 +.chosen-container-active.chosen-with-drop .chosen-single div b {
  375 + background-position: -18px 2px;
  376 +}
  377 +
  378 +.chosen-container-active .chosen-choices {
  379 + border: 1px solid #5897fb;
  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 +
  384 +.chosen-container-active .chosen-choices li.search-field input[type="text"] {
  385 + color: #222 !important;
  386 +}
  387 +
  388 +/* @end */
  389 +/* @group Disabled Support */
  390 +.chosen-disabled {
  391 + opacity: 0.5 !important;
  392 + cursor: default;
  393 +}
  394 +
  395 +.chosen-disabled .chosen-single {
  396 + cursor: default;
  397 +}
  398 +
  399 +.chosen-disabled .chosen-choices .search-choice .search-choice-close {
  400 + cursor: default;
  401 +}
  402 +
  403 +/* @end */
  404 +/* @group Right to Left */
  405 +.chosen-rtl {
  406 + text-align: right;
  407 +}
  408 +
  409 +.chosen-rtl .chosen-single {
  410 + overflow: visible;
  411 + padding: 0 8px 0 0;
  412 +}
  413 +
  414 +.chosen-rtl .chosen-single span {
  415 + margin-right: 0;
  416 + margin-left: 26px;
  417 + direction: rtl;
  418 +}
  419 +
  420 +.chosen-rtl .chosen-single-with-deselect span {
  421 + margin-left: 38px;
  422 +}
  423 +
  424 +.chosen-rtl .chosen-single div {
  425 + right: auto;
  426 + left: 3px;
  427 +}
  428 +
  429 +.chosen-rtl .chosen-single abbr {
  430 + right: auto;
  431 + left: 26px;
  432 +}
  433 +
  434 +.chosen-rtl .chosen-choices li {
  435 + float: right;
  436 +}
  437 +
  438 +.chosen-rtl .chosen-choices li.search-field input[type="text"] {
  439 + direction: rtl;
  440 +}
  441 +
  442 +.chosen-rtl .chosen-choices li.search-choice {
  443 + margin: 3px 5px 3px 0;
  444 + padding: 3px 5px 3px 19px;
  445 +}
  446 +
  447 +.chosen-rtl .chosen-choices li.search-choice .search-choice-close {
  448 + right: auto;
  449 + left: 4px;
  450 +}
  451 +
  452 +.chosen-rtl.chosen-container-single .chosen-results {
  453 + margin: 0 0 4px 4px;
  454 + padding: 0 4px 0 0;
  455 +}
  456 +
  457 +.chosen-rtl .chosen-results li.group-option {
  458 + padding-right: 15px;
  459 + padding-left: 0;
  460 +}
  461 +
  462 +.chosen-rtl.chosen-container-active.chosen-with-drop .chosen-single div {
  463 + border-right: none;
  464 +}
  465 +
  466 +.chosen-rtl .chosen-search input[type="text"] {
  467 + padding: 4px 5px 4px 20px;
  468 + background: url("chosen-sprite.png") no-repeat -30px -20px;
  469 + direction: rtl;
  470 +}
  471 +
  472 +.chosen-rtl.chosen-container-single .chosen-single div b {
  473 + background-position: 6px 2px;
  474 +}
  475 +
  476 +.chosen-rtl.chosen-container-single.chosen-with-drop .chosen-single div b {
  477 + background-position: -12px 2px;
  478 +}
  479 +
  480 +/* @end */
  481 +/* @group Retina compatibility */
  482 +@media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 144dpi), only screen and (min-resolution: 1.5dppx) {
  483 + .chosen-rtl .chosen-search input[type="text"],
  484 + .chosen-container-single .chosen-single abbr,
  485 + .chosen-container-single .chosen-single div b,
  486 + .chosen-container-single .chosen-search input[type="text"],
  487 + .chosen-container-multi .chosen-choices .search-choice .search-choice-close,
  488 + .chosen-container .chosen-results-scroll-down span,
  489 + .chosen-container .chosen-results-scroll-up span {
  490 + background-image: url("chosen-sprite@2x.png") !important;
  491 + background-size: 52px 37px !important;
  492 + background-repeat: no-repeat !important;
  493 + }
  494 +}
  495 +
  496 +/* @end */
public/js/chosen/chosen.jquery.js
Changes suppressed. Click to show
... ... @@ -0,0 +1,1359 @@
  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.7
  6 +Full source at https://github.com/harvesthq/chosen
  7 +Copyright (c) 2011-2018 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 +
  13 +(function() {
  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;
  18 +
  19 + SelectParser = (function() {
  20 + function SelectParser() {
  21 + this.options_index = 0;
  22 + this.parsed = [];
  23 + }
  24 +
  25 + SelectParser.prototype.add_node = function(child) {
  26 + if (child.nodeName.toUpperCase() === "OPTGROUP") {
  27 + return this.add_group(child);
  28 + } else {
  29 + return this.add_option(child);
  30 + }
  31 + };
  32 +
  33 + SelectParser.prototype.add_group = function(group) {
  34 + var group_position, i, len, option, ref, results1;
  35 + group_position = this.parsed.length;
  36 + this.parsed.push({
  37 + array_index: group_position,
  38 + group: true,
  39 + label: group.label,
  40 + title: group.title ? group.title : void 0,
  41 + children: 0,
  42 + disabled: group.disabled,
  43 + classes: group.className
  44 + });
  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;
  52 + };
  53 +
  54 + SelectParser.prototype.add_option = function(option, group_position, group_disabled) {
  55 + if (option.nodeName.toUpperCase() === "OPTION") {
  56 + if (option.text !== "") {
  57 + if (group_position != null) {
  58 + this.parsed[group_position].children += 1;
  59 + }
  60 + this.parsed.push({
  61 + array_index: this.parsed.length,
  62 + options_index: this.options_index,
  63 + value: option.value,
  64 + text: option.text,
  65 + html: option.innerHTML,
  66 + title: option.title ? option.title : void 0,
  67 + selected: option.selected,
  68 + disabled: group_disabled === true ? group_disabled : option.disabled,
  69 + group_array_index: group_position,
  70 + group_label: group_position != null ? this.parsed[group_position].label : null,
  71 + classes: option.className,
  72 + style: option.style.cssText
  73 + });
  74 + } else {
  75 + this.parsed.push({
  76 + array_index: this.parsed.length,
  77 + options_index: this.options_index,
  78 + empty: true
  79 + });
  80 + }
  81 + return this.options_index += 1;
  82 + }
  83 + };
  84 +
  85 + return SelectParser;
  86 +
  87 + })();
  88 +
  89 + SelectParser.select_to_array = function(select) {
  90 + var child, i, len, parser, ref;
  91 + parser = new SelectParser();
  92 + ref = select.childNodes;
  93 + for (i = 0, len = ref.length; i < len; i++) {
  94 + child = ref[i];
  95 + parser.add_node(child);
  96 + }
  97 + return parser.parsed;
  98 + };
  99 +
  100 + AbstractChosen = (function() {
  101 + function AbstractChosen(form_field, options1) {
  102 + this.form_field = form_field;
  103 + this.options = options1 != null ? options1 : {};
  104 + this.label_click_handler = bind(this.label_click_handler, this);
  105 + if (!AbstractChosen.browser_is_supported()) {
  106 + return;
  107 + }
  108 + this.is_multiple = this.form_field.multiple;
  109 + this.set_default_text();
  110 + this.set_default_values();
  111 + this.setup();
  112 + this.set_up_html();
  113 + this.register_observers();
  114 + this.on_ready();
  115 + }
  116 +
  117 + AbstractChosen.prototype.set_default_values = function() {
  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);
  128 + this.active_field = false;
  129 + this.mouse_on_container = false;
  130 + this.results_showing = false;
  131 + this.result_highlighted = null;
  132 + this.is_rtl = this.options.rtl || /\bchosen-rtl\b/.test(this.form_field.className);
  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;
  134 + this.disable_search_threshold = this.options.disable_search_threshold || 0;
  135 + this.disable_search = this.options.disable_search || false;
  136 + this.enable_split_word_search = this.options.enable_split_word_search != null ? this.options.enable_split_word_search : true;
  137 + this.group_search = this.options.group_search != null ? this.options.group_search : true;
  138 + this.search_contains = this.options.search_contains || false;
  139 + this.single_backstroke_delete = this.options.single_backstroke_delete != null ? this.options.single_backstroke_delete : true;
  140 + this.max_selected_options = this.options.max_selected_options || Infinity;
  141 + this.inherit_select_classes = this.options.inherit_select_classes || false;
  142 + this.display_selected_options = this.options.display_selected_options != null ? this.options.display_selected_options : true;
  143 + this.display_disabled_options = this.options.display_disabled_options != null ? this.options.display_disabled_options : true;
  144 + this.include_group_label_in_selected = this.options.include_group_label_in_selected || false;
  145 + this.max_shown_results = this.options.max_shown_results || Number.POSITIVE_INFINITY;
  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;
  148 + };
  149 +
  150 + AbstractChosen.prototype.set_default_text = function() {
  151 + if (this.form_field.getAttribute("data-placeholder")) {
  152 + this.default_text = this.form_field.getAttribute("data-placeholder");
  153 + } else if (this.is_multiple) {
  154 + this.default_text = this.options.placeholder_text_multiple || this.options.placeholder_text || AbstractChosen.default_multiple_text;
  155 + } else {
  156 + this.default_text = this.options.placeholder_text_single || this.options.placeholder_text || AbstractChosen.default_single_text;
  157 + }
  158 + this.default_text = this.escape_html(this.default_text);
  159 + return this.results_none_found = this.form_field.getAttribute("data-no_results_text") || this.options.no_results_text || AbstractChosen.default_no_result_text;
  160 + };
  161 +
  162 + AbstractChosen.prototype.choice_label = function(item) {
  163 + if (this.include_group_label_in_selected && (item.group_label != null)) {
  164 + return "<b class='group-name'>" + (this.escape_html(item.group_label)) + "</b>" + item.html;
  165 + } else {
  166 + return item.html;
  167 + }
  168 + };
  169 +
  170 + AbstractChosen.prototype.mouse_enter = function() {
  171 + return this.mouse_on_container = true;
  172 + };
  173 +
  174 + AbstractChosen.prototype.mouse_leave = function() {
  175 + return this.mouse_on_container = false;
  176 + };
  177 +
  178 + AbstractChosen.prototype.input_focus = function(evt) {
  179 + if (this.is_multiple) {
  180 + if (!this.active_field) {
  181 + return setTimeout(((function(_this) {
  182 + return function() {
  183 + return _this.container_mousedown();
  184 + };
  185 + })(this)), 50);
  186 + }
  187 + } else {
  188 + if (!this.active_field) {
  189 + return this.activate_field();
  190 + }
  191 + }
  192 + };
  193 +
  194 + AbstractChosen.prototype.input_blur = function(evt) {
  195 + if (!this.mouse_on_container) {
  196 + this.active_field = false;
  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();
  210 + }
  211 + };
  212 +
  213 + AbstractChosen.prototype.results_option_build = function(options) {
  214 + var content, data, data_content, i, len, ref, shown_results;
  215 + content = '';
  216 + shown_results = 0;
  217 + ref = this.results_data;
  218 + for (i = 0, len = ref.length; i < len; i++) {
  219 + data = ref[i];
  220 + data_content = '';
  221 + if (data.group) {
  222 + data_content = this.result_add_group(data);
  223 + } else {
  224 + data_content = this.result_add_option(data);
  225 + }
  226 + if (data_content !== '') {
  227 + shown_results++;
  228 + content += data_content;
  229 + }
  230 + if (options != null ? options.first : void 0) {
  231 + if (data.selected && this.is_multiple) {
  232 + this.choice_build(data);
  233 + } else if (data.selected && !this.is_multiple) {
  234 + this.single_set_selected_text(this.choice_label(data));
  235 + }
  236 + }
  237 + if (shown_results >= this.max_shown_results) {
  238 + break;
  239 + }
  240 + }
  241 + return content;
  242 + };
  243 +
  244 + AbstractChosen.prototype.result_add_option = function(option) {
  245 + var classes, option_el;
  246 + if (!option.search_match) {
  247 + return '';
  248 + }
  249 + if (!this.include_option_in_results(option)) {
  250 + return '';
  251 + }
  252 + classes = [];
  253 + if (!option.disabled && !(option.selected && this.is_multiple)) {
  254 + classes.push("active-result");
  255 + }
  256 + if (option.disabled && !(option.selected && this.is_multiple)) {
  257 + classes.push("disabled-result");
  258 + }
  259 + if (option.selected) {
  260 + classes.push("result-selected");
  261 + }
  262 + if (option.group_array_index != null) {
  263 + classes.push("group-option");
  264 + }
  265 + if (option.classes !== "") {
  266 + classes.push(option.classes);
  267 + }
  268 + option_el = document.createElement("li");
  269 + option_el.className = classes.join(" ");
  270 + if (option.style) {
  271 + option_el.style.cssText = option.style;
  272 + }
  273 + option_el.setAttribute("data-option-array-index", option.array_index);
  274 + option_el.innerHTML = option.highlighted_html || option.html;
  275 + if (option.title) {
  276 + option_el.title = option.title;
  277 + }
  278 + return this.outerHTML(option_el);
  279 + };
  280 +
  281 + AbstractChosen.prototype.result_add_group = function(group) {
  282 + var classes, group_el;
  283 + if (!(group.search_match || group.group_match)) {
  284 + return '';
  285 + }
  286 + if (!(group.active_options > 0)) {
  287 + return '';
  288 + }
  289 + classes = [];
  290 + classes.push("group-result");
  291 + if (group.classes) {
  292 + classes.push(group.classes);
  293 + }
  294 + group_el = document.createElement("li");
  295 + group_el.className = classes.join(" ");
  296 + group_el.innerHTML = group.highlighted_html || this.escape_html(group.label);
  297 + if (group.title) {
  298 + group_el.title = group.title;
  299 + }
  300 + return this.outerHTML(group_el);
  301 + };
  302 +
  303 + AbstractChosen.prototype.results_update_field = function() {
  304 + this.set_default_text();
  305 + if (!this.is_multiple) {
  306 + this.results_reset_cleanup();
  307 + }
  308 + this.result_clear_highlight();
  309 + this.results_build();
  310 + if (this.results_showing) {
  311 + return this.winnow_results();
  312 + }
  313 + };
  314 +
  315 + AbstractChosen.prototype.reset_single_select_options = function() {
  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];
  321 + if (result.selected) {
  322 + results1.push(result.selected = false);
  323 + } else {
  324 + results1.push(void 0);
  325 + }
  326 + }
  327 + return results1;
  328 + };
  329 +
  330 + AbstractChosen.prototype.results_toggle = function() {
  331 + if (this.results_showing) {
  332 + return this.results_hide();
  333 + } else {
  334 + return this.results_show();
  335 + }
  336 + };
  337 +
  338 + AbstractChosen.prototype.results_search = function(evt) {
  339 + if (this.results_showing) {
  340 + return this.winnow_results();
  341 + } else {
  342 + return this.results_show();
  343 + }
  344 + };
  345 +
  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;
  348 + this.no_results_clear();
  349 + results = 0;
  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];
  356 + option.search_match = false;
  357 + results_group = null;
  358 + search_match = null;
  359 + option.highlighted_html = '';
  360 + if (this.include_option_in_results(option)) {
  361 + if (option.group) {
  362 + option.group_match = false;
  363 + option.active_options = 0;
  364 + }
  365 + if ((option.group_array_index != null) && this.results_data[option.group_array_index]) {
  366 + results_group = this.results_data[option.group_array_index];
  367 + if (results_group.active_options === 0 && results_group.search_match) {
  368 + results += 1;
  369 + }
  370 + results_group.active_options += 1;
  371 + }
  372 + text = option.group ? option.label : option.text;
  373 + if (!(option.group && !this.group_search)) {
  374 + search_match = this.search_string_match(text, regex);
  375 + option.search_match = search_match != null;
  376 + if (option.search_match && !option.group) {
  377 + results += 1;
  378 + }
  379 + if (option.search_match) {
  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));
  386 + }
  387 + if (results_group != null) {
  388 + results_group.group_match = true;
  389 + }
  390 + } else if ((option.group_array_index != null) && this.results_data[option.group_array_index].search_match) {
  391 + option.search_match = true;
  392 + }
  393 + }
  394 + }
  395 + }
  396 + this.result_clear_highlight();
  397 + if (results < 1 && query.length) {
  398 + this.update_results_content("");
  399 + return this.no_results(query);
  400 + } else {
  401 + this.update_results_content(this.results_option_build());
  402 + if (!(options != null ? options.skip_highlight : void 0)) {
  403 + return this.winnow_results_set_highlight();
  404 + }
  405 + }
  406 + };
  407 +
  408 + AbstractChosen.prototype.get_search_regex = function(escaped_search_string) {
  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 + }
  414 + regex_flag = this.case_sensitive_search ? "" : "i";
  415 + return new RegExp(regex_string, regex_flag);
  416 + };
  417 +
  418 + AbstractChosen.prototype.search_string_match = function(search_string, regex) {
  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 + };
  426 +
  427 + AbstractChosen.prototype.choices_count = function() {
  428 + var i, len, option, ref;
  429 + if (this.selected_option_count != null) {
  430 + return this.selected_option_count;
  431 + }
  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];
  436 + if (option.selected) {
  437 + this.selected_option_count += 1;
  438 + }
  439 + }
  440 + return this.selected_option_count;
  441 + };
  442 +
  443 + AbstractChosen.prototype.choices_click = function(evt) {
  444 + evt.preventDefault();
  445 + this.activate_field();
  446 + if (!(this.results_showing || this.is_disabled)) {
  447 + return this.results_show();
  448 + }
  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 +
  494 + AbstractChosen.prototype.keyup_checker = function(evt) {
  495 + var ref, stroke;
  496 + stroke = (ref = evt.which) != null ? ref : evt.keyCode;
  497 + this.search_field_scale();
  498 + switch (stroke) {
  499 + case 8:
  500 + if (this.is_multiple && this.backstroke_length < 1 && this.choices_count() > 0) {
  501 + this.keydown_backstroke();
  502 + } else if (!this.pending_backstroke) {
  503 + this.result_clear_highlight();
  504 + this.results_search();
  505 + }
  506 + break;
  507 + case 13:
  508 + evt.preventDefault();
  509 + if (this.results_showing) {
  510 + this.result_select(evt);
  511 + }
  512 + break;
  513 + case 27:
  514 + if (this.results_showing) {
  515 + this.results_hide();
  516 + }
  517 + break;
  518 + case 9:
  519 + case 16:
  520 + case 17:
  521 + case 18:
  522 + case 38:
  523 + case 40:
  524 + case 91:
  525 + break;
  526 + default:
  527 + this.results_search();
  528 + break;
  529 + }
  530 + };
  531 +
  532 + AbstractChosen.prototype.clipboard_event_checker = function(evt) {
  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);
  541 + };
  542 +
  543 + AbstractChosen.prototype.container_width = function() {
  544 + if (this.options.width != null) {
  545 + return this.options.width;
  546 + } else {
  547 + return this.form_field.offsetWidth + "px";
  548 + }
  549 + };
  550 +
  551 + AbstractChosen.prototype.include_option_in_results = function(option) {
  552 + if (this.is_multiple && (!this.display_selected_options && option.selected)) {
  553 + return false;
  554 + }
  555 + if (!this.display_disabled_options && option.disabled) {
  556 + return false;
  557 + }
  558 + if (option.empty) {
  559 + return false;
  560 + }
  561 + return true;
  562 + };
  563 +
  564 + AbstractChosen.prototype.search_results_touchstart = function(evt) {
  565 + this.touch_started = true;
  566 + return this.search_results_mouseover(evt);
  567 + };
  568 +
  569 + AbstractChosen.prototype.search_results_touchmove = function(evt) {
  570 + this.touch_started = false;
  571 + return this.search_results_mouseout(evt);
  572 + };
  573 +
  574 + AbstractChosen.prototype.search_results_touchend = function(evt) {
  575 + if (this.touch_started) {
  576 + return this.search_results_mouseup(evt);
  577 + }
  578 + };
  579 +
  580 + AbstractChosen.prototype.outerHTML = function(element) {
  581 + var tmp;
  582 + if (element.outerHTML) {
  583 + return element.outerHTML;
  584 + }
  585 + tmp = document.createElement("div");
  586 + tmp.appendChild(element);
  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>";
  600 + };
  601 +
  602 + AbstractChosen.browser_is_supported = function() {
  603 + if ("Microsoft Internet Explorer" === window.navigator.appName) {
  604 + return document.documentMode >= 8;
  605 + }
  606 + if (/iP(od|hone)/i.test(window.navigator.userAgent) || /IEMobile/i.test(window.navigator.userAgent) || /Windows Phone/i.test(window.navigator.userAgent) || /BlackBerry/i.test(window.navigator.userAgent) || /BB10/i.test(window.navigator.userAgent) || /Android.*Mobile/i.test(window.navigator.userAgent)) {
  607 + return false;
  608 + }
  609 + return true;
  610 + };
  611 +
  612 + AbstractChosen.default_multiple_text = "Select Some Options";
  613 +
  614 + AbstractChosen.default_single_text = "Select an Option";
  615 +
  616 + AbstractChosen.default_no_result_text = "No results match";
  617 +
  618 + return AbstractChosen;
  619 +
  620 + })();
  621 +
  622 + $ = jQuery;
  623 +
  624 + $.fn.extend({
  625 + chosen: function(options) {
  626 + if (!AbstractChosen.browser_is_supported()) {
  627 + return this;
  628 + }
  629 + return this.each(function(input_field) {
  630 + var $this, chosen;
  631 + $this = $(this);
  632 + chosen = $this.data('chosen');
  633 + if (options === 'destroy') {
  634 + if (chosen instanceof Chosen) {
  635 + chosen.destroy();
  636 + }
  637 + return;
  638 + }
  639 + if (!(chosen instanceof Chosen)) {
  640 + $this.data('chosen', new Chosen(this, options));
  641 + }
  642 + });
  643 + }
  644 + });
  645 +
  646 + Chosen = (function(superClass) {
  647 + extend(Chosen, superClass);
  648 +
  649 + function Chosen() {
  650 + return Chosen.__super__.constructor.apply(this, arguments);
  651 + }
  652 +
  653 + Chosen.prototype.setup = function() {
  654 + this.form_field_jq = $(this.form_field);
  655 + return this.current_selectedIndex = this.form_field.selectedIndex;
  656 + };
  657 +
  658 + Chosen.prototype.set_up_html = function() {
  659 + var container_classes, container_props;
  660 + container_classes = ["chosen-container"];
  661 + container_classes.push("chosen-container-" + (this.is_multiple ? "multi" : "single"));
  662 + if (this.inherit_select_classes && this.form_field.className) {
  663 + container_classes.push(this.form_field.className);
  664 + }
  665 + if (this.is_rtl) {
  666 + container_classes.push("chosen-rtl");
  667 + }
  668 + container_props = {
  669 + 'class': container_classes.join(' '),
  670 + 'title': this.form_field.title
  671 + };
  672 + if (this.form_field.id.length) {
  673 + container_props.id = this.form_field.id.replace(/[^\w]/g, '_') + "_chosen";
  674 + }
  675 + this.container = $("<div />", container_props);
  676 + this.container.width(this.container_width());
  677 + if (this.is_multiple) {
  678 + this.container.html(this.get_multi_html());
  679 + } else {
  680 + this.container.html(this.get_single_html());
  681 + }
  682 + this.form_field_jq.hide().after(this.container);
  683 + this.dropdown = this.container.find('div.chosen-drop').first();
  684 + this.search_field = this.container.find('input').first();
  685 + this.search_results = this.container.find('ul.chosen-results').first();
  686 + this.search_field_scale();
  687 + this.search_no_results = this.container.find('li.no-results').first();
  688 + if (this.is_multiple) {
  689 + this.search_choices = this.container.find('ul.chosen-choices').first();
  690 + this.search_container = this.container.find('li.search-field').first();
  691 + } else {
  692 + this.search_container = this.container.find('div.chosen-search').first();
  693 + this.selected_item = this.container.find('.chosen-single').first();
  694 + }
  695 + this.results_build();
  696 + this.set_tab_index();
  697 + return this.set_label_behavior();
  698 + };
  699 +
  700 + Chosen.prototype.on_ready = function() {
  701 + return this.form_field_jq.trigger("chosen:ready", {
  702 + chosen: this
  703 + });
  704 + };
  705 +
  706 + Chosen.prototype.register_observers = function() {
  707 + this.container.on('touchstart.chosen', (function(_this) {
  708 + return function(evt) {
  709 + _this.container_mousedown(evt);
  710 + };
  711 + })(this));
  712 + this.container.on('touchend.chosen', (function(_this) {
  713 + return function(evt) {
  714 + _this.container_mouseup(evt);
  715 + };
  716 + })(this));
  717 + this.container.on('mousedown.chosen', (function(_this) {
  718 + return function(evt) {
  719 + _this.container_mousedown(evt);
  720 + };
  721 + })(this));
  722 + this.container.on('mouseup.chosen', (function(_this) {
  723 + return function(evt) {
  724 + _this.container_mouseup(evt);
  725 + };
  726 + })(this));
  727 + this.container.on('mouseenter.chosen', (function(_this) {
  728 + return function(evt) {
  729 + _this.mouse_enter(evt);
  730 + };
  731 + })(this));
  732 + this.container.on('mouseleave.chosen', (function(_this) {
  733 + return function(evt) {
  734 + _this.mouse_leave(evt);
  735 + };
  736 + })(this));
  737 + this.search_results.on('mouseup.chosen', (function(_this) {
  738 + return function(evt) {
  739 + _this.search_results_mouseup(evt);
  740 + };
  741 + })(this));
  742 + this.search_results.on('mouseover.chosen', (function(_this) {
  743 + return function(evt) {
  744 + _this.search_results_mouseover(evt);
  745 + };
  746 + })(this));
  747 + this.search_results.on('mouseout.chosen', (function(_this) {
  748 + return function(evt) {
  749 + _this.search_results_mouseout(evt);
  750 + };
  751 + })(this));
  752 + this.search_results.on('mousewheel.chosen DOMMouseScroll.chosen', (function(_this) {
  753 + return function(evt) {
  754 + _this.search_results_mousewheel(evt);
  755 + };
  756 + })(this));
  757 + this.search_results.on('touchstart.chosen', (function(_this) {
  758 + return function(evt) {
  759 + _this.search_results_touchstart(evt);
  760 + };
  761 + })(this));
  762 + this.search_results.on('touchmove.chosen', (function(_this) {
  763 + return function(evt) {
  764 + _this.search_results_touchmove(evt);
  765 + };
  766 + })(this));
  767 + this.search_results.on('touchend.chosen', (function(_this) {
  768 + return function(evt) {
  769 + _this.search_results_touchend(evt);
  770 + };
  771 + })(this));
  772 + this.form_field_jq.on("chosen:updated.chosen", (function(_this) {
  773 + return function(evt) {
  774 + _this.results_update_field(evt);
  775 + };
  776 + })(this));
  777 + this.form_field_jq.on("chosen:activate.chosen", (function(_this) {
  778 + return function(evt) {
  779 + _this.activate_field(evt);
  780 + };
  781 + })(this));
  782 + this.form_field_jq.on("chosen:open.chosen", (function(_this) {
  783 + return function(evt) {
  784 + _this.container_mousedown(evt);
  785 + };
  786 + })(this));
  787 + this.form_field_jq.on("chosen:close.chosen", (function(_this) {
  788 + return function(evt) {
  789 + _this.close_field(evt);
  790 + };
  791 + })(this));
  792 + this.search_field.on('blur.chosen', (function(_this) {
  793 + return function(evt) {
  794 + _this.input_blur(evt);
  795 + };
  796 + })(this));
  797 + this.search_field.on('keyup.chosen', (function(_this) {
  798 + return function(evt) {
  799 + _this.keyup_checker(evt);
  800 + };
  801 + })(this));
  802 + this.search_field.on('keydown.chosen', (function(_this) {
  803 + return function(evt) {
  804 + _this.keydown_checker(evt);
  805 + };
  806 + })(this));
  807 + this.search_field.on('focus.chosen', (function(_this) {
  808 + return function(evt) {
  809 + _this.input_focus(evt);
  810 + };
  811 + })(this));
  812 + this.search_field.on('cut.chosen', (function(_this) {
  813 + return function(evt) {
  814 + _this.clipboard_event_checker(evt);
  815 + };
  816 + })(this));
  817 + this.search_field.on('paste.chosen', (function(_this) {
  818 + return function(evt) {
  819 + _this.clipboard_event_checker(evt);
  820 + };
  821 + })(this));
  822 + if (this.is_multiple) {
  823 + return this.search_choices.on('click.chosen', (function(_this) {
  824 + return function(evt) {
  825 + _this.choices_click(evt);
  826 + };
  827 + })(this));
  828 + } else {
  829 + return this.container.on('click.chosen', function(evt) {
  830 + evt.preventDefault();
  831 + });
  832 + }
  833 + };
  834 +
  835 + Chosen.prototype.destroy = function() {
  836 + $(this.container[0].ownerDocument).off('click.chosen', this.click_test_action);
  837 + if (this.form_field_label.length > 0) {
  838 + this.form_field_label.off('click.chosen');
  839 + }
  840 + if (this.search_field[0].tabIndex) {
  841 + this.form_field_jq[0].tabIndex = this.search_field[0].tabIndex;
  842 + }
  843 + this.container.remove();
  844 + this.form_field_jq.removeData('chosen');
  845 + return this.form_field_jq.show();
  846 + };
  847 +
  848 + Chosen.prototype.search_field_disabled = function() {
  849 + this.is_disabled = this.form_field.disabled || this.form_field_jq.parents('fieldset').is(':disabled');
  850 + this.container.toggleClass('chosen-disabled', this.is_disabled);
  851 + this.search_field[0].disabled = this.is_disabled;
  852 + if (!this.is_multiple) {
  853 + this.selected_item.off('focus.chosen', this.activate_field);
  854 + }
  855 + if (this.is_disabled) {
  856 + return this.close_field();
  857 + } else if (!this.is_multiple) {
  858 + return this.selected_item.on('focus.chosen', this.activate_field);
  859 + }
  860 + };
  861 +
  862 + Chosen.prototype.container_mousedown = function(evt) {
  863 + var ref;
  864 + if (this.is_disabled) {
  865 + return;
  866 + }
  867 + if (evt && ((ref = evt.type) === 'mousedown' || ref === 'touchstart') && !this.results_showing) {
  868 + evt.preventDefault();
  869 + }
  870 + if (!((evt != null) && ($(evt.target)).hasClass("search-choice-close"))) {
  871 + if (!this.active_field) {
  872 + if (this.is_multiple) {
  873 + this.search_field.val("");
  874 + }
  875 + $(this.container[0].ownerDocument).on('click.chosen', this.click_test_action);
  876 + this.results_show();
  877 + } else if (!this.is_multiple && evt && (($(evt.target)[0] === this.selected_item[0]) || $(evt.target).parents("a.chosen-single").length)) {
  878 + evt.preventDefault();
  879 + this.results_toggle();
  880 + }
  881 + return this.activate_field();
  882 + }
  883 + };
  884 +
  885 + Chosen.prototype.container_mouseup = function(evt) {
  886 + if (evt.target.nodeName === "ABBR" && !this.is_disabled) {
  887 + return this.results_reset(evt);
  888 + }
  889 + };
  890 +
  891 + Chosen.prototype.search_results_mousewheel = function(evt) {
  892 + var delta;
  893 + if (evt.originalEvent) {
  894 + delta = evt.originalEvent.deltaY || -evt.originalEvent.wheelDelta || evt.originalEvent.detail;
  895 + }
  896 + if (delta != null) {
  897 + evt.preventDefault();
  898 + if (evt.type === 'DOMMouseScroll') {
  899 + delta = delta * 40;
  900 + }
  901 + return this.search_results.scrollTop(delta + this.search_results.scrollTop());
  902 + }
  903 + };
  904 +
  905 + Chosen.prototype.blur_test = function(evt) {
  906 + if (!this.active_field && this.container.hasClass("chosen-container-active")) {
  907 + return this.close_field();
  908 + }
  909 + };
  910 +
  911 + Chosen.prototype.close_field = function() {
  912 + $(this.container[0].ownerDocument).off("click.chosen", this.click_test_action);
  913 + this.active_field = false;
  914 + this.results_hide();
  915 + this.container.removeClass("chosen-container-active");
  916 + this.clear_backstroke();
  917 + this.show_search_field_default();
  918 + this.search_field_scale();
  919 + return this.search_field.blur();
  920 + };
  921 +
  922 + Chosen.prototype.activate_field = function() {
  923 + if (this.is_disabled) {
  924 + return;
  925 + }
  926 + this.container.addClass("chosen-container-active");
  927 + this.active_field = true;
  928 + this.search_field.val(this.search_field.val());
  929 + return this.search_field.focus();
  930 + };
  931 +
  932 + Chosen.prototype.test_active_click = function(evt) {
  933 + var active_container;
  934 + active_container = $(evt.target).closest('.chosen-container');
  935 + if (active_container.length && this.container[0] === active_container[0]) {
  936 + return this.active_field = true;
  937 + } else {
  938 + return this.close_field();
  939 + }
  940 + };
  941 +
  942 + Chosen.prototype.results_build = function() {
  943 + this.parsing = true;
  944 + this.selected_option_count = null;
  945 + this.results_data = SelectParser.select_to_array(this.form_field);
  946 + if (this.is_multiple) {
  947 + this.search_choices.find("li.search-choice").remove();
  948 + } else {
  949 + this.single_set_selected_text();
  950 + if (this.disable_search || this.form_field.options.length <= this.disable_search_threshold) {
  951 + this.search_field[0].readOnly = true;
  952 + this.container.addClass("chosen-container-single-nosearch");
  953 + } else {
  954 + this.search_field[0].readOnly = false;
  955 + this.container.removeClass("chosen-container-single-nosearch");
  956 + }
  957 + }
  958 + this.update_results_content(this.results_option_build({
  959 + first: true
  960 + }));
  961 + this.search_field_disabled();
  962 + this.show_search_field_default();
  963 + this.search_field_scale();
  964 + return this.parsing = false;
  965 + };
  966 +
  967 + Chosen.prototype.result_do_highlight = function(el) {
  968 + var high_bottom, high_top, maxHeight, visible_bottom, visible_top;
  969 + if (el.length) {
  970 + this.result_clear_highlight();
  971 + this.result_highlight = el;
  972 + this.result_highlight.addClass("highlighted");
  973 + maxHeight = parseInt(this.search_results.css("maxHeight"), 10);
  974 + visible_top = this.search_results.scrollTop();
  975 + visible_bottom = maxHeight + visible_top;
  976 + high_top = this.result_highlight.position().top + this.search_results.scrollTop();
  977 + high_bottom = high_top + this.result_highlight.outerHeight();
  978 + if (high_bottom >= visible_bottom) {
  979 + return this.search_results.scrollTop((high_bottom - maxHeight) > 0 ? high_bottom - maxHeight : 0);
  980 + } else if (high_top < visible_top) {
  981 + return this.search_results.scrollTop(high_top);
  982 + }
  983 + }
  984 + };
  985 +
  986 + Chosen.prototype.result_clear_highlight = function() {
  987 + if (this.result_highlight) {
  988 + this.result_highlight.removeClass("highlighted");
  989 + }
  990 + return this.result_highlight = null;
  991 + };
  992 +
  993 + Chosen.prototype.results_show = function() {
  994 + if (this.is_multiple && this.max_selected_options <= this.choices_count()) {
  995 + this.form_field_jq.trigger("chosen:maxselected", {
  996 + chosen: this
  997 + });
  998 + return false;
  999 + }
  1000 + this.container.addClass("chosen-with-drop");
  1001 + this.results_showing = true;
  1002 + this.search_field.focus();
  1003 + this.search_field.val(this.get_search_field_value());
  1004 + this.winnow_results();
  1005 + return this.form_field_jq.trigger("chosen:showing_dropdown", {
  1006 + chosen: this
  1007 + });
  1008 + };
  1009 +
  1010 + Chosen.prototype.update_results_content = function(content) {
  1011 + return this.search_results.html(content);
  1012 + };
  1013 +
  1014 + Chosen.prototype.results_hide = function() {
  1015 + if (this.results_showing) {
  1016 + this.result_clear_highlight();
  1017 + this.container.removeClass("chosen-with-drop");
  1018 + this.form_field_jq.trigger("chosen:hiding_dropdown", {
  1019 + chosen: this
  1020 + });
  1021 + }
  1022 + return this.results_showing = false;
  1023 + };
  1024 +
  1025 + Chosen.prototype.set_tab_index = function(el) {
  1026 + var ti;
  1027 + if (this.form_field.tabIndex) {
  1028 + ti = this.form_field.tabIndex;
  1029 + this.form_field.tabIndex = -1;
  1030 + return this.search_field[0].tabIndex = ti;
  1031 + }
  1032 + };
  1033 +
  1034 + Chosen.prototype.set_label_behavior = function() {
  1035 + this.form_field_label = this.form_field_jq.parents("label");
  1036 + if (!this.form_field_label.length && this.form_field.id.length) {
  1037 + this.form_field_label = $("label[for='" + this.form_field.id + "']");
  1038 + }
  1039 + if (this.form_field_label.length > 0) {
  1040 + return this.form_field_label.on('click.chosen', this.label_click_handler);
  1041 + }
  1042 + };
  1043 +
  1044 + Chosen.prototype.show_search_field_default = function() {
  1045 + if (this.is_multiple && this.choices_count() < 1 && !this.active_field) {
  1046 + this.search_field.val(this.default_text);
  1047 + return this.search_field.addClass("default");
  1048 + } else {
  1049 + this.search_field.val("");
  1050 + return this.search_field.removeClass("default");
  1051 + }
  1052 + };
  1053 +
  1054 + Chosen.prototype.search_results_mouseup = function(evt) {
  1055 + var target;
  1056 + target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
  1057 + if (target.length) {
  1058 + this.result_highlight = target;
  1059 + this.result_select(evt);
  1060 + return this.search_field.focus();
  1061 + }
  1062 + };
  1063 +
  1064 + Chosen.prototype.search_results_mouseover = function(evt) {
  1065 + var target;
  1066 + target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
  1067 + if (target) {
  1068 + return this.result_do_highlight(target);
  1069 + }
  1070 + };
  1071 +
  1072 + Chosen.prototype.search_results_mouseout = function(evt) {
  1073 + if ($(evt.target).hasClass("active-result") || $(evt.target).parents('.active-result').first()) {
  1074 + return this.result_clear_highlight();
  1075 + }
  1076 + };
  1077 +
  1078 + Chosen.prototype.choice_build = function(item) {
  1079 + var choice, close_link;
  1080 + choice = $('<li />', {
  1081 + "class": "search-choice"
  1082 + }).html("<span>" + (this.choice_label(item)) + "</span>");
  1083 + if (item.disabled) {
  1084 + choice.addClass('search-choice-disabled');
  1085 + } else {
  1086 + close_link = $('<a />', {
  1087 + "class": 'search-choice-close',
  1088 + 'data-option-array-index': item.array_index
  1089 + });
  1090 + close_link.on('click.chosen', (function(_this) {
  1091 + return function(evt) {
  1092 + return _this.choice_destroy_link_click(evt);
  1093 + };
  1094 + })(this));
  1095 + choice.append(close_link);
  1096 + }
  1097 + return this.search_container.before(choice);
  1098 + };
  1099 +
  1100 + Chosen.prototype.choice_destroy_link_click = function(evt) {
  1101 + evt.preventDefault();
  1102 + evt.stopPropagation();
  1103 + if (!this.is_disabled) {
  1104 + return this.choice_destroy($(evt.target));
  1105 + }
  1106 + };
  1107 +
  1108 + Chosen.prototype.choice_destroy = function(link) {
  1109 + if (this.result_deselect(link[0].getAttribute("data-option-array-index"))) {
  1110 + if (this.active_field) {
  1111 + this.search_field.focus();
  1112 + } else {
  1113 + this.show_search_field_default();
  1114 + }
  1115 + if (this.is_multiple && this.choices_count() > 0 && this.get_search_field_value().length < 1) {
  1116 + this.results_hide();
  1117 + }
  1118 + link.parents('li').first().remove();
  1119 + return this.search_field_scale();
  1120 + }
  1121 + };
  1122 +
  1123 + Chosen.prototype.results_reset = function() {
  1124 + this.reset_single_select_options();
  1125 + this.form_field.options[0].selected = true;
  1126 + this.single_set_selected_text();
  1127 + this.show_search_field_default();
  1128 + this.results_reset_cleanup();
  1129 + this.trigger_form_field_change();
  1130 + if (this.active_field) {
  1131 + return this.results_hide();
  1132 + }
  1133 + };
  1134 +
  1135 + Chosen.prototype.results_reset_cleanup = function() {
  1136 + this.current_selectedIndex = this.form_field.selectedIndex;
  1137 + return this.selected_item.find("abbr").remove();
  1138 + };
  1139 +
  1140 + Chosen.prototype.result_select = function(evt) {
  1141 + var high, item;
  1142 + if (this.result_highlight) {
  1143 + high = this.result_highlight;
  1144 + this.result_clear_highlight();
  1145 + if (this.is_multiple && this.max_selected_options <= this.choices_count()) {
  1146 + this.form_field_jq.trigger("chosen:maxselected", {
  1147 + chosen: this
  1148 + });
  1149 + return false;
  1150 + }
  1151 + if (this.is_multiple) {
  1152 + high.removeClass("active-result");
  1153 + } else {
  1154 + this.reset_single_select_options();
  1155 + }
  1156 + high.addClass("result-selected");
  1157 + item = this.results_data[high[0].getAttribute("data-option-array-index")];
  1158 + item.selected = true;
  1159 + this.form_field.options[item.options_index].selected = true;
  1160 + this.selected_option_count = null;
  1161 + if (this.is_multiple) {
  1162 + this.choice_build(item);
  1163 + } else {
  1164 + this.single_set_selected_text(this.choice_label(item));
  1165 + }
  1166 + if (this.is_multiple && (!this.hide_results_on_select || (evt.metaKey || evt.ctrlKey))) {
  1167 + if (evt.metaKey || evt.ctrlKey) {
  1168 + this.winnow_results({
  1169 + skip_highlight: true
  1170 + });
  1171 + } else {
  1172 + this.search_field.val("");
  1173 + this.winnow_results();
  1174 + }
  1175 + } else {
  1176 + this.results_hide();
  1177 + this.show_search_field_default();
  1178 + }
  1179 + if (this.is_multiple || this.form_field.selectedIndex !== this.current_selectedIndex) {
  1180 + this.trigger_form_field_change({
  1181 + selected: this.form_field.options[item.options_index].value
  1182 + });
  1183 + }
  1184 + this.current_selectedIndex = this.form_field.selectedIndex;
  1185 + evt.preventDefault();
  1186 + return this.search_field_scale();
  1187 + }
  1188 + };
  1189 +
  1190 + Chosen.prototype.single_set_selected_text = function(text) {
  1191 + if (text == null) {
  1192 + text = this.default_text;
  1193 + }
  1194 + if (text === this.default_text) {
  1195 + this.selected_item.addClass("chosen-default");
  1196 + } else {
  1197 + this.single_deselect_control_build();
  1198 + this.selected_item.removeClass("chosen-default");
  1199 + }
  1200 + return this.selected_item.find("span").html(text);
  1201 + };
  1202 +
  1203 + Chosen.prototype.result_deselect = function(pos) {
  1204 + var result_data;
  1205 + result_data = this.results_data[pos];
  1206 + if (!this.form_field.options[result_data.options_index].disabled) {
  1207 + result_data.selected = false;
  1208 + this.form_field.options[result_data.options_index].selected = false;
  1209 + this.selected_option_count = null;
  1210 + this.result_clear_highlight();
  1211 + if (this.results_showing) {
  1212 + this.winnow_results();
  1213 + }
  1214 + this.trigger_form_field_change({
  1215 + deselected: this.form_field.options[result_data.options_index].value
  1216 + });
  1217 + this.search_field_scale();
  1218 + return true;
  1219 + } else {
  1220 + return false;
  1221 + }
  1222 + };
  1223 +
  1224 + Chosen.prototype.single_deselect_control_build = function() {
  1225 + if (!this.allow_single_deselect) {
  1226 + return;
  1227 + }
  1228 + if (!this.selected_item.find("abbr").length) {
  1229 + this.selected_item.find("span").first().after("<abbr class=\"search-choice-close\"></abbr>");
  1230 + }
  1231 + return this.selected_item.addClass("chosen-single-with-deselect");
  1232 + };
  1233 +
  1234 + Chosen.prototype.get_search_field_value = function() {
  1235 + return this.search_field.val();
  1236 + };
  1237 +
  1238 + Chosen.prototype.get_search_text = function() {
  1239 + return $.trim(this.get_search_field_value());
  1240 + };
  1241 +
  1242 + Chosen.prototype.escape_html = function(text) {
  1243 + return $('<div/>').text(text).html();
  1244 + };
  1245 +
  1246 + Chosen.prototype.winnow_results_set_highlight = function() {
  1247 + var do_high, selected_results;
  1248 + selected_results = !this.is_multiple ? this.search_results.find(".result-selected.active-result") : [];
  1249 + do_high = selected_results.length ? selected_results.first() : this.search_results.find(".active-result").first();
  1250 + if (do_high != null) {
  1251 + return this.result_do_highlight(do_high);
  1252 + }
  1253 + };
  1254 +
  1255 + Chosen.prototype.no_results = function(terms) {
  1256 + var no_results_html;
  1257 + no_results_html = this.get_no_results_html(terms);
  1258 + this.search_results.append(no_results_html);
  1259 + return this.form_field_jq.trigger("chosen:no_results", {
  1260 + chosen: this
  1261 + });
  1262 + };
  1263 +
  1264 + Chosen.prototype.no_results_clear = function() {
  1265 + return this.search_results.find(".no-results").remove();
  1266 + };
  1267 +
  1268 + Chosen.prototype.keydown_arrow = function() {
  1269 + var next_sib;
  1270 + if (this.results_showing && this.result_highlight) {
  1271 + next_sib = this.result_highlight.nextAll("li.active-result").first();
  1272 + if (next_sib) {
  1273 + return this.result_do_highlight(next_sib);
  1274 + }
  1275 + } else {
  1276 + return this.results_show();
  1277 + }
  1278 + };
  1279 +
  1280 + Chosen.prototype.keyup_arrow = function() {
  1281 + var prev_sibs;
  1282 + if (!this.results_showing && !this.is_multiple) {
  1283 + return this.results_show();
  1284 + } else if (this.result_highlight) {
  1285 + prev_sibs = this.result_highlight.prevAll("li.active-result");
  1286 + if (prev_sibs.length) {
  1287 + return this.result_do_highlight(prev_sibs.first());
  1288 + } else {
  1289 + if (this.choices_count() > 0) {
  1290 + this.results_hide();
  1291 + }
  1292 + return this.result_clear_highlight();
  1293 + }
  1294 + }
  1295 + };
  1296 +
  1297 + Chosen.prototype.keydown_backstroke = function() {
  1298 + var next_available_destroy;
  1299 + if (this.pending_backstroke) {
  1300 + this.choice_destroy(this.pending_backstroke.find("a").first());
  1301 + return this.clear_backstroke();
  1302 + } else {
  1303 + next_available_destroy = this.search_container.siblings("li.search-choice").last();
  1304 + if (next_available_destroy.length && !next_available_destroy.hasClass("search-choice-disabled")) {
  1305 + this.pending_backstroke = next_available_destroy;
  1306 + if (this.single_backstroke_delete) {
  1307 + return this.keydown_backstroke();
  1308 + } else {
  1309 + return this.pending_backstroke.addClass("search-choice-focus");
  1310 + }
  1311 + }
  1312 + }
  1313 + };
  1314 +
  1315 + Chosen.prototype.clear_backstroke = function() {
  1316 + if (this.pending_backstroke) {
  1317 + this.pending_backstroke.removeClass("search-choice-focus");
  1318 + }
  1319 + return this.pending_backstroke = null;
  1320 + };
  1321 +
  1322 + Chosen.prototype.search_field_scale = function() {
  1323 + var div, i, len, style, style_block, styles, width;
  1324 + if (!this.is_multiple) {
  1325 + return;
  1326 + }
  1327 + style_block = {
  1328 + position: 'absolute',
  1329 + left: '-1000px',
  1330 + top: '-1000px',
  1331 + display: 'none',
  1332 + whiteSpace: 'pre'
  1333 + };
  1334 + styles = ['fontSize', 'fontStyle', 'fontWeight', 'fontFamily', 'lineHeight', 'textTransform', 'letterSpacing'];
  1335 + for (i = 0, len = styles.length; i < len; i++) {
  1336 + style = styles[i];
  1337 + style_block[style] = this.search_field.css(style);
  1338 + }
  1339 + div = $('<div />').css(style_block);
  1340 + div.text(this.get_search_field_value());
  1341 + $('body').append(div);
  1342 + width = div.width() + 25;
  1343 + div.remove();
  1344 + if (this.container.is(':visible')) {
  1345 + width = Math.min(this.container.outerWidth() - 10, width);
  1346 + }
  1347 + return this.search_field.width(width);
  1348 + };
  1349 +
  1350 + Chosen.prototype.trigger_form_field_change = function(extra) {
  1351 + this.form_field_jq.trigger("input", extra);
  1352 + return this.form_field_jq.trigger("change", extra);
  1353 + };
  1354 +
  1355 + return Chosen;
  1356 +
  1357 + })(AbstractChosen);
  1358 +
  1359 +}).call(this);
public/js/chosen/chosen.jquery.min.js
... ... @@ -0,0 +1,3 @@
  1 +/* Chosen v1.8.7 | (c) 2011-2018 by Harvest | MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md */
  2 +
  3 +(function(){var t,e,s,i,n=function(t,e){return function(){return t.apply(e,arguments)}},r=function(t,e){function s(){this.constructor=t}for(var i in e)o.call(e,i)&&(t[i]=e[i]);return s.prototype=e.prototype,t.prototype=new s,t.__super__=e.prototype,t},o={}.hasOwnProperty;(i=function(){function t(){this.options_index=0,this.parsed=[]}return t.prototype.add_node=function(t){return"OPTGROUP"===t.nodeName.toUpperCase()?this.add_group(t):this.add_option(t)},t.prototype.add_group=function(t){var e,s,i,n,r,o;for(e=this.parsed.length,this.parsed.push({array_index:e,group:!0,label:t.label,title:t.title?t.title:void 0,children:0,disabled:t.disabled,classes:t.className}),o=[],s=0,i=(r=t.childNodes).length;s<i;s++)n=r[s],o.push(this.add_option(n,e,t.disabled));return o},t.prototype.add_option=function(t,e,s){if("OPTION"===t.nodeName.toUpperCase())return""!==t.text?(null!=e&&(this.parsed[e].children+=1),this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,value:t.value,text:t.text,html:t.innerHTML,title:t.title?t.title:void 0,selected:t.selected,disabled:!0===s?s:t.disabled,group_array_index:e,group_label:null!=e?this.parsed[e].label:null,classes:t.className,style:t.style.cssText})):this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,empty:!0}),this.options_index+=1},t}()).select_to_array=function(t){var e,s,n,r,o;for(r=new i,s=0,n=(o=t.childNodes).length;s<n;s++)e=o[s],r.add_node(e);return r.parsed},e=function(){function t(e,s){this.form_field=e,this.options=null!=s?s:{},this.label_click_handler=n(this.label_click_handler,this),t.browser_is_supported()&&(this.is_multiple=this.form_field.multiple,this.set_default_text(),this.set_default_values(),this.setup(),this.set_up_html(),this.register_observers(),this.on_ready())}return t.prototype.set_default_values=function(){return this.click_test_action=function(t){return function(e){return t.test_active_click(e)}}(this),this.activate_action=function(t){return function(e){return t.activate_field(e)}}(this),this.active_field=!1,this.mouse_on_container=!1,this.results_showing=!1,this.result_highlighted=null,this.is_rtl=this.options.rtl||/\bchosen-rtl\b/.test(this.form_field.className),this.allow_single_deselect=null!=this.options.allow_single_deselect&&null!=this.form_field.options[0]&&""===this.form_field.options[0].text&&this.options.allow_single_deselect,this.disable_search_threshold=this.options.disable_search_threshold||0,this.disable_search=this.options.disable_search||!1,this.enable_split_word_search=null==this.options.enable_split_word_search||this.options.enable_split_word_search,this.group_search=null==this.options.group_search||this.options.group_search,this.search_contains=this.options.search_contains||!1,this.single_backstroke_delete=null==this.options.single_backstroke_delete||this.options.single_backstroke_delete,this.max_selected_options=this.options.max_selected_options||Infinity,this.inherit_select_classes=this.options.inherit_select_classes||!1,this.display_selected_options=null==this.options.display_selected_options||this.options.display_selected_options,this.display_disabled_options=null==this.options.display_disabled_options||this.options.display_disabled_options,this.include_group_label_in_selected=this.options.include_group_label_in_selected||!1,this.max_shown_results=this.options.max_shown_results||Number.POSITIVE_INFINITY,this.case_sensitive_search=this.options.case_sensitive_search||!1,this.hide_results_on_select=null==this.options.hide_results_on_select||this.options.hide_results_on_select},t.prototype.set_default_text=function(){return this.form_field.getAttribute("data-placeholder")?this.default_text=this.form_field.getAttribute("data-placeholder"):this.is_multiple?this.default_text=this.options.placeholder_text_multiple||this.options.placeholder_text||t.default_multiple_text:this.default_text=this.options.placeholder_text_single||this.options.placeholder_text||t.default_single_text,this.default_text=this.escape_html(this.default_text),this.results_none_found=this.form_field.getAttribute("data-no_results_text")||this.options.no_results_text||t.default_no_result_text},t.prototype.choice_label=function(t){return this.include_group_label_in_selected&&null!=t.group_label?"<b class='group-name'>"+this.escape_html(t.group_label)+"</b>"+t.html:t.html},t.prototype.mouse_enter=function(){return this.mouse_on_container=!0},t.prototype.mouse_leave=function(){return this.mouse_on_container=!1},t.prototype.input_focus=function(t){if(this.is_multiple){if(!this.active_field)return setTimeout(function(t){return function(){return t.container_mousedown()}}(this),50)}else if(!this.active_field)return this.activate_field()},t.prototype.input_blur=function(t){if(!this.mouse_on_container)return this.active_field=!1,setTimeout(function(t){return function(){return t.blur_test()}}(this),100)},t.prototype.label_click_handler=function(t){return this.is_multiple?this.container_mousedown(t):this.activate_field()},t.prototype.results_option_build=function(t){var e,s,i,n,r,o,h;for(e="",h=0,n=0,r=(o=this.results_data).length;n<r&&(s=o[n],i="",""!==(i=s.group?this.result_add_group(s):this.result_add_option(s))&&(h++,e+=i),(null!=t?t.first:void 0)&&(s.selected&&this.is_multiple?this.choice_build(s):s.selected&&!this.is_multiple&&this.single_set_selected_text(this.choice_label(s))),!(h>=this.max_shown_results));n++);return e},t.prototype.result_add_option=function(t){var e,s;return t.search_match&&this.include_option_in_results(t)?(e=[],t.disabled||t.selected&&this.is_multiple||e.push("active-result"),!t.disabled||t.selected&&this.is_multiple||e.push("disabled-result"),t.selected&&e.push("result-selected"),null!=t.group_array_index&&e.push("group-option"),""!==t.classes&&e.push(t.classes),s=document.createElement("li"),s.className=e.join(" "),t.style&&(s.style.cssText=t.style),s.setAttribute("data-option-array-index",t.array_index),s.innerHTML=t.highlighted_html||t.html,t.title&&(s.title=t.title),this.outerHTML(s)):""},t.prototype.result_add_group=function(t){var e,s;return(t.search_match||t.group_match)&&t.active_options>0?((e=[]).push("group-result"),t.classes&&e.push(t.classes),s=document.createElement("li"),s.className=e.join(" "),s.innerHTML=t.highlighted_html||this.escape_html(t.label),t.title&&(s.title=t.title),this.outerHTML(s)):""},t.prototype.results_update_field=function(){if(this.set_default_text(),this.is_multiple||this.results_reset_cleanup(),this.result_clear_highlight(),this.results_build(),this.results_showing)return this.winnow_results()},t.prototype.reset_single_select_options=function(){var t,e,s,i,n;for(n=[],t=0,e=(s=this.results_data).length;t<e;t++)(i=s[t]).selected?n.push(i.selected=!1):n.push(void 0);return n},t.prototype.results_toggle=function(){return this.results_showing?this.results_hide():this.results_show()},t.prototype.results_search=function(t){return this.results_showing?this.winnow_results():this.results_show()},t.prototype.winnow_results=function(t){var e,s,i,n,r,o,h,l,c,_,a,u,d,p,f;for(this.no_results_clear(),_=0,e=(h=this.get_search_text()).replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),c=this.get_search_regex(e),i=0,n=(l=this.results_data).length;i<n;i++)(r=l[i]).search_match=!1,a=null,u=null,r.highlighted_html="",this.include_option_in_results(r)&&(r.group&&(r.group_match=!1,r.active_options=0),null!=r.group_array_index&&this.results_data[r.group_array_index]&&(0===(a=this.results_data[r.group_array_index]).active_options&&a.search_match&&(_+=1),a.active_options+=1),f=r.group?r.label:r.text,r.group&&!this.group_search||(u=this.search_string_match(f,c),r.search_match=null!=u,r.search_match&&!r.group&&(_+=1),r.search_match?(h.length&&(d=u.index,o=f.slice(0,d),s=f.slice(d,d+h.length),p=f.slice(d+h.length),r.highlighted_html=this.escape_html(o)+"<em>"+this.escape_html(s)+"</em>"+this.escape_html(p)),null!=a&&(a.group_match=!0)):null!=r.group_array_index&&this.results_data[r.group_array_index].search_match&&(r.search_match=!0)));return this.result_clear_highlight(),_<1&&h.length?(this.update_results_content(""),this.no_results(h)):(this.update_results_content(this.results_option_build()),(null!=t?t.skip_highlight:void 0)?void 0:this.winnow_results_set_highlight())},t.prototype.get_search_regex=function(t){var e,s;return s=this.search_contains?t:"(^|\\s|\\b)"+t+"[^\\s]*",this.enable_split_word_search||this.search_contains||(s="^"+s),e=this.case_sensitive_search?"":"i",new RegExp(s,e)},t.prototype.search_string_match=function(t,e){var s;return s=e.exec(t),!this.search_contains&&(null!=s?s[1]:void 0)&&(s.index+=1),s},t.prototype.choices_count=function(){var t,e,s;if(null!=this.selected_option_count)return this.selected_option_count;for(this.selected_option_count=0,t=0,e=(s=this.form_field.options).length;t<e;t++)s[t].selected&&(this.selected_option_count+=1);return this.selected_option_count},t.prototype.choices_click=function(t){if(t.preventDefault(),this.activate_field(),!this.results_showing&&!this.is_disabled)return this.results_show()},t.prototype.keydown_checker=function(t){var e,s;switch(s=null!=(e=t.which)?e:t.keyCode,this.search_field_scale(),8!==s&&this.pending_backstroke&&this.clear_backstroke(),s){case 8:this.backstroke_length=this.get_search_field_value().length;break;case 9:this.results_showing&&!this.is_multiple&&this.result_select(t),this.mouse_on_container=!1;break;case 13:case 27:this.results_showing&&t.preventDefault();break;case 32:this.disable_search&&t.preventDefault();break;case 38:t.preventDefault(),this.keyup_arrow();break;case 40:t.preventDefault(),this.keydown_arrow()}},t.prototype.keyup_checker=function(t){var e,s;switch(s=null!=(e=t.which)?e:t.keyCode,this.search_field_scale(),s){case 8:this.is_multiple&&this.backstroke_length<1&&this.choices_count()>0?this.keydown_backstroke():this.pending_backstroke||(this.result_clear_highlight(),this.results_search());break;case 13:t.preventDefault(),this.results_showing&&this.result_select(t);break;case 27:this.results_showing&&this.results_hide();break;case 9:case 16:case 17:case 18:case 38:case 40:case 91:break;default:this.results_search()}},t.prototype.clipboard_event_checker=function(t){if(!this.is_disabled)return setTimeout(function(t){return function(){return t.results_search()}}(this),50)},t.prototype.container_width=function(){return null!=this.options.width?this.options.width:this.form_field.offsetWidth+"px"},t.prototype.include_option_in_results=function(t){return!(this.is_multiple&&!this.display_selected_options&&t.selected)&&(!(!this.display_disabled_options&&t.disabled)&&!t.empty)},t.prototype.search_results_touchstart=function(t){return this.touch_started=!0,this.search_results_mouseover(t)},t.prototype.search_results_touchmove=function(t){return this.touch_started=!1,this.search_results_mouseout(t)},t.prototype.search_results_touchend=function(t){if(this.touch_started)return this.search_results_mouseup(t)},t.prototype.outerHTML=function(t){var e;return t.outerHTML?t.outerHTML:((e=document.createElement("div")).appendChild(t),e.innerHTML)},t.prototype.get_single_html=function(){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>'},t.prototype.get_multi_html=function(){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>'},t.prototype.get_no_results_html=function(t){return'<li class="no-results">\n '+this.results_none_found+" <span>"+this.escape_html(t)+"</span>\n</li>"},t.browser_is_supported=function(){return"Microsoft Internet Explorer"===window.navigator.appName?document.documentMode>=8:!(/iP(od|hone)/i.test(window.navigator.userAgent)||/IEMobile/i.test(window.navigator.userAgent)||/Windows Phone/i.test(window.navigator.userAgent)||/BlackBerry/i.test(window.navigator.userAgent)||/BB10/i.test(window.navigator.userAgent)||/Android.*Mobile/i.test(window.navigator.userAgent))},t.default_multiple_text="Select Some Options",t.default_single_text="Select an Option",t.default_no_result_text="No results match",t}(),(t=jQuery).fn.extend({chosen:function(i){return e.browser_is_supported()?this.each(function(e){var n,r;r=(n=t(this)).data("chosen"),"destroy"!==i?r instanceof s||n.data("chosen",new s(this,i)):r instanceof s&&r.destroy()}):this}}),s=function(s){function n(){return n.__super__.constructor.apply(this,arguments)}return r(n,e),n.prototype.setup=function(){return this.form_field_jq=t(this.form_field),this.current_selectedIndex=this.form_field.selectedIndex},n.prototype.set_up_html=function(){var e,s;return(e=["chosen-container"]).push("chosen-container-"+(this.is_multiple?"multi":"single")),this.inherit_select_classes&&this.form_field.className&&e.push(this.form_field.className),this.is_rtl&&e.push("chosen-rtl"),s={"class":e.join(" "),title:this.form_field.title},this.form_field.id.length&&(s.id=this.form_field.id.replace(/[^\w]/g,"_")+"_chosen"),this.container=t("<div />",s),this.container.width(this.container_width()),this.is_multiple?this.container.html(this.get_multi_html()):this.container.html(this.get_single_html()),this.form_field_jq.hide().after(this.container),this.dropdown=this.container.find("div.chosen-drop").first(),this.search_field=this.container.find("input").first(),this.search_results=this.container.find("ul.chosen-results").first(),this.search_field_scale(),this.search_no_results=this.container.find("li.no-results").first(),this.is_multiple?(this.search_choices=this.container.find("ul.chosen-choices").first(),this.search_container=this.container.find("li.search-field").first()):(this.search_container=this.container.find("div.chosen-search").first(),this.selected_item=this.container.find(".chosen-single").first()),this.results_build(),this.set_tab_index(),this.set_label_behavior()},n.prototype.on_ready=function(){return this.form_field_jq.trigger("chosen:ready",{chosen:this})},n.prototype.register_observers=function(){return this.container.on("touchstart.chosen",function(t){return function(e){t.container_mousedown(e)}}(this)),this.container.on("touchend.chosen",function(t){return function(e){t.container_mouseup(e)}}(this)),this.container.on("mousedown.chosen",function(t){return function(e){t.container_mousedown(e)}}(this)),this.container.on("mouseup.chosen",function(t){return function(e){t.container_mouseup(e)}}(this)),this.container.on("mouseenter.chosen",function(t){return function(e){t.mouse_enter(e)}}(this)),this.container.on("mouseleave.chosen",function(t){return function(e){t.mouse_leave(e)}}(this)),this.search_results.on("mouseup.chosen",function(t){return function(e){t.search_results_mouseup(e)}}(this)),this.search_results.on("mouseover.chosen",function(t){return function(e){t.search_results_mouseover(e)}}(this)),this.search_results.on("mouseout.chosen",function(t){return function(e){t.search_results_mouseout(e)}}(this)),this.search_results.on("mousewheel.chosen DOMMouseScroll.chosen",function(t){return function(e){t.search_results_mousewheel(e)}}(this)),this.search_results.on("touchstart.chosen",function(t){return function(e){t.search_results_touchstart(e)}}(this)),this.search_results.on("touchmove.chosen",function(t){return function(e){t.search_results_touchmove(e)}}(this)),this.search_results.on("touchend.chosen",function(t){return function(e){t.search_results_touchend(e)}}(this)),this.form_field_jq.on("chosen:updated.chosen",function(t){return function(e){t.results_update_field(e)}}(this)),this.form_field_jq.on("chosen:activate.chosen",function(t){return function(e){t.activate_field(e)}}(this)),this.form_field_jq.on("chosen:open.chosen",function(t){return function(e){t.container_mousedown(e)}}(this)),this.form_field_jq.on("chosen:close.chosen",function(t){return function(e){t.close_field(e)}}(this)),this.search_field.on("blur.chosen",function(t){return function(e){t.input_blur(e)}}(this)),this.search_field.on("keyup.chosen",function(t){return function(e){t.keyup_checker(e)}}(this)),this.search_field.on("keydown.chosen",function(t){return function(e){t.keydown_checker(e)}}(this)),this.search_field.on("focus.chosen",function(t){return function(e){t.input_focus(e)}}(this)),this.search_field.on("cut.chosen",function(t){return function(e){t.clipboard_event_checker(e)}}(this)),this.search_field.on("paste.chosen",function(t){return function(e){t.clipboard_event_checker(e)}}(this)),this.is_multiple?this.search_choices.on("click.chosen",function(t){return function(e){t.choices_click(e)}}(this)):this.container.on("click.chosen",function(t){t.preventDefault()})},n.prototype.destroy=function(){return t(this.container[0].ownerDocument).off("click.chosen",this.click_test_action),this.form_field_label.length>0&&this.form_field_label.off("click.chosen"),this.search_field[0].tabIndex&&(this.form_field_jq[0].tabIndex=this.search_field[0].tabIndex),this.container.remove(),this.form_field_jq.removeData("chosen"),this.form_field_jq.show()},n.prototype.search_field_disabled=function(){return this.is_disabled=this.form_field.disabled||this.form_field_jq.parents("fieldset").is(":disabled"),this.container.toggleClass("chosen-disabled",this.is_disabled),this.search_field[0].disabled=this.is_disabled,this.is_multiple||this.selected_item.off("focus.chosen",this.activate_field),this.is_disabled?this.close_field():this.is_multiple?void 0:this.selected_item.on("focus.chosen",this.activate_field)},n.prototype.container_mousedown=function(e){var s;if(!this.is_disabled)return!e||"mousedown"!==(s=e.type)&&"touchstart"!==s||this.results_showing||e.preventDefault(),null!=e&&t(e.target).hasClass("search-choice-close")?void 0:(this.active_field?this.is_multiple||!e||t(e.target)[0]!==this.selected_item[0]&&!t(e.target).parents("a.chosen-single").length||(e.preventDefault(),this.results_toggle()):(this.is_multiple&&this.search_field.val(""),t(this.container[0].ownerDocument).on("click.chosen",this.click_test_action),this.results_show()),this.activate_field())},n.prototype.container_mouseup=function(t){if("ABBR"===t.target.nodeName&&!this.is_disabled)return this.results_reset(t)},n.prototype.search_results_mousewheel=function(t){var e;if(t.originalEvent&&(e=t.originalEvent.deltaY||-t.originalEvent.wheelDelta||t.originalEvent.detail),null!=e)return t.preventDefault(),"DOMMouseScroll"===t.type&&(e*=40),this.search_results.scrollTop(e+this.search_results.scrollTop())},n.prototype.blur_test=function(t){if(!this.active_field&&this.container.hasClass("chosen-container-active"))return this.close_field()},n.prototype.close_field=function(){return t(this.container[0].ownerDocument).off("click.chosen",this.click_test_action),this.active_field=!1,this.results_hide(),this.container.removeClass("chosen-container-active"),this.clear_backstroke(),this.show_search_field_default(),this.search_field_scale(),this.search_field.blur()},n.prototype.activate_field=function(){if(!this.is_disabled)return this.container.addClass("chosen-container-active"),this.active_field=!0,this.search_field.val(this.search_field.val()),this.search_field.focus()},n.prototype.test_active_click=function(e){var s;return(s=t(e.target).closest(".chosen-container")).length&&this.container[0]===s[0]?this.active_field=!0:this.close_field()},n.prototype.results_build=function(){return this.parsing=!0,this.selected_option_count=null,this.results_data=i.select_to_array(this.form_field),this.is_multiple?this.search_choices.find("li.search-choice").remove():(this.single_set_selected_text(),this.disable_search||this.form_field.options.length<=this.disable_search_threshold?(this.search_field[0].readOnly=!0,this.container.addClass("chosen-container-single-nosearch")):(this.search_field[0].readOnly=!1,this.container.removeClass("chosen-container-single-nosearch"))),this.update_results_content(this.results_option_build({first:!0})),this.search_field_disabled(),this.show_search_field_default(),this.search_field_scale(),this.parsing=!1},n.prototype.result_do_highlight=function(t){var e,s,i,n,r;if(t.length){if(this.result_clear_highlight(),this.result_highlight=t,this.result_highlight.addClass("highlighted"),i=parseInt(this.search_results.css("maxHeight"),10),r=this.search_results.scrollTop(),n=i+r,s=this.result_highlight.position().top+this.search_results.scrollTop(),(e=s+this.result_highlight.outerHeight())>=n)return this.search_results.scrollTop(e-i>0?e-i:0);if(s<r)return this.search_results.scrollTop(s)}},n.prototype.result_clear_highlight=function(){return this.result_highlight&&this.result_highlight.removeClass("highlighted"),this.result_highlight=null},n.prototype.results_show=function(){return this.is_multiple&&this.max_selected_options<=this.choices_count()?(this.form_field_jq.trigger("chosen:maxselected",{chosen:this}),!1):(this.container.addClass("chosen-with-drop"),this.results_showing=!0,this.search_field.focus(),this.search_field.val(this.get_search_field_value()),this.winnow_results(),this.form_field_jq.trigger("chosen:showing_dropdown",{chosen:this}))},n.prototype.update_results_content=function(t){return this.search_results.html(t)},n.prototype.results_hide=function(){return this.results_showing&&(this.result_clear_highlight(),this.container.removeClass("chosen-with-drop"),this.form_field_jq.trigger("chosen:hiding_dropdown",{chosen:this})),this.results_showing=!1},n.prototype.set_tab_index=function(t){var e;if(this.form_field.tabIndex)return e=this.form_field.tabIndex,this.form_field.tabIndex=-1,this.search_field[0].tabIndex=e},n.prototype.set_label_behavior=function(){if(this.form_field_label=this.form_field_jq.parents("label"),!this.form_field_label.length&&this.form_field.id.length&&(this.form_field_label=t("label[for='"+this.form_field.id+"']")),this.form_field_label.length>0)return this.form_field_label.on("click.chosen",this.label_click_handler)},n.prototype.show_search_field_default=function(){return this.is_multiple&&this.choices_count()<1&&!this.active_field?(this.search_field.val(this.default_text),this.search_field.addClass("default")):(this.search_field.val(""),this.search_field.removeClass("default"))},n.prototype.search_results_mouseup=function(e){var s;if((s=t(e.target).hasClass("active-result")?t(e.target):t(e.target).parents(".active-result").first()).length)return this.result_highlight=s,this.result_select(e),this.search_field.focus()},n.prototype.search_results_mouseover=function(e){var s;if(s=t(e.target).hasClass("active-result")?t(e.target):t(e.target).parents(".active-result").first())return this.result_do_highlight(s)},n.prototype.search_results_mouseout=function(e){if(t(e.target).hasClass("active-result")||t(e.target).parents(".active-result").first())return this.result_clear_highlight()},n.prototype.choice_build=function(e){var s,i;return s=t("<li />",{"class":"search-choice"}).html("<span>"+this.choice_label(e)+"</span>"),e.disabled?s.addClass("search-choice-disabled"):((i=t("<a />",{"class":"search-choice-close","data-option-array-index":e.array_index})).on("click.chosen",function(t){return function(e){return t.choice_destroy_link_click(e)}}(this)),s.append(i)),this.search_container.before(s)},n.prototype.choice_destroy_link_click=function(e){if(e.preventDefault(),e.stopPropagation(),!this.is_disabled)return this.choice_destroy(t(e.target))},n.prototype.choice_destroy=function(t){if(this.result_deselect(t[0].getAttribute("data-option-array-index")))return this.active_field?this.search_field.focus():this.show_search_field_default(),this.is_multiple&&this.choices_count()>0&&this.get_search_field_value().length<1&&this.results_hide(),t.parents("li").first().remove(),this.search_field_scale()},n.prototype.results_reset=function(){if(this.reset_single_select_options(),this.form_field.options[0].selected=!0,this.single_set_selected_text(),this.show_search_field_default(),this.results_reset_cleanup(),this.trigger_form_field_change(),this.active_field)return this.results_hide()},n.prototype.results_reset_cleanup=function(){return this.current_selectedIndex=this.form_field.selectedIndex,this.selected_item.find("abbr").remove()},n.prototype.result_select=function(t){var e,s;if(this.result_highlight)return e=this.result_highlight,this.result_clear_highlight(),this.is_multiple&&this.max_selected_options<=this.choices_count()?(this.form_field_jq.trigger("chosen:maxselected",{chosen:this}),!1):(this.is_multiple?e.removeClass("active-result"):this.reset_single_select_options(),e.addClass("result-selected"),s=this.results_data[e[0].getAttribute("data-option-array-index")],s.selected=!0,this.form_field.options[s.options_index].selected=!0,this.selected_option_count=null,this.is_multiple?this.choice_build(s):this.single_set_selected_text(this.choice_label(s)),this.is_multiple&&(!this.hide_results_on_select||t.metaKey||t.ctrlKey)?t.metaKey||t.ctrlKey?this.winnow_results({skip_highlight:!0}):(this.search_field.val(""),this.winnow_results()):(this.results_hide(),this.show_search_field_default()),(this.is_multiple||this.form_field.selectedIndex!==this.current_selectedIndex)&&this.trigger_form_field_change({selected:this.form_field.options[s.options_index].value}),this.current_selectedIndex=this.form_field.selectedIndex,t.preventDefault(),this.search_field_scale())},n.prototype.single_set_selected_text=function(t){return null==t&&(t=this.default_text),t===this.default_text?this.selected_item.addClass("chosen-default"):(this.single_deselect_control_build(),this.selected_item.removeClass("chosen-default")),this.selected_item.find("span").html(t)},n.prototype.result_deselect=function(t){var e;return e=this.results_data[t],!this.form_field.options[e.options_index].disabled&&(e.selected=!1,this.form_field.options[e.options_index].selected=!1,this.selected_option_count=null,this.result_clear_highlight(),this.results_showing&&this.winnow_results(),this.trigger_form_field_change({deselected:this.form_field.options[e.options_index].value}),this.search_field_scale(),!0)},n.prototype.single_deselect_control_build=function(){if(this.allow_single_deselect)return this.selected_item.find("abbr").length||this.selected_item.find("span").first().after('<abbr class="search-choice-close"></abbr>'),this.selected_item.addClass("chosen-single-with-deselect")},n.prototype.get_search_field_value=function(){return this.search_field.val()},n.prototype.get_search_text=function(){return t.trim(this.get_search_field_value())},n.prototype.escape_html=function(e){return t("<div/>").text(e).html()},n.prototype.winnow_results_set_highlight=function(){var t,e;if(e=this.is_multiple?[]:this.search_results.find(".result-selected.active-result"),null!=(t=e.length?e.first():this.search_results.find(".active-result").first()))return this.result_do_highlight(t)},n.prototype.no_results=function(t){var e;return e=this.get_no_results_html(t),this.search_results.append(e),this.form_field_jq.trigger("chosen:no_results",{chosen:this})},n.prototype.no_results_clear=function(){return this.search_results.find(".no-results").remove()},n.prototype.keydown_arrow=function(){var t;return this.results_showing&&this.result_highlight?(t=this.result_highlight.nextAll("li.active-result").first())?this.result_do_highlight(t):void 0:this.results_show()},n.prototype.keyup_arrow=function(){var t;return this.results_showing||this.is_multiple?this.result_highlight?(t=this.result_highlight.prevAll("li.active-result")).length?this.result_do_highlight(t.first()):(this.choices_count()>0&&this.results_hide(),this.result_clear_highlight()):void 0:this.results_show()},n.prototype.keydown_backstroke=function(){var t;return this.pending_backstroke?(this.choice_destroy(this.pending_backstroke.find("a").first()),this.clear_backstroke()):(t=this.search_container.siblings("li.search-choice").last()).length&&!t.hasClass("search-choice-disabled")?(this.pending_backstroke=t,this.single_backstroke_delete?this.keydown_backstroke():this.pending_backstroke.addClass("search-choice-focus")):void 0},n.prototype.clear_backstroke=function(){return this.pending_backstroke&&this.pending_backstroke.removeClass("search-choice-focus"),this.pending_backstroke=null},n.prototype.search_field_scale=function(){var e,s,i,n,r,o,h;if(this.is_multiple){for(r={position:"absolute",left:"-1000px",top:"-1000px",display:"none",whiteSpace:"pre"},s=0,i=(o=["fontSize","fontStyle","fontWeight","fontFamily","lineHeight","textTransform","letterSpacing"]).length;s<i;s++)r[n=o[s]]=this.search_field.css(n);return(e=t("<div />").css(r)).text(this.get_search_field_value()),t("body").append(e),h=e.width()+25,e.remove(),this.container.is(":visible")&&(h=Math.min(this.container.outerWidth()-10,h)),this.search_field.width(h)}},n.prototype.trigger_form_field_change=function(t){return this.form_field_jq.trigger("input",t),this.form_field_jq.trigger("change",t)},n}()}).call(this);
0 4 \ No newline at end of file
public/js/chosen/chosen.min.css
... ... @@ -0,0 +1,11 @@
  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.7
  6 +Full source at https://github.com/harvesthq/chosen
  7 +Copyright (c) 2011-2018 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 +*/.chosen-container{position:relative;display:inline-block;vertical-align:middle;font-size:13px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.chosen-container *{-webkit-box-sizing:border-box;box-sizing:border-box}.chosen-container .chosen-drop{position:absolute;top:100%;z-index:1010;width:100%;border:1px solid #aaa;border-top:0;background:#fff;-webkit-box-shadow:0 4px 5px rgba(0,0,0,.15);box-shadow:0 4px 5px rgba(0,0,0,.15);clip:rect(0,0,0,0);-webkit-clip-path:inset(100% 100%);clip-path:inset(100% 100%)}.chosen-container.chosen-with-drop .chosen-drop{clip:auto;-webkit-clip-path:none;clip-path:none}.chosen-container a{cursor:pointer}.chosen-container .chosen-single .group-name,.chosen-container .search-choice .group-name{margin-right:4px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;font-weight:400;color:#999}.chosen-container .chosen-single .group-name:after,.chosen-container .search-choice .group-name:after{content:":";padding-left:2px;vertical-align:top}.chosen-container-single .chosen-single{position:relative;display:block;overflow:hidden;padding:0 0 0 8px;height:25px;border:1px solid #aaa;border-radius:5px;background-color:#fff;background:-webkit-gradient(linear,left top,left bottom,color-stop(20%,#fff),color-stop(50%,#f6f6f6),color-stop(52%,#eee),to(#f4f4f4));background:linear-gradient(#fff 20%,#f6f6f6 50%,#eee 52%,#f4f4f4 100%);background-clip:padding-box;-webkit-box-shadow:0 0 3px #fff inset,0 1px 1px rgba(0,0,0,.1);box-shadow:0 0 3px #fff inset,0 1px 1px rgba(0,0,0,.1);color:#444;text-decoration:none;white-space:nowrap;line-height:24px}.chosen-container-single .chosen-default{color:#999}.chosen-container-single .chosen-single span{display:block;overflow:hidden;margin-right:26px;text-overflow:ellipsis;white-space:nowrap}.chosen-container-single .chosen-single-with-deselect span{margin-right:38px}.chosen-container-single .chosen-single abbr{position:absolute;top:6px;right:26px;display:block;width:12px;height:12px;background:url(chosen-sprite.png) -42px 1px no-repeat;font-size:1px}.chosen-container-single .chosen-single abbr:hover{background-position:-42px -10px}.chosen-container-single.chosen-disabled .chosen-single abbr:hover{background-position:-42px -10px}.chosen-container-single .chosen-single div{position:absolute;top:0;right:0;display:block;width:18px;height:100%}.chosen-container-single .chosen-single div b{display:block;width:100%;height:100%;background:url(chosen-sprite.png) no-repeat 0 2px}.chosen-container-single .chosen-search{position:relative;z-index:1010;margin:0;padding:3px 4px;white-space:nowrap}.chosen-container-single .chosen-search input[type=text]{margin:1px 0;padding:4px 20px 4px 5px;width:100%;height:auto;outline:0;border:1px solid #aaa;background:url(chosen-sprite.png) no-repeat 100% -20px;font-size:1em;font-family:sans-serif;line-height:normal;border-radius:0}.chosen-container-single .chosen-drop{margin-top:-1px;border-radius:0 0 4px 4px;background-clip:padding-box}.chosen-container-single.chosen-container-single-nosearch .chosen-search{position:absolute;clip:rect(0,0,0,0);-webkit-clip-path:inset(100% 100%);clip-path:inset(100% 100%)}.chosen-container .chosen-results{color:#444;position:relative;overflow-x:hidden;overflow-y:auto;margin:0 4px 4px 0;padding:0 0 0 4px;max-height:240px;-webkit-overflow-scrolling:touch}.chosen-container .chosen-results li{display:none;margin:0;padding:5px 6px;list-style:none;line-height:15px;word-wrap:break-word;-webkit-touch-callout:none}.chosen-container .chosen-results li.active-result{display:list-item;cursor:pointer}.chosen-container .chosen-results li.disabled-result{display:list-item;color:#ccc;cursor:default}.chosen-container .chosen-results li.highlighted{background-color:#3875d7;background-image:-webkit-gradient(linear,left top,left bottom,color-stop(20%,#3875d7),color-stop(90%,#2a62bc));background-image:linear-gradient(#3875d7 20%,#2a62bc 90%);color:#fff}.chosen-container .chosen-results li.no-results{color:#777;display:list-item;background:#f4f4f4}.chosen-container .chosen-results li.group-result{display:list-item;font-weight:700;cursor:default}.chosen-container .chosen-results li.group-option{padding-left:15px}.chosen-container .chosen-results li em{font-style:normal;text-decoration:underline}.chosen-container-multi .chosen-choices{position:relative;overflow:hidden;margin:0;padding:0 5px;width:100%;height:auto;border:1px solid #aaa;background-color:#fff;background-image:-webkit-gradient(linear,left top,left bottom,color-stop(1%,#eee),color-stop(15%,#fff));background-image:linear-gradient(#eee 1%,#fff 15%);cursor:text}.chosen-container-multi .chosen-choices li{float:left;list-style:none}.chosen-container-multi .chosen-choices li.search-field{margin:0;padding:0;white-space:nowrap}.chosen-container-multi .chosen-choices li.search-field input[type=text]{margin:1px 0;padding:0;height:25px;outline:0;border:0!important;background:0 0!important;-webkit-box-shadow:none;box-shadow:none;color:#999;font-size:100%;font-family:sans-serif;line-height:normal;border-radius:0;width:25px}.chosen-container-multi .chosen-choices li.search-choice{position:relative;margin:3px 5px 3px 0;padding:3px 20px 3px 5px;border:1px solid #aaa;max-width:100%;border-radius:3px;background-color:#eee;background-image:-webkit-gradient(linear,left top,left bottom,color-stop(20%,#f4f4f4),color-stop(50%,#f0f0f0),color-stop(52%,#e8e8e8),to(#eee));background-image:linear-gradient(#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-size:100% 19px;background-repeat:repeat-x;background-clip:padding-box;-webkit-box-shadow:0 0 2px #fff inset,0 1px 0 rgba(0,0,0,.05);box-shadow:0 0 2px #fff inset,0 1px 0 rgba(0,0,0,.05);color:#333;line-height:13px;cursor:default}.chosen-container-multi .chosen-choices li.search-choice span{word-wrap:break-word}.chosen-container-multi .chosen-choices li.search-choice .search-choice-close{position:absolute;top:4px;right:3px;display:block;width:12px;height:12px;background:url(chosen-sprite.png) -42px 1px no-repeat;font-size:1px}.chosen-container-multi .chosen-choices li.search-choice .search-choice-close:hover{background-position:-42px -10px}.chosen-container-multi .chosen-choices li.search-choice-disabled{padding-right:5px;border:1px solid #ccc;background-color:#e4e4e4;background-image:-webkit-gradient(linear,left top,left bottom,color-stop(20%,#f4f4f4),color-stop(50%,#f0f0f0),color-stop(52%,#e8e8e8),to(#eee));background-image:linear-gradient(#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);color:#666}.chosen-container-multi .chosen-choices li.search-choice-focus{background:#d4d4d4}.chosen-container-multi .chosen-choices li.search-choice-focus .search-choice-close{background-position:-42px -10px}.chosen-container-multi .chosen-results{margin:0;padding:0}.chosen-container-multi .chosen-drop .result-selected{display:list-item;color:#ccc;cursor:default}.chosen-container-active .chosen-single{border:1px solid #5897fb;-webkit-box-shadow:0 0 5px rgba(0,0,0,.3);box-shadow:0 0 5px rgba(0,0,0,.3)}.chosen-container-active.chosen-with-drop .chosen-single{border:1px solid #aaa;border-bottom-right-radius:0;border-bottom-left-radius:0;background-image:-webkit-gradient(linear,left top,left bottom,color-stop(20%,#eee),color-stop(80%,#fff));background-image:linear-gradient(#eee 20%,#fff 80%);-webkit-box-shadow:0 1px 0 #fff inset;box-shadow:0 1px 0 #fff inset}.chosen-container-active.chosen-with-drop .chosen-single div{border-left:none;background:0 0}.chosen-container-active.chosen-with-drop .chosen-single div b{background-position:-18px 2px}.chosen-container-active .chosen-choices{border:1px solid #5897fb;-webkit-box-shadow:0 0 5px rgba(0,0,0,.3);box-shadow:0 0 5px rgba(0,0,0,.3)}.chosen-container-active .chosen-choices li.search-field input[type=text]{color:#222!important}.chosen-disabled{opacity:.5!important;cursor:default}.chosen-disabled .chosen-single{cursor:default}.chosen-disabled .chosen-choices .search-choice .search-choice-close{cursor:default}.chosen-rtl{text-align:right}.chosen-rtl .chosen-single{overflow:visible;padding:0 8px 0 0}.chosen-rtl .chosen-single span{margin-right:0;margin-left:26px;direction:rtl}.chosen-rtl .chosen-single-with-deselect span{margin-left:38px}.chosen-rtl .chosen-single div{right:auto;left:3px}.chosen-rtl .chosen-single abbr{right:auto;left:26px}.chosen-rtl .chosen-choices li{float:right}.chosen-rtl .chosen-choices li.search-field input[type=text]{direction:rtl}.chosen-rtl .chosen-choices li.search-choice{margin:3px 5px 3px 0;padding:3px 5px 3px 19px}.chosen-rtl .chosen-choices li.search-choice .search-choice-close{right:auto;left:4px}.chosen-rtl.chosen-container-single .chosen-results{margin:0 0 4px 4px;padding:0 4px 0 0}.chosen-rtl .chosen-results li.group-option{padding-right:15px;padding-left:0}.chosen-rtl.chosen-container-active.chosen-with-drop .chosen-single div{border-right:none}.chosen-rtl .chosen-search input[type=text]{padding:4px 5px 4px 20px;background:url(chosen-sprite.png) no-repeat -30px -20px;direction:rtl}.chosen-rtl.chosen-container-single .chosen-single div b{background-position:6px 2px}.chosen-rtl.chosen-container-single.chosen-with-drop .chosen-single div b{background-position:-12px 2px}@media only screen and (-webkit-min-device-pixel-ratio:1.5),only screen and (min-resolution:144dpi),only screen and (min-resolution:1.5dppx){.chosen-container .chosen-results-scroll-down span,.chosen-container .chosen-results-scroll-up span,.chosen-container-multi .chosen-choices .search-choice .search-choice-close,.chosen-container-single .chosen-search input[type=text],.chosen-container-single .chosen-single abbr,.chosen-container-single .chosen-single div b,.chosen-rtl .chosen-search input[type=text]{background-image:url(chosen-sprite@2x.png)!important;background-size:52px 37px!important;background-repeat:no-repeat!important}}
0 12 \ No newline at end of file
public/js/chosen/chosen.proto.js
Changes suppressed. Click to show
... ... @@ -0,0 +1,1399 @@
  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.7
  6 +Full source at https://github.com/harvesthq/chosen
  7 +Copyright (c) 2011-2018 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 +
  13 +(function() {
  14 + var AbstractChosen, 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;
  18 +
  19 + SelectParser = (function() {
  20 + function SelectParser() {
  21 + this.options_index = 0;
  22 + this.parsed = [];
  23 + }
  24 +
  25 + SelectParser.prototype.add_node = function(child) {
  26 + if (child.nodeName.toUpperCase() === "OPTGROUP") {
  27 + return this.add_group(child);
  28 + } else {
  29 + return this.add_option(child);
  30 + }
  31 + };
  32 +
  33 + SelectParser.prototype.add_group = function(group) {
  34 + var group_position, i, len, option, ref, results1;
  35 + group_position = this.parsed.length;
  36 + this.parsed.push({
  37 + array_index: group_position,
  38 + group: true,
  39 + label: group.label,
  40 + title: group.title ? group.title : void 0,
  41 + children: 0,
  42 + disabled: group.disabled,
  43 + classes: group.className
  44 + });
  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;
  52 + };
  53 +
  54 + SelectParser.prototype.add_option = function(option, group_position, group_disabled) {
  55 + if (option.nodeName.toUpperCase() === "OPTION") {
  56 + if (option.text !== "") {
  57 + if (group_position != null) {
  58 + this.parsed[group_position].children += 1;
  59 + }
  60 + this.parsed.push({
  61 + array_index: this.parsed.length,
  62 + options_index: this.options_index,
  63 + value: option.value,
  64 + text: option.text,
  65 + html: option.innerHTML,
  66 + title: option.title ? option.title : void 0,
  67 + selected: option.selected,
  68 + disabled: group_disabled === true ? group_disabled : option.disabled,
  69 + group_array_index: group_position,
  70 + group_label: group_position != null ? this.parsed[group_position].label : null,
  71 + classes: option.className,
  72 + style: option.style.cssText
  73 + });
  74 + } else {
  75 + this.parsed.push({
  76 + array_index: this.parsed.length,
  77 + options_index: this.options_index,
  78 + empty: true
  79 + });
  80 + }
  81 + return this.options_index += 1;
  82 + }
  83 + };
  84 +
  85 + return SelectParser;
  86 +
  87 + })();
  88 +
  89 + SelectParser.select_to_array = function(select) {
  90 + var child, i, len, parser, ref;
  91 + parser = new SelectParser();
  92 + ref = select.childNodes;
  93 + for (i = 0, len = ref.length; i < len; i++) {
  94 + child = ref[i];
  95 + parser.add_node(child);
  96 + }
  97 + return parser.parsed;
  98 + };
  99 +
  100 + AbstractChosen = (function() {
  101 + function AbstractChosen(form_field, options1) {
  102 + this.form_field = form_field;
  103 + this.options = options1 != null ? options1 : {};
  104 + this.label_click_handler = bind(this.label_click_handler, this);
  105 + if (!AbstractChosen.browser_is_supported()) {
  106 + return;
  107 + }
  108 + this.is_multiple = this.form_field.multiple;
  109 + this.set_default_text();
  110 + this.set_default_values();
  111 + this.setup();
  112 + this.set_up_html();
  113 + this.register_observers();
  114 + this.on_ready();
  115 + }
  116 +
  117 + AbstractChosen.prototype.set_default_values = function() {
  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);
  128 + this.active_field = false;
  129 + this.mouse_on_container = false;
  130 + this.results_showing = false;
  131 + this.result_highlighted = null;
  132 + this.is_rtl = this.options.rtl || /\bchosen-rtl\b/.test(this.form_field.className);
  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;
  134 + this.disable_search_threshold = this.options.disable_search_threshold || 0;
  135 + this.disable_search = this.options.disable_search || false;
  136 + this.enable_split_word_search = this.options.enable_split_word_search != null ? this.options.enable_split_word_search : true;
  137 + this.group_search = this.options.group_search != null ? this.options.group_search : true;
  138 + this.search_contains = this.options.search_contains || false;
  139 + this.single_backstroke_delete = this.options.single_backstroke_delete != null ? this.options.single_backstroke_delete : true;
  140 + this.max_selected_options = this.options.max_selected_options || Infinity;
  141 + this.inherit_select_classes = this.options.inherit_select_classes || false;
  142 + this.display_selected_options = this.options.display_selected_options != null ? this.options.display_selected_options : true;
  143 + this.display_disabled_options = this.options.display_disabled_options != null ? this.options.display_disabled_options : true;
  144 + this.include_group_label_in_selected = this.options.include_group_label_in_selected || false;
  145 + this.max_shown_results = this.options.max_shown_results || Number.POSITIVE_INFINITY;
  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;
  148 + };
  149 +
  150 + AbstractChosen.prototype.set_default_text = function() {
  151 + if (this.form_field.getAttribute("data-placeholder")) {
  152 + this.default_text = this.form_field.getAttribute("data-placeholder");
  153 + } else if (this.is_multiple) {
  154 + this.default_text = this.options.placeholder_text_multiple || this.options.placeholder_text || AbstractChosen.default_multiple_text;
  155 + } else {
  156 + this.default_text = this.options.placeholder_text_single || this.options.placeholder_text || AbstractChosen.default_single_text;
  157 + }
  158 + this.default_text = this.escape_html(this.default_text);
  159 + return this.results_none_found = this.form_field.getAttribute("data-no_results_text") || this.options.no_results_text || AbstractChosen.default_no_result_text;
  160 + };
  161 +
  162 + AbstractChosen.prototype.choice_label = function(item) {
  163 + if (this.include_group_label_in_selected && (item.group_label != null)) {
  164 + return "<b class='group-name'>" + (this.escape_html(item.group_label)) + "</b>" + item.html;
  165 + } else {
  166 + return item.html;
  167 + }
  168 + };
  169 +
  170 + AbstractChosen.prototype.mouse_enter = function() {
  171 + return this.mouse_on_container = true;
  172 + };
  173 +
  174 + AbstractChosen.prototype.mouse_leave = function() {
  175 + return this.mouse_on_container = false;
  176 + };
  177 +
  178 + AbstractChosen.prototype.input_focus = function(evt) {
  179 + if (this.is_multiple) {
  180 + if (!this.active_field) {
  181 + return setTimeout(((function(_this) {
  182 + return function() {
  183 + return _this.container_mousedown();
  184 + };
  185 + })(this)), 50);
  186 + }
  187 + } else {
  188 + if (!this.active_field) {
  189 + return this.activate_field();
  190 + }
  191 + }
  192 + };
  193 +
  194 + AbstractChosen.prototype.input_blur = function(evt) {
  195 + if (!this.mouse_on_container) {
  196 + this.active_field = false;
  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();
  210 + }
  211 + };
  212 +
  213 + AbstractChosen.prototype.results_option_build = function(options) {
  214 + var content, data, data_content, i, len, ref, shown_results;
  215 + content = '';
  216 + shown_results = 0;
  217 + ref = this.results_data;
  218 + for (i = 0, len = ref.length; i < len; i++) {
  219 + data = ref[i];
  220 + data_content = '';
  221 + if (data.group) {
  222 + data_content = this.result_add_group(data);
  223 + } else {
  224 + data_content = this.result_add_option(data);
  225 + }
  226 + if (data_content !== '') {
  227 + shown_results++;
  228 + content += data_content;
  229 + }
  230 + if (options != null ? options.first : void 0) {
  231 + if (data.selected && this.is_multiple) {
  232 + this.choice_build(data);
  233 + } else if (data.selected && !this.is_multiple) {
  234 + this.single_set_selected_text(this.choice_label(data));
  235 + }
  236 + }
  237 + if (shown_results >= this.max_shown_results) {
  238 + break;
  239 + }
  240 + }
  241 + return content;
  242 + };
  243 +
  244 + AbstractChosen.prototype.result_add_option = function(option) {
  245 + var classes, option_el;
  246 + if (!option.search_match) {
  247 + return '';
  248 + }
  249 + if (!this.include_option_in_results(option)) {
  250 + return '';
  251 + }
  252 + classes = [];
  253 + if (!option.disabled && !(option.selected && this.is_multiple)) {
  254 + classes.push("active-result");
  255 + }
  256 + if (option.disabled && !(option.selected && this.is_multiple)) {
  257 + classes.push("disabled-result");
  258 + }
  259 + if (option.selected) {
  260 + classes.push("result-selected");
  261 + }
  262 + if (option.group_array_index != null) {
  263 + classes.push("group-option");
  264 + }
  265 + if (option.classes !== "") {
  266 + classes.push(option.classes);
  267 + }
  268 + option_el = document.createElement("li");
  269 + option_el.className = classes.join(" ");
  270 + if (option.style) {
  271 + option_el.style.cssText = option.style;
  272 + }
  273 + option_el.setAttribute("data-option-array-index", option.array_index);
  274 + option_el.innerHTML = option.highlighted_html || option.html;
  275 + if (option.title) {
  276 + option_el.title = option.title;
  277 + }
  278 + return this.outerHTML(option_el);
  279 + };
  280 +
  281 + AbstractChosen.prototype.result_add_group = function(group) {
  282 + var classes, group_el;
  283 + if (!(group.search_match || group.group_match)) {
  284 + return '';
  285 + }
  286 + if (!(group.active_options > 0)) {
  287 + return '';
  288 + }
  289 + classes = [];
  290 + classes.push("group-result");
  291 + if (group.classes) {
  292 + classes.push(group.classes);
  293 + }
  294 + group_el = document.createElement("li");
  295 + group_el.className = classes.join(" ");
  296 + group_el.innerHTML = group.highlighted_html || this.escape_html(group.label);
  297 + if (group.title) {
  298 + group_el.title = group.title;
  299 + }
  300 + return this.outerHTML(group_el);
  301 + };
  302 +
  303 + AbstractChosen.prototype.results_update_field = function() {
  304 + this.set_default_text();
  305 + if (!this.is_multiple) {
  306 + this.results_reset_cleanup();
  307 + }
  308 + this.result_clear_highlight();
  309 + this.results_build();
  310 + if (this.results_showing) {
  311 + return this.winnow_results();
  312 + }
  313 + };
  314 +
  315 + AbstractChosen.prototype.reset_single_select_options = function() {
  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];
  321 + if (result.selected) {
  322 + results1.push(result.selected = false);
  323 + } else {
  324 + results1.push(void 0);
  325 + }
  326 + }
  327 + return results1;
  328 + };
  329 +
  330 + AbstractChosen.prototype.results_toggle = function() {
  331 + if (this.results_showing) {
  332 + return this.results_hide();
  333 + } else {
  334 + return this.results_show();
  335 + }
  336 + };
  337 +
  338 + AbstractChosen.prototype.results_search = function(evt) {
  339 + if (this.results_showing) {
  340 + return this.winnow_results();
  341 + } else {
  342 + return this.results_show();
  343 + }
  344 + };
  345 +
  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;
  348 + this.no_results_clear();
  349 + results = 0;
  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];
  356 + option.search_match = false;
  357 + results_group = null;
  358 + search_match = null;
  359 + option.highlighted_html = '';
  360 + if (this.include_option_in_results(option)) {
  361 + if (option.group) {
  362 + option.group_match = false;
  363 + option.active_options = 0;
  364 + }
  365 + if ((option.group_array_index != null) && this.results_data[option.group_array_index]) {
  366 + results_group = this.results_data[option.group_array_index];
  367 + if (results_group.active_options === 0 && results_group.search_match) {
  368 + results += 1;
  369 + }
  370 + results_group.active_options += 1;
  371 + }
  372 + text = option.group ? option.label : option.text;
  373 + if (!(option.group && !this.group_search)) {
  374 + search_match = this.search_string_match(text, regex);
  375 + option.search_match = search_match != null;
  376 + if (option.search_match && !option.group) {
  377 + results += 1;
  378 + }
  379 + if (option.search_match) {
  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));
  386 + }
  387 + if (results_group != null) {
  388 + results_group.group_match = true;
  389 + }
  390 + } else if ((option.group_array_index != null) && this.results_data[option.group_array_index].search_match) {
  391 + option.search_match = true;
  392 + }
  393 + }
  394 + }
  395 + }
  396 + this.result_clear_highlight();
  397 + if (results < 1 && query.length) {
  398 + this.update_results_content("");
  399 + return this.no_results(query);
  400 + } else {
  401 + this.update_results_content(this.results_option_build());
  402 + if (!(options != null ? options.skip_highlight : void 0)) {
  403 + return this.winnow_results_set_highlight();
  404 + }
  405 + }
  406 + };
  407 +
  408 + AbstractChosen.prototype.get_search_regex = function(escaped_search_string) {
  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 + }
  414 + regex_flag = this.case_sensitive_search ? "" : "i";
  415 + return new RegExp(regex_string, regex_flag);
  416 + };
  417 +
  418 + AbstractChosen.prototype.search_string_match = function(search_string, regex) {
  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 + };
  426 +
  427 + AbstractChosen.prototype.choices_count = function() {
  428 + var i, len, option, ref;
  429 + if (this.selected_option_count != null) {
  430 + return this.selected_option_count;
  431 + }
  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];
  436 + if (option.selected) {
  437 + this.selected_option_count += 1;
  438 + }
  439 + }
  440 + return this.selected_option_count;
  441 + };
  442 +
  443 + AbstractChosen.prototype.choices_click = function(evt) {
  444 + evt.preventDefault();
  445 + this.activate_field();
  446 + if (!(this.results_showing || this.is_disabled)) {
  447 + return this.results_show();
  448 + }
  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 +
  494 + AbstractChosen.prototype.keyup_checker = function(evt) {
  495 + var ref, stroke;
  496 + stroke = (ref = evt.which) != null ? ref : evt.keyCode;
  497 + this.search_field_scale();
  498 + switch (stroke) {
  499 + case 8:
  500 + if (this.is_multiple && this.backstroke_length < 1 && this.choices_count() > 0) {
  501 + this.keydown_backstroke();
  502 + } else if (!this.pending_backstroke) {
  503 + this.result_clear_highlight();
  504 + this.results_search();
  505 + }
  506 + break;
  507 + case 13:
  508 + evt.preventDefault();
  509 + if (this.results_showing) {
  510 + this.result_select(evt);
  511 + }
  512 + break;
  513 + case 27:
  514 + if (this.results_showing) {
  515 + this.results_hide();
  516 + }
  517 + break;
  518 + case 9:
  519 + case 16:
  520 + case 17:
  521 + case 18:
  522 + case 38:
  523 + case 40:
  524 + case 91:
  525 + break;
  526 + default:
  527 + this.results_search();
  528 + break;
  529 + }
  530 + };
  531 +
  532 + AbstractChosen.prototype.clipboard_event_checker = function(evt) {
  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);
  541 + };
  542 +
  543 + AbstractChosen.prototype.container_width = function() {
  544 + if (this.options.width != null) {
  545 + return this.options.width;
  546 + } else {
  547 + return this.form_field.offsetWidth + "px";
  548 + }
  549 + };
  550 +
  551 + AbstractChosen.prototype.include_option_in_results = function(option) {
  552 + if (this.is_multiple && (!this.display_selected_options && option.selected)) {
  553 + return false;
  554 + }
  555 + if (!this.display_disabled_options && option.disabled) {
  556 + return false;
  557 + }
  558 + if (option.empty) {
  559 + return false;
  560 + }
  561 + return true;
  562 + };
  563 +
  564 + AbstractChosen.prototype.search_results_touchstart = function(evt) {
  565 + this.touch_started = true;
  566 + return this.search_results_mouseover(evt);
  567 + };
  568 +
  569 + AbstractChosen.prototype.search_results_touchmove = function(evt) {
  570 + this.touch_started = false;
  571 + return this.search_results_mouseout(evt);
  572 + };
  573 +
  574 + AbstractChosen.prototype.search_results_touchend = function(evt) {
  575 + if (this.touch_started) {
  576 + return this.search_results_mouseup(evt);
  577 + }
  578 + };
  579 +
  580 + AbstractChosen.prototype.outerHTML = function(element) {
  581 + var tmp;
  582 + if (element.outerHTML) {
  583 + return element.outerHTML;
  584 + }
  585 + tmp = document.createElement("div");
  586 + tmp.appendChild(element);
  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>";
  600 + };
  601 +
  602 + AbstractChosen.browser_is_supported = function() {
  603 + if ("Microsoft Internet Explorer" === window.navigator.appName) {
  604 + return document.documentMode >= 8;
  605 + }
  606 + if (/iP(od|hone)/i.test(window.navigator.userAgent) || /IEMobile/i.test(window.navigator.userAgent) || /Windows Phone/i.test(window.navigator.userAgent) || /BlackBerry/i.test(window.navigator.userAgent) || /BB10/i.test(window.navigator.userAgent) || /Android.*Mobile/i.test(window.navigator.userAgent)) {
  607 + return false;
  608 + }
  609 + return true;
  610 + };
  611 +
  612 + AbstractChosen.default_multiple_text = "Select Some Options";
  613 +
  614 + AbstractChosen.default_single_text = "Select an Option";
  615 +
  616 + AbstractChosen.default_no_result_text = "No results match";
  617 +
  618 + return AbstractChosen;
  619 +
  620 + })();
  621 +
  622 + this.Chosen = (function(superClass) {
  623 + var triggerHtmlEvent;
  624 +
  625 + extend(Chosen, superClass);
  626 +
  627 + function Chosen() {
  628 + return Chosen.__super__.constructor.apply(this, arguments);
  629 + }
  630 +
  631 + Chosen.prototype.setup = function() {
  632 + return this.current_selectedIndex = this.form_field.selectedIndex;
  633 + };
  634 +
  635 + Chosen.prototype.set_up_html = function() {
  636 + var container_classes, container_props;
  637 + container_classes = ["chosen-container"];
  638 + container_classes.push("chosen-container-" + (this.is_multiple ? "multi" : "single"));
  639 + if (this.inherit_select_classes && this.form_field.className) {
  640 + container_classes.push(this.form_field.className);
  641 + }
  642 + if (this.is_rtl) {
  643 + container_classes.push("chosen-rtl");
  644 + }
  645 + container_props = {
  646 + 'class': container_classes.join(' '),
  647 + 'title': this.form_field.title
  648 + };
  649 + if (this.form_field.id.length) {
  650 + container_props.id = this.form_field.id.replace(/[^\w]/g, '_') + "_chosen";
  651 + }
  652 + this.container = new Element('div', container_props);
  653 + this.container.setStyle({
  654 + width: this.container_width()
  655 + });
  656 + if (this.is_multiple) {
  657 + this.container.update(this.get_multi_html());
  658 + } else {
  659 + this.container.update(this.get_single_html());
  660 + }
  661 + this.form_field.hide().insert({
  662 + after: this.container
  663 + });
  664 + this.dropdown = this.container.down('div.chosen-drop');
  665 + this.search_field = this.container.down('input');
  666 + this.search_results = this.container.down('ul.chosen-results');
  667 + this.search_field_scale();
  668 + this.search_no_results = this.container.down('li.no-results');
  669 + if (this.is_multiple) {
  670 + this.search_choices = this.container.down('ul.chosen-choices');
  671 + this.search_container = this.container.down('li.search-field');
  672 + } else {
  673 + this.search_container = this.container.down('div.chosen-search');
  674 + this.selected_item = this.container.down('.chosen-single');
  675 + }
  676 + this.results_build();
  677 + this.set_tab_index();
  678 + return this.set_label_behavior();
  679 + };
  680 +
  681 + Chosen.prototype.on_ready = function() {
  682 + return this.form_field.fire("chosen:ready", {
  683 + chosen: this
  684 + });
  685 + };
  686 +
  687 + Chosen.prototype.register_observers = function() {
  688 + this.container.observe("touchstart", (function(_this) {
  689 + return function(evt) {
  690 + return _this.container_mousedown(evt);
  691 + };
  692 + })(this));
  693 + this.container.observe("touchend", (function(_this) {
  694 + return function(evt) {
  695 + return _this.container_mouseup(evt);
  696 + };
  697 + })(this));
  698 + this.container.observe("mousedown", (function(_this) {
  699 + return function(evt) {
  700 + return _this.container_mousedown(evt);
  701 + };
  702 + })(this));
  703 + this.container.observe("mouseup", (function(_this) {
  704 + return function(evt) {
  705 + return _this.container_mouseup(evt);
  706 + };
  707 + })(this));
  708 + this.container.observe("mouseenter", (function(_this) {
  709 + return function(evt) {
  710 + return _this.mouse_enter(evt);
  711 + };
  712 + })(this));
  713 + this.container.observe("mouseleave", (function(_this) {
  714 + return function(evt) {
  715 + return _this.mouse_leave(evt);
  716 + };
  717 + })(this));
  718 + this.search_results.observe("mouseup", (function(_this) {
  719 + return function(evt) {
  720 + return _this.search_results_mouseup(evt);
  721 + };
  722 + })(this));
  723 + this.search_results.observe("mouseover", (function(_this) {
  724 + return function(evt) {
  725 + return _this.search_results_mouseover(evt);
  726 + };
  727 + })(this));
  728 + this.search_results.observe("mouseout", (function(_this) {
  729 + return function(evt) {
  730 + return _this.search_results_mouseout(evt);
  731 + };
  732 + })(this));
  733 + this.search_results.observe("mousewheel", (function(_this) {
  734 + return function(evt) {
  735 + return _this.search_results_mousewheel(evt);
  736 + };
  737 + })(this));
  738 + this.search_results.observe("DOMMouseScroll", (function(_this) {
  739 + return function(evt) {
  740 + return _this.search_results_mousewheel(evt);
  741 + };
  742 + })(this));
  743 + this.search_results.observe("touchstart", (function(_this) {
  744 + return function(evt) {
  745 + return _this.search_results_touchstart(evt);
  746 + };
  747 + })(this));
  748 + this.search_results.observe("touchmove", (function(_this) {
  749 + return function(evt) {
  750 + return _this.search_results_touchmove(evt);
  751 + };
  752 + })(this));
  753 + this.search_results.observe("touchend", (function(_this) {
  754 + return function(evt) {
  755 + return _this.search_results_touchend(evt);
  756 + };
  757 + })(this));
  758 + this.form_field.observe("chosen:updated", (function(_this) {
  759 + return function(evt) {
  760 + return _this.results_update_field(evt);
  761 + };
  762 + })(this));
  763 + this.form_field.observe("chosen:activate", (function(_this) {
  764 + return function(evt) {
  765 + return _this.activate_field(evt);
  766 + };
  767 + })(this));
  768 + this.form_field.observe("chosen:open", (function(_this) {
  769 + return function(evt) {
  770 + return _this.container_mousedown(evt);
  771 + };
  772 + })(this));
  773 + this.form_field.observe("chosen:close", (function(_this) {
  774 + return function(evt) {
  775 + return _this.close_field(evt);
  776 + };
  777 + })(this));
  778 + this.search_field.observe("blur", (function(_this) {
  779 + return function(evt) {
  780 + return _this.input_blur(evt);
  781 + };
  782 + })(this));
  783 + this.search_field.observe("keyup", (function(_this) {
  784 + return function(evt) {
  785 + return _this.keyup_checker(evt);
  786 + };
  787 + })(this));
  788 + this.search_field.observe("keydown", (function(_this) {
  789 + return function(evt) {
  790 + return _this.keydown_checker(evt);
  791 + };
  792 + })(this));
  793 + this.search_field.observe("focus", (function(_this) {
  794 + return function(evt) {
  795 + return _this.input_focus(evt);
  796 + };
  797 + })(this));
  798 + this.search_field.observe("cut", (function(_this) {
  799 + return function(evt) {
  800 + return _this.clipboard_event_checker(evt);
  801 + };
  802 + })(this));
  803 + this.search_field.observe("paste", (function(_this) {
  804 + return function(evt) {
  805 + return _this.clipboard_event_checker(evt);
  806 + };
  807 + })(this));
  808 + if (this.is_multiple) {
  809 + return this.search_choices.observe("click", (function(_this) {
  810 + return function(evt) {
  811 + return _this.choices_click(evt);
  812 + };
  813 + })(this));
  814 + } else {
  815 + return this.container.observe("click", (function(_this) {
  816 + return function(evt) {
  817 + return evt.preventDefault();
  818 + };
  819 + })(this));
  820 + }
  821 + };
  822 +
  823 + Chosen.prototype.destroy = function() {
  824 + var event, i, len, ref;
  825 + this.container.ownerDocument.stopObserving("click", this.click_test_action);
  826 + ref = ['chosen:updated', 'chosen:activate', 'chosen:open', 'chosen:close'];
  827 + for (i = 0, len = ref.length; i < len; i++) {
  828 + event = ref[i];
  829 + this.form_field.stopObserving(event);
  830 + }
  831 + this.container.stopObserving();
  832 + this.search_results.stopObserving();
  833 + this.search_field.stopObserving();
  834 + if (this.form_field_label != null) {
  835 + this.form_field_label.stopObserving();
  836 + }
  837 + if (this.is_multiple) {
  838 + this.search_choices.stopObserving();
  839 + this.container.select(".search-choice-close").each(function(choice) {
  840 + return choice.stopObserving();
  841 + });
  842 + } else {
  843 + this.selected_item.stopObserving();
  844 + }
  845 + if (this.search_field.tabIndex) {
  846 + this.form_field.tabIndex = this.search_field.tabIndex;
  847 + }
  848 + this.container.remove();
  849 + return this.form_field.show();
  850 + };
  851 +
  852 + Chosen.prototype.search_field_disabled = function() {
  853 + var ref;
  854 + this.is_disabled = this.form_field.disabled || ((ref = this.form_field.up('fieldset')) != null ? ref.disabled : void 0) || false;
  855 + if (this.is_disabled) {
  856 + this.container.addClassName('chosen-disabled');
  857 + } else {
  858 + this.container.removeClassName('chosen-disabled');
  859 + }
  860 + this.search_field.disabled = this.is_disabled;
  861 + if (!this.is_multiple) {
  862 + this.selected_item.stopObserving('focus', this.activate_field);
  863 + }
  864 + if (this.is_disabled) {
  865 + return this.close_field();
  866 + } else if (!this.is_multiple) {
  867 + return this.selected_item.observe('focus', this.activate_field);
  868 + }
  869 + };
  870 +
  871 + Chosen.prototype.container_mousedown = function(evt) {
  872 + var ref;
  873 + if (this.is_disabled) {
  874 + return;
  875 + }
  876 + if (evt && ((ref = evt.type) === 'mousedown' || ref === 'touchstart') && !this.results_showing) {
  877 + evt.preventDefault();
  878 + }
  879 + if (!((evt != null) && evt.target.hasClassName("search-choice-close"))) {
  880 + if (!this.active_field) {
  881 + if (this.is_multiple) {
  882 + this.search_field.clear();
  883 + }
  884 + this.container.ownerDocument.observe("click", this.click_test_action);
  885 + this.results_show();
  886 + } else if (!this.is_multiple && evt && (evt.target === this.selected_item || evt.target.up("a.chosen-single"))) {
  887 + this.results_toggle();
  888 + }
  889 + return this.activate_field();
  890 + }
  891 + };
  892 +
  893 + Chosen.prototype.container_mouseup = function(evt) {
  894 + if (evt.target.nodeName === "ABBR" && !this.is_disabled) {
  895 + return this.results_reset(evt);
  896 + }
  897 + };
  898 +
  899 + Chosen.prototype.search_results_mousewheel = function(evt) {
  900 + var delta;
  901 + delta = evt.deltaY || -evt.wheelDelta || evt.detail;
  902 + if (delta != null) {
  903 + evt.preventDefault();
  904 + if (evt.type === 'DOMMouseScroll') {
  905 + delta = delta * 40;
  906 + }
  907 + return this.search_results.scrollTop = delta + this.search_results.scrollTop;
  908 + }
  909 + };
  910 +
  911 + Chosen.prototype.blur_test = function(evt) {
  912 + if (!this.active_field && this.container.hasClassName("chosen-container-active")) {
  913 + return this.close_field();
  914 + }
  915 + };
  916 +
  917 + Chosen.prototype.close_field = function() {
  918 + this.container.ownerDocument.stopObserving("click", this.click_test_action);
  919 + this.active_field = false;
  920 + this.results_hide();
  921 + this.container.removeClassName("chosen-container-active");
  922 + this.clear_backstroke();
  923 + this.show_search_field_default();
  924 + this.search_field_scale();
  925 + return this.search_field.blur();
  926 + };
  927 +
  928 + Chosen.prototype.activate_field = function() {
  929 + if (this.is_disabled) {
  930 + return;
  931 + }
  932 + this.container.addClassName("chosen-container-active");
  933 + this.active_field = true;
  934 + this.search_field.value = this.get_search_field_value();
  935 + return this.search_field.focus();
  936 + };
  937 +
  938 + Chosen.prototype.test_active_click = function(evt) {
  939 + if (evt.target.up('.chosen-container') === this.container) {
  940 + return this.active_field = true;
  941 + } else {
  942 + return this.close_field();
  943 + }
  944 + };
  945 +
  946 + Chosen.prototype.results_build = function() {
  947 + this.parsing = true;
  948 + this.selected_option_count = null;
  949 + this.results_data = SelectParser.select_to_array(this.form_field);
  950 + if (this.is_multiple) {
  951 + this.search_choices.select("li.search-choice").invoke("remove");
  952 + } else {
  953 + this.single_set_selected_text();
  954 + if (this.disable_search || this.form_field.options.length <= this.disable_search_threshold) {
  955 + this.search_field.readOnly = true;
  956 + this.container.addClassName("chosen-container-single-nosearch");
  957 + } else {
  958 + this.search_field.readOnly = false;
  959 + this.container.removeClassName("chosen-container-single-nosearch");
  960 + }
  961 + }
  962 + this.update_results_content(this.results_option_build({
  963 + first: true
  964 + }));
  965 + this.search_field_disabled();
  966 + this.show_search_field_default();
  967 + this.search_field_scale();
  968 + return this.parsing = false;
  969 + };
  970 +
  971 + Chosen.prototype.result_do_highlight = function(el) {
  972 + var high_bottom, high_top, maxHeight, visible_bottom, visible_top;
  973 + this.result_clear_highlight();
  974 + this.result_highlight = el;
  975 + this.result_highlight.addClassName("highlighted");
  976 + maxHeight = parseInt(this.search_results.getStyle('maxHeight'), 10);
  977 + visible_top = this.search_results.scrollTop;
  978 + visible_bottom = maxHeight + visible_top;
  979 + high_top = this.result_highlight.positionedOffset().top;
  980 + high_bottom = high_top + this.result_highlight.getHeight();
  981 + if (high_bottom >= visible_bottom) {
  982 + return this.search_results.scrollTop = (high_bottom - maxHeight) > 0 ? high_bottom - maxHeight : 0;
  983 + } else if (high_top < visible_top) {
  984 + return this.search_results.scrollTop = high_top;
  985 + }
  986 + };
  987 +
  988 + Chosen.prototype.result_clear_highlight = function() {
  989 + if (this.result_highlight) {
  990 + this.result_highlight.removeClassName('highlighted');
  991 + }
  992 + return this.result_highlight = null;
  993 + };
  994 +
  995 + Chosen.prototype.results_show = function() {
  996 + if (this.is_multiple && this.max_selected_options <= this.choices_count()) {
  997 + this.form_field.fire("chosen:maxselected", {
  998 + chosen: this
  999 + });
  1000 + return false;
  1001 + }
  1002 + this.container.addClassName("chosen-with-drop");
  1003 + this.results_showing = true;
  1004 + this.search_field.focus();
  1005 + this.search_field.value = this.get_search_field_value();
  1006 + this.winnow_results();
  1007 + return this.form_field.fire("chosen:showing_dropdown", {
  1008 + chosen: this
  1009 + });
  1010 + };
  1011 +
  1012 + Chosen.prototype.update_results_content = function(content) {
  1013 + return this.search_results.update(content);
  1014 + };
  1015 +
  1016 + Chosen.prototype.results_hide = function() {
  1017 + if (this.results_showing) {
  1018 + this.result_clear_highlight();
  1019 + this.container.removeClassName("chosen-with-drop");
  1020 + this.form_field.fire("chosen:hiding_dropdown", {
  1021 + chosen: this
  1022 + });
  1023 + }
  1024 + return this.results_showing = false;
  1025 + };
  1026 +
  1027 + Chosen.prototype.set_tab_index = function(el) {
  1028 + var ti;
  1029 + if (this.form_field.tabIndex) {
  1030 + ti = this.form_field.tabIndex;
  1031 + this.form_field.tabIndex = -1;
  1032 + return this.search_field.tabIndex = ti;
  1033 + }
  1034 + };
  1035 +
  1036 + Chosen.prototype.set_label_behavior = function() {
  1037 + this.form_field_label = this.form_field.up("label");
  1038 + if (this.form_field_label == null) {
  1039 + this.form_field_label = $$("label[for='" + this.form_field.id + "']").first();
  1040 + }
  1041 + if (this.form_field_label != null) {
  1042 + return this.form_field_label.observe("click", this.label_click_handler);
  1043 + }
  1044 + };
  1045 +
  1046 + Chosen.prototype.show_search_field_default = function() {
  1047 + if (this.is_multiple && this.choices_count() < 1 && !this.active_field) {
  1048 + this.search_field.value = this.default_text;
  1049 + return this.search_field.addClassName("default");
  1050 + } else {
  1051 + this.search_field.value = "";
  1052 + return this.search_field.removeClassName("default");
  1053 + }
  1054 + };
  1055 +
  1056 + Chosen.prototype.search_results_mouseup = function(evt) {
  1057 + var target;
  1058 + target = evt.target.hasClassName("active-result") ? evt.target : evt.target.up(".active-result");
  1059 + if (target) {
  1060 + this.result_highlight = target;
  1061 + this.result_select(evt);
  1062 + return this.search_field.focus();
  1063 + }
  1064 + };
  1065 +
  1066 + Chosen.prototype.search_results_mouseover = function(evt) {
  1067 + var target;
  1068 + target = evt.target.hasClassName("active-result") ? evt.target : evt.target.up(".active-result");
  1069 + if (target) {
  1070 + return this.result_do_highlight(target);
  1071 + }
  1072 + };
  1073 +
  1074 + Chosen.prototype.search_results_mouseout = function(evt) {
  1075 + if (evt.target.hasClassName('active-result') || evt.target.up('.active-result')) {
  1076 + return this.result_clear_highlight();
  1077 + }
  1078 + };
  1079 +
  1080 + Chosen.prototype.choice_build = function(item) {
  1081 + var choice, close_link;
  1082 + choice = new Element('li', {
  1083 + "class": "search-choice"
  1084 + }).update("<span>" + (this.choice_label(item)) + "</span>");
  1085 + if (item.disabled) {
  1086 + choice.addClassName('search-choice-disabled');
  1087 + } else {
  1088 + close_link = new Element('a', {
  1089 + href: '#',
  1090 + "class": 'search-choice-close',
  1091 + rel: item.array_index
  1092 + });
  1093 + close_link.observe("click", (function(_this) {
  1094 + return function(evt) {
  1095 + return _this.choice_destroy_link_click(evt);
  1096 + };
  1097 + })(this));
  1098 + choice.insert(close_link);
  1099 + }
  1100 + return this.search_container.insert({
  1101 + before: choice
  1102 + });
  1103 + };
  1104 +
  1105 + Chosen.prototype.choice_destroy_link_click = function(evt) {
  1106 + evt.preventDefault();
  1107 + evt.stopPropagation();
  1108 + if (!this.is_disabled) {
  1109 + return this.choice_destroy(evt.target);
  1110 + }
  1111 + };
  1112 +
  1113 + Chosen.prototype.choice_destroy = function(link) {
  1114 + if (this.result_deselect(link.readAttribute("rel"))) {
  1115 + if (this.active_field) {
  1116 + this.search_field.focus();
  1117 + } else {
  1118 + this.show_search_field_default();
  1119 + }
  1120 + if (this.is_multiple && this.choices_count() > 0 && this.get_search_field_value().length < 1) {
  1121 + this.results_hide();
  1122 + }
  1123 + link.up('li').remove();
  1124 + return this.search_field_scale();
  1125 + }
  1126 + };
  1127 +
  1128 + Chosen.prototype.results_reset = function() {
  1129 + this.reset_single_select_options();
  1130 + this.form_field.options[0].selected = true;
  1131 + this.single_set_selected_text();
  1132 + this.show_search_field_default();
  1133 + this.results_reset_cleanup();
  1134 + this.trigger_form_field_change();
  1135 + if (this.active_field) {
  1136 + return this.results_hide();
  1137 + }
  1138 + };
  1139 +
  1140 + Chosen.prototype.results_reset_cleanup = function() {
  1141 + var deselect_trigger;
  1142 + this.current_selectedIndex = this.form_field.selectedIndex;
  1143 + deselect_trigger = this.selected_item.down("abbr");
  1144 + if (deselect_trigger) {
  1145 + return deselect_trigger.remove();
  1146 + }
  1147 + };
  1148 +
  1149 + Chosen.prototype.result_select = function(evt) {
  1150 + var high, item;
  1151 + if (this.result_highlight) {
  1152 + high = this.result_highlight;
  1153 + this.result_clear_highlight();
  1154 + if (this.is_multiple && this.max_selected_options <= this.choices_count()) {
  1155 + this.form_field.fire("chosen:maxselected", {
  1156 + chosen: this
  1157 + });
  1158 + return false;
  1159 + }
  1160 + if (this.is_multiple) {
  1161 + high.removeClassName("active-result");
  1162 + } else {
  1163 + this.reset_single_select_options();
  1164 + }
  1165 + high.addClassName("result-selected");
  1166 + item = this.results_data[high.getAttribute("data-option-array-index")];
  1167 + item.selected = true;
  1168 + this.form_field.options[item.options_index].selected = true;
  1169 + this.selected_option_count = null;
  1170 + if (this.is_multiple) {
  1171 + this.choice_build(item);
  1172 + } else {
  1173 + this.single_set_selected_text(this.choice_label(item));
  1174 + }
  1175 + if (this.is_multiple && (!this.hide_results_on_select || (evt.metaKey || evt.ctrlKey))) {
  1176 + if (evt.metaKey || evt.ctrlKey) {
  1177 + this.winnow_results({
  1178 + skip_highlight: true
  1179 + });
  1180 + } else {
  1181 + this.search_field.value = "";
  1182 + this.winnow_results();
  1183 + }
  1184 + } else {
  1185 + this.results_hide();
  1186 + this.show_search_field_default();
  1187 + }
  1188 + if (this.is_multiple || this.form_field.selectedIndex !== this.current_selectedIndex) {
  1189 + this.trigger_form_field_change();
  1190 + }
  1191 + this.current_selectedIndex = this.form_field.selectedIndex;
  1192 + evt.preventDefault();
  1193 + return this.search_field_scale();
  1194 + }
  1195 + };
  1196 +
  1197 + Chosen.prototype.single_set_selected_text = function(text) {
  1198 + if (text == null) {
  1199 + text = this.default_text;
  1200 + }
  1201 + if (text === this.default_text) {
  1202 + this.selected_item.addClassName("chosen-default");
  1203 + } else {
  1204 + this.single_deselect_control_build();
  1205 + this.selected_item.removeClassName("chosen-default");
  1206 + }
  1207 + return this.selected_item.down("span").update(text);
  1208 + };
  1209 +
  1210 + Chosen.prototype.result_deselect = function(pos) {
  1211 + var result_data;
  1212 + result_data = this.results_data[pos];
  1213 + if (!this.form_field.options[result_data.options_index].disabled) {
  1214 + result_data.selected = false;
  1215 + this.form_field.options[result_data.options_index].selected = false;
  1216 + this.selected_option_count = null;
  1217 + this.result_clear_highlight();
  1218 + if (this.results_showing) {
  1219 + this.winnow_results();
  1220 + }
  1221 + this.trigger_form_field_change();
  1222 + this.search_field_scale();
  1223 + return true;
  1224 + } else {
  1225 + return false;
  1226 + }
  1227 + };
  1228 +
  1229 + Chosen.prototype.single_deselect_control_build = function() {
  1230 + if (!this.allow_single_deselect) {
  1231 + return;
  1232 + }
  1233 + if (!this.selected_item.down("abbr")) {
  1234 + this.selected_item.down("span").insert({
  1235 + after: "<abbr class=\"search-choice-close\"></abbr>"
  1236 + });
  1237 + }
  1238 + return this.selected_item.addClassName("chosen-single-with-deselect");
  1239 + };
  1240 +
  1241 + Chosen.prototype.get_search_field_value = function() {
  1242 + return this.search_field.value;
  1243 + };
  1244 +
  1245 + Chosen.prototype.get_search_text = function() {
  1246 + return this.get_search_field_value().strip();
  1247 + };
  1248 +
  1249 + Chosen.prototype.escape_html = function(text) {
  1250 + return text.escapeHTML();
  1251 + };
  1252 +
  1253 + Chosen.prototype.winnow_results_set_highlight = function() {
  1254 + var do_high;
  1255 + if (!this.is_multiple) {
  1256 + do_high = this.search_results.down(".result-selected.active-result");
  1257 + }
  1258 + if (do_high == null) {
  1259 + do_high = this.search_results.down(".active-result");
  1260 + }
  1261 + if (do_high != null) {
  1262 + return this.result_do_highlight(do_high);
  1263 + }
  1264 + };
  1265 +
  1266 + Chosen.prototype.no_results = function(terms) {
  1267 + this.search_results.insert(this.get_no_results_html(terms));
  1268 + return this.form_field.fire("chosen:no_results", {
  1269 + chosen: this
  1270 + });
  1271 + };
  1272 +
  1273 + Chosen.prototype.no_results_clear = function() {
  1274 + var nr, results1;
  1275 + nr = null;
  1276 + results1 = [];
  1277 + while (nr = this.search_results.down(".no-results")) {
  1278 + results1.push(nr.remove());
  1279 + }
  1280 + return results1;
  1281 + };
  1282 +
  1283 + Chosen.prototype.keydown_arrow = function() {
  1284 + var next_sib;
  1285 + if (this.results_showing && this.result_highlight) {
  1286 + next_sib = this.result_highlight.next('.active-result');
  1287 + if (next_sib) {
  1288 + return this.result_do_highlight(next_sib);
  1289 + }
  1290 + } else {
  1291 + return this.results_show();
  1292 + }
  1293 + };
  1294 +
  1295 + Chosen.prototype.keyup_arrow = function() {
  1296 + var actives, prevs, sibs;
  1297 + if (!this.results_showing && !this.is_multiple) {
  1298 + return this.results_show();
  1299 + } else if (this.result_highlight) {
  1300 + sibs = this.result_highlight.previousSiblings();
  1301 + actives = this.search_results.select("li.active-result");
  1302 + prevs = sibs.intersect(actives);
  1303 + if (prevs.length) {
  1304 + return this.result_do_highlight(prevs.first());
  1305 + } else {
  1306 + if (this.choices_count() > 0) {
  1307 + this.results_hide();
  1308 + }
  1309 + return this.result_clear_highlight();
  1310 + }
  1311 + }
  1312 + };
  1313 +
  1314 + Chosen.prototype.keydown_backstroke = function() {
  1315 + var next_available_destroy;
  1316 + if (this.pending_backstroke) {
  1317 + this.choice_destroy(this.pending_backstroke.down("a"));
  1318 + return this.clear_backstroke();
  1319 + } else {
  1320 + next_available_destroy = this.search_container.siblings().last();
  1321 + if (next_available_destroy && next_available_destroy.hasClassName("search-choice") && !next_available_destroy.hasClassName("search-choice-disabled")) {
  1322 + this.pending_backstroke = next_available_destroy;
  1323 + if (this.pending_backstroke) {
  1324 + this.pending_backstroke.addClassName("search-choice-focus");
  1325 + }
  1326 + if (this.single_backstroke_delete) {
  1327 + return this.keydown_backstroke();
  1328 + } else {
  1329 + return this.pending_backstroke.addClassName("search-choice-focus");
  1330 + }
  1331 + }
  1332 + }
  1333 + };
  1334 +
  1335 + Chosen.prototype.clear_backstroke = function() {
  1336 + if (this.pending_backstroke) {
  1337 + this.pending_backstroke.removeClassName("search-choice-focus");
  1338 + }
  1339 + return this.pending_backstroke = null;
  1340 + };
  1341 +
  1342 + Chosen.prototype.search_field_scale = function() {
  1343 + var container_width, div, i, len, style, style_block, styles, width;
  1344 + if (!this.is_multiple) {
  1345 + return;
  1346 + }
  1347 + style_block = {
  1348 + position: 'absolute',
  1349 + left: '-1000px',
  1350 + top: '-1000px',
  1351 + display: 'none',
  1352 + whiteSpace: 'pre'
  1353 + };
  1354 + styles = ['fontSize', 'fontStyle', 'fontWeight', 'fontFamily', 'lineHeight', 'textTransform', 'letterSpacing'];
  1355 + for (i = 0, len = styles.length; i < len; i++) {
  1356 + style = styles[i];
  1357 + style_block[style] = this.search_field.getStyle(style);
  1358 + }
  1359 + div = new Element('div').update(this.escape_html(this.get_search_field_value()));
  1360 + div.setStyle(style_block);
  1361 + document.body.appendChild(div);
  1362 + width = div.measure('width') + 25;
  1363 + div.remove();
  1364 + if (container_width = this.container.getWidth()) {
  1365 + width = Math.min(container_width - 10, width);
  1366 + }
  1367 + return this.search_field.setStyle({
  1368 + width: width + 'px'
  1369 + });
  1370 + };
  1371 +
  1372 + Chosen.prototype.trigger_form_field_change = function() {
  1373 + triggerHtmlEvent(this.form_field, 'input');
  1374 + return triggerHtmlEvent(this.form_field, 'change');
  1375 + };
  1376 +
  1377 + triggerHtmlEvent = function(element, eventType) {
  1378 + var error, evt;
  1379 + if (element.dispatchEvent) {
  1380 + try {
  1381 + evt = new Event(eventType, {
  1382 + bubbles: true,
  1383 + cancelable: true
  1384 + });
  1385 + } catch (error) {
  1386 + evt = document.createEvent('HTMLEvents');
  1387 + evt.initEvent(eventType, true, true);
  1388 + }
  1389 + return element.dispatchEvent(evt);
  1390 + } else {
  1391 + return element.fireEvent("on" + eventType, document.createEventObject());
  1392 + }
  1393 + };
  1394 +
  1395 + return Chosen;
  1396 +
  1397 + })(AbstractChosen);
  1398 +
  1399 +}).call(this);
public/js/chosen/chosen.proto.min.js
... ... @@ -0,0 +1,3 @@
  1 +/* Chosen v1.8.7 | (c) 2011-2018 by Harvest | MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md */
  2 +
  3 +(function(){var e,t,s=function(e,t){return function(){return e.apply(t,arguments)}},i=function(e,t){function s(){this.constructor=e}for(var i in t)r.call(t,i)&&(e[i]=t[i]);return s.prototype=t.prototype,e.prototype=new s,e.__super__=t.prototype,e},r={}.hasOwnProperty;(t=function(){function e(){this.options_index=0,this.parsed=[]}return e.prototype.add_node=function(e){return"OPTGROUP"===e.nodeName.toUpperCase()?this.add_group(e):this.add_option(e)},e.prototype.add_group=function(e){var t,s,i,r,n,o;for(t=this.parsed.length,this.parsed.push({array_index:t,group:!0,label:e.label,title:e.title?e.title:void 0,children:0,disabled:e.disabled,classes:e.className}),o=[],s=0,i=(n=e.childNodes).length;s<i;s++)r=n[s],o.push(this.add_option(r,t,e.disabled));return o},e.prototype.add_option=function(e,t,s){if("OPTION"===e.nodeName.toUpperCase())return""!==e.text?(null!=t&&(this.parsed[t].children+=1),this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,value:e.value,text:e.text,html:e.innerHTML,title:e.title?e.title:void 0,selected:e.selected,disabled:!0===s?s:e.disabled,group_array_index:t,group_label:null!=t?this.parsed[t].label:null,classes:e.className,style:e.style.cssText})):this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,empty:!0}),this.options_index+=1},e}()).select_to_array=function(e){var s,i,r,n,o;for(n=new t,i=0,r=(o=e.childNodes).length;i<r;i++)s=o[i],n.add_node(s);return n.parsed},e=function(){function e(t,i){this.form_field=t,this.options=null!=i?i:{},this.label_click_handler=s(this.label_click_handler,this),e.browser_is_supported()&&(this.is_multiple=this.form_field.multiple,this.set_default_text(),this.set_default_values(),this.setup(),this.set_up_html(),this.register_observers(),this.on_ready())}return e.prototype.set_default_values=function(){return this.click_test_action=function(e){return function(t){return e.test_active_click(t)}}(this),this.activate_action=function(e){return function(t){return e.activate_field(t)}}(this),this.active_field=!1,this.mouse_on_container=!1,this.results_showing=!1,this.result_highlighted=null,this.is_rtl=this.options.rtl||/\bchosen-rtl\b/.test(this.form_field.className),this.allow_single_deselect=null!=this.options.allow_single_deselect&&null!=this.form_field.options[0]&&""===this.form_field.options[0].text&&this.options.allow_single_deselect,this.disable_search_threshold=this.options.disable_search_threshold||0,this.disable_search=this.options.disable_search||!1,this.enable_split_word_search=null==this.options.enable_split_word_search||this.options.enable_split_word_search,this.group_search=null==this.options.group_search||this.options.group_search,this.search_contains=this.options.search_contains||!1,this.single_backstroke_delete=null==this.options.single_backstroke_delete||this.options.single_backstroke_delete,this.max_selected_options=this.options.max_selected_options||1/0,this.inherit_select_classes=this.options.inherit_select_classes||!1,this.display_selected_options=null==this.options.display_selected_options||this.options.display_selected_options,this.display_disabled_options=null==this.options.display_disabled_options||this.options.display_disabled_options,this.include_group_label_in_selected=this.options.include_group_label_in_selected||!1,this.max_shown_results=this.options.max_shown_results||Number.POSITIVE_INFINITY,this.case_sensitive_search=this.options.case_sensitive_search||!1,this.hide_results_on_select=null==this.options.hide_results_on_select||this.options.hide_results_on_select},e.prototype.set_default_text=function(){return this.form_field.getAttribute("data-placeholder")?this.default_text=this.form_field.getAttribute("data-placeholder"):this.is_multiple?this.default_text=this.options.placeholder_text_multiple||this.options.placeholder_text||e.default_multiple_text:this.default_text=this.options.placeholder_text_single||this.options.placeholder_text||e.default_single_text,this.default_text=this.escape_html(this.default_text),this.results_none_found=this.form_field.getAttribute("data-no_results_text")||this.options.no_results_text||e.default_no_result_text},e.prototype.choice_label=function(e){return this.include_group_label_in_selected&&null!=e.group_label?"<b class='group-name'>"+this.escape_html(e.group_label)+"</b>"+e.html:e.html},e.prototype.mouse_enter=function(){return this.mouse_on_container=!0},e.prototype.mouse_leave=function(){return this.mouse_on_container=!1},e.prototype.input_focus=function(e){if(this.is_multiple){if(!this.active_field)return setTimeout(function(e){return function(){return e.container_mousedown()}}(this),50)}else if(!this.active_field)return this.activate_field()},e.prototype.input_blur=function(e){if(!this.mouse_on_container)return this.active_field=!1,setTimeout(function(e){return function(){return e.blur_test()}}(this),100)},e.prototype.label_click_handler=function(e){return this.is_multiple?this.container_mousedown(e):this.activate_field()},e.prototype.results_option_build=function(e){var t,s,i,r,n,o,l;for(t="",l=0,r=0,n=(o=this.results_data).length;r<n&&(s=o[r],i="",""!==(i=s.group?this.result_add_group(s):this.result_add_option(s))&&(l++,t+=i),(null!=e?e.first:void 0)&&(s.selected&&this.is_multiple?this.choice_build(s):s.selected&&!this.is_multiple&&this.single_set_selected_text(this.choice_label(s))),!(l>=this.max_shown_results));r++);return t},e.prototype.result_add_option=function(e){var t,s;return e.search_match&&this.include_option_in_results(e)?(t=[],e.disabled||e.selected&&this.is_multiple||t.push("active-result"),!e.disabled||e.selected&&this.is_multiple||t.push("disabled-result"),e.selected&&t.push("result-selected"),null!=e.group_array_index&&t.push("group-option"),""!==e.classes&&t.push(e.classes),s=document.createElement("li"),s.className=t.join(" "),e.style&&(s.style.cssText=e.style),s.setAttribute("data-option-array-index",e.array_index),s.innerHTML=e.highlighted_html||e.html,e.title&&(s.title=e.title),this.outerHTML(s)):""},e.prototype.result_add_group=function(e){var t,s;return(e.search_match||e.group_match)&&e.active_options>0?((t=[]).push("group-result"),e.classes&&t.push(e.classes),s=document.createElement("li"),s.className=t.join(" "),s.innerHTML=e.highlighted_html||this.escape_html(e.label),e.title&&(s.title=e.title),this.outerHTML(s)):""},e.prototype.results_update_field=function(){if(this.set_default_text(),this.is_multiple||this.results_reset_cleanup(),this.result_clear_highlight(),this.results_build(),this.results_showing)return this.winnow_results()},e.prototype.reset_single_select_options=function(){var e,t,s,i,r;for(r=[],e=0,t=(s=this.results_data).length;e<t;e++)(i=s[e]).selected?r.push(i.selected=!1):r.push(void 0);return r},e.prototype.results_toggle=function(){return this.results_showing?this.results_hide():this.results_show()},e.prototype.results_search=function(e){return this.results_showing?this.winnow_results():this.results_show()},e.prototype.winnow_results=function(e){var t,s,i,r,n,o,l,h,c,a,_,u,d,p,f;for(this.no_results_clear(),a=0,t=(l=this.get_search_text()).replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),c=this.get_search_regex(t),i=0,r=(h=this.results_data).length;i<r;i++)(n=h[i]).search_match=!1,_=null,u=null,n.highlighted_html="",this.include_option_in_results(n)&&(n.group&&(n.group_match=!1,n.active_options=0),null!=n.group_array_index&&this.results_data[n.group_array_index]&&(0===(_=this.results_data[n.group_array_index]).active_options&&_.search_match&&(a+=1),_.active_options+=1),f=n.group?n.label:n.text,n.group&&!this.group_search||(u=this.search_string_match(f,c),n.search_match=null!=u,n.search_match&&!n.group&&(a+=1),n.search_match?(l.length&&(d=u.index,o=f.slice(0,d),s=f.slice(d,d+l.length),p=f.slice(d+l.length),n.highlighted_html=this.escape_html(o)+"<em>"+this.escape_html(s)+"</em>"+this.escape_html(p)),null!=_&&(_.group_match=!0)):null!=n.group_array_index&&this.results_data[n.group_array_index].search_match&&(n.search_match=!0)));return this.result_clear_highlight(),a<1&&l.length?(this.update_results_content(""),this.no_results(l)):(this.update_results_content(this.results_option_build()),(null!=e?e.skip_highlight:void 0)?void 0:this.winnow_results_set_highlight())},e.prototype.get_search_regex=function(e){var t,s;return s=this.search_contains?e:"(^|\\s|\\b)"+e+"[^\\s]*",this.enable_split_word_search||this.search_contains||(s="^"+s),t=this.case_sensitive_search?"":"i",new RegExp(s,t)},e.prototype.search_string_match=function(e,t){var s;return s=t.exec(e),!this.search_contains&&(null!=s?s[1]:void 0)&&(s.index+=1),s},e.prototype.choices_count=function(){var e,t,s;if(null!=this.selected_option_count)return this.selected_option_count;for(this.selected_option_count=0,e=0,t=(s=this.form_field.options).length;e<t;e++)s[e].selected&&(this.selected_option_count+=1);return this.selected_option_count},e.prototype.choices_click=function(e){if(e.preventDefault(),this.activate_field(),!this.results_showing&&!this.is_disabled)return this.results_show()},e.prototype.keydown_checker=function(e){var t,s;switch(s=null!=(t=e.which)?t:e.keyCode,this.search_field_scale(),8!==s&&this.pending_backstroke&&this.clear_backstroke(),s){case 8:this.backstroke_length=this.get_search_field_value().length;break;case 9:this.results_showing&&!this.is_multiple&&this.result_select(e),this.mouse_on_container=!1;break;case 13:case 27:this.results_showing&&e.preventDefault();break;case 32:this.disable_search&&e.preventDefault();break;case 38:e.preventDefault(),this.keyup_arrow();break;case 40:e.preventDefault(),this.keydown_arrow()}},e.prototype.keyup_checker=function(e){var t,s;switch(s=null!=(t=e.which)?t:e.keyCode,this.search_field_scale(),s){case 8:this.is_multiple&&this.backstroke_length<1&&this.choices_count()>0?this.keydown_backstroke():this.pending_backstroke||(this.result_clear_highlight(),this.results_search());break;case 13:e.preventDefault(),this.results_showing&&this.result_select(e);break;case 27:this.results_showing&&this.results_hide();break;case 9:case 16:case 17:case 18:case 38:case 40:case 91:break;default:this.results_search()}},e.prototype.clipboard_event_checker=function(e){if(!this.is_disabled)return setTimeout(function(e){return function(){return e.results_search()}}(this),50)},e.prototype.container_width=function(){return null!=this.options.width?this.options.width:this.form_field.offsetWidth+"px"},e.prototype.include_option_in_results=function(e){return!(this.is_multiple&&!this.display_selected_options&&e.selected)&&(!(!this.display_disabled_options&&e.disabled)&&!e.empty)},e.prototype.search_results_touchstart=function(e){return this.touch_started=!0,this.search_results_mouseover(e)},e.prototype.search_results_touchmove=function(e){return this.touch_started=!1,this.search_results_mouseout(e)},e.prototype.search_results_touchend=function(e){if(this.touch_started)return this.search_results_mouseup(e)},e.prototype.outerHTML=function(e){var t;return e.outerHTML?e.outerHTML:((t=document.createElement("div")).appendChild(e),t.innerHTML)},e.prototype.get_single_html=function(){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>'},e.prototype.get_multi_html=function(){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>'},e.prototype.get_no_results_html=function(e){return'<li class="no-results">\n '+this.results_none_found+" <span>"+this.escape_html(e)+"</span>\n</li>"},e.browser_is_supported=function(){return"Microsoft Internet Explorer"===window.navigator.appName?document.documentMode>=8:!(/iP(od|hone)/i.test(window.navigator.userAgent)||/IEMobile/i.test(window.navigator.userAgent)||/Windows Phone/i.test(window.navigator.userAgent)||/BlackBerry/i.test(window.navigator.userAgent)||/BB10/i.test(window.navigator.userAgent)||/Android.*Mobile/i.test(window.navigator.userAgent))},e.default_multiple_text="Select Some Options",e.default_single_text="Select an Option",e.default_no_result_text="No results match",e}(),this.Chosen=function(s){function r(){return r.__super__.constructor.apply(this,arguments)}var n;return i(r,e),r.prototype.setup=function(){return this.current_selectedIndex=this.form_field.selectedIndex},r.prototype.set_up_html=function(){var e,t;return(e=["chosen-container"]).push("chosen-container-"+(this.is_multiple?"multi":"single")),this.inherit_select_classes&&this.form_field.className&&e.push(this.form_field.className),this.is_rtl&&e.push("chosen-rtl"),t={class:e.join(" "),title:this.form_field.title},this.form_field.id.length&&(t.id=this.form_field.id.replace(/[^\w]/g,"_")+"_chosen"),this.container=new Element("div",t),this.container.setStyle({width:this.container_width()}),this.is_multiple?this.container.update(this.get_multi_html()):this.container.update(this.get_single_html()),this.form_field.hide().insert({after:this.container}),this.dropdown=this.container.down("div.chosen-drop"),this.search_field=this.container.down("input"),this.search_results=this.container.down("ul.chosen-results"),this.search_field_scale(),this.search_no_results=this.container.down("li.no-results"),this.is_multiple?(this.search_choices=this.container.down("ul.chosen-choices"),this.search_container=this.container.down("li.search-field")):(this.search_container=this.container.down("div.chosen-search"),this.selected_item=this.container.down(".chosen-single")),this.results_build(),this.set_tab_index(),this.set_label_behavior()},r.prototype.on_ready=function(){return this.form_field.fire("chosen:ready",{chosen:this})},r.prototype.register_observers=function(){return this.container.observe("touchstart",function(e){return function(t){return e.container_mousedown(t)}}(this)),this.container.observe("touchend",function(e){return function(t){return e.container_mouseup(t)}}(this)),this.container.observe("mousedown",function(e){return function(t){return e.container_mousedown(t)}}(this)),this.container.observe("mouseup",function(e){return function(t){return e.container_mouseup(t)}}(this)),this.container.observe("mouseenter",function(e){return function(t){return e.mouse_enter(t)}}(this)),this.container.observe("mouseleave",function(e){return function(t){return e.mouse_leave(t)}}(this)),this.search_results.observe("mouseup",function(e){return function(t){return e.search_results_mouseup(t)}}(this)),this.search_results.observe("mouseover",function(e){return function(t){return e.search_results_mouseover(t)}}(this)),this.search_results.observe("mouseout",function(e){return function(t){return e.search_results_mouseout(t)}}(this)),this.search_results.observe("mousewheel",function(e){return function(t){return e.search_results_mousewheel(t)}}(this)),this.search_results.observe("DOMMouseScroll",function(e){return function(t){return e.search_results_mousewheel(t)}}(this)),this.search_results.observe("touchstart",function(e){return function(t){return e.search_results_touchstart(t)}}(this)),this.search_results.observe("touchmove",function(e){return function(t){return e.search_results_touchmove(t)}}(this)),this.search_results.observe("touchend",function(e){return function(t){return e.search_results_touchend(t)}}(this)),this.form_field.observe("chosen:updated",function(e){return function(t){return e.results_update_field(t)}}(this)),this.form_field.observe("chosen:activate",function(e){return function(t){return e.activate_field(t)}}(this)),this.form_field.observe("chosen:open",function(e){return function(t){return e.container_mousedown(t)}}(this)),this.form_field.observe("chosen:close",function(e){return function(t){return e.close_field(t)}}(this)),this.search_field.observe("blur",function(e){return function(t){return e.input_blur(t)}}(this)),this.search_field.observe("keyup",function(e){return function(t){return e.keyup_checker(t)}}(this)),this.search_field.observe("keydown",function(e){return function(t){return e.keydown_checker(t)}}(this)),this.search_field.observe("focus",function(e){return function(t){return e.input_focus(t)}}(this)),this.search_field.observe("cut",function(e){return function(t){return e.clipboard_event_checker(t)}}(this)),this.search_field.observe("paste",function(e){return function(t){return e.clipboard_event_checker(t)}}(this)),this.is_multiple?this.search_choices.observe("click",function(e){return function(t){return e.choices_click(t)}}(this)):this.container.observe("click",function(e){return e.preventDefault()})},r.prototype.destroy=function(){var e,t,s,i;for(this.container.ownerDocument.stopObserving("click",this.click_test_action),t=0,s=(i=["chosen:updated","chosen:activate","chosen:open","chosen:close"]).length;t<s;t++)e=i[t],this.form_field.stopObserving(e);return this.container.stopObserving(),this.search_results.stopObserving(),this.search_field.stopObserving(),null!=this.form_field_label&&this.form_field_label.stopObserving(),this.is_multiple?(this.search_choices.stopObserving(),this.container.select(".search-choice-close").each(function(e){return e.stopObserving()})):this.selected_item.stopObserving(),this.search_field.tabIndex&&(this.form_field.tabIndex=this.search_field.tabIndex),this.container.remove(),this.form_field.show()},r.prototype.search_field_disabled=function(){var e;return this.is_disabled=this.form_field.disabled||(null!=(e=this.form_field.up("fieldset"))?e.disabled:void 0)||!1,this.is_disabled?this.container.addClassName("chosen-disabled"):this.container.removeClassName("chosen-disabled"),this.search_field.disabled=this.is_disabled,this.is_multiple||this.selected_item.stopObserving("focus",this.activate_field),this.is_disabled?this.close_field():this.is_multiple?void 0:this.selected_item.observe("focus",this.activate_field)},r.prototype.container_mousedown=function(e){var t;if(!this.is_disabled)return!e||"mousedown"!==(t=e.type)&&"touchstart"!==t||this.results_showing||e.preventDefault(),null!=e&&e.target.hasClassName("search-choice-close")?void 0:(this.active_field?this.is_multiple||!e||e.target!==this.selected_item&&!e.target.up("a.chosen-single")||this.results_toggle():(this.is_multiple&&this.search_field.clear(),this.container.ownerDocument.observe("click",this.click_test_action),this.results_show()),this.activate_field())},r.prototype.container_mouseup=function(e){if("ABBR"===e.target.nodeName&&!this.is_disabled)return this.results_reset(e)},r.prototype.search_results_mousewheel=function(e){var t;if(null!=(t=e.deltaY||-e.wheelDelta||e.detail))return e.preventDefault(),"DOMMouseScroll"===e.type&&(t*=40),this.search_results.scrollTop=t+this.search_results.scrollTop},r.prototype.blur_test=function(e){if(!this.active_field&&this.container.hasClassName("chosen-container-active"))return this.close_field()},r.prototype.close_field=function(){return this.container.ownerDocument.stopObserving("click",this.click_test_action),this.active_field=!1,this.results_hide(),this.container.removeClassName("chosen-container-active"),this.clear_backstroke(),this.show_search_field_default(),this.search_field_scale(),this.search_field.blur()},r.prototype.activate_field=function(){if(!this.is_disabled)return this.container.addClassName("chosen-container-active"),this.active_field=!0,this.search_field.value=this.get_search_field_value(),this.search_field.focus()},r.prototype.test_active_click=function(e){return e.target.up(".chosen-container")===this.container?this.active_field=!0:this.close_field()},r.prototype.results_build=function(){return this.parsing=!0,this.selected_option_count=null,this.results_data=t.select_to_array(this.form_field),this.is_multiple?this.search_choices.select("li.search-choice").invoke("remove"):(this.single_set_selected_text(),this.disable_search||this.form_field.options.length<=this.disable_search_threshold?(this.search_field.readOnly=!0,this.container.addClassName("chosen-container-single-nosearch")):(this.search_field.readOnly=!1,this.container.removeClassName("chosen-container-single-nosearch"))),this.update_results_content(this.results_option_build({first:!0})),this.search_field_disabled(),this.show_search_field_default(),this.search_field_scale(),this.parsing=!1},r.prototype.result_do_highlight=function(e){var t,s,i,r,n;return this.result_clear_highlight(),this.result_highlight=e,this.result_highlight.addClassName("highlighted"),i=parseInt(this.search_results.getStyle("maxHeight"),10),n=this.search_results.scrollTop,r=i+n,s=this.result_highlight.positionedOffset().top,(t=s+this.result_highlight.getHeight())>=r?this.search_results.scrollTop=t-i>0?t-i:0:s<n?this.search_results.scrollTop=s:void 0},r.prototype.result_clear_highlight=function(){return this.result_highlight&&this.result_highlight.removeClassName("highlighted"),this.result_highlight=null},r.prototype.results_show=function(){return this.is_multiple&&this.max_selected_options<=this.choices_count()?(this.form_field.fire("chosen:maxselected",{chosen:this}),!1):(this.container.addClassName("chosen-with-drop"),this.results_showing=!0,this.search_field.focus(),this.search_field.value=this.get_search_field_value(),this.winnow_results(),this.form_field.fire("chosen:showing_dropdown",{chosen:this}))},r.prototype.update_results_content=function(e){return this.search_results.update(e)},r.prototype.results_hide=function(){return this.results_showing&&(this.result_clear_highlight(),this.container.removeClassName("chosen-with-drop"),this.form_field.fire("chosen:hiding_dropdown",{chosen:this})),this.results_showing=!1},r.prototype.set_tab_index=function(e){var t;if(this.form_field.tabIndex)return t=this.form_field.tabIndex,this.form_field.tabIndex=-1,this.search_field.tabIndex=t},r.prototype.set_label_behavior=function(){if(this.form_field_label=this.form_field.up("label"),null==this.form_field_label&&(this.form_field_label=$$("label[for='"+this.form_field.id+"']").first()),null!=this.form_field_label)return this.form_field_label.observe("click",this.label_click_handler)},r.prototype.show_search_field_default=function(){return this.is_multiple&&this.choices_count()<1&&!this.active_field?(this.search_field.value=this.default_text,this.search_field.addClassName("default")):(this.search_field.value="",this.search_field.removeClassName("default"))},r.prototype.search_results_mouseup=function(e){var t;if(t=e.target.hasClassName("active-result")?e.target:e.target.up(".active-result"))return this.result_highlight=t,this.result_select(e),this.search_field.focus()},r.prototype.search_results_mouseover=function(e){var t;if(t=e.target.hasClassName("active-result")?e.target:e.target.up(".active-result"))return this.result_do_highlight(t)},r.prototype.search_results_mouseout=function(e){if(e.target.hasClassName("active-result")||e.target.up(".active-result"))return this.result_clear_highlight()},r.prototype.choice_build=function(e){var t,s;return t=new Element("li",{class:"search-choice"}).update("<span>"+this.choice_label(e)+"</span>"),e.disabled?t.addClassName("search-choice-disabled"):((s=new Element("a",{href:"#",class:"search-choice-close",rel:e.array_index})).observe("click",function(e){return function(t){return e.choice_destroy_link_click(t)}}(this)),t.insert(s)),this.search_container.insert({before:t})},r.prototype.choice_destroy_link_click=function(e){if(e.preventDefault(),e.stopPropagation(),!this.is_disabled)return this.choice_destroy(e.target)},r.prototype.choice_destroy=function(e){if(this.result_deselect(e.readAttribute("rel")))return this.active_field?this.search_field.focus():this.show_search_field_default(),this.is_multiple&&this.choices_count()>0&&this.get_search_field_value().length<1&&this.results_hide(),e.up("li").remove(),this.search_field_scale()},r.prototype.results_reset=function(){if(this.reset_single_select_options(),this.form_field.options[0].selected=!0,this.single_set_selected_text(),this.show_search_field_default(),this.results_reset_cleanup(),this.trigger_form_field_change(),this.active_field)return this.results_hide()},r.prototype.results_reset_cleanup=function(){var e;if(this.current_selectedIndex=this.form_field.selectedIndex,e=this.selected_item.down("abbr"))return e.remove()},r.prototype.result_select=function(e){var t,s;if(this.result_highlight)return t=this.result_highlight,this.result_clear_highlight(),this.is_multiple&&this.max_selected_options<=this.choices_count()?(this.form_field.fire("chosen:maxselected",{chosen:this}),!1):(this.is_multiple?t.removeClassName("active-result"):this.reset_single_select_options(),t.addClassName("result-selected"),s=this.results_data[t.getAttribute("data-option-array-index")],s.selected=!0,this.form_field.options[s.options_index].selected=!0,this.selected_option_count=null,this.is_multiple?this.choice_build(s):this.single_set_selected_text(this.choice_label(s)),this.is_multiple&&(!this.hide_results_on_select||e.metaKey||e.ctrlKey)?e.metaKey||e.ctrlKey?this.winnow_results({skip_highlight:!0}):(this.search_field.value="",this.winnow_results()):(this.results_hide(),this.show_search_field_default()),(this.is_multiple||this.form_field.selectedIndex!==this.current_selectedIndex)&&this.trigger_form_field_change(),this.current_selectedIndex=this.form_field.selectedIndex,e.preventDefault(),this.search_field_scale())},r.prototype.single_set_selected_text=function(e){return null==e&&(e=this.default_text),e===this.default_text?this.selected_item.addClassName("chosen-default"):(this.single_deselect_control_build(),this.selected_item.removeClassName("chosen-default")),this.selected_item.down("span").update(e)},r.prototype.result_deselect=function(e){var t;return t=this.results_data[e],!this.form_field.options[t.options_index].disabled&&(t.selected=!1,this.form_field.options[t.options_index].selected=!1,this.selected_option_count=null,this.result_clear_highlight(),this.results_showing&&this.winnow_results(),this.trigger_form_field_change(),this.search_field_scale(),!0)},r.prototype.single_deselect_control_build=function(){if(this.allow_single_deselect)return this.selected_item.down("abbr")||this.selected_item.down("span").insert({after:'<abbr class="search-choice-close"></abbr>'}),this.selected_item.addClassName("chosen-single-with-deselect")},r.prototype.get_search_field_value=function(){return this.search_field.value},r.prototype.get_search_text=function(){return this.get_search_field_value().strip()},r.prototype.escape_html=function(e){return e.escapeHTML()},r.prototype.winnow_results_set_highlight=function(){var e;if(this.is_multiple||(e=this.search_results.down(".result-selected.active-result")),null==e&&(e=this.search_results.down(".active-result")),null!=e)return this.result_do_highlight(e)},r.prototype.no_results=function(e){return this.search_results.insert(this.get_no_results_html(e)),this.form_field.fire("chosen:no_results",{chosen:this})},r.prototype.no_results_clear=function(){var e,t;for(e=null,t=[];e=this.search_results.down(".no-results");)t.push(e.remove());return t},r.prototype.keydown_arrow=function(){var e;return this.results_showing&&this.result_highlight?(e=this.result_highlight.next(".active-result"))?this.result_do_highlight(e):void 0:this.results_show()},r.prototype.keyup_arrow=function(){var e,t,s;return this.results_showing||this.is_multiple?this.result_highlight?(s=this.result_highlight.previousSiblings(),e=this.search_results.select("li.active-result"),(t=s.intersect(e)).length?this.result_do_highlight(t.first()):(this.choices_count()>0&&this.results_hide(),this.result_clear_highlight())):void 0:this.results_show()},r.prototype.keydown_backstroke=function(){var e;return this.pending_backstroke?(this.choice_destroy(this.pending_backstroke.down("a")),this.clear_backstroke()):(e=this.search_container.siblings().last())&&e.hasClassName("search-choice")&&!e.hasClassName("search-choice-disabled")?(this.pending_backstroke=e,this.pending_backstroke&&this.pending_backstroke.addClassName("search-choice-focus"),this.single_backstroke_delete?this.keydown_backstroke():this.pending_backstroke.addClassName("search-choice-focus")):void 0},r.prototype.clear_backstroke=function(){return this.pending_backstroke&&this.pending_backstroke.removeClassName("search-choice-focus"),this.pending_backstroke=null},r.prototype.search_field_scale=function(){var e,t,s,i,r,n,o,l;if(this.is_multiple){for(n={position:"absolute",left:"-1000px",top:"-1000px",display:"none",whiteSpace:"pre"},s=0,i=(o=["fontSize","fontStyle","fontWeight","fontFamily","lineHeight","textTransform","letterSpacing"]).length;s<i;s++)n[r=o[s]]=this.search_field.getStyle(r);return(t=new Element("div").update(this.escape_html(this.get_search_field_value()))).setStyle(n),document.body.appendChild(t),l=t.measure("width")+25,t.remove(),(e=this.container.getWidth())&&(l=Math.min(e-10,l)),this.search_field.setStyle({width:l+"px"})}},r.prototype.trigger_form_field_change=function(){return n(this.form_field,"input"),n(this.form_field,"change")},n=function(e,t){var s;if(e.dispatchEvent){try{s=new Event(t,{bubbles:!0,cancelable:!0})}catch(e){(s=document.createEvent("HTMLEvents")).initEvent(t,!0,!0)}return e.dispatchEvent(s)}return e.fireEvent("on"+t,document.createEventObject())},r}()}).call(this);
0 4 \ No newline at end of file
resources/views/employers/bd.blade.php
... ... @@ -2,7 +2,23 @@
2 2  
3 3 @section('scripts')
4 4 <script>
5   - console.log('Test system');
  5 + $(document).ready(function(){
  6 + $('[name="job_title_list[]"]').chosen({
  7 + width: '100%'
  8 + })
  9 + $('[name="job_title"]').change(function(){
  10 + if ($(this).is(':checked')){
  11 + $(".job-title-list-wrap").css("display", "block");
  12 + } else {
  13 + $(".job-title-list-wrap").css("display", "none");
  14 + }
  15 + });
  16 + $('.cabinet__export-button-wrap button').click(function(){
  17 + $('.cabinet__export-error').parent().remove();
  18 + });
  19 + });
  20 +
  21 +
6 22 $(document).on('click', '.die_black', function() {
7 23 var this_ = $(this);
8 24 var ajax_ = $('#ajax_flot_div');
... ... @@ -61,16 +77,49 @@
61 77 </span>
62 78 </form>
63 79 </div>
64   -
65   - <div class="cabinet__filters-item">
66   - <a href="{{ route('resume_download_all') }}" class="button">
67   - <svg>
68   - <use xlink:href="{{ asset('images/sprite.svg#share') }}"></use>
69   - </svg>
70   - Экспорт
71   - </a>
  80 + </div>
  81 + <div class="cabinet__filters">
  82 + <div class="cabinet__export-wrap">
  83 + <form action="{{ route('resume_download_all') }}" method="GET" target="_blank">
  84 + <div class="cabinet__export-button-wrap">
  85 + <button type="submit" class="button">
  86 + <svg>
  87 + <use xlink:href="{{ asset('images/sprite.svg#share') }}"></use>
  88 + </svg>
  89 + Экспорт
  90 + </button>
  91 + </div>
  92 + <div class="cabinet__export-options-wrap">
  93 + @foreach ($export_options as $key => $export_option)
  94 + <label class="checkbox">
  95 + <input type="checkbox" value="1" name="{{$key}}" class="checkbox__input" checked="">
  96 + <span class="checkbox__icon">
  97 + <svg>
  98 + <use xlink:href="http://localhost/rekamore/public/images/sprite.svg#v"></use>
  99 + </svg>
  100 + </span>
  101 + <span class="checkbox__text">
  102 + <span>{{$export_option['title']}}</span>
  103 + </span>
  104 + </label>
  105 + @endforeach
  106 + </div>
  107 + <div class="job-title-list-wrap">
  108 + <select name="job_title_list[]" data-placeholder="Выберите должности" multiple >
  109 + @foreach($jobs_titles as $job_title)
  110 + <option value="{{$job_title['id']}}">{{$job_title['name']}}</option>
  111 + @endforeach
  112 + </select>
  113 + </div>
  114 + </form>
72 115 </div>
73 116 </div>
  117 + @if(session('error'))
  118 + <div class="cabinet__filters">
  119 + <p class="cabinet__export-error">{{ session('error') }}</p>
  120 + </div>
  121 + @endif
  122 +
74 123 </div>
75 124  
76 125 <div class="cabinet__body-item">
resources/views/layout/frontend.blade.php
... ... @@ -7,6 +7,8 @@
7 7 <meta name="viewport" content="width=device-width,initial-scale=1">
8 8 <meta name="theme-color" content="#377D87">
9 9 <script src="{{ asset('js/jquery.js') }}"></script>
  10 + <link rel="stylesheet" href="{{ asset('js/chosen/chosen.min.css') }}">
  11 + <script src="{{ asset('js/chosen/chosen.jquery.min.js') }}"></script>
10 12 <!--<script type="text/javascript" src=" asset('js/jquery.cookie.js') }}"></script>-->
11 13 <link rel="stylesheet" href="{{ asset('css/telegram.css') }}">
12 14 <link rel="stylesheet" href="{{ asset('css/star-rating.min.css') }}">