From 4f39376831be9f88965ef222e9e1f6646eec412b Mon Sep 17 00:00:00 2001 From: "Kirill (KIR) Maximov" Date: Sun, 5 Jan 2020 13:02:04 +0100 Subject: [PATCH 1/2] Add support for chosen:search_updated event MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The event is fired on the original selector when Chosen’s search results are updated after typing the search term. The event also includes a corresponding `search_term` parameter. --- coffee/chosen.jquery.coffee | 3 +++ coffee/chosen.proto.coffee | 3 +++ coffee/lib/abstract-chosen.coffee | 2 ++ public/options.html | 5 +++++ 4 files changed, 13 insertions(+) diff --git a/coffee/chosen.jquery.coffee b/coffee/chosen.jquery.coffee index 0054f0e89f0..05820b9de9a 100644 --- a/coffee/chosen.jquery.coffee +++ b/coffee/chosen.jquery.coffee @@ -255,6 +255,9 @@ class Chosen extends AbstractChosen update_results_content: (content) -> @search_results.html content + fire_search_updated: (search_term) -> + @form_field_jq.trigger("chosen:search_updated", {chosen: this, search_term: search_term}) + results_hide: -> if @results_showing this.result_clear_highlight() diff --git a/coffee/chosen.proto.coffee b/coffee/chosen.proto.coffee index 25bd08c9630..76e005c22ef 100644 --- a/coffee/chosen.proto.coffee +++ b/coffee/chosen.proto.coffee @@ -247,6 +247,9 @@ class @Chosen extends AbstractChosen update_results_content: (content) -> @search_results.update content + fire_search_updated: (search_term) -> + @form_field.fire("chosen:search_updated", {chosen: this, search_term: search_term}) + results_hide: -> if @results_showing this.result_clear_highlight() diff --git a/coffee/lib/abstract-chosen.coffee b/coffee/lib/abstract-chosen.coffee index e15282bee53..7e7578ecd76 100644 --- a/coffee/lib/abstract-chosen.coffee +++ b/coffee/lib/abstract-chosen.coffee @@ -211,9 +211,11 @@ class AbstractChosen if results < 1 and query.length this.update_results_content "" + this.fire_search_updated query this.no_results query else this.update_results_content this.results_option_build() + this.fire_search_updated query this.winnow_results_set_highlight() unless options?.skip_highlight get_search_regex: (escaped_search_string) -> diff --git a/public/options.html b/public/options.html index e53eb82ee86..c988a844885 100644 --- a/public/options.html +++ b/public/options.html @@ -244,6 +244,11 @@

Example:

chosen:maxselected Triggered if max_selected_options is set and that total is broken. + + chosen:search_updated + Triggered when Chosen’s search results are updated after typing search term. + The event includes a corresponding search_term parameter. + chosen:showing_dropdown Triggered when Chosen’s dropdown is opened. From 483e4f0fda731f966ed14e40b0353f09d0f24b96 Mon Sep 17 00:00:00 2001 From: "Kirill (KIR) Maximov" Date: Sun, 5 Jan 2020 16:59:05 +0100 Subject: [PATCH 2/2] Fix arrow down positioning on a non-retina display --- sass/chosen.scss | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sass/chosen.scss b/sass/chosen.scss index f2555a675f2..90f7dac0d7e 100644 --- a/sass/chosen.scss +++ b/sass/chosen.scss @@ -108,7 +108,7 @@ $chosen-sprite-retina: url('chosen-sprite@2x.png') !default; display: block; width: 100%; height: 100%; - background: $chosen-sprite no-repeat 0px 2px; + background: $chosen-sprite no-repeat 0 0; } } .chosen-search { @@ -421,5 +421,9 @@ $chosen-sprite-retina: url('chosen-sprite@2x.png') !default; background-size: 52px 37px !important; background-repeat: no-repeat !important; } + + .chosen-container-single .chosen-single div b { + background-position: 0 2px; + } } /* @end */