Ctrl/command-click to select without closing list. Related to #23
This commit is contained in:
parent
bddd1e4fb4
commit
110466a38f
|
@ -351,7 +351,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) {
|
||||||
|
@ -396,7 +396,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;
|
||||||
|
@ -417,7 +417,9 @@
|
||||||
} else {
|
} else {
|
||||||
this.selected_item.find("span").first().text(item.text);
|
this.selected_item.find("span").first().text(item.text);
|
||||||
}
|
}
|
||||||
|
if (!evt.metaKey) {
|
||||||
this.results_hide();
|
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();
|
||||||
|
@ -604,7 +606,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:
|
||||||
|
|
|
@ -338,7 +338,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) {
|
||||||
|
@ -389,7 +389,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;
|
||||||
|
@ -409,7 +409,9 @@
|
||||||
} else {
|
} else {
|
||||||
this.selected_item.down("span").update(item.text);
|
this.selected_item.down("span").update(item.text);
|
||||||
}
|
}
|
||||||
|
if (!evt.metaKey) {
|
||||||
this.results_hide();
|
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");
|
||||||
|
@ -607,7 +609,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:
|
||||||
|
|
|
@ -302,7 +302,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()
|
||||||
|
@ -338,7 +338,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"
|
||||||
|
@ -363,7 +363,9 @@ class Chosen
|
||||||
else
|
else
|
||||||
@selected_item.find("span").first().text item.text
|
@selected_item.find("span").first().text item.text
|
||||||
|
|
||||||
|
if not evt.metaKey
|
||||||
this.results_hide()
|
this.results_hide()
|
||||||
|
|
||||||
@search_field.val ""
|
@search_field.val ""
|
||||||
|
|
||||||
@form_field_jq.trigger "change"
|
@form_field_jq.trigger "change"
|
||||||
|
@ -519,7 +521,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
|
||||||
|
|
|
@ -295,7 +295,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")
|
||||||
|
@ -331,7 +331,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()
|
||||||
|
@ -354,7 +354,9 @@ class Chosen
|
||||||
else
|
else
|
||||||
@selected_item.down("span").update(item.text)
|
@selected_item.down("span").update(item.text)
|
||||||
|
|
||||||
|
if not evt.metaKey
|
||||||
this.results_hide()
|
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'
|
||||||
|
@ -512,7 +514,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
|
||||||
|
|
Loading…
Reference in a new issue