Single selects now allow disabled search below a certain option threshold.
This commit is contained in:
parent
d87310ee5d
commit
1e9b4ddbe9
7 changed files with 20 additions and 2 deletions
|
@ -101,6 +101,7 @@
|
|||
}
|
||||
.chzn-container-single .chzn-search {
|
||||
padding: 3px 4px;
|
||||
position: relative;
|
||||
margin: 0;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
@ -130,6 +131,11 @@
|
|||
}
|
||||
/* @end */
|
||||
|
||||
.chzn-container-single-nosearch .chzn-search input {
|
||||
position: absolute;
|
||||
left: -9000px;
|
||||
}
|
||||
|
||||
/* @group Multi Chosen */
|
||||
.chzn-container-multi .chzn-choices {
|
||||
background-color: #fff;
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
this.result_highlighted = null;
|
||||
this.result_single_selected = null;
|
||||
this.allow_single_deselect = (this.options.allow_single_deselect != null) && this.form_field.options[0].text === "" ? this.options.allow_single_deselect : false;
|
||||
this.disable_search_threshold = this.options.disable_search_threshold || 0;
|
||||
this.choices = 0;
|
||||
return this.results_none_found = this.options.no_results_text || "No results match";
|
||||
};
|
||||
|
@ -75,6 +76,9 @@
|
|||
this.form_field_jq.hide().after(container_div);
|
||||
this.container = $('#' + this.container_id);
|
||||
this.container.addClass("chzn-container-" + (this.is_multiple ? "multi" : "single"));
|
||||
if (!this.is_multiple && this.form_field.options.length <= this.disable_search_threshold) {
|
||||
this.container.addClass("chzn-container-single-nosearch");
|
||||
}
|
||||
this.dropdown = this.container.find('div.chzn-drop').first();
|
||||
dd_top = this.container.height();
|
||||
dd_width = this.f_width - get_side_border_padding(this.dropdown);
|
||||
|
|
2
chosen/chosen.jquery.min.js
vendored
2
chosen/chosen.jquery.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -39,6 +39,7 @@
|
|||
this.result_highlighted = null;
|
||||
this.result_single_selected = null;
|
||||
this.allow_single_deselect = (this.options.allow_single_deselect != null) && this.form_field.options[0].text === "" ? this.options.allow_single_deselect : false;
|
||||
this.disable_search_threshold = this.options.disable_search_threshold || 0;
|
||||
this.choices = 0;
|
||||
this.results_none_found = this.options.no_results_text || "No results match";
|
||||
this.single_temp = new Template('<a href="javascript:void(0)" class="chzn-single"><span>#{default}</span><div><b></b></div></a><div class="chzn-drop" style="left:-9000px;"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>');
|
||||
|
@ -66,6 +67,9 @@
|
|||
});
|
||||
this.container = $(this.container_id);
|
||||
this.container.addClassName("chzn-container-" + (this.is_multiple ? "multi" : "single"));
|
||||
if (!this.is_multiple && this.form_field.options.length <= this.disable_search_threshold) {
|
||||
this.container.addClassName("chzn-container-single-nosearch");
|
||||
}
|
||||
this.dropdown = this.container.down('div.chzn-drop');
|
||||
dd_top = this.container.getHeight();
|
||||
dd_width = this.f_width - get_side_border_padding(this.dropdown);
|
||||
|
|
2
chosen/chosen.proto.min.js
vendored
2
chosen/chosen.proto.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -38,6 +38,7 @@ class Chosen
|
|||
@result_highlighted = null
|
||||
@result_single_selected = null
|
||||
@allow_single_deselect = if @options.allow_single_deselect? and @form_field.options[0].text == "" then @options.allow_single_deselect else false
|
||||
@disable_search_threshold = @options.disable_search_threshold || 0
|
||||
@choices = 0
|
||||
@results_none_found = @options.no_results_text or "No results match"
|
||||
|
||||
|
@ -63,6 +64,7 @@ class Chosen
|
|||
@form_field_jq.hide().after container_div
|
||||
@container = ($ '#' + @container_id)
|
||||
@container.addClass( "chzn-container-" + (if @is_multiple then "multi" else "single") )
|
||||
@container.addClass "chzn-container-single-nosearch" if not @is_multiple and @form_field.options.length <= @disable_search_threshold
|
||||
@dropdown = @container.find('div.chzn-drop').first()
|
||||
|
||||
dd_top = @container.height()
|
||||
|
|
|
@ -30,6 +30,7 @@ class Chosen
|
|||
@result_highlighted = null
|
||||
@result_single_selected = null
|
||||
@allow_single_deselect = if @options.allow_single_deselect? and @form_field.options[0].text == "" then @options.allow_single_deselect else false
|
||||
@disable_search_threshold = @options.disable_search_threshold || 0
|
||||
@choices = 0
|
||||
|
||||
@results_none_found = @options.no_results_text or "No results match"
|
||||
|
@ -58,6 +59,7 @@ class Chosen
|
|||
@form_field.hide().insert({ after: base_template })
|
||||
@container = $(@container_id)
|
||||
@container.addClassName( "chzn-container-" + (if @is_multiple then "multi" else "single") )
|
||||
@container.addClassName "chzn-container-single-nosearch" if not @is_multiple and @form_field.options.length <= @disable_search_threshold
|
||||
@dropdown = @container.down('div.chzn-drop')
|
||||
|
||||
dd_top = @container.getHeight()
|
||||
|
|
Loading…
Reference in a new issue