No ctrl/command click when for single selects.

abstract-chosen
Patrick Filler 2011-08-08 11:37:56 -04:00
parent d6137ad5be
commit 528d77bc04
7 changed files with 16 additions and 12 deletions

View File

@ -424,7 +424,7 @@
} else { } else {
this.selected_item.find("span").first().text(item.text); this.selected_item.find("span").first().text(item.text);
} }
if (!evt.metaKey) { if (!(evt.metaKey && this.is_multiple)) {
this.results_hide(); this.results_hide();
} }
this.search_field.val(""); this.search_field.val("");
@ -626,6 +626,8 @@
case 38: case 38:
case 40: case 40:
case 16: case 16:
case 91:
case 17:
break; break;
default: default:
return this.results_search(); return this.results_search();

File diff suppressed because one or more lines are too long

View File

@ -416,7 +416,7 @@
} else { } else {
this.selected_item.down("span").update(item.html); this.selected_item.down("span").update(item.html);
} }
if (!evt.metaKey) { if (!(evt.metaKey && this.is_multiple)) {
this.results_hide(); this.results_hide();
} }
this.search_field.value = ""; this.search_field.value = "";
@ -633,6 +633,8 @@
case 38: case 38:
case 40: case 40:
case 16: case 16:
case 91:
case 17:
break; break;
default: default:
return this.results_search(); return this.results_search();

File diff suppressed because one or more lines are too long

View File

@ -360,8 +360,7 @@ 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() unless evt.metaKey and @is_multiple
this.results_hide()
@search_field.val "" @search_field.val ""
@ -523,7 +522,7 @@ class Chosen
this.result_select(evt) 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, 91, 17
# don't do anything on these keys # don't do anything on these keys
else this.results_search() else this.results_search()
@ -531,7 +530,7 @@ class Chosen
keydown_checker: (evt) -> keydown_checker: (evt) ->
stroke = evt.which ? evt.keyCode stroke = evt.which ? evt.keyCode
this.search_field_scale() this.search_field_scale()
this.clear_backstroke() if stroke != 8 and this.pending_backstroke this.clear_backstroke() if stroke != 8 and this.pending_backstroke
switch stroke switch stroke

View File

@ -355,8 +355,7 @@ class Chosen
else else
@selected_item.down("span").update(item.html) @selected_item.down("span").update(item.html)
if not evt.metaKey this.results_hide() unless evt.metaKey and @is_multiple
this.results_hide()
@search_field.value = "" @search_field.value = ""
@ -523,7 +522,7 @@ class Chosen
this.result_select(evt) 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, 91, 17
# don't do anything on these keys # don't do anything on these keys
else this.results_search() else this.results_search()

View File

@ -50,6 +50,7 @@
<link rel="stylesheet" href="chosen/chosen.css" /> <link rel="stylesheet" href="chosen/chosen.css" />
</head> </head>
<body> <body>
<form>
<div id="container"> <div id="container">
<h1>Chosen</h1> <h1>Chosen</h1>
<p>Chosen is a JavaScript plugin for Prototype and jQuery that makes long, unwieldy select boxes much more user-friendly. For more information (including usage, explanation and faqs), check out the <a href="http://harvesthq.github.com/chosen/">online documentation</a>.</p> <p>Chosen is a JavaScript plugin for Prototype and jQuery that makes long, unwieldy select boxes much more user-friendly. For more information (including usage, explanation and faqs), check out the <a href="http://harvesthq.github.com/chosen/">online documentation</a>.</p>
@ -1188,7 +1189,7 @@
</div> </div>
<div> <div>
<em>Multiple Select with Groups</em> <em>Multiple Select with Groups</em>
<select data-placeholder="Your Favorite Types of Bear" style="width:350px;" multiple class="chzn-select" tabindex="8"> <select data-placeholder="Your Favorite Types of Bear" style="width:350px;" multiple class="chzn-select" id="test_me" name="test_me_form" tabindex="8">
<option value=""></option> <option value=""></option>
<option>American Black Bear</option> <option>American Black Bear</option>
<option>Asiatic Black Bear</option> <option>Asiatic Black Bear</option>
@ -1271,4 +1272,5 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script>
<script src="chosen/chosen.jquery.js" type="text/javascript"></script> <script src="chosen/chosen.jquery.js" type="text/javascript"></script>
<script type="text/javascript"> $(".chzn-select").chosen(); </script> <script type="text/javascript"> $(".chzn-select").chosen(); </script>
</form>
</body> </body>