mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 14:41:29 +01:00
Fix/remove email validator and implement trailing_slash attribute
This commit is contained in:
parent
ebaebf65ca
commit
782958d7fc
@ -15,7 +15,7 @@ import {Et2Textbox} from "../Et2Textbox/Et2Textbox";
|
||||
/**
|
||||
* @customElement et2-url
|
||||
*
|
||||
* @ToDo: implement allow_path and trailing_slash attributes
|
||||
* @ToDo: implement allow_path attributes
|
||||
*/
|
||||
export class Et2Url extends Et2InvokerMixin(Et2Textbox)
|
||||
{
|
||||
@ -42,7 +42,6 @@ export class Et2Url extends Et2InvokerMixin(Et2Textbox)
|
||||
constructor()
|
||||
{
|
||||
super();
|
||||
this.defaultValidators.push(new IsEmail());
|
||||
this._invokerLabel = '⎆';
|
||||
this._invokerTitle = 'Open';
|
||||
this._invokerAction = () => {
|
||||
@ -52,11 +51,36 @@ export class Et2Url extends Et2InvokerMixin(Et2Textbox)
|
||||
this.trailing_slash = undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change handler calling custom handler set via onchange attribute
|
||||
*
|
||||
* Reimplemented to add/remove trailing slash depending on trailing_slash attribute
|
||||
*
|
||||
* @param _ev
|
||||
* @returns
|
||||
*/
|
||||
_oldChange(_ev: Event): boolean
|
||||
{
|
||||
const value = this.modelValue;
|
||||
if (typeof this.trailing_slash !== 'undefined' && value && this.trailing_slash !== (value.substr(-1)==='/'))
|
||||
{
|
||||
if (!this.trailing_slash)
|
||||
{
|
||||
this.modelValue = value.replace(/\/+$/, '');
|
||||
}
|
||||
else
|
||||
{
|
||||
this.modelValue += '/';
|
||||
}
|
||||
}
|
||||
return super._oldChange(_ev);
|
||||
}
|
||||
|
||||
static action(value)
|
||||
{
|
||||
if (!value) return;
|
||||
// implicit add http:// if no protocol given
|
||||
if(value.indexOf("://") == -1) value = "http://"+value;
|
||||
if(value.indexOf("://") === -1) value = "http://"+value;
|
||||
egw.open_link(value, '_blank');
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user