Ctrl/command-click to select without closing list. Related to #23

abstract-chosen
Chris Lee 2011-07-22 17:27:08 -07:00
parent bddd1e4fb4
commit 110466a38f
4 changed files with 24 additions and 16 deletions

View File

@ -351,7 +351,7 @@
target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
if (target.length) {
this.result_highlight = target;
return this.result_select();
return this.result_select(evt);
}
};
Chosen.prototype.search_results_mouseover = function(evt) {
@ -396,7 +396,7 @@
this.result_deselect(link.attr("rel"));
return link.parents('li').first().remove();
};
Chosen.prototype.result_select = function() {
Chosen.prototype.result_select = function(evt) {
var high, high_id, item, position;
if (this.result_highlight) {
high = this.result_highlight;
@ -417,7 +417,9 @@
} else {
this.selected_item.find("span").first().text(item.text);
}
this.results_hide();
if (!evt.metaKey) {
this.results_hide();
}
this.search_field.val("");
this.form_field_jq.trigger("change");
return this.search_field_scale();
@ -604,7 +606,7 @@
case 13:
evt.preventDefault();
if (this.results_showing) {
return this.result_select();
return this.result_select(evt);
}
break;
case 27:

View File

@ -338,7 +338,7 @@
target = evt.target.hasClassName("active-result") ? evt.target : evt.target.up(".active-result");
if (target) {
this.result_highlight = target;
return this.result_select();
return this.result_select(evt);
}
};
Chosen.prototype.search_results_mouseover = function(evt) {
@ -389,7 +389,7 @@
this.result_deselect(link.readAttribute("rel"));
return link.up('li').remove();
};
Chosen.prototype.result_select = function() {
Chosen.prototype.result_select = function(evt) {
var high, item, position;
if (this.result_highlight) {
high = this.result_highlight;
@ -409,7 +409,9 @@
} else {
this.selected_item.down("span").update(item.text);
}
this.results_hide();
if (!evt.metaKey) {
this.results_hide();
}
this.search_field.value = "";
if (typeof Event.simulate === 'function') {
this.form_field.simulate("change");
@ -607,7 +609,7 @@
case 13:
evt.preventDefault();
if (this.results_showing) {
return this.result_select();
return this.result_select(evt);
}
break;
case 27:

View File

@ -302,7 +302,7 @@ class Chosen
target = if $(evt.target).hasClass "active-result" then $(evt.target) else $(evt.target).parents(".active-result").first()
if target.length
@result_highlight = target
this.result_select()
this.result_select(evt)
search_results_mouseover: (evt) ->
target = if $(evt.target).hasClass "active-result" then $(evt.target) else $(evt.target).parents(".active-result").first()
@ -338,7 +338,7 @@ class Chosen
this.result_deselect (link.attr "rel")
link.parents('li').first().remove()
result_select: ->
result_select: (evt) ->
if @result_highlight
high = @result_highlight
high_id = high.attr "id"
@ -363,7 +363,9 @@ class Chosen
else
@selected_item.find("span").first().text item.text
this.results_hide()
if not evt.metaKey
this.results_hide()
@search_field.val ""
@form_field_jq.trigger "change"
@ -519,7 +521,7 @@ class Chosen
this.results_search()
when 13
evt.preventDefault()
this.result_select() if this.results_showing
this.result_select(evt) if this.results_showing
when 27
this.results_hide() if @results_showing
when 9, 38, 40, 16

View File

@ -295,7 +295,7 @@ class Chosen
target = if evt.target.hasClassName("active-result") then evt.target else evt.target.up(".active-result")
if target
@result_highlight = target
this.result_select()
this.result_select(evt)
search_results_mouseover: (evt) ->
target = if evt.target.hasClassName("active-result") then evt.target else evt.target.up(".active-result")
@ -331,7 +331,7 @@ class Chosen
this.result_deselect link.readAttribute("rel")
link.up('li').remove()
result_select: ->
result_select: (evt) ->
if @result_highlight
high = @result_highlight
this.result_clear_highlight()
@ -354,7 +354,9 @@ class Chosen
else
@selected_item.down("span").update(item.text)
this.results_hide()
if not evt.metaKey
this.results_hide()
@search_field.value = ""
@form_field.simulate("change") if typeof Event.simulate is 'function'
@ -512,7 +514,7 @@ class Chosen
this.results_search()
when 13
evt.preventDefault()
this.result_select() if this.results_showing
this.result_select(evt) if this.results_showing
when 27
this.results_hide() if @results_showing
when 9, 38, 40, 16