rollout_ui 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/lib/rollout_ui/feature.rb +6 -2
  2. data/lib/rollout_ui/version.rb +1 -1
  3. data/spec/dummy/log/test.log +231 -10862
  4. data/spec/lib/rollout_ui/feature_spec.rb +3 -1
  5. metadata +7 -72
  6. data/spec/dummy/log/development.log +0 -15639
  7. data/spec/dummy/log/production.log +0 -19
  8. data/spec/dummy/log/stdout.log +0 -3192
  9. data/spec/dummy/tmp/cache/assets/C44/C60/sprockets%2F32619064c16276c9031bc469f111b6f1 +0 -369
  10. data/spec/dummy/tmp/cache/assets/CA9/290/sprockets%2Ffde33cd38c83e40045112ef236908326 +0 -1012
  11. data/spec/dummy/tmp/cache/assets/CB1/0F0/sprockets%2F097929f05538ada1621d2b34d0748fb8 +0 -0
  12. data/spec/dummy/tmp/cache/assets/D0C/460/sprockets%2Fbf6917215d0871b152f3d3ec4ece0486 +0 -0
  13. data/spec/dummy/tmp/cache/assets/D1E/9E0/sprockets%2Fb92e466db7d4e78f107d8386ea19560a +0 -0
  14. data/spec/dummy/tmp/cache/assets/D22/D60/sprockets%2F6c1d9d3c966b8286c00d8dd46bd54598 +0 -371
  15. data/spec/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  16. data/spec/dummy/tmp/cache/assets/D3E/870/sprockets%2F82e617ed3b33c78bb8340cdbd603d189 +0 -1015
  17. data/spec/dummy/tmp/cache/assets/D45/1B0/sprockets%2F89743b2dcefe650c86e16c60dc248a26 +0 -0
  18. data/spec/dummy/tmp/cache/assets/D54/ED0/sprockets%2F71c9fa01091d432b131da3bb73faf3d4 +0 -0
  19. data/spec/dummy/tmp/cache/assets/D62/900/sprockets%2F4d745068b58dab09efc05fd3bd030c05 +0 -1387
  20. data/spec/dummy/tmp/cache/assets/D71/220/sprockets%2Fd07f8aed535b53034c9a4489bd6cb45d +0 -374
  21. data/spec/dummy/tmp/cache/assets/D74/0C0/sprockets%2F28c2d3c4b8de13fe5b746c94d96042dd +0 -0
  22. data/spec/dummy/tmp/cache/assets/D7D/C20/sprockets%2Ff5f71be7464ea98757bc8e41df514a4b +0 -433
  23. data/spec/dummy/tmp/cache/assets/D84/210/sprockets%2Fabd0103ccec2b428ac62c94e4c40b384 +0 -0
  24. data/spec/dummy/tmp/cache/assets/D93/100/sprockets%2Ffd9e48a89d83e7b764e2de324ee888b6 +0 -917
  25. data/spec/dummy/tmp/cache/assets/DC2/770/sprockets%2F7f10ac108ce75bbb0e9877b50bcb22fe +0 -0
  26. data/spec/dummy/tmp/cache/assets/E00/850/sprockets%2Fd5e1f4415f71da50c8365f7ecdeca2ff +0 -436
  27. data/spec/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  28. data/spec/dummy/tmp/cache/assets/E3E/230/sprockets%2F8156dcfebf95ff75b117c7e5bffb71dc +0 -372
  29. data/spec/dummy/tmp/cache/assets/E7A/F10/sprockets%2Ff3d71fbeaa5fdddf600a0ac52af1d8e2 +0 -0
  30. data/spec/dummy/tmp/capybara/capybara-201110152250496494273346.html +0 -141
  31. data/spec/dummy/tmp/capybara/capybara-201110152251237384633452.html +0 -141
  32. data/spec/dummy/tmp/capybara/capybara-201110152253073784924369.html +0 -141
  33. data/spec/dummy/tmp/capybara/capybara-201110152255118447806623.html +0 -141
  34. data/spec/dummy/tmp/capybara/capybara-201110152257286050916603.html +0 -141
  35. data/spec/dummy/tmp/capybara/capybara-201110152258202877532249.html +0 -139
  36. data/spec/dummy/tmp/capybara/capybara-201110152259224345897143.html +0 -139
  37. data/spec/dummy/tmp/pids/server.pid +0 -1
@@ -1,1387 +0,0 @@
1
- o: ActiveSupport::Cache::Entry :@expires_in0: @value{ "
2
- * Unobtrusive scripting adapter for jQuery
3
- *
4
- * Requires jQuery 1.6.0 or later.
5
- * https://github.com/rails/jquery-ujs
6
-
7
- * Uploading file using rails.js
8
- * =============================
9
- *
10
- * By default, browsers do not allow files to be uploaded via AJAX. As a result, if there are any non-blank file fields
11
- * in the remote form, this adapter aborts the AJAX submission and allows the form to submit through standard means.
12
- *
13
- * The `ajax:aborted:file` event allows you to bind your own handler to process the form submission however you wish.
14
- *
15
- * Ex:
16
- * $('form').live('ajax:aborted:file', function(event, elements){
17
- * // Implement own remote file-transfer handler here for non-blank file inputs passed in `elements`.
18
- * // Returning false in this handler tells rails.js to disallow standard form submission
19
- * return false;
20
- * });
21
- *
22
- * The `ajax:aborted:file` event is fired when a file-type input is detected with a non-blank value.
23
- *
24
- * Third-party tools can use this hook to detect when an AJAX file upload is attempted, and then use
25
- * techniques like the iframe method to upload the file instead.
26
- *
27
- * Required fields in rails.js
28
- * ===========================
29
- *
30
- * If any blank required inputs (required="required") are detected in the remote form, the whole form submission
31
- * is canceled. Note that this is unlike file inputs, which still allow standard (non-AJAX) form submission.
32
- *
33
- * The `ajax:aborted:required` event allows you to bind your own handler to inform the user of blank required inputs.
34
- *
35
- * !! Note that Opera does not fire the form's submit event if there are blank required inputs, so this event may never
36
- * get fired in Opera. This event is what causes other browsers to exhibit the same submit-aborting behavior.
37
- *
38
- * Ex:
39
- * $('form').live('ajax:aborted:required', function(event, elements){
40
- * // Returning false in this handler tells rails.js to submit the form anyway.
41
- * // The blank required inputs are passed to this function in `elements`.
42
- * return ! confirm("Would you like to submit the form with missing info?");
43
- * });
44
- */
45
-
46
-
47
- (function($, undefined) {
48
- // Shorthand to make it a little easier to call public rails functions from within rails.js
49
- var rails;
50
-
51
- $.rails = rails = {
52
- // Link elements bound by jquery-ujs
53
- linkClickSelector: 'a[data-confirm], a[data-method], a[data-remote], a[data-disable-with]',
54
-
55
- // Select elements bound by jquery-ujs
56
- inputChangeSelector: 'select[data-remote], input[data-remote], textarea[data-remote]',
57
-
58
- // Form elements bound by jquery-ujs
59
- formSubmitSelector: 'form',
60
-
61
- // Form input elements bound by jquery-ujs
62
- formInputClickSelector: 'form input[type=submit], form input[type=image], form button[type=submit], form button:not(button[type])',
63
-
64
- // Form input elements disabled during form submission
65
- disableSelector: 'input[data-disable-with], button[data-disable-with], textarea[data-disable-with]',
66
-
67
- // Form input elements re-enabled after form submission
68
- enableSelector: 'input[data-disable-with]:disabled, button[data-disable-with]:disabled, textarea[data-disable-with]:disabled',
69
-
70
- // Form required input elements
71
- requiredInputSelector: 'input[name][required]:not([disabled]),textarea[name][required]:not([disabled])',
72
-
73
- // Form file input elements
74
- fileInputSelector: 'input:file',
75
-
76
- // Link onClick disable selector with possible reenable after remote submission
77
- linkDisableSelector: 'a[data-disable-with]',
78
-
79
- // Make sure that every Ajax request sends the CSRF token
80
- CSRFProtection: function(xhr) {
81
- var token = $('meta[name="csrf-token"]').attr('content');
82
- if (token) xhr.setRequestHeader('X-CSRF-Token', token);
83
- },
84
-
85
- // Triggers an event on an element and returns false if the event result is false
86
- fire: function(obj, name, data) {
87
- var event = $.Event(name);
88
- obj.trigger(event, data);
89
- return event.result !== false;
90
- },
91
-
92
- // Default confirm dialog, may be overridden with custom confirm dialog in $.rails.confirm
93
- confirm: function(message) {
94
- return confirm(message);
95
- },
96
-
97
- // Default ajax function, may be overridden with custom function in $.rails.ajax
98
- ajax: function(options) {
99
- return $.ajax(options);
100
- },
101
-
102
- // Submits "remote" forms and links with ajax
103
- handleRemote: function(element) {
104
- var method, url, data,
105
- crossDomain = element.data('cross-domain') || null,
106
- dataType = element.data('type') || ($.ajaxSettings && $.ajaxSettings.dataType),
107
- options;
108
-
109
- if (rails.fire(element, 'ajax:before')) {
110
-
111
- if (element.is('form')) {
112
- method = element.attr('method');
113
- url = element.attr('action');
114
- data = element.serializeArray();
115
- // memoized value from clicked submit button
116
- var button = element.data('ujs:submit-button');
117
- if (button) {
118
- data.push(button);
119
- element.data('ujs:submit-button', null);
120
- }
121
- } else if (element.is(rails.inputChangeSelector)) {
122
- method = element.data('method');
123
- url = element.data('url');
124
- data = element.serialize();
125
- if (element.data('params')) data = data + "&" + element.data('params');
126
- } else {
127
- method = element.data('method');
128
- url = element.attr('href');
129
- data = element.data('params') || null;
130
- }
131
-
132
- options = {
133
- type: method || 'GET', data: data, dataType: dataType, crossDomain: crossDomain,
134
- // stopping the "ajax:beforeSend" event will cancel the ajax request
135
- beforeSend: function(xhr, settings) {
136
- if (settings.dataType === undefined) {
137
- xhr.setRequestHeader('accept', '*/*;q=0.5, ' + settings.accepts.script);
138
- }
139
- return rails.fire(element, 'ajax:beforeSend', [xhr, settings]);
140
- },
141
- success: function(data, status, xhr) {
142
- element.trigger('ajax:success', [data, status, xhr]);
143
- },
144
- complete: function(xhr, status) {
145
- element.trigger('ajax:complete', [xhr, status]);
146
- },
147
- error: function(xhr, status, error) {
148
- element.trigger('ajax:error', [xhr, status, error]);
149
- }
150
- };
151
- // Only pass url to `ajax` options if not blank
152
- if (url) { options.url = url; }
153
-
154
- rails.ajax(options);
155
- }
156
- },
157
-
158
- // Handles "data-method" on links such as:
159
- // <a href="/users/5" data-method="delete" rel="nofollow" data-confirm="Are you sure?">Delete</a>
160
- handleMethod: function(link) {
161
- var href = link.attr('href'),
162
- method = link.data('method'),
163
- target = link.attr('target'),
164
- csrf_token = $('meta[name=csrf-token]').attr('content'),
165
- csrf_param = $('meta[name=csrf-param]').attr('content'),
166
- form = $('<form method="post" action="' + href + '"></form>'),
167
- metadata_input = '<input name="_method" value="' + method + '" type="hidden" />';
168
-
169
- if (csrf_param !== undefined && csrf_token !== undefined) {
170
- metadata_input += '<input name="' + csrf_param + '" value="' + csrf_token + '" type="hidden" />';
171
- }
172
-
173
- if (target) { form.attr('target', target); }
174
-
175
- form.hide().append(metadata_input).appendTo('body');
176
- form.submit();
177
- },
178
-
179
- /* Disables form elements:
180
- - Caches element value in 'ujs:enable-with' data store
181
- - Replaces element text with value of 'data-disable-with' attribute
182
- - Sets disabled property to true
183
- */
184
- disableFormElements: function(form) {
185
- form.find(rails.disableSelector).each(function() {
186
- var element = $(this), method = element.is('button') ? 'html' : 'val';
187
- element.data('ujs:enable-with', element[method]());
188
- element[method](element.data('disable-with'));
189
- element.prop('disabled', true);
190
- });
191
- },
192
-
193
- /* Re-enables disabled form elements:
194
- - Replaces element text with cached value from 'ujs:enable-with' data store (created in `disableFormElements`)
195
- - Sets disabled property to false
196
- */
197
- enableFormElements: function(form) {
198
- form.find(rails.enableSelector).each(function() {
199
- var element = $(this), method = element.is('button') ? 'html' : 'val';
200
- if (element.data('ujs:enable-with')) element[method](element.data('ujs:enable-with'));
201
- element.prop('disabled', false);
202
- });
203
- },
204
-
205
- /* For 'data-confirm' attribute:
206
- - Fires `confirm` event
207
- - Shows the confirmation dialog
208
- - Fires the `confirm:complete` event
209
-
210
- Returns `true` if no function stops the chain and user chose yes; `false` otherwise.
211
- Attaching a handler to the element's `confirm` event that returns a `falsy` value cancels the confirmation dialog.
212
- Attaching a handler to the element's `confirm:complete` event that returns a `falsy` value makes this function
213
- return false. The `confirm:complete` event is fired whether or not the user answered true or false to the dialog.
214
- */
215
- allowAction: function(element) {
216
- var message = element.data('confirm'),
217
- answer = false, callback;
218
- if (!message) { return true; }
219
-
220
- if (rails.fire(element, 'confirm')) {
221
- answer = rails.confirm(message);
222
- callback = rails.fire(element, 'confirm:complete', [answer]);
223
- }
224
- return answer && callback;
225
- },
226
-
227
- // Helper function which checks for blank inputs in a form that match the specified CSS selector
228
- blankInputs: function(form, specifiedSelector, nonBlank) {
229
- var inputs = $(), input,
230
- selector = specifiedSelector || 'input,textarea';
231
- form.find(selector).each(function() {
232
- input = $(this);
233
- // Collect non-blank inputs if nonBlank option is true, otherwise, collect blank inputs
234
- if (nonBlank ? input.val() : !input.val()) {
235
- inputs = inputs.add(input);
236
- }
237
- });
238
- return inputs.length ? inputs : false;
239
- },
240
-
241
- // Helper function which checks for non-blank inputs in a form that match the specified CSS selector
242
- nonBlankInputs: function(form, specifiedSelector) {
243
- return rails.blankInputs(form, specifiedSelector, true); // true specifies nonBlank
244
- },
245
-
246
- // Helper function, needed to provide consistent behavior in IE
247
- stopEverything: function(e) {
248
- $(e.target).trigger('ujs:everythingStopped');
249
- e.stopImmediatePropagation();
250
- return false;
251
- },
252
-
253
- // find all the submit events directly bound to the form and
254
- // manually invoke them. If anyone returns false then stop the loop
255
- callFormSubmitBindings: function(form) {
256
- var events = form.data('events'), continuePropagation = true;
257
- if (events !== undefined && events['submit'] !== undefined) {
258
- $.each(events['submit'], function(i, obj){
259
- if (typeof obj.handler === 'function') return continuePropagation = obj.handler(obj.data);
260
- });
261
- }
262
- return continuePropagation;
263
- },
264
-
265
- // replace element's html with the 'data-disable-with' after storing original html
266
- // and prevent clicking on it
267
- disableElement: function(element) {
268
- element.data('ujs:enable-with', element.html()); // store enabled state
269
- element.html(element.data('disable-with')); // set to disabled state
270
- element.bind('click.railsDisable', function(e) { // prevent further clicking
271
- return rails.stopEverything(e)
272
- });
273
- },
274
-
275
- // restore element to its original state which was disabled by 'disableElement' above
276
- enableElement: function(element) {
277
- if (element.data('ujs:enable-with') !== undefined) {
278
- element.html(element.data('ujs:enable-with')); // set to old enabled state
279
- // this should be element.removeData('ujs:enable-with')
280
- // but, there is currently a bug in jquery which makes hyphenated data attributes not get removed
281
- element.data('ujs:enable-with', false); // clean up cache
282
- }
283
- element.unbind('click.railsDisable'); // enable element
284
- }
285
-
286
- };
287
-
288
- $.ajaxPrefilter(function(options, originalOptions, xhr){ if ( !options.crossDomain ) { rails.CSRFProtection(xhr); }});
289
-
290
- $(rails.linkDisableSelector).live('ajax:complete', function() {
291
- rails.enableElement($(this));
292
- });
293
-
294
- $(rails.linkClickSelector).live('click.rails', function(e) {
295
- var link = $(this), method = link.data('method'), data = link.data('params');
296
- if (!rails.allowAction(link)) return rails.stopEverything(e);
297
-
298
- if (link.is(rails.linkDisableSelector)) rails.disableElement(link);
299
-
300
- if (link.data('remote') !== undefined) {
301
- if ( (e.metaKey || e.ctrlKey) && (!method || method === 'GET') && !data ) { return true; }
302
- rails.handleRemote(link);
303
- return false;
304
- } else if (link.data('method')) {
305
- rails.handleMethod(link);
306
- return false;
307
- }
308
- });
309
-
310
- $(rails.inputChangeSelector).live('change.rails', function(e) {
311
- var link = $(this);
312
- if (!rails.allowAction(link)) return rails.stopEverything(e);
313
-
314
- rails.handleRemote(link);
315
- return false;
316
- });
317
-
318
- $(rails.formSubmitSelector).live('submit.rails', function(e) {
319
- var form = $(this),
320
- remote = form.data('remote') !== undefined,
321
- blankRequiredInputs = rails.blankInputs(form, rails.requiredInputSelector),
322
- nonBlankFileInputs = rails.nonBlankInputs(form, rails.fileInputSelector);
323
-
324
- if (!rails.allowAction(form)) return rails.stopEverything(e);
325
-
326
- // skip other logic when required values are missing or file upload is present
327
- if (blankRequiredInputs && form.attr("novalidate") == undefined && rails.fire(form, 'ajax:aborted:required', [blankRequiredInputs])) {
328
- return rails.stopEverything(e);
329
- }
330
-
331
- if (remote) {
332
- if (nonBlankFileInputs) {
333
- return rails.fire(form, 'ajax:aborted:file', [nonBlankFileInputs]);
334
- }
335
-
336
- // If browser does not support submit bubbling, then this live-binding will be called before direct
337
- // bindings. Therefore, we should directly call any direct bindings before remotely submitting form.
338
- if (!$.support.submitBubbles && rails.callFormSubmitBindings(form) === false) return rails.stopEverything(e);
339
-
340
- rails.handleRemote(form);
341
- return false;
342
- } else {
343
- // slight timeout so that the submit button gets properly serialized
344
- setTimeout(function(){ rails.disableFormElements(form); }, 13);
345
- }
346
- });
347
-
348
- $(rails.formInputClickSelector).live('click.rails', function(event) {
349
- var button = $(this);
350
-
351
- if (!rails.allowAction(button)) return rails.stopEverything(event);
352
-
353
- // register the pressed submit button
354
- var name = button.attr('name'),
355
- data = name ? {name:name, value:button.val()} : null;
356
-
357
- button.closest('form').data('ujs:submit-button', data);
358
- });
359
-
360
- $(rails.formSubmitSelector).live('ajax:beforeSend.rails', function(event) {
361
- if (this == event.target) rails.disableFormElements($(this));
362
- });
363
-
364
- $(rails.formSubmitSelector).live('ajax:complete.rails', function(event) {
365
- if (this == event.target) rails.enableFormElements($(this));
366
- });
367
-
368
- })( jQuery );
369
- // Chosen, a Select Box Enhancer for jQuery and Protoype
370
- // by Patrick Filler for Harvest, http://getharvest.com
371
- //
372
- // Version 0.9.5
373
- // Full source at https://github.com/harvesthq/chosen
374
- // Copyright (c) 2011 Harvest http://getharvest.com
375
-
376
- // MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md
377
- // This file is generated by `cake build`, do not edit it by hand.
378
- (function() {
379
- var SelectParser;
380
- SelectParser = (function() {
381
- function SelectParser() {
382
- this.options_index = 0;
383
- this.parsed = [];
384
- }
385
- SelectParser.prototype.add_node = function(child) {
386
- if (child.nodeName === "OPTGROUP") {
387
- return this.add_group(child);
388
- } else {
389
- return this.add_option(child);
390
- }
391
- };
392
- SelectParser.prototype.add_group = function(group) {
393
- var group_position, option, _i, _len, _ref, _results;
394
- group_position = this.parsed.length;
395
- this.parsed.push({
396
- array_index: group_position,
397
- group: true,
398
- label: group.label,
399
- children: 0,
400
- disabled: group.disabled
401
- });
402
- _ref = group.childNodes;
403
- _results = [];
404
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
405
- option = _ref[_i];
406
- _results.push(this.add_option(option, group_position, group.disabled));
407
- }
408
- return _results;
409
- };
410
- SelectParser.prototype.add_option = function(option, group_position, group_disabled) {
411
- if (option.nodeName === "OPTION") {
412
- if (option.text !== "") {
413
- if (group_position != null) {
414
- this.parsed[group_position].children += 1;
415
- }
416
- this.parsed.push({
417
- array_index: this.parsed.length,
418
- options_index: this.options_index,
419
- value: option.value,
420
- text: option.text,
421
- html: option.innerHTML,
422
- selected: option.selected,
423
- disabled: group_disabled === true ? group_disabled : option.disabled,
424
- group_array_index: group_position,
425
- classes: option.className,
426
- style: option.style.cssText
427
- });
428
- } else {
429
- this.parsed.push({
430
- array_index: this.parsed.length,
431
- options_index: this.options_index,
432
- empty: true
433
- });
434
- }
435
- return this.options_index += 1;
436
- }
437
- };
438
- return SelectParser;
439
- })();
440
- SelectParser.select_to_array = function(select) {
441
- var child, parser, _i, _len, _ref;
442
- parser = new SelectParser();
443
- _ref = select.childNodes;
444
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
445
- child = _ref[_i];
446
- parser.add_node(child);
447
- }
448
- return parser.parsed;
449
- };
450
- this.SelectParser = SelectParser;
451
- }).call(this);
452
- (function() {
453
- /*
454
- Chosen source: generate output using 'cake build'
455
- Copyright (c) 2011 by Harvest
456
- */
457
- var AbstractChosen, root;
458
- var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
459
- root = this;
460
- AbstractChosen = (function() {
461
- function AbstractChosen(form_field, options) {
462
- this.form_field = form_field;
463
- this.options = options != null ? options : {};
464
- this.set_default_values();
465
- this.is_multiple = this.form_field.multiple;
466
- this.default_text_default = this.form_field.multiple ? "Select Some Options" : "Select an Option";
467
- this.setup();
468
- this.set_up_html();
469
- this.register_observers();
470
- this.finish_setup();
471
- }
472
- AbstractChosen.prototype.set_default_values = function() {
473
- this.click_test_action = __bind(function(evt) {
474
- return this.test_active_click(evt);
475
- }, this);
476
- this.activate_action = __bind(function(evt) {
477
- return this.activate_field(evt);
478
- }, this);
479
- this.active_field = false;
480
- this.mouse_on_container = false;
481
- this.results_showing = false;
482
- this.result_highlighted = null;
483
- this.result_single_selected = null;
484
- this.allow_single_deselect = (this.options.allow_single_deselect != null) && this.form_field.options[0].text === "" ? this.options.allow_single_deselect : false;
485
- this.disable_search_threshold = this.options.disable_search_threshold || 0;
486
- this.choices = 0;
487
- return this.results_none_found = this.options.no_results_text || "No results match";
488
- };
489
- AbstractChosen.prototype.mouse_enter = function() {
490
- return this.mouse_on_container = true;
491
- };
492
- AbstractChosen.prototype.mouse_leave = function() {
493
- return this.mouse_on_container = false;
494
- };
495
- AbstractChosen.prototype.input_focus = function(evt) {
496
- if (!this.active_field) {
497
- return setTimeout((__bind(function() {
498
- return this.container_mousedown();
499
- }, this)), 50);
500
- }
501
- };
502
- AbstractChosen.prototype.input_blur = function(evt) {
503
- if (!this.mouse_on_container) {
504
- this.active_field = false;
505
- return setTimeout((__bind(function() {
506
- return this.blur_test();
507
- }, this)), 100);
508
- }
509
- };
510
- AbstractChosen.prototype.result_add_option = function(option) {
511
- var classes, style;
512
- if (!option.disabled) {
513
- option.dom_id = this.container_id + "_o_" + option.array_index;
514
- classes = option.selected && this.is_multiple ? [] : ["active-result"];
515
- if (option.selected) {
516
- classes.push("result-selected");
517
- }
518
- if (option.group_array_index != null) {
519
- classes.push("group-option");
520
- }
521
- if (option.classes !== "") {
522
- classes.push(option.classes);
523
- }
524
- style = option.style.cssText !== "" ? " style=\"" + option.style + "\"" : "";
525
- return '<li id="' + option.dom_id + '" class="' + classes.join(' ') + '"' + style + '>' + option.html + '</li>';
526
- } else {
527
- return "";
528
- }
529
- };
530
- AbstractChosen.prototype.results_update_field = function() {
531
- this.result_clear_highlight();
532
- this.result_single_selected = null;
533
- return this.results_build();
534
- };
535
- AbstractChosen.prototype.results_toggle = function() {
536
- if (this.results_showing) {
537
- return this.results_hide();
538
- } else {
539
- return this.results_show();
540
- }
541
- };
542
- AbstractChosen.prototype.results_search = function(evt) {
543
- if (this.results_showing) {
544
- return this.winnow_results();
545
- } else {
546
- return this.results_show();
547
- }
548
- };
549
- AbstractChosen.prototype.keyup_checker = function(evt) {
550
- var stroke, _ref;
551
- stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
552
- this.search_field_scale();
553
- switch (stroke) {
554
- case 8:
555
- if (this.is_multiple && this.backstroke_length < 1 && this.choices > 0) {
556
- return this.keydown_backstroke();
557
- } else if (!this.pending_backstroke) {
558
- this.result_clear_highlight();
559
- return this.results_search();
560
- }
561
- break;
562
- case 13:
563
- evt.preventDefault();
564
- if (this.results_showing) {
565
- return this.result_select(evt);
566
- } else if (this.is_tag) {
567
- return this.choice_append();
568
- }
569
- break;
570
- case 27:
571
- if (this.results_showing) {
572
- return this.results_hide();
573
- }
574
- break;
575
- case 9:
576
- case 38:
577
- case 40:
578
- case 16:
579
- case 91:
580
- case 17:
581
- break;
582
- default:
583
- return this.results_search();
584
- }
585
- };
586
- AbstractChosen.prototype.generate_field_id = function() {
587
- var new_id;
588
- new_id = this.generate_random_id();
589
- this.form_field.id = new_id;
590
- return new_id;
591
- };
592
- AbstractChosen.prototype.generate_random_char = function() {
593
- var chars, newchar, rand;
594
- chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZ";
595
- rand = Math.floor(Math.random() * chars.length);
596
- return newchar = chars.substring(rand, rand + 1);
597
- };
598
- return AbstractChosen;
599
- })();
600
- root.AbstractChosen = AbstractChosen;
601
- }).call(this);
602
- (function() {
603
- /*
604
- Chosen source: generate output using 'cake build'
605
- Copyright (c) 2011 by Harvest
606
- */
607
- var $, Chosen, get_side_border_padding, root;
608
- var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
609
- for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
610
- function ctor() { this.constructor = child; }
611
- ctor.prototype = parent.prototype;
612
- child.prototype = new ctor;
613
- child.__super__ = parent.prototype;
614
- return child;
615
- }, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
616
- root = this;
617
- $ = jQuery;
618
- $.fn.extend({
619
- chosen: function(options) {
620
- if ($.browser.msie && ($.browser.version === "6.0" || $.browser.version === "7.0")) {
621
- return this;
622
- }
623
- return $(this).each(function(input_field) {
624
- if (!($(this)).hasClass("chzn-done")) {
625
- return new Chosen(this, options);
626
- }
627
- });
628
- }
629
- });
630
- Chosen = (function() {
631
- __extends(Chosen, AbstractChosen);
632
- function Chosen() {
633
- Chosen.__super__.constructor.apply(this, arguments);
634
- }
635
- Chosen.prototype.setup = function() {
636
- var tag, tags, val, _i, _len, _results;
637
- this.form_field_jq = $(this.form_field);
638
- this.is_tag = this.form_field_jq.attr("type") === "text";
639
- this.is_multiple = this.is_tag ? true : this.is_multiple;
640
- this.default_text_default = this.is_tag ? "Enter Tags" : this.default_text_default;
641
- this.is_rtl = this.form_field_jq.hasClass("chzn-rtl");
642
- this.tags = [];
643
- if (this.is_tag) {
644
- val = this.form_field.value;
645
- this.form_field.value = '';
646
- if (val !== '') {
647
- tags = val.split(',');
648
- _results = [];
649
- for (_i = 0, _len = tags.length; _i < _len; _i++) {
650
- tag = tags[_i];
651
- _results.push(this.tags.push(unescape(tag)));
652
- }
653
- return _results;
654
- }
655
- }
656
- };
657
- Chosen.prototype.finish_setup = function() {
658
- var tag, _i, _len, _ref, _results;
659
- this.form_field_jq.addClass("chzn-done");
660
- _ref = this.tags;
661
- _results = [];
662
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
663
- tag = _ref[_i];
664
- _results.push(this.choice_append(tag, tag));
665
- }
666
- return _results;
667
- };
668
- Chosen.prototype.set_up_html = function() {
669
- var container_div, dd_top, dd_width, sf_width;
670
- this.container_id = this.form_field.id.length ? this.form_field.id.replace(/(:|\.)/g, '_') : this.generate_field_id();
671
- this.container_id += "_chzn";
672
- this.f_width = this.form_field_jq.outerWidth();
673
- this.default_text = this.form_field_jq.data('placeholder') ? this.form_field_jq.data('placeholder') : this.default_text_default;
674
- container_div = $("<div />", {
675
- id: this.container_id,
676
- "class": "chzn-container" + (this.is_rtl ? ' chzn-rtl' : ''),
677
- style: 'width: ' + this.f_width + 'px;'
678
- });
679
- if (this.is_multiple) {
680
- container_div.html('<ul class="chzn-choices"><li class="search-field"><input type="text" value="' + this.default_text + '" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop" style="left:-9000px;"><ul class="chzn-results"></ul></div>');
681
- } else {
682
- container_div.html('<a href="javascript:void(0)" class="chzn-single"><span>' + this.default_text + '</span><div><b></b></div></a><div class="chzn-drop" style="left:-9000px;"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>');
683
- }
684
- this.form_field_jq.hide().after(container_div);
685
- this.container = $('#' + this.container_id);
686
- this.container.addClass("chzn-container-" + (this.is_multiple ? "multi" : "single"));
687
- if (!this.is_multiple && this.form_field.options.length <= this.disable_search_threshold) {
688
- this.container.addClass("chzn-container-single-nosearch");
689
- }
690
- this.dropdown = this.container.find('div.chzn-drop').first();
691
- dd_top = this.container.height();
692
- dd_width = this.f_width - get_side_border_padding(this.dropdown);
693
- this.dropdown.css({
694
- "width": dd_width + "px",
695
- "top": dd_top + "px"
696
- });
697
- this.search_field = this.container.find('input').first();
698
- this.search_results = this.container.find('ul.chzn-results').first();
699
- this.search_field_scale();
700
- this.search_no_results = this.container.find('li.no-results').first();
701
- if (this.is_multiple) {
702
- this.search_choices = this.container.find('ul.chzn-choices').first();
703
- this.search_container = this.container.find('li.search-field').first();
704
- } else {
705
- this.search_container = this.container.find('div.chzn-search').first();
706
- this.selected_item = this.container.find('.chzn-single').first();
707
- sf_width = dd_width - get_side_border_padding(this.search_container) - get_side_border_padding(this.search_field);
708
- this.search_field.css({
709
- "width": sf_width + "px"
710
- });
711
- }
712
- if (this.is_tag) {
713
- this.container.prepend('<select id="' + this.container_id + '_shadow" name="' + this.form_field.name + '" style="display: none;" multiple="multiple"></select>');
714
- this.form_field_jq = $('#' + this.container_id + '_shadow');
715
- this.form_field = this.form_field_jq.get(0);
716
- }
717
- this.results_build();
718
- return this.set_tab_index();
719
- };
720
- Chosen.prototype.register_observers = function() {
721
- this.container.mousedown(__bind(function(evt) {
722
- return this.container_mousedown(evt);
723
- }, this));
724
- this.container.mouseup(__bind(function(evt) {
725
- return this.container_mouseup(evt);
726
- }, this));
727
- this.container.mouseenter(__bind(function(evt) {
728
- return this.mouse_enter(evt);
729
- }, this));
730
- this.container.mouseleave(__bind(function(evt) {
731
- return this.mouse_leave(evt);
732
- }, this));
733
- this.search_results.mouseup(__bind(function(evt) {
734
- return this.search_results_mouseup(evt);
735
- }, this));
736
- this.search_results.mouseover(__bind(function(evt) {
737
- return this.search_results_mouseover(evt);
738
- }, this));
739
- this.search_results.mouseout(__bind(function(evt) {
740
- return this.search_results_mouseout(evt);
741
- }, this));
742
- this.form_field_jq.bind("liszt:updated", __bind(function(evt) {
743
- return this.results_update_field(evt);
744
- }, this));
745
- this.search_field.blur(__bind(function(evt) {
746
- return this.input_blur(evt);
747
- }, this));
748
- this.search_field.keyup(__bind(function(evt) {
749
- return this.keyup_checker(evt);
750
- }, this));
751
- this.search_field.keydown(__bind(function(evt) {
752
- return this.keydown_checker(evt);
753
- }, this));
754
- if (this.is_multiple) {
755
- this.search_choices.click(__bind(function(evt) {
756
- return this.choices_click(evt);
757
- }, this));
758
- return this.search_field.focus(__bind(function(evt) {
759
- return this.input_focus(evt);
760
- }, this));
761
- }
762
- };
763
- Chosen.prototype.search_field_disabled = function() {
764
- this.is_disabled = this.form_field_jq.attr('disabled');
765
- if (this.is_disabled) {
766
- this.container.addClass('chzn-disabled');
767
- this.search_field.attr('disabled', true);
768
- if (!this.is_multiple) {
769
- this.selected_item.unbind("focus", this.activate_action);
770
- }
771
- return this.close_field();
772
- } else {
773
- this.container.removeClass('chzn-disabled');
774
- this.search_field.attr('disabled', false);
775
- if (!this.is_multiple) {
776
- return this.selected_item.bind("focus", this.activate_action);
777
- }
778
- }
779
- };
780
- Chosen.prototype.container_mousedown = function(evt) {
781
- var target_closelink;
782
- if (!this.is_disabled) {
783
- target_closelink = evt != null ? ($(evt.target)).hasClass("search-choice-close") : false;
784
- if (evt && evt.type === "mousedown") {
785
- evt.stopPropagation();
786
- }
787
- if (!this.pending_destroy_click && !target_closelink) {
788
- if (!this.active_field) {
789
- if (this.is_multiple) {
790
- this.search_field.val("");
791
- }
792
- $(document).click(this.click_test_action);
793
- this.results_show();
794
- } else if (!this.is_multiple && evt && ($(evt.target) === this.selected_item || $(evt.target).parents("a.chzn-single").length)) {
795
- evt.preventDefault();
796
- this.results_toggle();
797
- }
798
- return this.activate_field();
799
- } else {
800
- return this.pending_destroy_click = false;
801
- }
802
- }
803
- };
804
- Chosen.prototype.container_mouseup = function(evt) {
805
- if (evt.target.nodeName === "ABBR") {
806
- return this.results_reset(evt);
807
- }
808
- };
809
- Chosen.prototype.blur_test = function(evt) {
810
- if (!this.active_field && this.container.hasClass("chzn-container-active")) {
811
- return this.close_field();
812
- }
813
- };
814
- Chosen.prototype.close_field = function() {
815
- $(document).unbind("click", this.click_test_action);
816
- if (!this.is_multiple) {
817
- this.selected_item.attr("tabindex", this.search_field.attr("tabindex"));
818
- this.search_field.attr("tabindex", -1);
819
- }
820
- this.active_field = false;
821
- this.results_hide();
822
- this.container.removeClass("chzn-container-active");
823
- this.winnow_results_clear();
824
- this.clear_backstroke();
825
- this.show_search_field_default();
826
- return this.search_field_scale();
827
- };
828
- Chosen.prototype.activate_field = function() {
829
- if (!this.is_multiple && !this.active_field) {
830
- this.search_field.attr("tabindex", this.selected_item.attr("tabindex"));
831
- this.selected_item.attr("tabindex", -1);
832
- }
833
- this.container.addClass("chzn-container-active");
834
- this.active_field = true;
835
- this.search_field.val(this.search_field.val());
836
- return this.search_field.focus();
837
- };
838
- Chosen.prototype.test_active_click = function(evt) {
839
- if ($(evt.target).parents('#' + this.container_id).length) {
840
- return this.active_field = true;
841
- } else {
842
- return this.close_field();
843
- }
844
- };
845
- Chosen.prototype.results_build = function() {
846
- var content, data, hash, i, opt, result, startTime, _i, _j, _len, _len2, _len3, _ref, _ref2;
847
- startTime = new Date();
848
- this.parsing = true;
849
- if (this.is_tag && (typeof results !== "undefined" && results !== null)) {
850
- hash = {};
851
- _ref = this.form_field.options;
852
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
853
- opt = _ref[_i];
854
- if (opt.selected) {
855
- hash[opt.value] = true;
856
- }
857
- }
858
- this.results_data = [];
859
- for (i = 0, _len2 = results.length; i < _len2; i++) {
860
- result = results[i];
861
- this.results_data.push({
862
- array_index: i,
863
- options_index: i,
864
- value: result.value,
865
- text: result.text,
866
- html: result.text,
867
- selected: result.value in hash ? 1 : 0,
868
- disabled: 0,
869
- group_array_index: null
870
- });
871
- }
872
- } else {
873
- this.results_data = root.SelectParser.select_to_array(this.form_field);
874
- if (this.is_multiple && this.choices > 0) {
875
- this.search_choices.find("li.search-choice").remove();
876
- this.choices = 0;
877
- } else if (!this.is_multiple) {
878
- this.selected_item.find("span").text(this.default_text);
879
- }
880
- }
881
- content = '';
882
- _ref2 = this.results_data;
883
- for (_j = 0, _len3 = _ref2.length; _j < _len3; _j++) {
884
- data = _ref2[_j];
885
- if (data.group) {
886
- content += this.result_add_group(data);
887
- } else if (!data.empty) {
888
- content += this.result_add_option(data);
889
- if (this.is_tag && (typeof results !== "undefined" && results !== null)) {
890
- continue;
891
- }
892
- if (data.selected && this.is_multiple) {
893
- this.choice_build(data);
894
- } else if (data.selected && !this.is_multiple) {
895
- this.selected_item.find("span").text(data.text);
896
- if (this.allow_single_deselect) {
897
- this.selected_item.find("span").first().after("<abbr class=\"search-choice-close\"></abbr>");
898
- }
899
- }
900
- }
901
- }
902
- if (this.is_tag && (typeof results !== "undefined" && results !== null)) {
903
- this.search_results.html(content);
904
- this.results_show();
905
- } else {
906
- this.search_field_disabled();
907
- this.show_search_field_default();
908
- this.search_field_scale();
909
- this.search_results.html(content);
910
- }
911
- return this.parsing = false;
912
- };
913
- Chosen.prototype.result_add_group = function(group) {
914
- if (!group.disabled) {
915
- group.dom_id = this.container_id + "_g_" + group.array_index;
916
- return '<li id="' + group.dom_id + '" class="group-result">' + $("<div />").text(group.label).html() + '</li>';
917
- } else {
918
- return "";
919
- }
920
- };
921
- Chosen.prototype.result_do_highlight = function(el) {
922
- var high_bottom, high_top, maxHeight, visible_bottom, visible_top;
923
- if (el.length) {
924
- this.result_clear_highlight();
925
- this.result_highlight = el;
926
- this.result_highlight.addClass("highlighted");
927
- maxHeight = parseInt(this.search_results.css("maxHeight"), 10);
928
- visible_top = this.search_results.scrollTop();
929
- visible_bottom = maxHeight + visible_top;
930
- high_top = this.result_highlight.position().top + this.search_results.scrollTop();
931
- high_bottom = high_top + this.result_highlight.outerHeight();
932
- if (high_bottom >= visible_bottom) {
933
- return this.search_results.scrollTop((high_bottom - maxHeight) > 0 ? high_bottom - maxHeight : 0);
934
- } else if (high_top < visible_top) {
935
- return this.search_results.scrollTop(high_top);
936
- }
937
- }
938
- };
939
- Chosen.prototype.result_clear_highlight = function() {
940
- if (this.result_highlight) {
941
- this.result_highlight.removeClass("highlighted");
942
- }
943
- return this.result_highlight = null;
944
- };
945
- Chosen.prototype.results_show = function() {
946
- var dd_top;
947
- if (!this.is_multiple) {
948
- this.selected_item.addClass("chzn-single-with-drop");
949
- if (this.result_single_selected) {
950
- this.result_do_highlight(this.result_single_selected);
951
- }
952
- }
953
- dd_top = this.is_multiple ? this.container.height() : this.container.height() - 1;
954
- this.dropdown.css({
955
- "top": dd_top + "px",
956
- "left": 0
957
- });
958
- this.results_showing = true;
959
- this.search_field.focus();
960
- this.search_field.val(this.search_field.val());
961
- return this.winnow_results();
962
- };
963
- Chosen.prototype.results_hide = function() {
964
- if (!this.is_multiple) {
965
- this.selected_item.removeClass("chzn-single-with-drop");
966
- }
967
- this.result_clear_highlight();
968
- this.dropdown.css({
969
- "left": "-9000px"
970
- });
971
- return this.results_showing = false;
972
- };
973
- Chosen.prototype.set_tab_index = function(el) {
974
- var ti;
975
- if (this.form_field_jq.attr("tabindex")) {
976
- ti = this.form_field_jq.attr("tabindex");
977
- this.form_field_jq.attr("tabindex", -1);
978
- if (this.is_multiple) {
979
- return this.search_field.attr("tabindex", ti);
980
- } else {
981
- this.selected_item.attr("tabindex", ti);
982
- return this.search_field.attr("tabindex", -1);
983
- }
984
- }
985
- };
986
- Chosen.prototype.show_search_field_default = function() {
987
- if (this.is_multiple && this.choices < 1 && !this.active_field) {
988
- this.search_field.val(this.default_text);
989
- return this.search_field.addClass("default");
990
- } else {
991
- this.search_field.val("");
992
- return this.search_field.removeClass("default");
993
- }
994
- };
995
- Chosen.prototype.search_results_mouseup = function(evt) {
996
- var target;
997
- target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
998
- if (target.length) {
999
- this.result_highlight = target;
1000
- return this.result_select(evt);
1001
- }
1002
- };
1003
- Chosen.prototype.search_results_mouseover = function(evt) {
1004
- var target;
1005
- target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
1006
- if (target) {
1007
- return this.result_do_highlight(target);
1008
- }
1009
- };
1010
- Chosen.prototype.search_results_mouseout = function(evt) {
1011
- if ($(evt.target).hasClass("active-result" || $(evt.target).parents('.active-result').first())) {
1012
- return this.result_clear_highlight();
1013
- }
1014
- };
1015
- Chosen.prototype.choices_click = function(evt) {
1016
- evt.preventDefault();
1017
- if (this.active_field && !($(evt.target).hasClass("search-choice" || $(evt.target).parents('.search-choice').first)) && !this.results_showing) {
1018
- return this.results_show();
1019
- }
1020
- };
1021
- Chosen.prototype.choice_append = function(text, value) {
1022
- var i, item, opt, result, txt, val, _i, _len, _len2, _ref, _ref2;
1023
- txt = text != null ? text : $.trim(this.search_field.val());
1024
- val = value != null ? value : txt;
1025
- if (txt.length < 1 || val.length < 1) {
1026
- return this.results_hide();
1027
- }
1028
- _ref = this.form_field.options;
1029
- for (i = 0, _len = _ref.length; i < _len; i++) {
1030
- opt = _ref[i];
1031
- if (opt.value === val) {
1032
- if (opt.selected) {
1033
- return this.results_hide();
1034
- } else {
1035
- break;
1036
- }
1037
- }
1038
- }
1039
- _ref2 = this.results_data;
1040
- for (_i = 0, _len2 = _ref2.length; _i < _len2; _i++) {
1041
- result = _ref2[_i];
1042
- if (result.value === val) {
1043
- result.selected = true;
1044
- break;
1045
- }
1046
- }
1047
- if (i === this.form_field.length) {
1048
- this.form_field.options[i] = new Option(txt, val);
1049
- }
1050
- this.form_field.options[i].selected = true;
1051
- item = {
1052
- array_index: i,
1053
- options_index: i,
1054
- value: val,
1055
- text: txt,
1056
- html: txt,
1057
- selected: 1,
1058
- disabled: 0,
1059
- group_array_index: null
1060
- };
1061
- this.choice_build(item);
1062
- this.results_hide();
1063
- this.search_field.val("");
1064
- this.form_field_jq.trigger("change");
1065
- return this.search_field_scale();
1066
- };
1067
- Chosen.prototype.choice_build = function(item) {
1068
- var choice_id, link;
1069
- choice_id = this.container_id + "_c_" + item.array_index;
1070
- this.choices += 1;
1071
- this.search_container.before('<li class="search-choice" id="' + choice_id + '"><span>' + item.html + '</span><a href="javascript:void(0)" class="search-choice-close" rel="' + item.array_index + '"></a></li>');
1072
- link = $('#' + choice_id).find("a").first();
1073
- return link.click(__bind(function(evt) {
1074
- return this.choice_destroy_link_click(evt);
1075
- }, this));
1076
- };
1077
- Chosen.prototype.choice_destroy_link_click = function(evt) {
1078
- evt.preventDefault();
1079
- if (!this.is_disabled) {
1080
- this.pending_destroy_click = true;
1081
- return this.choice_destroy($(evt.target));
1082
- } else {
1083
- return evt.stopPropagation;
1084
- }
1085
- };
1086
- Chosen.prototype.choice_destroy = function(link) {
1087
- this.choices -= 1;
1088
- this.show_search_field_default();
1089
- if (this.is_multiple && this.choices > 0 && this.search_field.val().length < 1) {
1090
- this.results_hide();
1091
- }
1092
- this.result_deselect(link.attr("rel"));
1093
- return link.parents('li').first().remove();
1094
- };
1095
- Chosen.prototype.results_reset = function(evt) {
1096
- this.form_field.options[0].selected = true;
1097
- this.selected_item.find("span").text(this.default_text);
1098
- this.show_search_field_default();
1099
- $(evt.target).remove();
1100
- this.form_field_jq.trigger("change");
1101
- if (this.active_field) {
1102
- return this.results_hide();
1103
- }
1104
- };
1105
- Chosen.prototype.result_select = function(evt) {
1106
- var high, high_id, item, position;
1107
- if (this.result_highlight) {
1108
- high = this.result_highlight;
1109
- high_id = high.attr("id");
1110
- this.result_clear_highlight();
1111
- if (this.is_multiple) {
1112
- this.result_deactivate(high);
1113
- } else {
1114
- this.search_results.find(".result-selected").removeClass("result-selected");
1115
- this.result_single_selected = high;
1116
- }
1117
- high.addClass("result-selected");
1118
- position = high_id.substr(high_id.lastIndexOf("_") + 1);
1119
- item = this.results_data[position];
1120
- item.selected = true;
1121
- if (this.is_tag) {
1122
- this.choice_append(item.text, item.value);
1123
- } else {
1124
- this.form_field.options[item.options_index].selected = true;
1125
- if (this.is_multiple) {
1126
- this.choice_build(item);
1127
- } else {
1128
- this.selected_item.find("span").first().text(item.text);
1129
- if (this.allow_single_deselect) {
1130
- this.selected_item.find("span").first().after("<abbr class=\"search-choice-close\"></abbr>");
1131
- }
1132
- }
1133
- }
1134
- if (!(evt.metaKey && this.is_multiple)) {
1135
- this.results_hide();
1136
- }
1137
- this.search_field.val("");
1138
- this.form_field_jq.trigger("change");
1139
- return this.search_field_scale();
1140
- }
1141
- };
1142
- Chosen.prototype.result_activate = function(el) {
1143
- return el.addClass("active-result");
1144
- };
1145
- Chosen.prototype.result_deactivate = function(el) {
1146
- return el.removeClass("active-result");
1147
- };
1148
- Chosen.prototype.result_deselect = function(pos) {
1149
- var result, result_data;
1150
- if (this.is_tag) {
1151
- this.form_field.options[pos].selected = false;
1152
- } else {
1153
- result_data = this.results_data[pos];
1154
- result_data.selected = false;
1155
- this.form_field.options[result_data.options_index].selected = false;
1156
- }
1157
- result = $("#" + this.container_id + "_o_" + pos);
1158
- result.removeClass("result-selected").addClass("active-result").show();
1159
- this.result_clear_highlight();
1160
- this.winnow_results();
1161
- this.form_field_jq.trigger("change");
1162
- return this.search_field_scale();
1163
- };
1164
- Chosen.prototype.winnow_results = function() {
1165
- var found, option, part, parts, regex, result_id, results, searchText, startTime, startpos, text, zregex, _i, _j, _len, _len2, _ref;
1166
- startTime = new Date();
1167
- this.no_results_clear();
1168
- results = 0;
1169
- searchText = this.search_field.val() === this.default_text ? "" : $('<div/>').text($.trim(this.search_field.val())).html();
1170
- regex = new RegExp('^' + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
1171
- zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
1172
- _ref = this.results_data;
1173
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
1174
- option = _ref[_i];
1175
- if (!option.disabled && !option.empty) {
1176
- if (option.group) {
1177
- $('#' + option.dom_id).hide();
1178
- } else if (!(this.is_multiple && option.selected)) {
1179
- found = false;
1180
- result_id = option.dom_id;
1181
- if (regex.test(option.html)) {
1182
- found = true;
1183
- results += 1;
1184
- } else if (option.html.indexOf(" ") >= 0 || option.html.indexOf("[") === 0) {
1185
- parts = option.html.replace(/\[|\]/g, "").split(" ");
1186
- if (parts.length) {
1187
- for (_j = 0, _len2 = parts.length; _j < _len2; _j++) {
1188
- part = parts[_j];
1189
- if (regex.test(part)) {
1190
- found = true;
1191
- results += 1;
1192
- }
1193
- }
1194
- }
1195
- }
1196
- if (found) {
1197
- if (searchText.length) {
1198
- startpos = option.html.search(zregex);
1199
- text = option.html.substr(0, startpos + searchText.length) + '</em>' + option.html.substr(startpos + searchText.length);
1200
- text = text.substr(0, startpos) + '<em>' + text.substr(startpos);
1201
- } else {
1202
- text = option.html;
1203
- }
1204
- if ($("#" + result_id).html !== text) {
1205
- $("#" + result_id).html(text);
1206
- }
1207
- this.result_activate($("#" + result_id));
1208
- if (option.group_array_index != null) {
1209
- $("#" + this.results_data[option.group_array_index].dom_id).show();
1210
- }
1211
- } else {
1212
- if (this.result_highlight && result_id === this.result_highlight.attr('id')) {
1213
- this.result_clear_highlight();
1214
- }
1215
- this.result_deactivate($("#" + result_id));
1216
- }
1217
- }
1218
- }
1219
- }
1220
- if (results < 1 && searchText.length) {
1221
- return this.no_results(searchText);
1222
- } else {
1223
- return this.winnow_results_set_highlight();
1224
- }
1225
- };
1226
- Chosen.prototype.winnow_results_clear = function() {
1227
- var li, lis, _i, _len, _results;
1228
- this.search_field.val("");
1229
- lis = this.search_results.find("li");
1230
- _results = [];
1231
- for (_i = 0, _len = lis.length; _i < _len; _i++) {
1232
- li = lis[_i];
1233
- li = $(li);
1234
- _results.push(li.hasClass("group-result") ? li.show() : !this.is_multiple || !li.hasClass("result-selected") ? this.result_activate(li) : void 0);
1235
- }
1236
- return _results;
1237
- };
1238
- Chosen.prototype.winnow_results_set_highlight = function() {
1239
- var do_high, selected_results;
1240
- if (!this.result_highlight) {
1241
- selected_results = !this.is_multiple ? this.search_results.find(".result-selected.active-result") : [];
1242
- do_high = selected_results.length ? selected_results.first() : this.search_results.find(".active-result").first();
1243
- if (do_high != null) {
1244
- return this.result_do_highlight(do_high);
1245
- }
1246
- }
1247
- };
1248
- Chosen.prototype.no_results = function(terms) {
1249
- var no_results_html;
1250
- if (this.is_tag) {
1251
- return this.results_hide();
1252
- }
1253
- no_results_html = $('<li class="no-results">' + this.results_none_found + ' "<span></span>"</li>');
1254
- no_results_html.find("span").first().html(terms);
1255
- return this.search_results.append(no_results_html);
1256
- };
1257
- Chosen.prototype.no_results_clear = function() {
1258
- return this.search_results.find(".no-results").remove();
1259
- };
1260
- Chosen.prototype.keydown_arrow = function() {
1261
- var first_active, next_sib;
1262
- if (!this.result_highlight) {
1263
- first_active = this.search_results.find("li.active-result").first();
1264
- if (first_active) {
1265
- this.result_do_highlight($(first_active));
1266
- }
1267
- } else if (this.results_showing) {
1268
- next_sib = this.result_highlight.nextAll("li.active-result").first();
1269
- if (next_sib) {
1270
- this.result_do_highlight(next_sib);
1271
- }
1272
- }
1273
- if (!this.results_showing) {
1274
- return this.results_show();
1275
- }
1276
- };
1277
- Chosen.prototype.keyup_arrow = function() {
1278
- var prev_sibs;
1279
- if (!this.results_showing && !this.is_multiple) {
1280
- return this.results_show();
1281
- } else if (this.result_highlight) {
1282
- prev_sibs = this.result_highlight.prevAll("li.active-result");
1283
- if (prev_sibs.length) {
1284
- return this.result_do_highlight(prev_sibs.first());
1285
- } else {
1286
- if (this.choices > 0) {
1287
- this.results_hide();
1288
- }
1289
- return this.result_clear_highlight();
1290
- }
1291
- }
1292
- };
1293
- Chosen.prototype.keydown_backstroke = function() {
1294
- if (this.pending_backstroke) {
1295
- this.choice_destroy(this.pending_backstroke.find("a").first());
1296
- return this.clear_backstroke();
1297
- } else {
1298
- this.pending_backstroke = this.search_container.siblings("li.search-choice").last();
1299
- return this.pending_backstroke.addClass("search-choice-focus");
1300
- }
1301
- };
1302
- Chosen.prototype.clear_backstroke = function() {
1303
- if (this.pending_backstroke) {
1304
- this.pending_backstroke.removeClass("search-choice-focus");
1305
- }
1306
- return this.pending_backstroke = null;
1307
- };
1308
- Chosen.prototype.keydown_checker = function(evt) {
1309
- var stroke, _ref;
1310
- stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
1311
- this.search_field_scale();
1312
- if (stroke !== 8 && this.pending_backstroke) {
1313
- this.clear_backstroke();
1314
- }
1315
- switch (stroke) {
1316
- case 8:
1317
- this.backstroke_length = this.search_field.val().length;
1318
- break;
1319
- case 9:
1320
- this.mouse_on_container = false;
1321
- break;
1322
- case 13:
1323
- evt.preventDefault();
1324
- break;
1325
- case 38:
1326
- evt.preventDefault();
1327
- this.keyup_arrow();
1328
- break;
1329
- case 40:
1330
- this.keydown_arrow();
1331
- break;
1332
- }
1333
- };
1334
- Chosen.prototype.search_field_scale = function() {
1335
- var dd_top, div, h, style, style_block, styles, w, _i, _len;
1336
- if (this.is_multiple) {
1337
- h = 0;
1338
- w = 0;
1339
- style_block = "position:absolute; left: -1000px; top: -1000px; display:none;";
1340
- styles = ['font-size', 'font-style', 'font-weight', 'font-family', 'line-height', 'text-transform', 'letter-spacing'];
1341
- for (_i = 0, _len = styles.length; _i < _len; _i++) {
1342
- style = styles[_i];
1343
- style_block += style + ":" + this.search_field.css(style) + ";";
1344
- }
1345
- div = $('<div />', {
1346
- 'style': style_block
1347
- });
1348
- div.text(this.search_field.val());
1349
- $('body').append(div);
1350
- w = div.width() + 25;
1351
- div.remove();
1352
- if (w > this.f_width - 10) {
1353
- w = this.f_width - 10;
1354
- }
1355
- this.search_field.css({
1356
- 'width': w + 'px'
1357
- });
1358
- dd_top = this.container.height();
1359
- return this.dropdown.css({
1360
- "top": dd_top + "px"
1361
- });
1362
- }
1363
- };
1364
- Chosen.prototype.generate_random_id = function() {
1365
- var string;
1366
- string = "sel" + this.generate_random_char() + this.generate_random_char() + this.generate_random_char();
1367
- while ($("#" + string).length > 0) {
1368
- string += this.generate_random_char();
1369
- }
1370
- return string;
1371
- };
1372
- return Chosen;
1373
- })();
1374
- get_side_border_padding = function(elmt) {
1375
- var side_border_padding;
1376
- return side_border_padding = elmt.outerWidth() - elmt.width();
1377
- };
1378
- root.get_side_border_padding = get_side_border_padding;
1379
- }).call(this);
1380
- // This is a manifest file that'll be compiled into including all the files listed below.
1381
- // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
1382
- // be included in the compiled file accessible from http://example.com/assets/application.js
1383
- // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
1384
- // the compiled file.
1385
- //
1386
- ;
1387
- :@compressedF:@created_atf1318830254.8277481��