forked from extern/egroupware
* Mail: allow to enter name+mail eg. "Ralf Becker <rb@stylite.de>" in compose, automatic fix unquoted commas in entered mail addresses
This commit is contained in:
parent
7bcf736f09
commit
1c9a14159e
@ -99,7 +99,13 @@ var et2_taglist = et2_selectbox.extend(
|
||||
// Selectbox attributes that are not applicable
|
||||
"multiple": { ignore: true},
|
||||
"rows": { ignore: true},
|
||||
"tags": { ignore: true}
|
||||
"tags": { ignore: true},
|
||||
useCommaKey: {
|
||||
name: "comma will start validation",
|
||||
type: "boolean",
|
||||
"default": true,
|
||||
description: "Set to false to allow comma in entered content"
|
||||
}
|
||||
},
|
||||
|
||||
// Allows sub-widgets to override options to the library
|
||||
@ -160,6 +166,7 @@ var et2_taglist = et2_selectbox.extend(
|
||||
required: this.options.required,
|
||||
allowFreeEntries: this.options.allowFreeEntries,
|
||||
useTabKey: true,
|
||||
useCommaKey: this.options.useCommaKey,
|
||||
disabled: this.options.disabled || this.options.readonly,
|
||||
editable: !(this.options.disabled || this.options.readonly),
|
||||
selectionRenderer: jQuery.proxy(this.options.tagRenderer || this.selectionRenderer,this),
|
||||
@ -474,8 +481,14 @@ var et2_taglist_email = et2_taglist.extend(
|
||||
description:"Include mailing lists in search results",
|
||||
default: false,
|
||||
type: "boolean"
|
||||
}
|
||||
},
|
||||
useCommaKey: {
|
||||
name: "comma will start validation",
|
||||
type: "boolean",
|
||||
"default": false,
|
||||
description: "Set to false to allow comma in entered content"
|
||||
}
|
||||
},
|
||||
lib_options: {
|
||||
// Search function limits to 3 anyway
|
||||
minChars: 3
|
||||
@ -507,6 +520,48 @@ var et2_taglist_email = et2_taglist.extend(
|
||||
// We check free entries for valid email, and render as invalid if it's not.
|
||||
var valid = item.id != item.label || et2_url.prototype.EMAIL_PREG.test(item.id || '');
|
||||
|
||||
if (!valid && item.id)
|
||||
{
|
||||
// automatic quote 'Becker, Ralf <rb@stylite.de>' as '"Becker, Ralf" <rb@stylite.de>'
|
||||
var matches = item.id.match(/^(.*) ?<(.*)>$/);
|
||||
if (matches && et2_url.prototype.EMAIL_PREG.test('"'+matches[1].trim()+'" <'+matches[2].trim()+'>'))
|
||||
{
|
||||
item.id = item.label = '"'+matches[1].trim()+'" <'+matches[2].trim()+'>';
|
||||
valid = true;
|
||||
}
|
||||
// automatic insert multiple comma-separated emails like "rb@stylite.de, hn@stylite.de"
|
||||
if (!valid)
|
||||
{
|
||||
var parts = item.id.split(/, */);
|
||||
if (parts.length > 1)
|
||||
{
|
||||
valid = true;
|
||||
for(var i=0; i < parts.length; ++i)
|
||||
{
|
||||
parts[i] = parts[i].trim();
|
||||
if (!et2_url.prototype.EMAIL_PREG.test(parts[i]))
|
||||
{
|
||||
valid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (valid)
|
||||
{
|
||||
item.id = item.label = parts.shift();
|
||||
// insert further parts into taglist, after validation first one
|
||||
var taglist = this.taglist;
|
||||
window.setTimeout(function()
|
||||
{
|
||||
for(var i=0; i < parts.length; ++i)
|
||||
{
|
||||
taglist.addToSelection({id: parts[i], label: parts[i]});
|
||||
}
|
||||
}, 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var label = jQuery('<span>').text(item.label);
|
||||
if (item.class) label.addClass(item.class);
|
||||
if (typeof item.title != 'undefined') label.attr('title', item.title);
|
||||
|
@ -1291,7 +1291,9 @@
|
||||
}
|
||||
break;
|
||||
case 188: // comma
|
||||
if(!cfg.useCommaKey) break;
|
||||
if(e.shiftKey) break; // Shift + , = < on some keyboards
|
||||
if(e.originalEvent && e.originalEvent.keyIdentifier && e.originalEvent.keyIdentifier != "U+002C") break;
|
||||
case 9: // tab
|
||||
case 13: // enter
|
||||
e.preventDefault();
|
||||
@ -1348,7 +1350,8 @@
|
||||
break;
|
||||
case 13:case 9:case 188:// enter, tab, comma
|
||||
// Shift + comma = < on English keyboard
|
||||
if(e.keyCode !== 188 || (cfg.useCommaKey === true && !e.shiftKey)) {
|
||||
if(e.keyCode !== 188 || (cfg.useCommaKey === true &&
|
||||
!(e.shiftKey || e.originalEvent && e.originalEvent.keyIdentifier && e.originalEvent.keyIdentifier != "U+002C"))) {
|
||||
e.preventDefault();
|
||||
if(cfg.expanded === true){ // if a selection is performed, select it and reset field
|
||||
selected = ms.combobox.find('.ms-res-item-active:first');
|
||||
|
Loading…
Reference in New Issue
Block a user