From 465fb6549ba2bde05d98aa3f5d8661d8b4d36b55 Mon Sep 17 00:00:00 2001 From: Tse-Ching Ho Date: Wed, 11 Mar 2015 21:56:09 +0800 Subject: [PATCH] rake update-chosen --- lib/chosen-rails/version.rb | 2 +- vendor/assets/javascripts/chosen.jquery.coffee | 9 ++++++--- vendor/assets/javascripts/chosen.proto.coffee | 8 +++++--- .../javascripts/lib/abstract-chosen.coffee | 16 +++++++++------- .../assets/javascripts/lib/select-parser.coffee | 2 ++ 5 files changed, 23 insertions(+), 14 deletions(-) diff --git a/lib/chosen-rails/version.rb b/lib/chosen-rails/version.rb index e94c0ab..1b017be 100644 --- a/lib/chosen-rails/version.rb +++ b/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 diff --git a/vendor/assets/javascripts/chosen.jquery.coffee b/vendor/assets/javascripts/chosen.jquery.coffee index 10cc94a..6fae2d4 100644 --- a/vendor/assets/javascripts/chosen.jquery.coffee +++ b/vendor/assets/javascripts/chosen.jquery.coffee @@ -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 @@ -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) -> @@ -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 $('
').text($.trim(@search_field.val())).html() + $('
').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 [] diff --git a/vendor/assets/javascripts/chosen.proto.coffee b/vendor/assets/javascripts/chosen.proto.coffee index 2b928db..3c6534f 100644 --- a/vendor/assets/javascripts/chosen.proto.coffee +++ b/vendor/assets/javascripts/chosen.proto.coffee @@ -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) @@ -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) -> @@ -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 diff --git a/vendor/assets/javascripts/lib/abstract-chosen.coffee b/vendor/assets/javascripts/lib/abstract-chosen.coffee index 268df57..1f4de1b 100644 --- a/vendor/assets/javascripts/lib/abstract-chosen.coffee +++ b/vendor/assets/javascripts/lib/abstract-chosen.coffee @@ -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 @@ -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) @@ -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) @@ -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 @@ -176,7 +178,7 @@ class AbstractChosen option.search_text = text.substr(0, startpos) + '' + 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 @@ -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) -> @@ -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" diff --git a/vendor/assets/javascripts/lib/select-parser.coffee b/vendor/assets/javascripts/lib/select-parser.coffee index 2a14c55..6c49c72 100644 --- a/vendor/assets/javascripts/lib/select-parser.coffee +++ b/vendor/assets/javascripts/lib/select-parser.coffee @@ -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 @@ -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