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