chosen_rails 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "rails", "3.1.0.rc4"
4
+ gem "capybara", "~> 1.0.0"
5
+ gem "sqlite3"
6
+
7
+ # Asset template engines
8
+ gem 'sprockets', '2.0.0.beta.10'
9
+ gem 'sass'
10
+ gem 'coffee-script'
11
+ gem 'uglifier'
12
+ gem 'nokogiri'
13
+
14
+ gem 'jquery-rails'
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "chosen_rails/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "chosen_rails"
7
+ s.version = ChosenRails::VERSION
8
+ s.authors = ["Sean Behan"]
9
+ s.email = ["bseanvt@gmail.com"]
10
+ s.homepage = "http://github.com/bseanvt/chosen_rails"
11
+ s.summary = %q{Chosen jQuery Plugin for Rails 3.1 Asset Pipeline}
12
+ s.description = %q{This plugin turns unsightly select boxes into pretty, searchable, drop down unordered list that you can style.}
13
+
14
+ s.rubyforge_project = "chosen_rails"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+ end
@@ -0,0 +1 @@
1
+ require 'chosen_rails/engine' if defined?(Rails && Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR >=1)
@@ -0,0 +1,7 @@
1
+ module ChosenRails
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ end
5
+ end
6
+ end
7
+
@@ -0,0 +1,3 @@
1
+ module ChosenRails
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,38 @@
1
+
2
+ # Chosen jQuery Plugin for Rails 3.1 Asset Pipeline
3
+ This plugin makes select boxes look nice. It also provides a search bar to sift through the collection.
4
+
5
+ # Install
6
+
7
+ ```ruby
8
+ # Add to Gemfile
9
+ gem 'chosen_rails'
10
+
11
+ # app/assets/javascripts/application.js
12
+ //= require jquery
13
+ //= require chosen
14
+
15
+ # app/assets/stylesheets/application.css
16
+ /*
17
+ *= require_self
18
+ *= require chosen
19
+ */
20
+
21
+ ```
22
+
23
+ # Usage
24
+
25
+ ```html
26
+ <select title="Choose a country..." id='form_field' style="width:350px;" multiple class="chzn-select">
27
+ <script>$("#form_field").chosen()</script>
28
+ ```
29
+ Demos and examples available here http://harvesthq.github.com/chosen/
30
+
31
+ # Credits
32
+ The jQuery was written and made available by the following folks.
33
+
34
+ Chosen jQuery Plugin is hosted on Github at https://github.com/harvesthq/chosen
35
+
36
+ Built by Harvest http://www.getharvest.com/
37
+ Concept and development by Patrick Filler http://www.patrickfiller.com/
38
+ Design and CSS by Matthew Lettini http://matthewlettini.com/
@@ -0,0 +1,794 @@
1
+ // Chosen, a Select Box Enhancer for jQuery and Protoype
2
+ // by Patrick Filler for Harvest, http://getharvest.com
3
+ //
4
+ // Version 0.9.1
5
+ // Full source at https://github.com/harvesthq/chosen
6
+ // Copyright (c) 2011 Harvest http://getharvest.com
7
+
8
+ // MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md
9
+ // This file is generated by `cake build`, do not edit it by hand.
10
+ (function() {
11
+ /*
12
+ Chosen source: generate output using 'cake build'
13
+ Copyright (c) 2011 by Harvest
14
+ */ var $, Chosen, get_side_border_padding, root;
15
+ var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
16
+ root = this;
17
+ $ = jQuery;
18
+ $.fn.extend({
19
+ chosen: function(data, options) {
20
+ if ($.browser === "msie" && ($.browser.version === "6.0" || $.browser.version === "7.0")) {
21
+ return this;
22
+ }
23
+ return $(this).each(function(input_field) {
24
+ if (!($(this)).hasClass("chzn-done")) {
25
+ return new Chosen(this, data, options);
26
+ }
27
+ });
28
+ }
29
+ });
30
+ Chosen = (function() {
31
+ function Chosen(elmn) {
32
+ this.set_default_values();
33
+ this.form_field = elmn;
34
+ this.form_field_jq = $(this.form_field);
35
+ this.is_multiple = this.form_field.multiple;
36
+ this.is_rtl = this.form_field_jq.hasClass("chzn-rtl");
37
+ this.default_text_default = this.form_field.multiple ? "Select Some Options" : "Select an Option";
38
+ this.set_up_html();
39
+ this.register_observers();
40
+ this.form_field_jq.addClass("chzn-done");
41
+ }
42
+ Chosen.prototype.set_default_values = function() {
43
+ this.click_test_action = __bind(function(evt) {
44
+ return this.test_active_click(evt);
45
+ }, this);
46
+ this.active_field = false;
47
+ this.mouse_on_container = false;
48
+ this.results_showing = false;
49
+ this.result_highlighted = null;
50
+ this.result_single_selected = null;
51
+ return this.choices = 0;
52
+ };
53
+ Chosen.prototype.set_up_html = function() {
54
+ var container_div, dd_top, dd_width, sf_width;
55
+ this.container_id = this.form_field.id.length ? this.form_field.id.replace(/(:|\.)/g, '_') : this.generate_field_id();
56
+ this.container_id += "_chzn";
57
+ this.f_width = this.form_field_jq.width();
58
+ this.default_text = this.form_field_jq.data('placeholder') ? this.form_field_jq.data('placeholder') : this.default_text_default;
59
+ container_div = $("<div />", {
60
+ id: this.container_id,
61
+ "class": "chzn-container " + (this.is_rtl ? 'chzn-rtl' : ''),
62
+ style: 'width: ' + this.f_width + 'px;'
63
+ });
64
+ if (this.is_multiple) {
65
+ 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>');
66
+ } else {
67
+ 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>');
68
+ }
69
+ this.form_field_jq.hide().after(container_div);
70
+ this.container = $('#' + this.container_id);
71
+ this.container.addClass("chzn-container-" + (this.is_multiple ? "multi" : "single"));
72
+ this.dropdown = this.container.find('div.chzn-drop').first();
73
+ dd_top = this.container.height();
74
+ dd_width = this.f_width - get_side_border_padding(this.dropdown);
75
+ this.dropdown.css({
76
+ "width": dd_width + "px",
77
+ "top": dd_top + "px"
78
+ });
79
+ this.search_field = this.container.find('input').first();
80
+ this.search_results = this.container.find('ul.chzn-results').first();
81
+ this.search_field_scale();
82
+ this.search_no_results = this.container.find('li.no-results').first();
83
+ if (this.is_multiple) {
84
+ this.search_choices = this.container.find('ul.chzn-choices').first();
85
+ this.search_container = this.container.find('li.search-field').first();
86
+ } else {
87
+ this.search_container = this.container.find('div.chzn-search').first();
88
+ this.selected_item = this.container.find('.chzn-single').first();
89
+ sf_width = dd_width - get_side_border_padding(this.search_container) - get_side_border_padding(this.search_field);
90
+ this.search_field.css({
91
+ "width": sf_width + "px"
92
+ });
93
+ }
94
+ this.results_build();
95
+ return this.set_tab_index();
96
+ };
97
+ Chosen.prototype.register_observers = function() {
98
+ this.container.mousedown(__bind(function(evt) {
99
+ return this.container_mousedown(evt);
100
+ }, this));
101
+ this.container.mouseenter(__bind(function(evt) {
102
+ return this.mouse_enter(evt);
103
+ }, this));
104
+ this.container.mouseleave(__bind(function(evt) {
105
+ return this.mouse_leave(evt);
106
+ }, this));
107
+ this.search_results.mouseup(__bind(function(evt) {
108
+ return this.search_results_mouseup(evt);
109
+ }, this));
110
+ this.search_results.mouseover(__bind(function(evt) {
111
+ return this.search_results_mouseover(evt);
112
+ }, this));
113
+ this.search_results.mouseout(__bind(function(evt) {
114
+ return this.search_results_mouseout(evt);
115
+ }, this));
116
+ this.form_field_jq.bind("liszt:updated", __bind(function(evt) {
117
+ return this.results_update_field(evt);
118
+ }, this));
119
+ this.search_field.blur(__bind(function(evt) {
120
+ return this.input_blur(evt);
121
+ }, this));
122
+ this.search_field.keyup(__bind(function(evt) {
123
+ return this.keyup_checker(evt);
124
+ }, this));
125
+ this.search_field.keydown(__bind(function(evt) {
126
+ return this.keydown_checker(evt);
127
+ }, this));
128
+ if (this.is_multiple) {
129
+ this.search_choices.click(__bind(function(evt) {
130
+ return this.choices_click(evt);
131
+ }, this));
132
+ return this.search_field.focus(__bind(function(evt) {
133
+ return this.input_focus(evt);
134
+ }, this));
135
+ } else {
136
+ return this.selected_item.focus(__bind(function(evt) {
137
+ return this.activate_field(evt);
138
+ }, this));
139
+ }
140
+ };
141
+ Chosen.prototype.container_mousedown = function(evt) {
142
+ if (evt && evt.type === "mousedown") {
143
+ evt.stopPropagation();
144
+ }
145
+ if (!this.pending_destroy_click) {
146
+ if (!this.active_field) {
147
+ if (this.is_multiple) {
148
+ this.search_field.val("");
149
+ }
150
+ $(document).click(this.click_test_action);
151
+ this.results_show();
152
+ } else if (!this.is_multiple && evt && ($(evt.target) === this.selected_item || $(evt.target).parents("a.chzn-single").length)) {
153
+ evt.preventDefault();
154
+ this.results_toggle();
155
+ }
156
+ return this.activate_field();
157
+ } else {
158
+ return this.pending_destroy_click = false;
159
+ }
160
+ };
161
+ Chosen.prototype.mouse_enter = function() {
162
+ return this.mouse_on_container = true;
163
+ };
164
+ Chosen.prototype.mouse_leave = function() {
165
+ return this.mouse_on_container = false;
166
+ };
167
+ Chosen.prototype.input_focus = function(evt) {
168
+ if (!this.active_field) {
169
+ return setTimeout((__bind(function() {
170
+ return this.container_mousedown();
171
+ }, this)), 50);
172
+ }
173
+ };
174
+ Chosen.prototype.input_blur = function(evt) {
175
+ if (!this.mouse_on_container) {
176
+ this.active_field = false;
177
+ return setTimeout((__bind(function() {
178
+ return this.blur_test();
179
+ }, this)), 100);
180
+ }
181
+ };
182
+ Chosen.prototype.blur_test = function(evt) {
183
+ if (!this.active_field && this.container.hasClass("chzn-container-active")) {
184
+ return this.close_field();
185
+ }
186
+ };
187
+ Chosen.prototype.close_field = function() {
188
+ $(document).unbind("click", this.click_test_action);
189
+ if (!this.is_multiple) {
190
+ this.selected_item.attr("tabindex", this.search_field.attr("tabindex"));
191
+ this.search_field.attr("tabindex", -1);
192
+ }
193
+ this.active_field = false;
194
+ this.results_hide();
195
+ this.container.removeClass("chzn-container-active");
196
+ this.winnow_results_clear();
197
+ this.clear_backstroke();
198
+ this.show_search_field_default();
199
+ return this.search_field_scale();
200
+ };
201
+ Chosen.prototype.activate_field = function() {
202
+ if (!this.is_multiple && !this.active_field) {
203
+ this.search_field.attr("tabindex", this.selected_item.attr("tabindex"));
204
+ this.selected_item.attr("tabindex", -1);
205
+ }
206
+ this.container.addClass("chzn-container-active");
207
+ this.active_field = true;
208
+ this.search_field.val(this.search_field.val());
209
+ return this.search_field.focus();
210
+ };
211
+ Chosen.prototype.test_active_click = function(evt) {
212
+ if ($(evt.target).parents('#' + this.container_id).length) {
213
+ return this.active_field = true;
214
+ } else {
215
+ return this.close_field();
216
+ }
217
+ };
218
+ Chosen.prototype.results_build = function() {
219
+ var content, data, startTime, _i, _len, _ref;
220
+ startTime = new Date();
221
+ this.parsing = true;
222
+ this.results_data = root.SelectParser.select_to_array(this.form_field);
223
+ if (this.is_multiple && this.choices > 0) {
224
+ this.search_choices.find("li.search-choice").remove();
225
+ this.choices = 0;
226
+ } else if (!this.is_multiple) {
227
+ this.selected_item.find("span").text(this.default_text);
228
+ }
229
+ content = '';
230
+ _ref = this.results_data;
231
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
232
+ data = _ref[_i];
233
+ if (data.group) {
234
+ content += this.result_add_group(data);
235
+ } else if (!data.empty) {
236
+ content += this.result_add_option(data);
237
+ if (data.selected && this.is_multiple) {
238
+ this.choice_build(data);
239
+ } else if (data.selected && !this.is_multiple) {
240
+ this.selected_item.find("span").text(data.text);
241
+ }
242
+ }
243
+ }
244
+ this.show_search_field_default();
245
+ this.search_field_scale();
246
+ this.search_results.html(content);
247
+ return this.parsing = false;
248
+ };
249
+ Chosen.prototype.result_add_group = function(group) {
250
+ if (!group.disabled) {
251
+ group.dom_id = this.container_id + "_g_" + group.array_index;
252
+ return '<li id="' + group.dom_id + '" class="group-result">' + $("<div />").text(group.label).html() + '</li>';
253
+ } else {
254
+ return "";
255
+ }
256
+ };
257
+ Chosen.prototype.result_add_option = function(option) {
258
+ var classes;
259
+ if (!option.disabled) {
260
+ option.dom_id = this.container_id + "_o_" + option.array_index;
261
+ classes = option.selected && this.is_multiple ? [] : ["active-result"];
262
+ if (option.selected) {
263
+ classes.push("result-selected");
264
+ }
265
+ if (option.group_array_index != null) {
266
+ classes.push("group-option");
267
+ }
268
+ return '<li id="' + option.dom_id + '" class="' + classes.join(' ') + '">' + option.html + '</li>';
269
+ } else {
270
+ return "";
271
+ }
272
+ };
273
+ Chosen.prototype.results_update_field = function() {
274
+ this.result_clear_highlight();
275
+ this.result_single_selected = null;
276
+ return this.results_build();
277
+ };
278
+ Chosen.prototype.result_do_highlight = function(el) {
279
+ var high_bottom, high_top, maxHeight, visible_bottom, visible_top;
280
+ if (el.length) {
281
+ this.result_clear_highlight();
282
+ this.result_highlight = el;
283
+ this.result_highlight.addClass("highlighted");
284
+ maxHeight = parseInt(this.search_results.css("maxHeight"), 10);
285
+ visible_top = this.search_results.scrollTop();
286
+ visible_bottom = maxHeight + visible_top;
287
+ high_top = this.result_highlight.position().top + this.search_results.scrollTop();
288
+ high_bottom = high_top + this.result_highlight.outerHeight();
289
+ if (high_bottom >= visible_bottom) {
290
+ return this.search_results.scrollTop((high_bottom - maxHeight) > 0 ? high_bottom - maxHeight : 0);
291
+ } else if (high_top < visible_top) {
292
+ return this.search_results.scrollTop(high_top);
293
+ }
294
+ }
295
+ };
296
+ Chosen.prototype.result_clear_highlight = function() {
297
+ if (this.result_highlight) {
298
+ this.result_highlight.removeClass("highlighted");
299
+ }
300
+ return this.result_highlight = null;
301
+ };
302
+ Chosen.prototype.results_toggle = function() {
303
+ if (this.results_showing) {
304
+ return this.results_hide();
305
+ } else {
306
+ return this.results_show();
307
+ }
308
+ };
309
+ Chosen.prototype.results_show = function() {
310
+ var dd_top;
311
+ if (!this.is_multiple) {
312
+ this.selected_item.addClass("chzn-single-with-drop");
313
+ if (this.result_single_selected) {
314
+ this.result_do_highlight(this.result_single_selected);
315
+ }
316
+ }
317
+ dd_top = this.is_multiple ? this.container.height() : this.container.height() - 1;
318
+ this.dropdown.css({
319
+ "top": dd_top + "px",
320
+ "left": 0
321
+ });
322
+ this.results_showing = true;
323
+ this.search_field.focus();
324
+ this.search_field.val(this.search_field.val());
325
+ return this.winnow_results();
326
+ };
327
+ Chosen.prototype.results_hide = function() {
328
+ if (!this.is_multiple) {
329
+ this.selected_item.removeClass("chzn-single-with-drop");
330
+ }
331
+ this.result_clear_highlight();
332
+ this.dropdown.css({
333
+ "left": "-9000px"
334
+ });
335
+ return this.results_showing = false;
336
+ };
337
+ Chosen.prototype.set_tab_index = function(el) {
338
+ var ti;
339
+ if (this.form_field_jq.attr("tabindex")) {
340
+ ti = this.form_field_jq.attr("tabindex");
341
+ this.form_field_jq.attr("tabindex", -1);
342
+ if (this.is_multiple) {
343
+ return this.search_field.attr("tabindex", ti);
344
+ } else {
345
+ this.selected_item.attr("tabindex", ti);
346
+ return this.search_field.attr("tabindex", -1);
347
+ }
348
+ }
349
+ };
350
+ Chosen.prototype.show_search_field_default = function() {
351
+ if (this.is_multiple && this.choices < 1 && !this.active_field) {
352
+ this.search_field.val(this.default_text);
353
+ return this.search_field.addClass("default");
354
+ } else {
355
+ this.search_field.val("");
356
+ return this.search_field.removeClass("default");
357
+ }
358
+ };
359
+ Chosen.prototype.search_results_mouseup = function(evt) {
360
+ var target;
361
+ target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
362
+ if (target.length) {
363
+ this.result_highlight = target;
364
+ return this.result_select(evt);
365
+ }
366
+ };
367
+ Chosen.prototype.search_results_mouseover = function(evt) {
368
+ var target;
369
+ target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
370
+ if (target) {
371
+ return this.result_do_highlight(target);
372
+ }
373
+ };
374
+ Chosen.prototype.search_results_mouseout = function(evt) {
375
+ if ($(evt.target).hasClass("active-result" || $(evt.target).parents('.active-result').first())) {
376
+ return this.result_clear_highlight();
377
+ }
378
+ };
379
+ Chosen.prototype.choices_click = function(evt) {
380
+ evt.preventDefault();
381
+ if (this.active_field && !($(evt.target).hasClass("search-choice" || $(evt.target).parents('.search-choice').first)) && !this.results_showing) {
382
+ return this.results_show();
383
+ }
384
+ };
385
+ Chosen.prototype.choice_build = function(item) {
386
+ var choice_id, link;
387
+ choice_id = this.container_id + "_c_" + item.array_index;
388
+ this.choices += 1;
389
+ 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>');
390
+ link = $('#' + choice_id).find("a").first();
391
+ return link.click(__bind(function(evt) {
392
+ return this.choice_destroy_link_click(evt);
393
+ }, this));
394
+ };
395
+ Chosen.prototype.choice_destroy_link_click = function(evt) {
396
+ evt.preventDefault();
397
+ this.pending_destroy_click = true;
398
+ return this.choice_destroy($(evt.target));
399
+ };
400
+ Chosen.prototype.choice_destroy = function(link) {
401
+ this.choices -= 1;
402
+ this.show_search_field_default();
403
+ if (this.is_multiple && this.choices > 0 && this.search_field.val().length < 1) {
404
+ this.results_hide();
405
+ }
406
+ this.result_deselect(link.attr("rel"));
407
+ return link.parents('li').first().remove();
408
+ };
409
+ Chosen.prototype.result_select = function(evt) {
410
+ var high, high_id, item, position;
411
+ if (this.result_highlight) {
412
+ high = this.result_highlight;
413
+ high_id = high.attr("id");
414
+ this.result_clear_highlight();
415
+ high.addClass("result-selected");
416
+ if (this.is_multiple) {
417
+ this.result_deactivate(high);
418
+ } else {
419
+ this.result_single_selected = high;
420
+ }
421
+ position = high_id.substr(high_id.lastIndexOf("_") + 1);
422
+ item = this.results_data[position];
423
+ item.selected = true;
424
+ this.form_field.options[item.options_index].selected = true;
425
+ if (this.is_multiple) {
426
+ this.choice_build(item);
427
+ } else {
428
+ this.selected_item.find("span").first().text(item.text);
429
+ }
430
+ if (!(evt.metaKey && this.is_multiple)) {
431
+ this.results_hide();
432
+ }
433
+ this.search_field.val("");
434
+ this.form_field_jq.trigger("change");
435
+ return this.search_field_scale();
436
+ }
437
+ };
438
+ Chosen.prototype.result_activate = function(el) {
439
+ return el.addClass("active-result").show();
440
+ };
441
+ Chosen.prototype.result_deactivate = function(el) {
442
+ return el.removeClass("active-result").hide();
443
+ };
444
+ Chosen.prototype.result_deselect = function(pos) {
445
+ var result, result_data;
446
+ result_data = this.results_data[pos];
447
+ result_data.selected = false;
448
+ this.form_field.options[result_data.options_index].selected = false;
449
+ result = $("#" + this.container_id + "_o_" + pos);
450
+ result.removeClass("result-selected").addClass("active-result").show();
451
+ this.result_clear_highlight();
452
+ this.winnow_results();
453
+ this.form_field_jq.trigger("change");
454
+ return this.search_field_scale();
455
+ };
456
+ Chosen.prototype.results_search = function(evt) {
457
+ if (this.results_showing) {
458
+ return this.winnow_results();
459
+ } else {
460
+ return this.results_show();
461
+ }
462
+ };
463
+ Chosen.prototype.winnow_results = function() {
464
+ var found, option, part, parts, regex, result_id, results, searchText, startTime, startpos, text, zregex, _i, _j, _len, _len2, _ref;
465
+ startTime = new Date();
466
+ this.no_results_clear();
467
+ results = 0;
468
+ searchText = this.search_field.val() === this.default_text ? "" : $('<div/>').text($.trim(this.search_field.val())).html();
469
+ regex = new RegExp('^' + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
470
+ zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
471
+ _ref = this.results_data;
472
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
473
+ option = _ref[_i];
474
+ if (!option.disabled && !option.empty) {
475
+ if (option.group) {
476
+ $('#' + option.dom_id).hide();
477
+ } else if (!(this.is_multiple && option.selected)) {
478
+ found = false;
479
+ result_id = option.dom_id;
480
+ if (regex.test(option.html)) {
481
+ found = true;
482
+ results += 1;
483
+ } else if (option.html.indexOf(" ") >= 0 || option.html.indexOf("[") === 0) {
484
+ parts = option.html.replace(/\[|\]/g, "").split(" ");
485
+ if (parts.length) {
486
+ for (_j = 0, _len2 = parts.length; _j < _len2; _j++) {
487
+ part = parts[_j];
488
+ if (regex.test(part)) {
489
+ found = true;
490
+ results += 1;
491
+ }
492
+ }
493
+ }
494
+ }
495
+ if (found) {
496
+ if (searchText.length) {
497
+ startpos = option.html.search(zregex);
498
+ text = option.html.substr(0, startpos + searchText.length) + '</em>' + option.html.substr(startpos + searchText.length);
499
+ text = text.substr(0, startpos) + '<em>' + text.substr(startpos);
500
+ } else {
501
+ text = option.html;
502
+ }
503
+ if ($("#" + result_id).html !== text) {
504
+ $("#" + result_id).html(text);
505
+ }
506
+ this.result_activate($("#" + result_id));
507
+ if (option.group_array_index != null) {
508
+ $("#" + this.results_data[option.group_array_index].dom_id).show();
509
+ }
510
+ } else {
511
+ if (this.result_highlight && result_id === this.result_highlight.attr('id')) {
512
+ this.result_clear_highlight();
513
+ }
514
+ this.result_deactivate($("#" + result_id));
515
+ }
516
+ }
517
+ }
518
+ }
519
+ if (results < 1 && searchText.length) {
520
+ return this.no_results(searchText);
521
+ } else {
522
+ return this.winnow_results_set_highlight();
523
+ }
524
+ };
525
+ Chosen.prototype.winnow_results_clear = function() {
526
+ var li, lis, _i, _len, _results;
527
+ this.search_field.val("");
528
+ lis = this.search_results.find("li");
529
+ _results = [];
530
+ for (_i = 0, _len = lis.length; _i < _len; _i++) {
531
+ li = lis[_i];
532
+ li = $(li);
533
+ _results.push(li.hasClass("group-result") ? li.show() : !this.is_multiple || !li.hasClass("result-selected") ? this.result_activate(li) : void 0);
534
+ }
535
+ return _results;
536
+ };
537
+ Chosen.prototype.winnow_results_set_highlight = function() {
538
+ var do_high, selected_results;
539
+ if (!this.result_highlight) {
540
+ selected_results = !this.is_multiple ? this.search_results.find(".result-selected") : [];
541
+ do_high = selected_results.length ? selected_results.first() : this.search_results.find(".active-result").first();
542
+ if (do_high != null) {
543
+ return this.result_do_highlight(do_high);
544
+ }
545
+ }
546
+ };
547
+ Chosen.prototype.no_results = function(terms) {
548
+ var no_results_html;
549
+ no_results_html = $('<li class="no-results">No results match "<span></span>"</li>');
550
+ no_results_html.find("span").first().html(terms);
551
+ return this.search_results.append(no_results_html);
552
+ };
553
+ Chosen.prototype.no_results_clear = function() {
554
+ return this.search_results.find(".no-results").remove();
555
+ };
556
+ Chosen.prototype.keydown_arrow = function() {
557
+ var first_active, next_sib;
558
+ if (!this.result_highlight) {
559
+ first_active = this.search_results.find("li.active-result").first();
560
+ if (first_active) {
561
+ this.result_do_highlight($(first_active));
562
+ }
563
+ } else if (this.results_showing) {
564
+ next_sib = this.result_highlight.nextAll("li.active-result").first();
565
+ if (next_sib) {
566
+ this.result_do_highlight(next_sib);
567
+ }
568
+ }
569
+ if (!this.results_showing) {
570
+ return this.results_show();
571
+ }
572
+ };
573
+ Chosen.prototype.keyup_arrow = function() {
574
+ var prev_sibs;
575
+ if (!this.results_showing && !this.is_multiple) {
576
+ return this.results_show();
577
+ } else if (this.result_highlight) {
578
+ prev_sibs = this.result_highlight.prevAll("li.active-result");
579
+ if (prev_sibs.length) {
580
+ return this.result_do_highlight(prev_sibs.first());
581
+ } else {
582
+ if (this.choices > 0) {
583
+ this.results_hide();
584
+ }
585
+ return this.result_clear_highlight();
586
+ }
587
+ }
588
+ };
589
+ Chosen.prototype.keydown_backstroke = function() {
590
+ if (this.pending_backstroke) {
591
+ this.choice_destroy(this.pending_backstroke.find("a").first());
592
+ return this.clear_backstroke();
593
+ } else {
594
+ this.pending_backstroke = this.search_container.siblings("li.search-choice").last();
595
+ return this.pending_backstroke.addClass("search-choice-focus");
596
+ }
597
+ };
598
+ Chosen.prototype.clear_backstroke = function() {
599
+ if (this.pending_backstroke) {
600
+ this.pending_backstroke.removeClass("search-choice-focus");
601
+ }
602
+ return this.pending_backstroke = null;
603
+ };
604
+ Chosen.prototype.keyup_checker = function(evt) {
605
+ var stroke, _ref;
606
+ stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
607
+ this.search_field_scale();
608
+ switch (stroke) {
609
+ case 8:
610
+ if (this.is_multiple && this.backstroke_length < 1 && this.choices > 0) {
611
+ return this.keydown_backstroke();
612
+ } else if (!this.pending_backstroke) {
613
+ this.result_clear_highlight();
614
+ return this.results_search();
615
+ }
616
+ break;
617
+ case 13:
618
+ evt.preventDefault();
619
+ if (this.results_showing) {
620
+ return this.result_select(evt);
621
+ }
622
+ break;
623
+ case 27:
624
+ if (this.results_showing) {
625
+ return this.results_hide();
626
+ }
627
+ break;
628
+ case 9:
629
+ case 38:
630
+ case 40:
631
+ case 16:
632
+ case 91:
633
+ case 17:
634
+ break;
635
+ default:
636
+ return this.results_search();
637
+ }
638
+ };
639
+ Chosen.prototype.keydown_checker = function(evt) {
640
+ var stroke, _ref;
641
+ stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
642
+ this.search_field_scale();
643
+ if (stroke !== 8 && this.pending_backstroke) {
644
+ this.clear_backstroke();
645
+ }
646
+ switch (stroke) {
647
+ case 8:
648
+ this.backstroke_length = this.search_field.val().length;
649
+ break;
650
+ case 9:
651
+ this.mouse_on_container = false;
652
+ break;
653
+ case 13:
654
+ evt.preventDefault();
655
+ break;
656
+ case 38:
657
+ evt.preventDefault();
658
+ this.keyup_arrow();
659
+ break;
660
+ case 40:
661
+ this.keydown_arrow();
662
+ break;
663
+ }
664
+ };
665
+ Chosen.prototype.search_field_scale = function() {
666
+ var dd_top, div, h, style, style_block, styles, w, _i, _len;
667
+ if (this.is_multiple) {
668
+ h = 0;
669
+ w = 0;
670
+ style_block = "position:absolute; left: -1000px; top: -1000px; display:none;";
671
+ styles = ['font-size', 'font-style', 'font-weight', 'font-family', 'line-height', 'text-transform', 'letter-spacing'];
672
+ for (_i = 0, _len = styles.length; _i < _len; _i++) {
673
+ style = styles[_i];
674
+ style_block += style + ":" + this.search_field.css(style) + ";";
675
+ }
676
+ div = $('<div />', {
677
+ 'style': style_block
678
+ });
679
+ div.text(this.search_field.val());
680
+ $('body').append(div);
681
+ w = div.width() + 25;
682
+ div.remove();
683
+ if (w > this.f_width - 10) {
684
+ w = this.f_width - 10;
685
+ }
686
+ this.search_field.css({
687
+ 'width': w + 'px'
688
+ });
689
+ dd_top = this.container.height();
690
+ return this.dropdown.css({
691
+ "top": dd_top + "px"
692
+ });
693
+ }
694
+ };
695
+ Chosen.prototype.generate_field_id = function() {
696
+ var new_id;
697
+ new_id = this.generate_random_id();
698
+ this.form_field.id = new_id;
699
+ return new_id;
700
+ };
701
+ Chosen.prototype.generate_random_id = function() {
702
+ var string;
703
+ string = "sel" + this.generate_random_char() + this.generate_random_char() + this.generate_random_char();
704
+ while ($("#" + string).length > 0) {
705
+ string += this.generate_random_char();
706
+ }
707
+ return string;
708
+ };
709
+ Chosen.prototype.generate_random_char = function() {
710
+ var chars, newchar, rand;
711
+ chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZ";
712
+ rand = Math.floor(Math.random() * chars.length);
713
+ return newchar = chars.substring(rand, rand + 1);
714
+ };
715
+ return Chosen;
716
+ })();
717
+ get_side_border_padding = function(elmt) {
718
+ var side_border_padding;
719
+ return side_border_padding = elmt.outerWidth() - elmt.width();
720
+ };
721
+ root.get_side_border_padding = get_side_border_padding;
722
+ }).call(this);
723
+ (function() {
724
+ var SelectParser;
725
+ SelectParser = (function() {
726
+ function SelectParser() {
727
+ this.options_index = 0;
728
+ this.parsed = [];
729
+ }
730
+ SelectParser.prototype.add_node = function(child) {
731
+ if (child.nodeName === "OPTGROUP") {
732
+ return this.add_group(child);
733
+ } else {
734
+ return this.add_option(child);
735
+ }
736
+ };
737
+ SelectParser.prototype.add_group = function(group) {
738
+ var group_position, option, _i, _len, _ref, _results;
739
+ group_position = this.parsed.length;
740
+ this.parsed.push({
741
+ array_index: group_position,
742
+ group: true,
743
+ label: group.label,
744
+ children: 0,
745
+ disabled: group.disabled
746
+ });
747
+ _ref = group.childNodes;
748
+ _results = [];
749
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
750
+ option = _ref[_i];
751
+ _results.push(this.add_option(option, group_position, group.disabled));
752
+ }
753
+ return _results;
754
+ };
755
+ SelectParser.prototype.add_option = function(option, group_position, group_disabled) {
756
+ if (option.nodeName === "OPTION") {
757
+ if (option.text !== "") {
758
+ if (group_position != null) {
759
+ this.parsed[group_position].children += 1;
760
+ }
761
+ this.parsed.push({
762
+ array_index: this.parsed.length,
763
+ options_index: this.options_index,
764
+ value: option.value,
765
+ text: option.text,
766
+ html: option.innerHTML,
767
+ selected: option.selected,
768
+ disabled: group_disabled === true ? group_disabled : option.disabled,
769
+ group_array_index: group_position
770
+ });
771
+ } else {
772
+ this.parsed.push({
773
+ array_index: this.parsed.length,
774
+ options_index: this.options_index,
775
+ empty: true
776
+ });
777
+ }
778
+ return this.options_index += 1;
779
+ }
780
+ };
781
+ return SelectParser;
782
+ })();
783
+ SelectParser.select_to_array = function(select) {
784
+ var child, parser, _i, _len, _ref;
785
+ parser = new SelectParser();
786
+ _ref = select.childNodes;
787
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
788
+ child = _ref[_i];
789
+ parser.add_node(child);
790
+ }
791
+ return parser.parsed;
792
+ };
793
+ this.SelectParser = SelectParser;
794
+ }).call(this);
@@ -0,0 +1,2 @@
1
+ //= require chosen.jquery
2
+
@@ -0,0 +1,334 @@
1
+ /* @group Base */
2
+ .chzn-container {
3
+ font-size: 13px;
4
+ position: relative;
5
+ display: inline-block;
6
+ zoom: 1;
7
+ *display: inline;
8
+ }
9
+ .chzn-container .chzn-drop {
10
+ background: #fff;
11
+ border: 1px solid #aaa;
12
+ border-top: 0;
13
+ position: absolute;
14
+ top: 29px;
15
+ left: 0;
16
+ -webkit-box-shadow: 0 4px 5px rgba(0,0,0,.15);
17
+ -moz-box-shadow : 0 4px 5px rgba(0,0,0,.15);
18
+ -o-box-shadow : 0 4px 5px rgba(0,0,0,.15);
19
+ box-shadow : 0 4px 5px rgba(0,0,0,.15);
20
+ z-index: 999;
21
+ }
22
+ /* @end */
23
+
24
+ /* @group Single Chosen */
25
+ .chzn-container-single .chzn-single {
26
+ background-color: #fff;
27
+ background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eeeeee), color-stop(0.5, white));
28
+ background-image: -webkit-linear-gradient(center bottom, #eeeeee 0%, white 50%);
29
+ background-image: -moz-linear-gradient(center bottom, #eeeeee 0%, white 50%);
30
+ background-image: -o-linear-gradient(top, #eeeeee 0%,#ffffff 50%);
31
+ background-image: -ms-linear-gradient(top, #eeeeee 0%,#ffffff 50%);
32
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eeeeee', endColorstr='#ffffff',GradientType=0 );
33
+ background-image: linear-gradient(top, #eeeeee 0%,#ffffff 50%);
34
+ -webkit-border-radius: 4px;
35
+ -moz-border-radius : 4px;
36
+ border-radius : 4px;
37
+ -moz-background-clip : padding;
38
+ -webkit-background-clip: padding-box;
39
+ background-clip : padding-box;
40
+ border: 1px solid #aaa;
41
+ display: block;
42
+ overflow: hidden;
43
+ white-space: nowrap;
44
+ position: relative;
45
+ height: 26px;
46
+ line-height: 26px;
47
+ padding: 0 0 0 8px;
48
+ color: #444;
49
+ text-decoration: none;
50
+ }
51
+ .chzn-container-single .chzn-single span {
52
+ margin-right: 26px;
53
+ display: block;
54
+ overflow: hidden;
55
+ white-space: nowrap;
56
+ -o-text-overflow: ellipsis;
57
+ -ms-text-overflow: ellipsis;
58
+ text-overflow: ellipsis;
59
+ }
60
+ .chzn-container-single .chzn-single div {
61
+ -webkit-border-radius: 0 4px 4px 0;
62
+ -moz-border-radius : 0 4px 4px 0;
63
+ border-radius : 0 4px 4px 0;
64
+ -moz-background-clip : padding;
65
+ -webkit-background-clip: padding-box;
66
+ background-clip : padding-box;
67
+ background: #ccc;
68
+ background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #ccc), color-stop(0.6, #eee));
69
+ background-image: -webkit-linear-gradient(center bottom, #ccc 0%, #eee 60%);
70
+ background-image: -moz-linear-gradient(center bottom, #ccc 0%, #eee 60%);
71
+ background-image: -o-linear-gradient(bottom, #ccc 0%, #eee 60%);
72
+ background-image: -ms-linear-gradient(top, #cccccc 0%,#eeeeee 60%);
73
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#cccccc', endColorstr='#eeeeee',GradientType=0 );
74
+ background-image: linear-gradient(top, #cccccc 0%,#eeeeee 60%);
75
+ border-left: 1px solid #aaa;
76
+ position: absolute;
77
+ right: 0;
78
+ top: 0;
79
+ display: block;
80
+ height: 100%;
81
+ width: 18px;
82
+ }
83
+ .chzn-container-single .chzn-single div b {
84
+ background: url('chosen-sprite.png') no-repeat 0 1px;
85
+ display: block;
86
+ width: 100%;
87
+ height: 100%;
88
+ }
89
+ .chzn-container-single .chzn-search {
90
+ padding: 3px 4px;
91
+ margin: 0;
92
+ white-space: nowrap;
93
+ }
94
+ .chzn-container-single .chzn-search input {
95
+ background: #fff url('chosen-sprite.png') no-repeat 100% -20px;
96
+ background: url('chosen-sprite.png') no-repeat 100% -20px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, white), color-stop(0.99, #eeeeee));
97
+ background: url('chosen-sprite.png') no-repeat 100% -20px, -webkit-linear-gradient(center bottom, white 85%, #eeeeee 99%);
98
+ background: url('chosen-sprite.png') no-repeat 100% -20px, -moz-linear-gradient(center bottom, white 85%, #eeeeee 99%);
99
+ background: url('chosen-sprite.png') no-repeat 100% -20px, -o-linear-gradient(bottom, white 85%, #eeeeee 99%);
100
+ background: url('chosen-sprite.png') no-repeat 100% -20px, -ms-linear-gradient(top, #ffffff 85%,#eeeeee 99%);
101
+ background: url('chosen-sprite.png') no-repeat 100% -20px, -ms-linear-gradient(top, #ffffff 85%,#eeeeee 99%);
102
+ background: url('chosen-sprite.png') no-repeat 100% -20px, linear-gradient(top, #ffffff 85%,#eeeeee 99%);
103
+ margin: 1px 0;
104
+ padding: 4px 20px 4px 5px;
105
+ outline: 0;
106
+ border: 1px solid #aaa;
107
+ font-family: sans-serif;
108
+ font-size: 1em;
109
+ }
110
+ .chzn-container-single .chzn-drop {
111
+ -webkit-border-radius: 0 0 4px 4px;
112
+ -moz-border-radius : 0 0 4px 4px;
113
+ border-radius : 0 0 4px 4px;
114
+ -moz-background-clip : padding;
115
+ -webkit-background-clip: padding-box;
116
+ background-clip : padding-box;
117
+ }
118
+ /* @end */
119
+
120
+ /* @group Multi Chosen */
121
+ .chzn-container-multi .chzn-choices {
122
+ background-color: #fff;
123
+ background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0.85, white), color-stop(0.99, #eeeeee));
124
+ background-image: -webkit-linear-gradient(center bottom, white 85%, #eeeeee 99%);
125
+ background-image: -moz-linear-gradient(center bottom, white 85%, #eeeeee 99%);
126
+ background-image: -o-linear-gradient(bottom, white 85%, #eeeeee 99%);
127
+ background-image: -ms-linear-gradient(top, #ffffff 85%,#eeeeee 99%);
128
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#eeeeee',GradientType=0 );
129
+ background-image: linear-gradient(top, #ffffff 85%,#eeeeee 99%);
130
+ border: 1px solid #aaa;
131
+ margin: 0;
132
+ padding: 0;
133
+ cursor: text;
134
+ overflow: hidden;
135
+ height: auto !important;
136
+ height: 1%;
137
+ position: relative;
138
+ }
139
+ .chzn-container-multi .chzn-choices li {
140
+ float: left;
141
+ list-style: none;
142
+ }
143
+ .chzn-container-multi .chzn-choices .search-field {
144
+ white-space: nowrap;
145
+ margin: 0;
146
+ padding: 0;
147
+ }
148
+ .chzn-container-multi .chzn-choices .search-field input {
149
+ color: #666;
150
+ background: transparent !important;
151
+ border: 0 !important;
152
+ padding: 5px;
153
+ margin: 1px 0;
154
+ outline: 0;
155
+ -webkit-box-shadow: none;
156
+ -moz-box-shadow : none;
157
+ -o-box-shadow : none;
158
+ box-shadow : none;
159
+ }
160
+ .chzn-container-multi .chzn-choices .search-field .default {
161
+ color: #999;
162
+ }
163
+ .chzn-container-multi .chzn-choices .search-choice {
164
+ -webkit-border-radius: 3px;
165
+ -moz-border-radius : 3px;
166
+ border-radius : 3px;
167
+ -moz-background-clip : padding;
168
+ -webkit-background-clip: padding-box;
169
+ background-clip : padding-box;
170
+ background-color: #e4e4e4;
171
+ background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #e4e4e4), color-stop(0.7, #eeeeee));
172
+ background-image: -webkit-linear-gradient(center bottom, #e4e4e4 0%, #eeeeee 70%);
173
+ background-image: -moz-linear-gradient(center bottom, #e4e4e4 0%, #eeeeee 70%);
174
+ background-image: -o-linear-gradient(bottom, #e4e4e4 0%, #eeeeee 70%);
175
+ background-image: -ms-linear-gradient(top, #e4e4e4 0%,#eeeeee 70%);
176
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#e4e4e4', endColorstr='#eeeeee',GradientType=0 );
177
+ background-image: linear-gradient(top, #e4e4e4 0%,#eeeeee 70%);
178
+ color: #333;
179
+ border: 1px solid #b4b4b4;
180
+ line-height: 13px;
181
+ padding: 3px 19px 3px 6px;
182
+ margin: 3px 0 3px 5px;
183
+ position: relative;
184
+ }
185
+ .chzn-container-multi .chzn-choices .search-choice span {
186
+ cursor: default;
187
+ }
188
+ .chzn-container-multi .chzn-choices .search-choice-focus {
189
+ background: #d4d4d4;
190
+ }
191
+ .chzn-container-multi .chzn-choices .search-choice .search-choice-close {
192
+ display: block;
193
+ position: absolute;
194
+ right: 5px;
195
+ top: 6px;
196
+ width: 8px;
197
+ height: 9px;
198
+ font-size: 1px;
199
+ background: url(chosen-sprite.png) right top no-repeat;
200
+ }
201
+ .chzn-container-multi .chzn-choices .search-choice .search-choice-close:hover {
202
+ background-position: right -9px;
203
+ }
204
+ .chzn-container-multi .chzn-choices .search-choice-focus .search-choice-close {
205
+ background-position: right -9px;
206
+ }
207
+ /* @end */
208
+
209
+ /* @group Results */
210
+ .chzn-container .chzn-results {
211
+ margin: 0 4px 4px 0;
212
+ max-height: 190px;
213
+ padding: 0 0 0 4px;
214
+ position: relative;
215
+ overflow-x: hidden;
216
+ overflow-y: auto;
217
+ }
218
+ .chzn-container-multi .chzn-results {
219
+ margin: -1px 0 0;
220
+ padding: 0;
221
+ }
222
+ .chzn-container .chzn-results li {
223
+ line-height: 80%;
224
+ padding: 7px 7px 8px;
225
+ margin: 0;
226
+ list-style: none;
227
+ }
228
+ .chzn-container .chzn-results .active-result {
229
+ cursor: pointer;
230
+ }
231
+ .chzn-container .chzn-results .highlighted {
232
+ background: #3875d7;
233
+ color: #fff;
234
+ }
235
+ .chzn-container .chzn-results li em {
236
+ background: #feffde;
237
+ font-style: normal;
238
+ }
239
+ .chzn-container .chzn-results .highlighted em {
240
+ background: transparent;
241
+ }
242
+ .chzn-container .chzn-results .no-results {
243
+ background: #f4f4f4;
244
+ }
245
+ .chzn-container .chzn-results .group-result {
246
+ cursor: default;
247
+ color: #999;
248
+ font-weight: bold;
249
+ }
250
+ .chzn-container .chzn-results .group-option {
251
+ padding-left: 20px;
252
+ }
253
+ .chzn-container-multi .chzn-drop .result-selected {
254
+ display: none;
255
+ }
256
+ /* @end */
257
+
258
+ /* @group Active */
259
+ .chzn-container-active .chzn-single {
260
+ -webkit-box-shadow: 0 0 5px rgba(0,0,0,.3);
261
+ -moz-box-shadow : 0 0 5px rgba(0,0,0,.3);
262
+ -o-box-shadow : 0 0 5px rgba(0,0,0,.3);
263
+ box-shadow : 0 0 5px rgba(0,0,0,.3);
264
+ border: 1px solid #5897fb;
265
+ }
266
+ .chzn-container-active .chzn-single-with-drop {
267
+ border: 1px solid #aaa;
268
+ -webkit-box-shadow: 0 1px 0 #fff inset;
269
+ -moz-box-shadow : 0 1px 0 #fff inset;
270
+ -o-box-shadow : 0 1px 0 #fff inset;
271
+ box-shadow : 0 1px 0 #fff inset;
272
+ background-color: #eee;
273
+ background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, white), color-stop(0.5, #eeeeee));
274
+ background-image: -webkit-linear-gradient(center bottom, white 0%, #eeeeee 50%);
275
+ background-image: -moz-linear-gradient(center bottom, white 0%, #eeeeee 50%);
276
+ background-image: -o-linear-gradient(bottom, white 0%, #eeeeee 50%);
277
+ background-image: -ms-linear-gradient(top, #ffffff 0%,#eeeeee 50%);
278
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#eeeeee',GradientType=0 );
279
+ background-image: linear-gradient(top, #ffffff 0%,#eeeeee 50%);
280
+ -webkit-border-bottom-left-radius : 0;
281
+ -webkit-border-bottom-right-radius: 0;
282
+ -moz-border-radius-bottomleft : 0;
283
+ -moz-border-radius-bottomright: 0;
284
+ border-bottom-left-radius : 0;
285
+ border-bottom-right-radius: 0;
286
+ }
287
+ .chzn-container-active .chzn-single-with-drop div {
288
+ background: transparent;
289
+ border-left: none;
290
+ }
291
+ .chzn-container-active .chzn-single-with-drop div b {
292
+ background-position: -18px 1px;
293
+ }
294
+ .chzn-container-active .chzn-choices {
295
+ -webkit-box-shadow: 0 0 5px rgba(0,0,0,.3);
296
+ -moz-box-shadow : 0 0 5px rgba(0,0,0,.3);
297
+ -o-box-shadow : 0 0 5px rgba(0,0,0,.3);
298
+ box-shadow : 0 0 5px rgba(0,0,0,.3);
299
+ border: 1px solid #5897fb;
300
+ }
301
+ .chzn-container-active .chzn-choices .search-field input {
302
+ color: #111 !important;
303
+ }
304
+ /* @end */
305
+
306
+ /* @group Right to Left */
307
+ .chzn-rtl { direction:rtl;text-align: right; }
308
+ .chzn-rtl .chzn-single { padding-left: 0; padding-right: 8px; }
309
+ .chzn-rtl .chzn-single span { margin-left: 26px; margin-right: 0; }
310
+ .chzn-rtl .chzn-single div {
311
+ left: 0; right: auto;
312
+ border-left: none; border-right: 1px solid #aaaaaa;
313
+ -webkit-border-radius: 4px 0 0 4px;
314
+ -moz-border-radius : 4px 0 0 4px;
315
+ border-radius : 4px 0 0 4px;
316
+ }
317
+ .chzn-rtl .chzn-choices li { float: right; }
318
+ .chzn-rtl .chzn-choices .search-choice { padding: 3px 6px 3px 19px; margin: 3px 5px 3px 0; }
319
+ .chzn-rtl .chzn-choices .search-choice .search-choice-close { left: 5px; right: auto; background-position: right top;}
320
+ .chzn-rtl.chzn-container-single .chzn-results { margin-left: 4px; margin-right: 0; padding-left: 0; padding-right: 4px; }
321
+ .chzn-rtl .chzn-results .group-option { padding-left: 0; padding-right: 20px; }
322
+ .chzn-rtl.chzn-container-active .chzn-single-with-drop div { border-right: none; }
323
+ .chzn-rtl .chzn-search input {
324
+ background: url('chosen-sprite.png') no-repeat -38px -20px, #ffffff;
325
+ background: url('chosen-sprite.png') no-repeat -38px -20px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, white), color-stop(0.99, #eeeeee));
326
+ background: url('chosen-sprite.png') no-repeat -38px -20px, -webkit-linear-gradient(center bottom, white 85%, #eeeeee 99%);
327
+ background: url('chosen-sprite.png') no-repeat -38px -20px, -moz-linear-gradient(center bottom, white 85%, #eeeeee 99%);
328
+ background: url('chosen-sprite.png') no-repeat -38px -20px, -o-linear-gradient(bottom, white 85%, #eeeeee 99%);
329
+ background: url('chosen-sprite.png') no-repeat -38px -20px, -ms-linear-gradient(top, #ffffff 85%,#eeeeee 99%);
330
+ background: url('chosen-sprite.png') no-repeat -38px -20px, -ms-linear-gradient(top, #ffffff 85%,#eeeeee 99%);
331
+ background: url('chosen-sprite.png') no-repeat -38px -20px, linear-gradient(top, #ffffff 85%,#eeeeee 99%);
332
+ padding: 4px 5px 4px 20px;
333
+ }
334
+ /* @end */
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: chosen_rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Sean Behan
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-09-11 00:00:00.000000000Z
13
+ dependencies: []
14
+ description: This plugin turns unsightly select boxes into pretty, searchable, drop
15
+ down unordered list that you can style.
16
+ email:
17
+ - bseanvt@gmail.com
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - .gitignore
23
+ - Gemfile
24
+ - Rakefile
25
+ - chosen_rails.gemspec
26
+ - lib/chosen_rails.rb
27
+ - lib/chosen_rails/engine.rb
28
+ - lib/chosen_rails/version.rb
29
+ - readme.md
30
+ - vendor/assets/images/chosen-sprite.png
31
+ - vendor/assets/javascripts/chosen.jquery.js
32
+ - vendor/assets/javascripts/chosen.js
33
+ - vendor/assets/stylesheets/chosen.css
34
+ homepage: http://github.com/bseanvt/chosen_rails
35
+ licenses: []
36
+ post_install_message:
37
+ rdoc_options: []
38
+ require_paths:
39
+ - lib
40
+ required_ruby_version: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ none: false
48
+ requirements:
49
+ - - ! '>='
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ requirements: []
53
+ rubyforge_project: chosen_rails
54
+ rubygems_version: 1.8.7
55
+ signing_key:
56
+ specification_version: 3
57
+ summary: Chosen jQuery Plugin for Rails 3.1 Asset Pipeline
58
+ test_files: []