chosen-rails 0.9.10 → 0.9.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  module Chosen
2
2
  module Rails
3
- VERSION = "0.9.10"
4
- CHOSEN_VERSION = "0.9.10"
3
+ VERSION = "0.9.11"
4
+ CHOSEN_VERSION = "0.9.11"
5
5
  end
6
6
  end
@@ -30,11 +30,16 @@ class Chosen extends AbstractChosen
30
30
  @container_id = if @form_field.id.length then @form_field.id.replace(/[^\w]/g, '_') else this.generate_field_id()
31
31
  @container_id += "_chzn"
32
32
 
33
+ container_classes = ["chzn-container"]
34
+ container_classes.push "chzn-container-" + (if @is_multiple then "multi" else "single")
35
+ container_classes.push @form_field.className if @inherit_select_classes && @form_field.className
36
+ container_classes.push "chzn-rtl" if @is_rtl
37
+
33
38
  @f_width = @form_field_jq.outerWidth()
34
39
 
35
40
  container_props =
36
41
  id: @container_id
37
- class: "chzn-container#{ if @is_rtl then ' chzn-rtl' else '' }"
42
+ class: container_classes.join ' '
38
43
  style: 'width: ' + (@f_width) + 'px;' #use parens around @f_width so coffeescript doesn't think + ' px' is a function parameter
39
44
  title: @form_field.title
40
45
 
@@ -47,7 +52,6 @@ class Chosen extends AbstractChosen
47
52
 
48
53
  @form_field_jq.hide().after container_div
49
54
  @container = ($ '#' + @container_id)
50
- @container.addClass( "chzn-container-" + (if @is_multiple then "multi" else "single") )
51
55
  @dropdown = @container.find('div.chzn-drop').first()
52
56
 
53
57
  dd_top = @container.height()
@@ -420,7 +424,7 @@ class Chosen extends AbstractChosen
420
424
  if regex.test option.html
421
425
  found = true
422
426
  results += 1
423
- else if @search_split_words and (option.html.indexOf(" ") >= 0 or option.html.indexOf("[") == 0)
427
+ else if @enable_split_word_search and (option.html.indexOf(" ") >= 0 or option.html.indexOf("[") == 0)
424
428
  #TODO: replace this substitution of /\[\]/ with a list of characters to skip.
425
429
  parts = option.html.replace(/\[|\]/g, "").split(" ")
426
430
  if parts.length
@@ -26,11 +26,16 @@ class Chosen extends AbstractChosen
26
26
  set_up_html: ->
27
27
  @container_id = @form_field.identify().replace(/[^\w]/g, '_') + "_chzn"
28
28
 
29
+ container_classes = ["chzn-container"]
30
+ container_classes.push "chzn-container-" + (if @is_multiple then "multi" else "single")
31
+ container_classes.push @form_field.className if @inherit_select_classes && @form_field.className
32
+ container_classes.push "chzn-rtl" if @is_rtl
33
+
29
34
  @f_width = if @form_field.getStyle("width") then parseInt @form_field.getStyle("width"), 10 else @form_field.getWidth()
30
35
 
31
36
  container_props =
32
37
  'id': @container_id
33
- 'class': "chzn-container#{ if @is_rtl then ' chzn-rtl' else '' }"
38
+ 'class': container_classes.join ' '
34
39
  'style': 'width: ' + (@f_width) + 'px' #use parens around @f_width so coffeescript doesn't think + ' px' is a function parameter
35
40
  'title': @form_field.title
36
41
 
@@ -38,7 +43,6 @@ class Chosen extends AbstractChosen
38
43
 
39
44
  @form_field.hide().insert({ after: base_template })
40
45
  @container = $(@container_id)
41
- @container.addClassName( "chzn-container-" + (if @is_multiple then "multi" else "single") )
42
46
  @dropdown = @container.down('div.chzn-drop')
43
47
 
44
48
  dd_top = @container.getHeight()
@@ -404,7 +408,7 @@ class Chosen extends AbstractChosen
404
408
  if regex.test option.html
405
409
  found = true
406
410
  results += 1
407
- else if @search_split_words and (option.html.indexOf(" ") >= 0 or option.html.indexOf("[") == 0)
411
+ else if @enable_split_word_search and (option.html.indexOf(" ") >= 0 or option.html.indexOf("[") == 0)
408
412
  #TODO: replace this substitution of /\[\]/ with a list of characters to skip.
409
413
  parts = option.html.replace(/\[|\]/g, "").split(" ")
410
414
  if parts.length
@@ -29,11 +29,12 @@ class AbstractChosen
29
29
  @allow_single_deselect = if @options.allow_single_deselect? and @form_field.options[0]? and @form_field.options[0].text is "" then @options.allow_single_deselect else false
30
30
  @disable_search_threshold = @options.disable_search_threshold || 0
31
31
  @disable_search = @options.disable_search || false
32
- @search_split_words = not (@options.disable_search_split_words || false)
32
+ @enable_split_word_search = if @options.enable_split_word_search? then @options.enable_split_word_search else true
33
33
  @search_contains = @options.search_contains || false
34
34
  @choices = 0
35
35
  @single_backstroke_delete = @options.single_backstroke_delete || false
36
36
  @max_selected_options = @options.max_selected_options || Infinity
37
+ @inherit_select_classes = @options.inherit_select_classes || false
37
38
 
38
39
  set_default_text: ->
39
40
  if @form_field.getAttribute("data-placeholder")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chosen-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.10
4
+ version: 0.9.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-09 00:00:00.000000000 Z
12
+ date: 2012-12-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties