chosen-rails 0.13.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f63c4381ea016723a73d951f117d1e29829fd0f9
4
- data.tar.gz: fdfd7ad68bd5df045917bf113ad716772ef5fa0b
3
+ metadata.gz: c5812584c5181aa451334406808d07978d251851
4
+ data.tar.gz: 43f40dbd823a2b44b34ad12d8b93a4f05919965f
5
5
  SHA512:
6
- metadata.gz: a803abd4ea21aee231b49e5ac11238d62455fcafb2994278d8d735823a219a0feedd60cf855f38ef1ba63ac90073f9555053515f8f7408bdc9ac4e5c8b9e4614
7
- data.tar.gz: b5617dba2330e8cc5434a80ac57019e81b5afbaaa50f7b6a6b709abb84456ba51ae73603cb00a269c1981bfd32dca02d0bb5b656820ee177c3f5f26b4ae8aa36
6
+ metadata.gz: 26248f3d19863fefb7d454f003f58f9a2d7eba1e3479198c0b0a7c57c8c18bbfa677026a2e7feccfee4503e6d59ec60e4a251a09d1087f7b4d75f4dd701f08af
7
+ data.tar.gz: 202143305a02bc84937d711c47cecc483477682ed6a1ca168d556c49d39666dc91d8e8bb710afda596c74672ad1a77bbb5dedbaa032885dc8ef51f92009a8901
data/README.md CHANGED
@@ -12,6 +12,14 @@ Include `chosen-rails` in Gemefile
12
12
 
13
13
  gem 'chosen-rails'
14
14
 
15
+ For Rails 4 project, it is required to add [compass-rails](https://github.com/Compass/compass-rails) gem explicitly and use unofficial branch for [compatible issue](https://github.com/Compass/compass-rails/pull/59).
16
+
17
+
18
+ ```ruby
19
+ # gem 'compass-rails', github: 'Compass/compass-rails', branch: 'rails4'
20
+ gem 'compass-rails', github: 'milgner/compass-rails', branch: 'rails4'
21
+ ```
22
+
15
23
  Then run `bundle install`
16
24
 
17
25
  ### Include chosen javascript assets
@@ -36,7 +44,7 @@ Add to one coffee script file, like `scaffold.js.coffee`
36
44
 
37
45
  $ ->
38
46
  # enable chosen js
39
- $('.chzn-select').chosen
47
+ $('.chosen-select').chosen
40
48
  allow_single_deselect: true
41
49
  no_results_text: 'No results matched'
42
50
  width: '200px'
@@ -53,7 +61,7 @@ Also add the class to your form field
53
61
  <%= f.select :author,
54
62
  User.all.map { |u| [u.name, u.id] },
55
63
  { include_blank: true },
56
- { class: 'chzn-select' }
64
+ { class: 'chosen-select' }
57
65
  %>
58
66
 
59
67
  If you use simple form as form builder
@@ -61,7 +69,7 @@ If you use simple form as form builder
61
69
  <%= f.association :author,
62
70
  collection: User.all,
63
71
  include_blank: true,
64
- input_html: { class: 'chzn-select' }
72
+ input_html: { class: 'chosen-select' }
65
73
  %>
66
74
 
67
75
  ### Deployment
data/Rakefile CHANGED
@@ -8,5 +8,6 @@ task 'update-chosen', 'remote', 'branch' do |task, args|
8
8
  branch = args['branch'] || 'master'
9
9
  files = SourceFile.new
10
10
  files.fetch remote, branch
11
+ files.eject_javascript_class_from_closure
11
12
  files.cleanup
12
13
  end
@@ -18,6 +18,19 @@ class SourceFile < Thor
18
18
  bump_version
19
19
  end
20
20
 
21
+ desc 'eject class from closure', 'eject javascript library class from closure'
22
+ def eject_javascript_class_from_closure
23
+ self.destination_root = 'vendor/assets'
24
+ inside destination_root do
25
+ append_to_file 'javascripts/lib/abstract-chosen.coffee' do
26
+ "\nwindow.AbstractChosen = AbstractChosen\n"
27
+ end
28
+ append_to_file 'javascripts/lib/select-parser.coffee' do
29
+ "\n\nwindow.SelectParser = SelectParser\n"
30
+ end
31
+ end
32
+ end
33
+
21
34
  desc 'clean up useless files', 'clean up useless files'
22
35
  def cleanup
23
36
  self.destination_root = 'vendor/assets'
@@ -1,6 +1,6 @@
1
1
  module Chosen
2
2
  module Rails
3
- VERSION = '0.13.2'
4
- CHOSEN_VERSION = '0.13.0'
3
+ VERSION = '1.0.0'
4
+ CHOSEN_VERSION = '1.0.0'
5
5
  end
6
6
  end
@@ -1,4 +1,3 @@
1
- root = this
2
1
  $ = jQuery
3
2
 
4
3
  $.fn.extend({
@@ -6,10 +5,16 @@ $.fn.extend({
6
5
  # Do no harm and return as soon as possible for unsupported browsers, namely IE6 and IE7
7
6
  # Continue on if running IE document type but in compatibility mode
8
7
  return this unless AbstractChosen.browser_is_supported()
9
- this.each((input_field) ->
8
+ this.each (input_field) ->
10
9
  $this = $ this
11
- $this.data('chosen', new Chosen(this, options)) unless $this.hasClass "chzn-done"
12
- )
10
+ chosen = $this.data('chosen')
11
+ if options is 'destroy' && chosen
12
+ chosen.destroy()
13
+ else unless chosen
14
+ $this.data('chosen', new Chosen(this, options))
15
+
16
+ return
17
+
13
18
  })
14
19
 
15
20
  class Chosen extends AbstractChosen
@@ -17,88 +22,98 @@ class Chosen extends AbstractChosen
17
22
  setup: ->
18
23
  @form_field_jq = $ @form_field
19
24
  @current_selectedIndex = @form_field.selectedIndex
20
- @is_rtl = @form_field_jq.hasClass "chzn-rtl"
21
-
22
- finish_setup: ->
23
- @form_field_jq.addClass "chzn-done"
25
+ @is_rtl = @form_field_jq.hasClass "chosen-rtl"
24
26
 
25
27
  set_up_html: ->
26
- container_classes = ["chzn-container"]
27
- container_classes.push "chzn-container-" + (if @is_multiple then "multi" else "single")
28
+ container_classes = ["chosen-container"]
29
+ container_classes.push "chosen-container-" + (if @is_multiple then "multi" else "single")
28
30
  container_classes.push @form_field.className if @inherit_select_classes && @form_field.className
29
- container_classes.push "chzn-rtl" if @is_rtl
31
+ container_classes.push "chosen-rtl" if @is_rtl
30
32
 
31
33
  container_props =
32
34
  'class': container_classes.join ' '
33
35
  'style': "width: #{this.container_width()};"
34
36
  'title': @form_field.title
35
37
 
36
- container_props.id = @form_field.id.replace(/[^\w]/g, '_') + "_chzn" if @form_field.id.length
38
+ container_props.id = @form_field.id.replace(/[^\w]/g, '_') + "_chosen" if @form_field.id.length
37
39
 
38
40
  @container = ($ "<div />", container_props)
39
41
 
40
42
  if @is_multiple
41
- @container.html '<ul class="chzn-choices"><li class="search-field"><input type="text" value="' + @default_text + '" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop"><ul class="chzn-results"></ul></div>'
43
+ @container.html '<ul class="chosen-choices"><li class="search-field"><input type="text" value="' + @default_text + '" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chosen-drop"><ul class="chosen-results"></ul></div>'
42
44
  else
43
- @container.html '<a href="javascript:void(0)" class="chzn-single chzn-default" tabindex="-1"><span>' + @default_text + '</span><div><b></b></div></a><div class="chzn-drop"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>'
45
+ @container.html '<a class="chosen-single chosen-default" tabindex="-1"><span>' + @default_text + '</span><div><b></b></div></a><div class="chosen-drop"><div class="chosen-search"><input type="text" autocomplete="off" /></div><ul class="chosen-results"></ul></div>'
44
46
 
45
47
  @form_field_jq.hide().after @container
46
- @dropdown = @container.find('div.chzn-drop').first()
48
+ @dropdown = @container.find('div.chosen-drop').first()
47
49
 
48
50
  @search_field = @container.find('input').first()
49
- @search_results = @container.find('ul.chzn-results').first()
51
+ @search_results = @container.find('ul.chosen-results').first()
50
52
  this.search_field_scale()
51
53
 
52
54
  @search_no_results = @container.find('li.no-results').first()
53
55
 
54
56
  if @is_multiple
55
- @search_choices = @container.find('ul.chzn-choices').first()
57
+ @search_choices = @container.find('ul.chosen-choices').first()
56
58
  @search_container = @container.find('li.search-field').first()
57
59
  else
58
- @search_container = @container.find('div.chzn-search').first()
59
- @selected_item = @container.find('.chzn-single').first()
60
+ @search_container = @container.find('div.chosen-search').first()
61
+ @selected_item = @container.find('.chosen-single').first()
60
62
 
61
63
  this.results_build()
62
64
  this.set_tab_index()
63
65
  this.set_label_behavior()
64
- @form_field_jq.trigger("liszt:ready", {chosen: this})
66
+ @form_field_jq.trigger("chosen:ready", {chosen: this})
65
67
 
66
68
  register_observers: ->
67
- @container.mousedown (evt) => this.container_mousedown(evt); return
68
- @container.mouseup (evt) => this.container_mouseup(evt); return
69
- @container.mouseenter (evt) => this.mouse_enter(evt); return
70
- @container.mouseleave (evt) => this.mouse_leave(evt); return
69
+ @container.bind 'mousedown.chosen', (evt) => this.container_mousedown(evt); return
70
+ @container.bind 'mouseup.chosen', (evt) => this.container_mouseup(evt); return
71
+ @container.bind 'mouseenter.chosen', (evt) => this.mouse_enter(evt); return
72
+ @container.bind 'mouseleave.chosen', (evt) => this.mouse_leave(evt); return
73
+
74
+ @search_results.bind 'mouseup.chosen', (evt) => this.search_results_mouseup(evt); return
75
+ @search_results.bind 'mouseover.chosen', (evt) => this.search_results_mouseover(evt); return
76
+ @search_results.bind 'mouseout.chosen', (evt) => this.search_results_mouseout(evt); return
77
+ @search_results.bind 'mousewheel.chosen DOMMouseScroll.chosen', (evt) => this.search_results_mousewheel(evt); return
71
78
 
72
- @search_results.mouseup (evt) => this.search_results_mouseup(evt); return
73
- @search_results.mouseover (evt) => this.search_results_mouseover(evt); return
74
- @search_results.mouseout (evt) => this.search_results_mouseout(evt); return
75
- @search_results.bind 'mousewheel DOMMouseScroll', (evt) => this.search_results_mousewheel(evt); return
79
+ @search_results.bind 'touchstart.chosen', (evt) => this.search_results_touchstart(evt); return
80
+ @search_results.bind 'touchmove.chosen', (evt) => this.search_results_touchmove(evt); return
81
+ @search_results.bind 'touchend.chosen', (evt) => this.search_results_touchend(evt); return
76
82
 
77
- @form_field_jq.bind "liszt:updated", (evt) => this.results_update_field(evt); return
78
- @form_field_jq.bind "liszt:activate", (evt) => this.activate_field(evt); return
79
- @form_field_jq.bind "liszt:open", (evt) => this.container_mousedown(evt); return
83
+ @form_field_jq.bind "chosen:updated.chosen", (evt) => this.results_update_field(evt); return
84
+ @form_field_jq.bind "chosen:activate.chosen", (evt) => this.activate_field(evt); return
85
+ @form_field_jq.bind "chosen:open.chosen", (evt) => this.container_mousedown(evt); return
80
86
 
81
- @search_field.blur (evt) => this.input_blur(evt); return
82
- @search_field.keyup (evt) => this.keyup_checker(evt); return
83
- @search_field.keydown (evt) => this.keydown_checker(evt); return
84
- @search_field.focus (evt) => this.input_focus(evt); return
87
+ @search_field.bind 'blur.chosen', (evt) => this.input_blur(evt); return
88
+ @search_field.bind 'keyup.chosen', (evt) => this.keyup_checker(evt); return
89
+ @search_field.bind 'keydown.chosen', (evt) => this.keydown_checker(evt); return
90
+ @search_field.bind 'focus.chosen', (evt) => this.input_focus(evt); return
85
91
 
86
92
  if @is_multiple
87
- @search_choices.click (evt) => this.choices_click(evt); return
93
+ @search_choices.bind 'click.chosen', (evt) => this.choices_click(evt); return
88
94
  else
89
- @container.click (evt) => evt.preventDefault(); return # gobble click of anchor
95
+ @container.bind 'click.chosen', (evt) -> evt.preventDefault(); return # gobble click of anchor
96
+
97
+ destroy: ->
98
+ $(document).unbind "click.chosen", @click_test_action
99
+ if @search_field[0].tabIndex
100
+ @form_field_jq[0].tabIndex = @search_field[0].tabIndex
101
+
102
+ @container.remove()
103
+ @form_field_jq.removeData('chosen')
104
+ @form_field_jq.show()
90
105
 
91
106
  search_field_disabled: ->
92
107
  @is_disabled = @form_field_jq[0].disabled
93
108
  if(@is_disabled)
94
- @container.addClass 'chzn-disabled'
109
+ @container.addClass 'chosen-disabled'
95
110
  @search_field[0].disabled = true
96
- @selected_item.unbind "focus", @activate_action if !@is_multiple
111
+ @selected_item.unbind "focus.chosen", @activate_action if !@is_multiple
97
112
  this.close_field()
98
113
  else
99
- @container.removeClass 'chzn-disabled'
114
+ @container.removeClass 'chosen-disabled'
100
115
  @search_field[0].disabled = false
101
- @selected_item.bind "focus", @activate_action if !@is_multiple
116
+ @selected_item.bind "focus.chosen", @activate_action if !@is_multiple
102
117
 
103
118
  container_mousedown: (evt) ->
104
119
  if !@is_disabled
@@ -108,9 +123,9 @@ class Chosen extends AbstractChosen
108
123
  if not (evt? and ($ evt.target).hasClass "search-choice-close")
109
124
  if not @active_field
110
125
  @search_field.val "" if @is_multiple
111
- $(document).click @click_test_action
126
+ $(document).bind 'click.chosen', @click_test_action
112
127
  this.results_show()
113
- else if not @is_multiple and evt and (($(evt.target)[0] == @selected_item[0]) || $(evt.target).parents("a.chzn-single").length)
128
+ else if not @is_multiple and evt and (($(evt.target)[0] == @selected_item[0]) || $(evt.target).parents("a.chosen-single").length)
114
129
  evt.preventDefault()
115
130
  this.results_toggle()
116
131
 
@@ -127,22 +142,22 @@ class Chosen extends AbstractChosen
127
142
  @search_results.scrollTop(delta + @search_results.scrollTop())
128
143
 
129
144
  blur_test: (evt) ->
130
- this.close_field() if not @active_field and @container.hasClass "chzn-container-active"
145
+ this.close_field() if not @active_field and @container.hasClass "chosen-container-active"
131
146
 
132
147
  close_field: ->
133
- $(document).unbind "click", @click_test_action
148
+ $(document).unbind "click.chosen", @click_test_action
134
149
 
135
150
  @active_field = false
136
151
  this.results_hide()
137
152
 
138
- @container.removeClass "chzn-container-active"
153
+ @container.removeClass "chosen-container-active"
139
154
  this.clear_backstroke()
140
155
 
141
156
  this.show_search_field_default()
142
157
  this.search_field_scale()
143
158
 
144
159
  activate_field: ->
145
- @container.addClass "chzn-container-active"
160
+ @container.addClass "chosen-container-active"
146
161
  @active_field = true
147
162
 
148
163
  @search_field.val(@search_field.val())
@@ -150,7 +165,7 @@ class Chosen extends AbstractChosen
150
165
 
151
166
 
152
167
  test_active_click: (evt) ->
153
- if @container.is($(evt.target).closest('.chzn-container'))
168
+ if @container.is($(evt.target).closest('.chosen-container'))
154
169
  @active_field = true
155
170
  else
156
171
  this.close_field()
@@ -159,7 +174,7 @@ class Chosen extends AbstractChosen
159
174
  @parsing = true
160
175
  @selected_option_count = null
161
176
 
162
- @results_data = root.SelectParser.select_to_array @form_field
177
+ @results_data = SelectParser.select_to_array @form_field
163
178
 
164
179
  if @is_multiple
165
180
  @search_choices.find("li.search-choice").remove()
@@ -167,10 +182,10 @@ class Chosen extends AbstractChosen
167
182
  this.single_set_selected_text()
168
183
  if @disable_search or @form_field.options.length <= @disable_search_threshold
169
184
  @search_field[0].readOnly = true
170
- @container.addClass "chzn-container-single-nosearch"
185
+ @container.addClass "chosen-container-single-nosearch"
171
186
  else
172
187
  @search_field[0].readOnly = false
173
- @container.removeClass "chzn-container-single-nosearch"
188
+ @container.removeClass "chosen-container-single-nosearch"
174
189
 
175
190
  this.update_results_content this.results_option_build({first:true})
176
191
 
@@ -205,11 +220,11 @@ class Chosen extends AbstractChosen
205
220
 
206
221
  results_show: ->
207
222
  if @is_multiple and @max_selected_options <= this.choices_count()
208
- @form_field_jq.trigger("liszt:maxselected", {chosen: this})
223
+ @form_field_jq.trigger("chosen:maxselected", {chosen: this})
209
224
  return false
210
225
 
211
- @container.addClass "chzn-with-drop"
212
- @form_field_jq.trigger("liszt:showing_dropdown", {chosen: this})
226
+ @container.addClass "chosen-with-drop"
227
+ @form_field_jq.trigger("chosen:showing_dropdown", {chosen: this})
213
228
 
214
229
  @results_showing = true
215
230
 
@@ -225,17 +240,17 @@ class Chosen extends AbstractChosen
225
240
  if @results_showing
226
241
  this.result_clear_highlight()
227
242
 
228
- @container.removeClass "chzn-with-drop"
229
- @form_field_jq.trigger("liszt:hiding_dropdown", {chosen: this})
243
+ @container.removeClass "chosen-with-drop"
244
+ @form_field_jq.trigger("chosen:hiding_dropdown", {chosen: this})
230
245
 
231
246
  @results_showing = false
232
247
 
233
248
 
234
249
  set_tab_index: (el) ->
235
- if @form_field_jq.attr "tabindex"
236
- ti = @form_field_jq.attr "tabindex"
237
- @form_field_jq.attr "tabindex", -1
238
- @search_field.attr "tabindex", ti
250
+ if @form_field.tabIndex
251
+ ti = @form_field.tabIndex
252
+ @form_field.tabIndex = -1
253
+ @search_field[0].tabIndex = ti
239
254
 
240
255
  set_label_behavior: ->
241
256
  @form_field_label = @form_field_jq.parents("label") # first check for a parent label
@@ -243,7 +258,7 @@ class Chosen extends AbstractChosen
243
258
  @form_field_label = $("label[for='#{@form_field.id}']") #next check for a for=#{id}
244
259
 
245
260
  if @form_field_label.length > 0
246
- @form_field_label.click (evt) => if @is_multiple then this.container_mousedown(evt) else this.activate_field()
261
+ @form_field_label.bind 'click.chosen', (evt) => if @is_multiple then this.container_mousedown(evt) else this.activate_field()
247
262
 
248
263
  show_search_field_default: ->
249
264
  if @is_multiple and this.choices_count() < 1 and not @active_field
@@ -273,8 +288,8 @@ class Chosen extends AbstractChosen
273
288
  if item.disabled
274
289
  choice.addClass 'search-choice-disabled'
275
290
  else
276
- close_link = $('<a />', { href: '#', class: 'search-choice-close', rel: item.array_index })
277
- close_link.click (evt) => this.choice_destroy_link_click(evt)
291
+ close_link = $('<a />', { class: 'search-choice-close', 'data-option-array-index': item.array_index })
292
+ close_link.bind 'click.chosen', (evt) => this.choice_destroy_link_click(evt)
278
293
  choice.append close_link
279
294
 
280
295
  @search_container.before choice
@@ -285,7 +300,7 @@ class Chosen extends AbstractChosen
285
300
  this.choice_destroy $(evt.target) unless @is_disabled
286
301
 
287
302
  choice_destroy: (link) ->
288
- if this.result_deselect (link.attr "rel")
303
+ if this.result_deselect( link[0].getAttribute("data-option-array-index") )
289
304
  this.show_search_field_default()
290
305
 
291
306
  this.results_hide() if @is_multiple and this.choices_count() > 0 and @search_field.val().length < 1
@@ -314,13 +329,17 @@ class Chosen extends AbstractChosen
314
329
  this.result_clear_highlight()
315
330
 
316
331
  if @is_multiple and @max_selected_options <= this.choices_count()
317
- @form_field_jq.trigger("liszt:maxselected", {chosen: this})
332
+ @form_field_jq.trigger("chosen:maxselected", {chosen: this})
318
333
  return false
319
334
 
320
335
  if @is_multiple
321
336
  high.removeClass("active-result")
322
337
  else
323
- @search_results.find(".result-selected").removeClass "result-selected"
338
+ if @result_single_selected
339
+ @result_single_selected.removeClass("result-selected")
340
+ selected_index = @result_single_selected[0].getAttribute('data-option-array-index')
341
+ @results_data[selected_index].selected = false
342
+
324
343
  @result_single_selected = high
325
344
 
326
345
  high.addClass "result-selected"
@@ -346,10 +365,10 @@ class Chosen extends AbstractChosen
346
365
 
347
366
  single_set_selected_text: (text=@default_text) ->
348
367
  if text is @default_text
349
- @selected_item.addClass("chzn-default")
368
+ @selected_item.addClass("chosen-default")
350
369
  else
351
370
  this.single_deselect_control_build()
352
- @selected_item.removeClass("chzn-default")
371
+ @selected_item.removeClass("chosen-default")
353
372
 
354
373
  @selected_item.find("span").text(text)
355
374
 
@@ -375,7 +394,7 @@ class Chosen extends AbstractChosen
375
394
  single_deselect_control_build: ->
376
395
  return unless @allow_single_deselect
377
396
  @selected_item.find("span").first().after "<abbr class=\"search-choice-close\"></abbr>" unless @selected_item.find("abbr").length
378
- @selected_item.addClass("chzn-single-with-deselect")
397
+ @selected_item.addClass("chosen-single-with-deselect")
379
398
 
380
399
  get_search_text: ->
381
400
  if @search_field.val() is @default_text then "" else $('<div/>').text($.trim(@search_field.val())).html()
@@ -482,5 +501,3 @@ class Chosen extends AbstractChosen
482
501
  w = f_width - 10
483
502
 
484
503
  @search_field.css({'width': w + 'px'})
485
-
486
- root.Chosen = Chosen
@@ -1,57 +1,52 @@
1
- root = this
2
-
3
- class Chosen extends AbstractChosen
1
+ class @Chosen extends AbstractChosen
4
2
 
5
3
  setup: ->
6
4
  @current_selectedIndex = @form_field.selectedIndex
7
- @is_rtl = @form_field.hasClassName "chzn-rtl"
8
-
9
- finish_setup: ->
10
- @form_field.addClassName "chzn-done"
5
+ @is_rtl = @form_field.hasClassName "chosen-rtl"
11
6
 
12
7
  set_default_values: ->
13
8
  super()
14
9
 
15
10
  # HTML Templates
16
- @single_temp = new Template('<a href="javascript:void(0)" class="chzn-single chzn-default" tabindex="-1"><span>#{default}</span><div><b></b></div></a><div class="chzn-drop"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>')
17
- @multi_temp = new Template('<ul class="chzn-choices"><li class="search-field"><input type="text" value="#{default}" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop"><ul class="chzn-results"></ul></div>')
11
+ @single_temp = new Template('<a class="chosen-single chosen-default" tabindex="-1"><span>#{default}</span><div><b></b></div></a><div class="chosen-drop"><div class="chosen-search"><input type="text" autocomplete="off" /></div><ul class="chosen-results"></ul></div>')
12
+ @multi_temp = new Template('<ul class="chosen-choices"><li class="search-field"><input type="text" value="#{default}" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chosen-drop"><ul class="chosen-results"></ul></div>')
18
13
  @no_results_temp = new Template('<li class="no-results">' + @results_none_found + ' "<span>#{terms}</span>"</li>')
19
14
 
20
15
  set_up_html: ->
21
- container_classes = ["chzn-container"]
22
- container_classes.push "chzn-container-" + (if @is_multiple then "multi" else "single")
16
+ container_classes = ["chosen-container"]
17
+ container_classes.push "chosen-container-" + (if @is_multiple then "multi" else "single")
23
18
  container_classes.push @form_field.className if @inherit_select_classes && @form_field.className
24
- container_classes.push "chzn-rtl" if @is_rtl
19
+ container_classes.push "chosen-rtl" if @is_rtl
25
20
 
26
21
  container_props =
27
22
  'class': container_classes.join ' '
28
23
  'style': "width: #{this.container_width()};"
29
24
  'title': @form_field.title
30
25
 
31
- container_props.id = @form_field.id.replace(/[^\w]/g, '_') + "_chzn" if @form_field.id.length
26
+ container_props.id = @form_field.id.replace(/[^\w]/g, '_') + "_chosen" if @form_field.id.length
32
27
 
33
28
  @container = if @is_multiple then new Element('div', container_props).update( @multi_temp.evaluate({ "default": @default_text}) ) else new Element('div', container_props).update( @single_temp.evaluate({ "default":@default_text }) )
34
29
 
35
30
  @form_field.hide().insert({ after: @container })
36
- @dropdown = @container.down('div.chzn-drop')
31
+ @dropdown = @container.down('div.chosen-drop')
37
32
 
38
33
  @search_field = @container.down('input')
39
- @search_results = @container.down('ul.chzn-results')
34
+ @search_results = @container.down('ul.chosen-results')
40
35
  this.search_field_scale()
41
36
 
42
37
  @search_no_results = @container.down('li.no-results')
43
38
 
44
39
  if @is_multiple
45
- @search_choices = @container.down('ul.chzn-choices')
40
+ @search_choices = @container.down('ul.chosen-choices')
46
41
  @search_container = @container.down('li.search-field')
47
42
  else
48
- @search_container = @container.down('div.chzn-search')
49
- @selected_item = @container.down('.chzn-single')
43
+ @search_container = @container.down('div.chosen-search')
44
+ @selected_item = @container.down('.chosen-single')
50
45
 
51
46
  this.results_build()
52
47
  this.set_tab_index()
53
48
  this.set_label_behavior()
54
- @form_field.fire("liszt:ready", {chosen: this})
49
+ @form_field.fire("chosen:ready", {chosen: this})
55
50
 
56
51
  register_observers: ->
57
52
  @container.observe "mousedown", (evt) => this.container_mousedown(evt)
@@ -65,9 +60,13 @@ class Chosen extends AbstractChosen
65
60
  @search_results.observe "mousewheel", (evt) => this.search_results_mousewheel(evt)
66
61
  @search_results.observe "DOMMouseScroll", (evt) => this.search_results_mousewheel(evt)
67
62
 
68
- @form_field.observe "liszt:updated", (evt) => this.results_update_field(evt)
69
- @form_field.observe "liszt:activate", (evt) => this.activate_field(evt)
70
- @form_field.observe "liszt:open", (evt) => this.container_mousedown(evt)
63
+ @search_results.observe "touchstart", (evt) => this.search_results_touchstart(evt)
64
+ @search_results.observe "touchmove", (evt) => this.search_results_touchmove(evt)
65
+ @search_results.observe "touchend", (evt) => this.search_results_touchend(evt)
66
+
67
+ @form_field.observe "chosen:updated", (evt) => this.results_update_field(evt)
68
+ @form_field.observe "chosen:activate", (evt) => this.activate_field(evt)
69
+ @form_field.observe "chosen:open", (evt) => this.container_mousedown(evt)
71
70
 
72
71
  @search_field.observe "blur", (evt) => this.input_blur(evt)
73
72
  @search_field.observe "keyup", (evt) => this.keyup_checker(evt)
@@ -79,15 +78,37 @@ class Chosen extends AbstractChosen
79
78
  else
80
79
  @container.observe "click", (evt) => evt.preventDefault() # gobble click of anchor
81
80
 
81
+ destroy: ->
82
+ document.stopObserving "click", @click_test_action
83
+
84
+ @form_field.stopObserving()
85
+ @container.stopObserving()
86
+ @search_results.stopObserving()
87
+ @search_field.stopObserving()
88
+ @form_field_label.stopObserving() if @form_field_label?
89
+
90
+ if @is_multiple
91
+ @search_choices.stopObserving()
92
+ @container.select(".search-choice-close").each (choice) ->
93
+ choice.stopObserving()
94
+ else
95
+ @selected_item.stopObserving()
96
+
97
+ if @search_field.tabIndex
98
+ @form_field.tabIndex = @search_field.tabIndex
99
+
100
+ @container.remove()
101
+ @form_field.show()
102
+
82
103
  search_field_disabled: ->
83
104
  @is_disabled = @form_field.disabled
84
105
  if(@is_disabled)
85
- @container.addClassName 'chzn-disabled'
106
+ @container.addClassName 'chosen-disabled'
86
107
  @search_field.disabled = true
87
108
  @selected_item.stopObserving "focus", @activate_action if !@is_multiple
88
109
  this.close_field()
89
110
  else
90
- @container.removeClassName 'chzn-disabled'
111
+ @container.removeClassName 'chosen-disabled'
91
112
  @search_field.disabled = false
92
113
  @selected_item.observe "focus", @activate_action if !@is_multiple
93
114
 
@@ -101,7 +122,7 @@ class Chosen extends AbstractChosen
101
122
  @search_field.clear() if @is_multiple
102
123
  document.observe "click", @click_test_action
103
124
  this.results_show()
104
- else if not @is_multiple and evt and (evt.target is @selected_item || evt.target.up("a.chzn-single"))
125
+ else if not @is_multiple and evt and (evt.target is @selected_item || evt.target.up("a.chosen-single"))
105
126
  this.results_toggle()
106
127
 
107
128
  this.activate_field()
@@ -117,7 +138,7 @@ class Chosen extends AbstractChosen
117
138
  @search_results.scrollTop = delta + @search_results.scrollTop
118
139
 
119
140
  blur_test: (evt) ->
120
- this.close_field() if not @active_field and @container.hasClassName("chzn-container-active")
141
+ this.close_field() if not @active_field and @container.hasClassName("chosen-container-active")
121
142
 
122
143
  close_field: ->
123
144
  document.stopObserving "click", @click_test_action
@@ -125,21 +146,21 @@ class Chosen extends AbstractChosen
125
146
  @active_field = false
126
147
  this.results_hide()
127
148
 
128
- @container.removeClassName "chzn-container-active"
149
+ @container.removeClassName "chosen-container-active"
129
150
  this.clear_backstroke()
130
151
 
131
152
  this.show_search_field_default()
132
153
  this.search_field_scale()
133
154
 
134
155
  activate_field: ->
135
- @container.addClassName "chzn-container-active"
156
+ @container.addClassName "chosen-container-active"
136
157
  @active_field = true
137
158
 
138
159
  @search_field.value = @search_field.value
139
160
  @search_field.focus()
140
161
 
141
162
  test_active_click: (evt) ->
142
- if evt.target.up('.chzn-container') is @container
163
+ if evt.target.up('.chosen-container') is @container
143
164
  @active_field = true
144
165
  else
145
166
  this.close_field()
@@ -148,7 +169,7 @@ class Chosen extends AbstractChosen
148
169
  @parsing = true
149
170
  @selected_option_count = null
150
171
 
151
- @results_data = root.SelectParser.select_to_array @form_field
172
+ @results_data = SelectParser.select_to_array @form_field
152
173
 
153
174
  if @is_multiple
154
175
  @search_choices.select("li.search-choice").invoke("remove")
@@ -156,10 +177,10 @@ class Chosen extends AbstractChosen
156
177
  this.single_set_selected_text()
157
178
  if @disable_search or @form_field.options.length <= @disable_search_threshold
158
179
  @search_field.readOnly = true
159
- @container.addClassName "chzn-container-single-nosearch"
180
+ @container.addClassName "chosen-container-single-nosearch"
160
181
  else
161
182
  @search_field.readOnly = false
162
- @container.removeClassName "chzn-container-single-nosearch"
183
+ @container.removeClassName "chosen-container-single-nosearch"
163
184
 
164
185
  this.update_results_content this.results_option_build({first:true})
165
186
 
@@ -193,11 +214,11 @@ class Chosen extends AbstractChosen
193
214
 
194
215
  results_show: ->
195
216
  if @is_multiple and @max_selected_options <= this.choices_count()
196
- @form_field.fire("liszt:maxselected", {chosen: this})
217
+ @form_field.fire("chosen:maxselected", {chosen: this})
197
218
  return false
198
219
 
199
- @container.addClassName "chzn-with-drop"
200
- @form_field.fire("liszt:showing_dropdown", {chosen: this})
220
+ @container.addClassName "chosen-with-drop"
221
+ @form_field.fire("chosen:showing_dropdown", {chosen: this})
201
222
 
202
223
  @results_showing = true
203
224
 
@@ -213,8 +234,8 @@ class Chosen extends AbstractChosen
213
234
  if @results_showing
214
235
  this.result_clear_highlight()
215
236
 
216
- @container.removeClassName "chzn-with-drop"
217
- @form_field.fire("liszt:hiding_dropdown", {chosen: this})
237
+ @container.removeClassName "chosen-with-drop"
238
+ @form_field.fire("chosen:hiding_dropdown", {chosen: this})
218
239
 
219
240
  @results_showing = false
220
241
 
@@ -302,13 +323,17 @@ class Chosen extends AbstractChosen
302
323
  this.result_clear_highlight()
303
324
 
304
325
  if @is_multiple and @max_selected_options <= this.choices_count()
305
- @form_field.fire("liszt:maxselected", {chosen: this})
326
+ @form_field.fire("chosen:maxselected", {chosen: this})
306
327
  return false
307
328
 
308
329
  if @is_multiple
309
330
  high.removeClassName("active-result")
310
331
  else
311
- @search_results.descendants(".result-selected").invoke "removeClassName", "result-selected"
332
+ if @result_single_selected
333
+ @result_single_selected.removeClassName("result-selected")
334
+ selected_index = @result_single_selected.getAttribute('data-option-array-index')
335
+ @results_data[selected_index].selected = false
336
+
312
337
  @result_single_selected = high
313
338
 
314
339
  high.addClassName("result-selected")
@@ -335,10 +360,10 @@ class Chosen extends AbstractChosen
335
360
 
336
361
  single_set_selected_text: (text=@default_text) ->
337
362
  if text is @default_text
338
- @selected_item.addClassName("chzn-default")
363
+ @selected_item.addClassName("chosen-default")
339
364
  else
340
365
  this.single_deselect_control_build()
341
- @selected_item.removeClassName("chzn-default")
366
+ @selected_item.removeClassName("chosen-default")
342
367
 
343
368
  @selected_item.down("span").update(text)
344
369
 
@@ -363,7 +388,7 @@ class Chosen extends AbstractChosen
363
388
  single_deselect_control_build: ->
364
389
  return unless @allow_single_deselect
365
390
  @selected_item.down("span").insert { after: "<abbr class=\"search-choice-close\"></abbr>" } unless @selected_item.down("abbr")
366
- @selected_item.addClassName("chzn-single-with-deselect")
391
+ @selected_item.addClassName("chosen-single-with-deselect")
367
392
 
368
393
  get_search_text: ->
369
394
  if @search_field.value is @default_text then "" else @search_field.value.strip().escapeHTML()
@@ -473,5 +498,3 @@ class Chosen extends AbstractChosen
473
498
  w = f_width - 10
474
499
 
475
500
  @search_field.setStyle({'width': w + 'px'})
476
-
477
- root.Chosen = Chosen
@@ -1,5 +1,3 @@
1
- root = this
2
-
3
1
  class AbstractChosen
4
2
 
5
3
  constructor: (@form_field, @options={}) ->
@@ -13,8 +11,6 @@ class AbstractChosen
13
11
  this.set_up_html()
14
12
  this.register_observers()
15
13
 
16
- this.finish_setup()
17
-
18
14
  set_default_values: ->
19
15
  @click_test_action = (evt) => this.test_active_click(evt)
20
16
  @activate_action = (evt) => this.activate_field(evt)
@@ -32,6 +28,8 @@ class AbstractChosen
32
28
  @single_backstroke_delete = if @options.single_backstroke_delete? then @options.single_backstroke_delete else true
33
29
  @max_selected_options = @options.max_selected_options || Infinity
34
30
  @inherit_select_classes = @options.inherit_select_classes || false
31
+ @display_selected_options = if @options.display_selected_options? then @options.display_selected_options else true
32
+ @display_disabled_options = if @options.display_disabled_options? then @options.display_disabled_options else true
35
33
 
36
34
  set_default_text: ->
37
35
  if @form_field.getAttribute("data-placeholder")
@@ -60,9 +58,9 @@ class AbstractChosen
60
58
  results_option_build: (options) ->
61
59
  content = ''
62
60
  for data in @results_data
63
- if data.group && (data.search_match || data.group_match)
61
+ if data.group
64
62
  content += this.result_add_group data
65
- else if !data.empty && data.search_match
63
+ else
66
64
  content += this.result_add_option data
67
65
 
68
66
  # this select logic pins on an awkward flag
@@ -76,6 +74,9 @@ class AbstractChosen
76
74
  content
77
75
 
78
76
  result_add_option: (option) ->
77
+ return '' unless option.search_match
78
+ return '' unless this.include_option_in_results(option)
79
+
79
80
  classes = []
80
81
  classes.push "active-result" if !option.disabled and !(option.selected and @is_multiple)
81
82
  classes.push "disabled-result" if option.disabled and !(option.selected and @is_multiple)
@@ -83,12 +84,23 @@ class AbstractChosen
83
84
  classes.push "group-option" if option.group_array_index?
84
85
  classes.push option.classes if option.classes != ""
85
86
 
86
- style = if option.style.cssText != "" then " style=\"#{option.style}\"" else ""
87
+ option_el = document.createElement("li")
88
+ option_el.className = classes.join(" ")
89
+ option_el.style.cssText = option.style
90
+ option_el.setAttribute("data-option-array-index", option.array_index)
91
+ option_el.innerHTML = option.search_text
87
92
 
88
- """<li class="#{classes.join(' ')}"#{style} data-option-array-index="#{option.array_index}">#{option.search_text}</li>"""
93
+ this.outerHTML(option_el)
89
94
 
90
95
  result_add_group: (group) ->
91
- """<li class="group-result">#{group.search_text}</li>"""
96
+ return '' unless group.search_match || group.group_match
97
+ return '' unless group.active_options > 0
98
+
99
+ group_el = document.createElement("li")
100
+ group_el.className = "group-result"
101
+ group_el.innerHTML = group.search_text
102
+
103
+ this.outerHTML(group_el)
92
104
 
93
105
  results_update_field: ->
94
106
  this.set_default_text()
@@ -116,21 +128,32 @@ class AbstractChosen
116
128
  results = 0
117
129
 
118
130
  searchText = this.get_search_text()
131
+ escapedSearchText = searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&")
119
132
  regexAnchor = if @search_contains then "" else "^"
120
- regex = new RegExp(regexAnchor + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i')
121
- zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i')
133
+ regex = new RegExp(regexAnchor + escapedSearchText, 'i')
134
+ zregex = new RegExp(escapedSearchText, 'i')
122
135
 
123
136
  for option in @results_data
124
- if not option.empty
125
137
 
126
- option.group_match = false if option.group
138
+ option.search_match = false
139
+ results_group = null
127
140
 
141
+ if this.include_option_in_results(option)
142
+
143
+ if option.group
144
+ option.group_match = false
145
+ option.active_options = 0
146
+
147
+ if option.group_array_index? and @results_data[option.group_array_index]
148
+ results_group = @results_data[option.group_array_index]
149
+ results += 1 if results_group.active_options is 0 and results_group.search_match
150
+ results_group.active_options += 1
151
+
128
152
  unless option.group and not @group_search
129
- option.search_match = false
130
153
 
131
154
  option.search_text = if option.group then option.label else option.html
132
155
  option.search_match = this.search_string_match(option.search_text, regex)
133
- results += 1 if option.search_match
156
+ results += 1 if option.search_match and not option.group
134
157
 
135
158
  if option.search_match
136
159
  if searchText.length
@@ -138,14 +161,15 @@ class AbstractChosen
138
161
  text = option.search_text.substr(0, startpos + searchText.length) + '</em>' + option.search_text.substr(startpos + searchText.length)
139
162
  option.search_text = text.substr(0, startpos) + '<em>' + text.substr(startpos)
140
163
 
141
- @results_data[option.group_array_index].group_match = true if option.group_array_index?
164
+ results_group.group_match = true if results_group?
142
165
 
143
166
  else if option.group_array_index? and @results_data[option.group_array_index].search_match
144
167
  option.search_match = true
145
168
 
169
+ this.result_clear_highlight()
170
+
146
171
  if results < 1 and searchText.length
147
172
  this.update_results_content ""
148
- this.result_clear_highlight()
149
173
  this.no_results searchText
150
174
  else
151
175
  this.update_results_content this.results_option_build()
@@ -199,15 +223,44 @@ class AbstractChosen
199
223
  container_width: ->
200
224
  return if @options.width? then @options.width else "#{@form_field.offsetWidth}px"
201
225
 
226
+ include_option_in_results: (option) ->
227
+ return false if @is_multiple and (not @display_selected_options and option.selected)
228
+ return false if not @display_disabled_options and option.disabled
229
+ return false if option.empty
230
+
231
+ return true
232
+
233
+ search_results_touchstart: (evt) ->
234
+ @touch_started = true
235
+ this.search_results_mouseover(evt)
236
+
237
+ search_results_touchmove: (evt) ->
238
+ @touch_started = false
239
+ this.search_results_mouseout(evt)
240
+
241
+ search_results_touchend: (evt) ->
242
+ this.search_results_mouseup(evt) if @touch_started
243
+
244
+ outerHTML: (element) ->
245
+ return element.outerHTML if element.outerHTML
246
+ tmp = document.createElement("div")
247
+ tmp.appendChild(element)
248
+ tmp.innerHTML
249
+
202
250
  # class methods and variables ============================================================
203
251
 
204
252
  @browser_is_supported: ->
205
253
  if window.navigator.appName == "Microsoft Internet Explorer"
206
- return null isnt document.documentMode >= 8
254
+ return document.documentMode >= 8
255
+ if /iP(od|hone)/i.test(window.navigator.userAgent)
256
+ return false
257
+ if /Android/i.test(window.navigator.userAgent)
258
+ return false if /Mobile/i.test(window.navigator.userAgent)
207
259
  return true
208
260
 
209
261
  @default_multiple_text: "Select Some Options"
210
262
  @default_single_text: "Select an Option"
211
263
  @default_no_result_text: "No results match"
212
264
 
213
- root.AbstractChosen = AbstractChosen
265
+
266
+ window.AbstractChosen = AbstractChosen
@@ -63,4 +63,4 @@ SelectParser.select_to_array = (select) ->
63
63
  parser.add_node( child ) for child in select.childNodes
64
64
  parser.parsed
65
65
 
66
- this.SelectParser = SelectParser
66
+ window.SelectParser = SelectParser
@@ -6,7 +6,7 @@ $chosen-sprite: image-url('chosen-sprite.png');
6
6
  $chosen-sprite-retina: image-url('chosen-sprite@2x.png');
7
7
 
8
8
  /* @group Base */
9
- .chzn-container {
9
+ .chosen-container {
10
10
  position: relative;
11
11
  display: inline-block;
12
12
  vertical-align: middle;
@@ -14,7 +14,7 @@ $chosen-sprite-retina: image-url('chosen-sprite@2x.png');
14
14
  zoom: 1;
15
15
  *display: inline;
16
16
  @include user-select(none);
17
- .chzn-drop {
17
+ .chosen-drop {
18
18
  position: absolute;
19
19
  top: 100%;
20
20
  left: -9999px;
@@ -26,15 +26,18 @@ $chosen-sprite-retina: image-url('chosen-sprite@2x.png');
26
26
  background: #fff;
27
27
  box-shadow: 0 4px 5px rgba(#000,.15);
28
28
  }
29
- &.chzn-with-drop .chzn-drop {
29
+ &.chosen-with-drop .chosen-drop {
30
30
  left: 0;
31
31
  }
32
+ a{
33
+ cursor: pointer;
34
+ }
32
35
  }
33
36
  /* @end */
34
37
 
35
38
  /* @group Single Chosen */
36
- .chzn-container-single{
37
- .chzn-single {
39
+ .chosen-container-single{
40
+ .chosen-single {
38
41
  position: relative;
39
42
  display: block;
40
43
  overflow: hidden;
@@ -51,20 +54,20 @@ $chosen-sprite-retina: image-url('chosen-sprite@2x.png');
51
54
  white-space: nowrap;
52
55
  line-height: 24px;
53
56
  }
54
- .chzn-default {
57
+ .chosen-default {
55
58
  color: #999;
56
59
  }
57
- .chzn-single span {
60
+ .chosen-single span {
58
61
  display: block;
59
62
  overflow: hidden;
60
63
  margin-right: 26px;
61
64
  text-overflow: ellipsis;
62
65
  white-space: nowrap;
63
66
  }
64
- .chzn-single-with-deselect span {
67
+ .chosen-single-with-deselect span {
65
68
  margin-right: 38px;
66
69
  }
67
- .chzn-single abbr {
70
+ .chosen-single abbr {
68
71
  position: absolute;
69
72
  top: 6px;
70
73
  right: 26px;
@@ -77,10 +80,10 @@ $chosen-sprite-retina: image-url('chosen-sprite@2x.png');
77
80
  background-position: -42px -10px;
78
81
  }
79
82
  }
80
- &.chzn-disabled .chzn-single abbr:hover {
83
+ &.chosen-disabled .chosen-single abbr:hover {
81
84
  background-position: -42px -10px;
82
85
  }
83
- .chzn-single div {
86
+ .chosen-single div {
84
87
  position: absolute;
85
88
  top: 0;
86
89
  right: 0;
@@ -94,7 +97,7 @@ $chosen-sprite-retina: image-url('chosen-sprite@2x.png');
94
97
  background: $chosen-sprite no-repeat 0px 2px;
95
98
  }
96
99
  }
97
- .chzn-search {
100
+ .chosen-search {
98
101
  position: relative;
99
102
  z-index: 1010;
100
103
  margin: 0;
@@ -116,12 +119,12 @@ $chosen-sprite-retina: image-url('chosen-sprite@2x.png');
116
119
  border-radius: 0;
117
120
  }
118
121
  }
119
- .chzn-drop {
122
+ .chosen-drop {
120
123
  margin-top: -1px;
121
124
  border-radius: 0 0 4px 4px;
122
125
  background-clip: padding-box;
123
126
  }
124
- &.chzn-container-single-nosearch .chzn-search {
127
+ &.chosen-container-single-nosearch .chosen-search {
125
128
  position: absolute;
126
129
  left: -9999px;
127
130
  }
@@ -129,7 +132,7 @@ $chosen-sprite-retina: image-url('chosen-sprite@2x.png');
129
132
  /* @end */
130
133
 
131
134
  /* @group Results */
132
- .chzn-container .chzn-results {
135
+ .chosen-container .chosen-results {
133
136
  position: relative;
134
137
  overflow-x: hidden;
135
138
  overflow-y: auto;
@@ -143,6 +146,7 @@ $chosen-sprite-retina: image-url('chosen-sprite@2x.png');
143
146
  padding: 5px 6px;
144
147
  list-style: none;
145
148
  line-height: 15px;
149
+ -webkit-touch-callout: none;
146
150
  &.active-result {
147
151
  display: list-item;
148
152
  cursor: pointer;
@@ -178,8 +182,8 @@ $chosen-sprite-retina: image-url('chosen-sprite@2x.png');
178
182
  /* @end */
179
183
 
180
184
  /* @group Multi Chosen */
181
- .chzn-container-multi{
182
- .chzn-choices {
185
+ .chosen-container-multi{
186
+ .chosen-choices {
183
187
  position: relative;
184
188
  overflow: hidden;
185
189
  @include box-sizing(border-box);
@@ -193,7 +197,7 @@ $chosen-sprite-retina: image-url('chosen-sprite@2x.png');
193
197
  @include background-image(linear-gradient(#eee 1%, #fff 15%));
194
198
  cursor: text;
195
199
  }
196
- .chzn-choices li {
200
+ .chosen-choices li {
197
201
  float: left;
198
202
  list-style: none;
199
203
  &.search-field {
@@ -259,11 +263,11 @@ $chosen-sprite-retina: image-url('chosen-sprite@2x.png');
259
263
  }
260
264
  }
261
265
  }
262
- .chzn-results {
266
+ .chosen-results {
263
267
  margin: 0;
264
268
  padding: 0;
265
269
  }
266
- .chzn-drop .result-selected {
270
+ .chosen-drop .result-selected {
267
271
  display: list-item;
268
272
  color: #ccc;
269
273
  cursor: default;
@@ -272,13 +276,13 @@ $chosen-sprite-retina: image-url('chosen-sprite@2x.png');
272
276
  /* @end */
273
277
 
274
278
  /* @group Active */
275
- .chzn-container-active{
276
- .chzn-single {
279
+ .chosen-container-active{
280
+ .chosen-single {
277
281
  border: 1px solid #5897fb;
278
282
  box-shadow: 0 0 5px rgba(#000,.3);
279
283
  }
280
- &.chzn-with-drop{
281
- .chzn-single {
284
+ &.chosen-with-drop{
285
+ .chosen-single {
282
286
  border: 1px solid #aaa;
283
287
  -moz-border-radius-bottomright: 0;
284
288
  border-bottom-right-radius: 0;
@@ -287,7 +291,7 @@ $chosen-sprite-retina: image-url('chosen-sprite@2x.png');
287
291
  @include background-image(linear-gradient(#eee 20%, #fff 80%));
288
292
  box-shadow: 0 1px 0 #fff inset;
289
293
  }
290
- .chzn-single div {
294
+ .chosen-single div {
291
295
  border-left: none;
292
296
  background: transparent;
293
297
  b {
@@ -295,7 +299,7 @@ $chosen-sprite-retina: image-url('chosen-sprite@2x.png');
295
299
  }
296
300
  }
297
301
  }
298
- .chzn-choices {
302
+ .chosen-choices {
299
303
  border: 1px solid #5897fb;
300
304
  box-shadow: 0 0 5px rgba(#000,.3);
301
305
  li.search-field input[type="text"] {
@@ -306,42 +310,42 @@ $chosen-sprite-retina: image-url('chosen-sprite@2x.png');
306
310
  /* @end */
307
311
 
308
312
  /* @group Disabled Support */
309
- .chzn-disabled {
313
+ .chosen-disabled {
310
314
  opacity: 0.5 !important;
311
315
  cursor: default;
312
- .chzn-single {
316
+ .chosen-single {
313
317
  cursor: default;
314
318
  }
315
- .chzn-choices .search-choice .search-choice-close {
319
+ .chosen-choices .search-choice .search-choice-close {
316
320
  cursor: default;
317
321
  }
318
322
  }
319
323
  /* @end */
320
324
 
321
325
  /* @group Right to Left */
322
- .chzn-rtl {
326
+ .chosen-rtl {
323
327
  text-align: right;
324
- .chzn-single {
328
+ .chosen-single {
325
329
  overflow: visible;
326
330
  padding: 0 8px 0 0;
327
331
  }
328
- .chzn-single span {
332
+ .chosen-single span {
329
333
  margin-right: 0;
330
334
  margin-left: 26px;
331
335
  direction: rtl;
332
336
  }
333
- .chzn-single-with-deselect span {
337
+ .chosen-single-with-deselect span {
334
338
  margin-left: 38px;
335
339
  }
336
- .chzn-single div {
340
+ .chosen-single div {
337
341
  right: auto;
338
342
  left: 3px;
339
343
  }
340
- .chzn-single abbr {
344
+ .chosen-single abbr {
341
345
  right: auto;
342
346
  left: 26px;
343
347
  }
344
- .chzn-choices li {
348
+ .chosen-choices li {
345
349
  float: right;
346
350
  &.search-field input[type="text"] {
347
351
  direction: rtl;
@@ -355,33 +359,33 @@ $chosen-sprite-retina: image-url('chosen-sprite@2x.png');
355
359
  }
356
360
  }
357
361
  }
358
- &.chzn-container-single-nosearch .chzn-search,
359
- .chzn-drop {
362
+ &.chosen-container-single-nosearch .chosen-search,
363
+ .chosen-drop {
360
364
  left: 9999px;
361
365
  }
362
- &.chzn-container-single .chzn-results {
366
+ &.chosen-container-single .chosen-results {
363
367
  margin: 0 0 4px 4px;
364
368
  padding: 0 4px 0 0;
365
369
  }
366
- .chzn-results li.group-option {
370
+ .chosen-results li.group-option {
367
371
  padding-right: 15px;
368
372
  padding-left: 0;
369
373
  }
370
- &.chzn-container-active.chzn-with-drop .chzn-single div {
374
+ &.chosen-container-active.chosen-with-drop .chosen-single div {
371
375
  border-right: none;
372
376
  }
373
- .chzn-search input[type="text"] {
377
+ .chosen-search input[type="text"] {
374
378
  padding: 4px 5px 4px 20px;
375
379
  background: #fff $chosen-sprite no-repeat -30px -20px;
376
380
  @include background($chosen-sprite no-repeat -30px -20px, linear-gradient(#eee 1%, #fff 15%));
377
381
  direction: rtl;
378
382
  }
379
- &.chzn-container-single{
380
- .chzn-single div b {
383
+ &.chosen-container-single{
384
+ .chosen-single div b {
381
385
  background-position: 6px 2px;
382
386
  }
383
- &.chzn-with-drop{
384
- .chzn-single div b {
387
+ &.chosen-with-drop{
388
+ .chosen-single div b {
385
389
  background-position: -12px 2px;
386
390
  }
387
391
  }
@@ -392,13 +396,13 @@ $chosen-sprite-retina: image-url('chosen-sprite@2x.png');
392
396
 
393
397
  /* @group Retina compatibility */
394
398
  @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min-resolution: 144dpi) {
395
- .chzn-rtl .chzn-search input[type="text"],
396
- .chzn-container-single .chzn-single abbr,
397
- .chzn-container-single .chzn-single div b,
398
- .chzn-container-single .chzn-search input[type="text"],
399
- .chzn-container-multi .chzn-choices .search-choice .search-choice-close,
400
- .chzn-container .chzn-results-scroll-down span,
401
- .chzn-container .chzn-results-scroll-up span {
399
+ .chosen-rtl .chosen-search input[type="text"],
400
+ .chosen-container-single .chosen-single abbr,
401
+ .chosen-container-single .chosen-single div b,
402
+ .chosen-container-single .chosen-search input[type="text"],
403
+ .chosen-container-multi .chosen-choices .search-choice .search-choice-close,
404
+ .chosen-container .chosen-results-scroll-down span,
405
+ .chosen-container .chosen-results-scroll-up span {
402
406
  background-image: $chosen-sprite-retina !important;
403
407
  background-size: 52px 37px !important;
404
408
  background-repeat: no-repeat !important;
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chosen-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tse-Ching Ho
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-22 00:00:00.000000000 Z
11
+ date: 2013-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties