Skip to content

Commit

Permalink
rake update-chosen
Browse files Browse the repository at this point in the history
  • Loading branch information
tsechingho committed Mar 11, 2015
1 parent 94bd8b2 commit 465fb65
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/chosen-rails/version.rb
@@ -1,6 +1,6 @@
module Chosen
module Rails
VERSION = '1.3.0'
CHOSEN_VERSION = '1.3.0'
CHOSEN_VERSION = '1.4.1'
end
end
9 changes: 6 additions & 3 deletions vendor/assets/javascripts/chosen.jquery.coffee
Expand Up @@ -68,8 +68,8 @@ class Chosen extends AbstractChosen
@form_field_jq.trigger("chosen:ready", {chosen: this})

register_observers: ->
@container.bind 'touchstart.chosen', (evt) => this.container_mousedown(evt); return
@container.bind 'touchend.chosen', (evt) => this.container_mouseup(evt); return
@container.bind 'touchstart.chosen', (evt) => this.container_mousedown(evt); evt.preventDefault()
@container.bind 'touchend.chosen', (evt) => this.container_mouseup(evt); evt.preventDefault()

@container.bind 'mousedown.chosen', (evt) => this.container_mousedown(evt); return
@container.bind 'mouseup.chosen', (evt) => this.container_mouseup(evt); return
Expand Down Expand Up @@ -362,6 +362,9 @@ class Chosen extends AbstractChosen

@form_field_jq.trigger "change", {'selected': @form_field.options[item.options_index].value} if @is_multiple || @form_field.selectedIndex != @current_selectedIndex
@current_selectedIndex = @form_field.selectedIndex

evt.preventDefault()

this.search_field_scale()

single_set_selected_text: (text=@default_text) ->
Expand Down Expand Up @@ -398,7 +401,7 @@ class Chosen extends AbstractChosen
@selected_item.addClass("chosen-single-with-deselect")

get_search_text: ->
if @search_field.val() is @default_text then "" else $('<div/>').text($.trim(@search_field.val())).html()
$('<div/>').text($.trim(@search_field.val())).html()

winnow_results_set_highlight: ->
selected_results = if not @is_multiple then @search_results.find(".result-selected.active-result") else []
Expand Down
8 changes: 5 additions & 3 deletions vendor/assets/javascripts/chosen.proto.coffee
Expand Up @@ -51,8 +51,8 @@ class @Chosen extends AbstractChosen
@form_field.fire("chosen:ready", {chosen: this})

register_observers: ->
@container.observe "touchstart", (evt) => this.container_mousedown(evt)
@container.observe "touchend", (evt) => this.container_mouseup(evt)
@container.observe "touchstart", (evt) => this.container_mousedown(evt); evt.preventDefault()
@container.observe "touchend", (evt) => this.container_mouseup(evt); evt.preventDefault()

@container.observe "mousedown", (evt) => this.container_mousedown(evt)
@container.observe "mouseup", (evt) => this.container_mouseup(evt)
Expand Down Expand Up @@ -358,6 +358,8 @@ class @Chosen extends AbstractChosen
@form_field.simulate("change") if typeof Event.simulate is 'function' && (@is_multiple || @form_field.selectedIndex != @current_selectedIndex)
@current_selectedIndex = @form_field.selectedIndex

evt.preventDefault()

this.search_field_scale()

single_set_selected_text: (text=@default_text) ->
Expand Down Expand Up @@ -393,7 +395,7 @@ class @Chosen extends AbstractChosen
@selected_item.addClassName("chosen-single-with-deselect")

get_search_text: ->
if @search_field.value is @default_text then "" else @search_field.value.strip().escapeHTML()
@search_field.value.strip().escapeHTML()

winnow_results_set_highlight: ->
if not @is_multiple
Expand Down
16 changes: 9 additions & 7 deletions vendor/assets/javascripts/lib/abstract-chosen.coffee
Expand Up @@ -77,7 +77,7 @@ class AbstractChosen
if data.selected and @is_multiple
this.choice_build data
else if data.selected and not @is_multiple
this.single_set_selected_text(data.text)
this.single_set_selected_text(this.choice_label(data))

content

Expand All @@ -97,6 +97,7 @@ class AbstractChosen
option_el.style.cssText = option.style
option_el.setAttribute("data-option-array-index", option.array_index)
option_el.innerHTML = option.search_text
option_el.title = option.title if option.title

this.outerHTML(option_el)

Expand All @@ -111,6 +112,7 @@ class AbstractChosen
group_el = document.createElement("li")
group_el.className = classes.join(" ")
group_el.innerHTML = group.search_text
group_el.title = group.title if group.title

this.outerHTML(group_el)

Expand Down Expand Up @@ -162,10 +164,10 @@ class AbstractChosen
results_group = @results_data[option.group_array_index]
results += 1 if results_group.active_options is 0 and results_group.search_match
results_group.active_options += 1

unless option.group and not @group_search

option.search_text = if option.group then option.label else option.text
option.search_text = if option.group then option.label else option.html

unless option.group and not @group_search
option.search_match = this.search_string_match(option.search_text, regex)
results += 1 if option.search_match and not option.group

Expand All @@ -176,7 +178,7 @@ class AbstractChosen
option.search_text = text.substr(0, startpos) + '<em>' + text.substr(startpos)

results_group.group_match = true if results_group?

else if option.group_array_index? and @results_data[option.group_array_index].search_match
option.search_match = true

Expand Down Expand Up @@ -210,7 +212,7 @@ class AbstractChosen
@selected_option_count = 0
for option in @form_field.options
@selected_option_count += 1 if option.selected

return @selected_option_count

choices_click: (evt) ->
Expand Down Expand Up @@ -268,7 +270,7 @@ class AbstractChosen
tmp.appendChild(element)
tmp.innerHTML

# class methods and variables ============================================================
# class methods and variables ============================================================

@browser_is_supported: ->
if window.navigator.appName == "Microsoft Internet Explorer"
Expand Down
2 changes: 2 additions & 0 deletions vendor/assets/javascripts/lib/select-parser.coffee
Expand Up @@ -16,6 +16,7 @@ class SelectParser
array_index: group_position
group: true
label: this.escapeExpression(group.label)
title: group.title if group.title
children: 0
disabled: group.disabled,
classes: group.className
Expand All @@ -32,6 +33,7 @@ class SelectParser
value: option.value
text: option.text
html: option.innerHTML
title: option.title if option.title
selected: option.selected
disabled: if group_disabled is true then group_disabled else option.disabled
group_array_index: group_position
Expand Down

0 comments on commit 465fb65

Please sign in to comment.