1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-29 20:32:15 -05:00

[WO-344] Fix delete and backspace events in writer headers

This commit is contained in:
Tankred Hase 2014-07-21 15:18:56 +02:00
parent 1c2f00cddd
commit 23298e8f12

View File

@ -573,13 +573,13 @@ define(function(require) {
ngModule.directive('addressInput', function() { ngModule.directive('addressInput', function() {
return { return {
scope: true, scope: true,
link: function(scope, element, attrs) { link: function(scope, elm, attrs) {
// get prefix for id // get prefix for id
var fieldName = attrs.addressInput; var fieldName = attrs.addressInput;
var field = scope[fieldName]; var field = scope[fieldName];
var index = parseInt(attrs.id.replace(fieldName, ''), 10); var index = parseInt(attrs.id.replace(fieldName, ''), 10);
element.on('blur', function() { elm.on('blur', function() {
if (!checkForEmptyInput(field)) { if (!checkForEmptyInput(field)) {
// create new field input // create new field input
addInput(field, scope); addInput(field, scope);
@ -588,15 +588,16 @@ define(function(require) {
cleanupEmptyInputs(field, scope); cleanupEmptyInputs(field, scope);
}); });
element.on('keydown', function(e) { elm.on('keydown', function(e) {
var code = e.keyCode; var code = e.keyCode;
var address = elm[0].value;
if (code === 32 || code === 188 || code === 186) { if (code === 32 || code === 188 || code === 186) {
// catch space, comma, semicolon // catch space, comma, semicolon
e.preventDefault(); e.preventDefault();
// add next field only if current input is not empty // add next field only if current input is not empty
if (field[index].address) { if (address) {
// create new field input // create new field input
addInput(field, scope); addInput(field, scope);
@ -604,7 +605,7 @@ define(function(require) {
focusInput(fieldName, index + 1); focusInput(fieldName, index + 1);
} }
} else if ((code === 8 || code === 46) && !field[index].address && field.length > 1) { } else if ((code === 8 || code === 46) && !address && field.length > 1) {
// backspace, delete on empty input // backspace, delete on empty input
// remove input // remove input
e.preventDefault(); e.preventDefault();