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

abstract-chosen
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();
if (target.length) {
this.result_highlight = target;
return this.result_select();
return this.result_select(evt);
}
};
Chosen.prototype.search_results_mouseover = function(evt) {
@ -403,7 +403,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;
@ -424,7 +424,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();
@ -612,7 +614,7 @@
case 13:
evt.preventDefault();
if (this.results_showing) {
return this.result_select();
return this.result_select(evt);
}
break;
case 27:

View File

@ -345,7 +345,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) {
@ -396,7 +396,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;
@ -416,7 +416,9 @@
} else {
this.selected_item.down("span").update(item.html);
}
this.results_hide();
if (!evt.metaKey) {
this.results_hide();
}
this.search_field.value = "";
if (typeof Event.simulate === 'function') {
this.form_field.simulate("change");
@ -619,7 +621,7 @@
case 13:
evt.preventDefault();
if (this.results_showing) {
return this.result_select();
return this.result_select(evt);
}
break;
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()
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()
@ -335,7 +335,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"
@ -360,7 +360,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"
@ -518,7 +520,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

@ -292,7 +292,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")
@ -332,7 +332,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()
@ -355,7 +355,9 @@ class Chosen
else
@selected_item.down("span").update(item.html)
this.results_hide()
if not evt.metaKey
this.results_hide()
@search_field.value = ""
@form_field.simulate("change") if typeof Event.simulate is 'function'
@ -518,7 +520,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