|
1 |
| -/*! selectize.js - v0.4.1 | https://github.com/brianreavis/selectize.js | Apache License (v2) */ |
| 1 | +/*! selectize.js - v0.4.2 | https://github.com/brianreavis/selectize.js | Apache License (v2) */ |
2 | 2 |
|
3 | 3 | (function(factory) {
|
4 | 4 | if (typeof exports === 'object') {
|
|
377 | 377 | var autoGrow = function($input) {
|
378 | 378 | var update = function(e) {
|
379 | 379 | var value, keyCode, printable, placeholder, width;
|
380 |
| - var shift, character; |
| 380 | + var shift, character, selection; |
| 381 | + e = e || window.event || {}; |
381 | 382 |
|
| 383 | + if (e.metaKey || e.altKey) return; |
382 | 384 | if ($input.data('grow') === false) return;
|
383 |
| - e = e || window.event || {}; |
| 385 | + |
384 | 386 | value = $input.val();
|
385 | 387 | if (e.type && e.type.toLowerCase() === 'keydown') {
|
386 | 388 | keyCode = e.keyCode;
|
|
391 | 393 | keyCode == 32 // space
|
392 | 394 | );
|
393 | 395 |
|
394 |
| - if (printable) { |
| 396 | + if (keyCode === KEY_DELETE || keyCode === KEY_BACKSPACE) { |
| 397 | + selection = getSelection($input[0]); |
| 398 | + if (selection.length) { |
| 399 | + value = value.substring(0, selection.start) + value.substring(selection.start + selection.length); |
| 400 | + } else if (keyCode === KEY_BACKSPACE && selection.start) { |
| 401 | + value = value.substring(0, selection.start - 1) + value.substring(selection.start + 1); |
| 402 | + } else if (keyCode === KEY_DELETE && typeof selection.start !== 'undefined') { |
| 403 | + value = value.substring(0, selection.start) + value.substring(selection.start + 1); |
| 404 | + } |
| 405 | + } else if (printable) { |
395 | 406 | shift = e.shiftKey;
|
396 | 407 | character = String.fromCharCode(e.keyCode);
|
397 | 408 | if (shift) character = character.toUpperCase();
|
|
0 commit comments