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