Highlight selected option in a single select on initial load.
Closes Gh-103
This commit is contained in:
parent
c41e05e824
commit
0812bc3d64
|
@ -1,7 +1,7 @@
|
|||
// Chosen, a Select Box Enhancer for jQuery and Protoype
|
||||
// by Patrick Filler for Harvest, http://getharvest.com
|
||||
//
|
||||
// Version 0.9
|
||||
// Version 0.9.1
|
||||
// Full source at https://github.com/harvesthq/chosen
|
||||
// Copyright (c) 2011 Harvest http://getharvest.com
|
||||
|
||||
|
@ -530,10 +530,11 @@
|
|||
return _results;
|
||||
};
|
||||
Chosen.prototype.winnow_results_set_highlight = function() {
|
||||
var do_high;
|
||||
var do_high, selected_results;
|
||||
if (!this.result_highlight) {
|
||||
do_high = this.search_results.find(".active-result").first();
|
||||
if (do_high) {
|
||||
selected_results = !this.is_multiple ? this.search_results.find(".result-selected") : [];
|
||||
do_high = selected_results.length ? selected_results.first() : this.search_results.find(".active-result").first();
|
||||
if (do_high != null) {
|
||||
return this.result_do_highlight(do_high);
|
||||
}
|
||||
}
|
||||
|
|
4
chosen/chosen.jquery.min.js
vendored
4
chosen/chosen.jquery.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -1,7 +1,7 @@
|
|||
// Chosen, a Select Box Enhancer for jQuery and Protoype
|
||||
// by Patrick Filler for Harvest, http://getharvest.com
|
||||
//
|
||||
// Version 0.9
|
||||
// Version 0.9.1
|
||||
// Full source at https://github.com/harvesthq/chosen
|
||||
// Copyright (c) 2011 Harvest http://getharvest.com
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
|||
this.default_text_default = this.form_field.multiple ? "Select Some Options" : "Select an Option";
|
||||
this.set_up_html();
|
||||
this.register_observers();
|
||||
this.form_field.addClassName("chzn-done");
|
||||
}
|
||||
Chosen.prototype.set_default_values = function() {
|
||||
this.click_test_action = __bind(function(evt) {
|
||||
|
@ -526,8 +527,13 @@
|
|||
Chosen.prototype.winnow_results_set_highlight = function() {
|
||||
var do_high;
|
||||
if (!this.result_highlight) {
|
||||
if (!this.is_multiple) {
|
||||
do_high = this.search_results.down(".result-selected");
|
||||
}
|
||||
if (!(do_high != null)) {
|
||||
do_high = this.search_results.down(".active-result");
|
||||
if (do_high) {
|
||||
}
|
||||
if (do_high != null) {
|
||||
return this.result_do_highlight(do_high);
|
||||
}
|
||||
}
|
||||
|
|
4
chosen/chosen.proto.min.js
vendored
4
chosen/chosen.proto.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -457,9 +457,11 @@ class Chosen
|
|||
|
||||
winnow_results_set_highlight: ->
|
||||
if not @result_highlight
|
||||
do_high = @search_results.find(".active-result").first()
|
||||
if(do_high)
|
||||
this.result_do_highlight do_high
|
||||
|
||||
selected_results = if not @is_multiple then @search_results.find(".result-selected") else []
|
||||
do_high = if selected_results.length then selected_results.first() else @search_results.find(".active-result").first()
|
||||
|
||||
this.result_do_highlight do_high if do_high?
|
||||
|
||||
no_results: (terms) ->
|
||||
no_results_html = $('<li class="no-results">No results match "<span></span>"</li>')
|
||||
|
|
|
@ -17,6 +17,7 @@ class Chosen
|
|||
|
||||
this.set_up_html()
|
||||
this.register_observers()
|
||||
@form_field.addClassName "chzn-done"
|
||||
|
||||
|
||||
set_default_values: ->
|
||||
|
@ -450,9 +451,14 @@ class Chosen
|
|||
|
||||
winnow_results_set_highlight: ->
|
||||
if not @result_highlight
|
||||
|
||||
if not @is_multiple
|
||||
do_high = @search_results.down(".result-selected")
|
||||
|
||||
if not do_high?
|
||||
do_high = @search_results.down(".active-result")
|
||||
if(do_high)
|
||||
this.result_do_highlight do_high
|
||||
|
||||
this.result_do_highlight do_high if do_high?
|
||||
|
||||
no_results: (terms) ->
|
||||
@search_results.insert @no_results_temp.evaluate( terms: terms )
|
||||
|
|
Loading…
Reference in a new issue