Merge branch 'master' of https://github.com/cleercode/chosen into cleercode-master

This commit is contained in:
Patrick Filler 2011-08-08 11:16:12 -04:00
commit d6137ad5be
4 changed files with 24 additions and 16 deletions

View file

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

View file

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

View file

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

View file

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