Don't show/hide results when deselecting option in single Chosen.

abstract-chosen^2
Patrick Filler 2011-09-29 16:48:12 -04:00
parent 785020b189
commit cde5fc8e69
6 changed files with 20 additions and 20 deletions

View File

@ -161,13 +161,13 @@
} }
}; };
Chosen.prototype.container_mousedown = function(evt) { Chosen.prototype.container_mousedown = function(evt) {
var target_node; var target_closelink;
if (!this.is_disabled) { if (!this.is_disabled) {
target_node = evt != null ? evt.target.nodeName : null; target_closelink = evt != null ? ($(evt.target)).hasClass("search-choice-close") : false;
if (evt && evt.type === "mousedown") { if (evt && evt.type === "mousedown") {
evt.stopPropagation(); evt.stopPropagation();
} }
if (!this.pending_destroy_click && target_node !== "ABBR") { if (!this.pending_destroy_click && !target_closelink) {
if (!this.active_field) { if (!this.active_field) {
if (this.is_multiple) { if (this.is_multiple) {
this.search_field.val(""); this.search_field.val("");
@ -270,7 +270,7 @@
} else if (data.selected && !this.is_multiple) { } else if (data.selected && !this.is_multiple) {
this.selected_item.find("span").text(data.text); this.selected_item.find("span").text(data.text);
if (this.allow_single_deselect) { if (this.allow_single_deselect) {
this.selected_item.find("span").first().after("<abbr></abbr>"); this.selected_item.find("span").first().after("<abbr class=\"search-choice-close\"></abbr>");
} }
} }
} }
@ -477,7 +477,7 @@
} else { } else {
this.selected_item.find("span").first().text(item.text); this.selected_item.find("span").first().text(item.text);
if (this.allow_single_deselect) { if (this.allow_single_deselect) {
this.selected_item.find("span").first().after("<abbr></abbr>"); this.selected_item.find("span").first().after("<abbr class=\"search-choice-close\"></abbr>");
} }
} }
if (!(evt.metaKey && this.is_multiple)) { if (!(evt.metaKey && this.is_multiple)) {

File diff suppressed because one or more lines are too long

View File

@ -152,13 +152,13 @@
} }
}; };
Chosen.prototype.container_mousedown = function(evt) { Chosen.prototype.container_mousedown = function(evt) {
var target_node; var target_closelink;
if (!this.is_disabled) { if (!this.is_disabled) {
target_node = evt != null ? evt.target.nodeName : null; target_closelink = evt != null ? evt.target.hasClassName("search-choice-close") : false;
if (evt && evt.type === "mousedown") { if (evt && evt.type === "mousedown") {
evt.stop(); evt.stop();
} }
if (!this.pending_destroy_click && target_node !== "ABBR") { if (!this.pending_destroy_click && !target_closelink) {
if (!this.active_field) { if (!this.active_field) {
if (this.is_multiple) { if (this.is_multiple) {
this.search_field.clear(); this.search_field.clear();
@ -257,7 +257,7 @@
this.selected_item.down("span").update(data.html); this.selected_item.down("span").update(data.html);
if (this.allow_single_deselect) { if (this.allow_single_deselect) {
this.selected_item.down("span").insert({ this.selected_item.down("span").insert({
after: "<abbr></abbr>" after: "<abbr class=\"search-choice-close\"></abbr>"
}); });
} }
} }
@ -469,7 +469,7 @@
this.selected_item.down("span").update(item.html); this.selected_item.down("span").update(item.html);
if (this.allow_single_deselect) { if (this.allow_single_deselect) {
this.selected_item.down("span").insert({ this.selected_item.down("span").insert({
after: "<abbr></abbr>" after: "<abbr class=\"search-choice-close\"></abbr>"
}); });
} }
} }

File diff suppressed because one or more lines are too long

View File

@ -123,10 +123,10 @@ class Chosen
container_mousedown: (evt) -> container_mousedown: (evt) ->
if !@is_disabled if !@is_disabled
target_node = if evt? then evt.target.nodeName else null target_closelink = if evt? then ($ evt.target).hasClass "search-choice-close" else false
if evt and evt.type is "mousedown" if evt and evt.type is "mousedown"
evt.stopPropagation() evt.stopPropagation()
if not @pending_destroy_click and target_node != "ABBR" if not @pending_destroy_click and not target_closelink
if not @active_field if not @active_field
@search_field.val "" if @is_multiple @search_field.val "" if @is_multiple
$(document).click @click_test_action $(document).click @click_test_action
@ -212,7 +212,7 @@ class Chosen
this.choice_build data this.choice_build data
else if data.selected and not @is_multiple else if data.selected and not @is_multiple
@selected_item.find("span").text data.text @selected_item.find("span").text data.text
@selected_item.find("span").first().after "<abbr></abbr>" if @allow_single_deselect @selected_item.find("span").first().after "<abbr class=\"search-choice-close\"></abbr>" if @allow_single_deselect
this.search_field_disabled() this.search_field_disabled()
this.show_search_field_default() this.show_search_field_default()
@ -392,7 +392,7 @@ class Chosen
this.choice_build item this.choice_build item
else else
@selected_item.find("span").first().text item.text @selected_item.find("span").first().text item.text
@selected_item.find("span").first().after "<abbr></abbr>" if @allow_single_deselect @selected_item.find("span").first().after "<abbr class=\"search-choice-close\"></abbr>" if @allow_single_deselect
this.results_hide() unless evt.metaKey and @is_multiple this.results_hide() unless evt.metaKey and @is_multiple

View File

@ -118,10 +118,10 @@ class Chosen
container_mousedown: (evt) -> container_mousedown: (evt) ->
if !@is_disabled if !@is_disabled
target_node = if evt? then evt.target.nodeName else null target_closelink = if evt? then evt.target.hasClassName "search-choice-close" else false
if evt and evt.type is "mousedown" if evt and evt.type is "mousedown"
evt.stop() evt.stop()
if not @pending_destroy_click and target_node != "ABBR" if not @pending_destroy_click and not target_closelink
if not @active_field if not @active_field
@search_field.clear() if @is_multiple @search_field.clear() if @is_multiple
document.observe "click", @click_test_action document.observe "click", @click_test_action
@ -206,7 +206,7 @@ class Chosen
this.choice_build data this.choice_build data
else if data.selected and not @is_multiple else if data.selected and not @is_multiple
@selected_item.down("span").update( data.html ) @selected_item.down("span").update( data.html )
@selected_item.down("span").insert { after: "<abbr></abbr>" } if @allow_single_deselect @selected_item.down("span").insert { after: "<abbr class=\"search-choice-close\"></abbr>" } if @allow_single_deselect
this.search_field_disabled() this.search_field_disabled()
this.show_search_field_default() this.show_search_field_default()
@ -385,7 +385,7 @@ class Chosen
this.choice_build item this.choice_build item
else else
@selected_item.down("span").update(item.html) @selected_item.down("span").update(item.html)
@selected_item.down("span").insert { after: "<abbr></abbr>" } if @allow_single_deselect @selected_item.down("span").insert { after: "<abbr class=\"search-choice-close\"></abbr>" } if @allow_single_deselect
this.results_hide() unless evt.metaKey and @is_multiple this.results_hide() unless evt.metaKey and @is_multiple