2022-03-08 19:19:33 +01:00
|
|
|
/**
|
|
|
|
* EGroupware eTemplate2 - Email input widget
|
|
|
|
*
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
* @package api
|
|
|
|
* @link https://www.egroupware.org
|
|
|
|
* @author Ralf Becker
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* eslint-disable import/no-extraneous-dependencies */
|
|
|
|
import {Et2InvokerMixin} from "./Et2InvokerMixin";
|
|
|
|
import {IsEmail} from "../Validators/IsEmail";
|
|
|
|
import {Et2Textbox} from "../Et2Textbox/Et2Textbox";
|
2022-03-10 17:13:43 +01:00
|
|
|
import {colorsDefStyles} from "../Styles/colorsDefStyles";
|
2023-09-13 19:55:33 +02:00
|
|
|
import {css} from "lit";
|
2023-03-22 20:03:23 +01:00
|
|
|
import {egw} from "../../jsapi/egw_global";
|
2022-03-08 19:19:33 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @customElement et2-url-email
|
|
|
|
*/
|
|
|
|
export class Et2UrlEmail extends Et2InvokerMixin(Et2Textbox)
|
|
|
|
{
|
2022-03-10 17:13:43 +01:00
|
|
|
static get styles()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
...super.styles,
|
|
|
|
colorsDefStyles,
|
|
|
|
css`
|
|
|
|
::slotted([slot="suffix"]) {
|
|
|
|
font-size: 90% !important;
|
2022-07-22 15:21:27 +02:00
|
|
|
height: auto;
|
|
|
|
width: auto;
|
2022-03-10 17:13:43 +01:00
|
|
|
}
|
|
|
|
`,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2022-07-22 20:43:09 +02:00
|
|
|
constructor(...args : any[])
|
2022-03-08 19:19:33 +01:00
|
|
|
{
|
2022-07-22 20:43:09 +02:00
|
|
|
super(...args);
|
|
|
|
|
2022-03-08 19:19:33 +01:00
|
|
|
this.defaultValidators.push(new IsEmail());
|
|
|
|
this._invokerLabel = '@';
|
|
|
|
this._invokerTitle = 'Compose mail to';
|
2022-03-10 09:15:59 +01:00
|
|
|
this._invokerAction = () =>
|
|
|
|
{
|
2023-02-17 16:51:27 +01:00
|
|
|
if(this.value.length > 0 && !this.hasFeedbackFor.length)
|
2022-03-10 09:15:59 +01:00
|
|
|
{
|
|
|
|
Et2UrlEmail.action(this.value);
|
|
|
|
}
|
|
|
|
}
|
2022-03-08 19:19:33 +01:00
|
|
|
}
|
|
|
|
|
2022-03-10 09:15:59 +01:00
|
|
|
static action(value)
|
2022-03-08 19:19:33 +01:00
|
|
|
{
|
2022-03-18 08:53:09 +01:00
|
|
|
if (value && egw.user('apps').mail && egw.preference('force_mailto','addressbook') != '1' )
|
2022-03-08 19:19:33 +01:00
|
|
|
{
|
2022-03-10 09:15:59 +01:00
|
|
|
egw.open_link('mailto:'+value);
|
2022-03-08 19:19:33 +01:00
|
|
|
}
|
2023-03-22 20:03:23 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
window.open("mailto:" + value);
|
|
|
|
}
|
2022-03-08 19:19:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// @ts-ignore TypeScript is not recognizing that this is a LitElement
|
|
|
|
customElements.define("et2-url-email", Et2UrlEmail);
|