|
1089 | 1089 | this makes sure the search field is focussed even if the current event would blur it */ |
1090 | 1090 | window.setTimeout(this.bind(function () { |
1091 | 1091 | this.search.focus(); |
| 1092 | + // reset the value so IE places the cursor at the end of the input box |
| 1093 | + this.search.val(this.search.val()); |
1092 | 1094 | }), 10); |
1093 | 1095 | }, |
1094 | 1096 |
|
|
1203 | 1205 | // single |
1204 | 1206 | focus: function () { |
1205 | 1207 | this.close(); |
1206 | | - this.search.focus(); |
| 1208 | + this.container.focus(); |
1207 | 1209 | }, |
1208 | 1210 |
|
1209 | 1211 | // single |
|
1214 | 1216 | // single |
1215 | 1217 | cancel: function () { |
1216 | 1218 | this.parent.cancel.apply(this, arguments); |
1217 | | - this.search.focus(); |
| 1219 | + this.container.focus(); |
1218 | 1220 | }, |
1219 | 1221 |
|
1220 | 1222 | // single |
|
1253 | 1255 | killEvent(e); |
1254 | 1256 | return; |
1255 | 1257 | } |
1256 | | - } else { |
1257 | | - if (e.which === KEY.TAB || KEY.isControl(e) || KEY.isFunctionKey(e) || e.which === KEY.ESC) { |
1258 | | - return; |
1259 | | - } |
1260 | | - |
1261 | | - this.open(); |
1262 | | - |
1263 | | - if (e.which === KEY.ENTER) { |
1264 | | - // do not propagate the event otherwise we open, and propagate enter which closes |
1265 | | - killEvent(e); |
1266 | | - return; |
1267 | | - } |
1268 | 1258 | } |
1269 | 1259 | })); |
1270 | 1260 |
|
|
1273 | 1263 |
|
1274 | 1264 | if (this.opened()) { |
1275 | 1265 | this.close(); |
1276 | | - this.search.focus(); |
| 1266 | + this.container.focus(); |
1277 | 1267 | } else if (this.enabled) { |
1278 | 1268 | this.open(); |
1279 | 1269 | } |
|
1283 | 1273 | })); |
1284 | 1274 |
|
1285 | 1275 | dropdown.bind("click", this.bind(function() { this.search.focus(); })); |
| 1276 | + |
| 1277 | + container.bind("focus", this.bind(function() { |
| 1278 | + // allows the container to recieve the keyup event |
| 1279 | + this.container.attr("tabindex", 1); |
| 1280 | + })); |
| 1281 | + |
| 1282 | + container.bind("blur", this.bind(function() { |
| 1283 | + // remove the tabindex so the tab key works properly |
| 1284 | + this.container.attr("tabindex", -1); |
| 1285 | + })); |
| 1286 | + |
| 1287 | + container.bind("keydown", this.bind(function(e) { |
| 1288 | + if (!this.enabled) return; |
| 1289 | + |
| 1290 | + this.container.attr("tabindex", -1); |
| 1291 | + |
| 1292 | + if (e.which === KEY.PAGE_UP || e.which === KEY.PAGE_DOWN) { |
| 1293 | + // prevent the page from scrolling |
| 1294 | + killEvent(e); |
| 1295 | + return; |
| 1296 | + } |
| 1297 | + |
| 1298 | + if (!this.opened()) { |
| 1299 | + if (e.which === KEY.TAB || KEY.isControl(e) || KEY.isFunctionKey(e) || e.which === KEY.ESC) { |
| 1300 | + return; |
| 1301 | + } |
| 1302 | + |
| 1303 | + this.open(); |
| 1304 | + |
| 1305 | + if (e.which === KEY.ENTER) { |
| 1306 | + // do not propagate the event otherwise we open, and propagate enter which closes |
| 1307 | + killEvent(e); |
| 1308 | + return; |
| 1309 | + } |
| 1310 | + |
| 1311 | + var keyWritten = String.fromCharCode(e.which).toLowerCase(); |
| 1312 | + |
| 1313 | + if (e.shiftKey) { |
| 1314 | + keyWritten = keyWritten.toUpperCase(); |
| 1315 | + } |
| 1316 | + |
| 1317 | + this.search.val(keyWritten); |
| 1318 | + } |
| 1319 | + })); |
1286 | 1320 |
|
1287 | 1321 | selection.delegate("abbr", "click", this.bind(function (e) { |
1288 | 1322 | if (!this.enabled) return; |
1289 | 1323 | this.clear(); |
1290 | 1324 | killEvent(e); |
1291 | 1325 | this.close(); |
1292 | 1326 | this.triggerChange(); |
1293 | | - this.search.focus(); |
| 1327 | + this.container.focus(); |
1294 | 1328 | })); |
1295 | 1329 |
|
1296 | 1330 | selection.bind("focus", this.bind(function() { this.search.focus(); })); |
|
1403 | 1437 | this.opts.element.val(this.id(data)); |
1404 | 1438 | this.updateSelection(data); |
1405 | 1439 | this.close(); |
1406 | | - this.search.focus(); |
| 1440 | + this.container.focus(); |
1407 | 1441 |
|
1408 | 1442 | if (!equal(old, this.id(data))) { this.triggerChange(); } |
1409 | 1443 | }, |
|
1697 | 1731 | // multi |
1698 | 1732 | focus: function () { |
1699 | 1733 | this.close(); |
1700 | | - this.search.focus(); |
| 1734 | + this.container.focus(); |
1701 | 1735 | }, |
1702 | 1736 |
|
1703 | 1737 | // multi |
|
0 commit comments