Permalink
Browse files

rake update-chosen (0.9.11)

  • Loading branch information...
tsechingho committed Dec 17, 2012
1 parent f69cfbf commit ef6d95fc922b95274d05b6acc1cad54eba038b9b
@@ -1,6 +1,6 @@
module Chosen
module Rails
- VERSION = "0.9.10"
- CHOSEN_VERSION = "0.9.10"
+ VERSION = "0.9.11"
+ CHOSEN_VERSION = "0.9.11"
end
end
@@ -30,11 +30,16 @@ class Chosen extends AbstractChosen
@container_id = if @form_field.id.length then @form_field.id.replace(/[^\w]/g, '_') else this.generate_field_id()
@container_id += "_chzn"
+ container_classes = ["chzn-container"]
+ container_classes.push "chzn-container-" + (if @is_multiple then "multi" else "single")
+ container_classes.push @form_field.className if @inherit_select_classes && @form_field.className
+ container_classes.push "chzn-rtl" if @is_rtl
+
@f_width = @form_field_jq.outerWidth()
container_props =
id: @container_id
- class: "chzn-container#{ if @is_rtl then ' chzn-rtl' else '' }"
+ class: container_classes.join ' '
style: 'width: ' + (@f_width) + 'px;' #use parens around @f_width so coffeescript doesn't think + ' px' is a function parameter
title: @form_field.title
@@ -47,7 +52,6 @@ class Chosen extends AbstractChosen
@form_field_jq.hide().after container_div
@container = ($ '#' + @container_id)
- @container.addClass( "chzn-container-" + (if @is_multiple then "multi" else "single") )
@dropdown = @container.find('div.chzn-drop').first()
dd_top = @container.height()
@@ -420,7 +424,7 @@ class Chosen extends AbstractChosen
if regex.test option.html
found = true
results += 1
- else if @search_split_words and (option.html.indexOf(" ") >= 0 or option.html.indexOf("[") == 0)
+ else if @enable_split_word_search and (option.html.indexOf(" ") >= 0 or option.html.indexOf("[") == 0)
#TODO: replace this substitution of /\[\]/ with a list of characters to skip.
parts = option.html.replace(/\[|\]/g, "").split(" ")
if parts.length
@@ -26,19 +26,23 @@ class Chosen extends AbstractChosen
set_up_html: ->
@container_id = @form_field.identify().replace(/[^\w]/g, '_') + "_chzn"
+ container_classes = ["chzn-container"]
+ container_classes.push "chzn-container-" + (if @is_multiple then "multi" else "single")
+ container_classes.push @form_field.className if @inherit_select_classes && @form_field.className
+ container_classes.push "chzn-rtl" if @is_rtl
+
@f_width = if @form_field.getStyle("width") then parseInt @form_field.getStyle("width"), 10 else @form_field.getWidth()
container_props =
'id': @container_id
- 'class': "chzn-container#{ if @is_rtl then ' chzn-rtl' else '' }"
+ 'class': container_classes.join ' '
'style': 'width: ' + (@f_width) + 'px' #use parens around @f_width so coffeescript doesn't think + ' px' is a function parameter
'title': @form_field.title
base_template = 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 }) )
@form_field.hide().insert({ after: base_template })
@container = $(@container_id)
- @container.addClassName( "chzn-container-" + (if @is_multiple then "multi" else "single") )
@dropdown = @container.down('div.chzn-drop')
dd_top = @container.getHeight()
@@ -404,7 +408,7 @@ class Chosen extends AbstractChosen
if regex.test option.html
found = true
results += 1
- else if @search_split_words and (option.html.indexOf(" ") >= 0 or option.html.indexOf("[") == 0)
+ else if @enable_split_word_search and (option.html.indexOf(" ") >= 0 or option.html.indexOf("[") == 0)
#TODO: replace this substitution of /\[\]/ with a list of characters to skip.
parts = option.html.replace(/\[|\]/g, "").split(" ")
if parts.length
@@ -29,11 +29,12 @@ class AbstractChosen
@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
@disable_search_threshold = @options.disable_search_threshold || 0
@disable_search = @options.disable_search || false
- @search_split_words = not (@options.disable_search_split_words || false)
+ @enable_split_word_search = if @options.enable_split_word_search? then @options.enable_split_word_search else true
@search_contains = @options.search_contains || false
@choices = 0
@single_backstroke_delete = @options.single_backstroke_delete || false
@max_selected_options = @options.max_selected_options || Infinity
+ @inherit_select_classes = @options.inherit_select_classes || false
set_default_text: ->
if @form_field.getAttribute("data-placeholder")

0 comments on commit ef6d95f

Please sign in to comment.