mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-11 01:43:23 +01:00
Improve link url dialog
This commit is contained in:
parent
602e58f58e
commit
ed8fe3a455
@ -60,7 +60,7 @@ class LinkEditor extends BootstrapDialog {
|
||||
|
||||
// Add Input
|
||||
const input = $('<input id="inputUrl"/>').attr({
|
||||
placeholder: 'http://www.example.com/',
|
||||
placeholder: 'https://www.example.com/',
|
||||
required: 'true',
|
||||
autofocus: 'autofocus',
|
||||
class: 'form-control',
|
||||
@ -92,9 +92,10 @@ class LinkEditor extends BootstrapDialog {
|
||||
const me = this;
|
||||
this.form.unbind('submit').submit((event) => {
|
||||
event.preventDefault();
|
||||
if (me.checkURL(input.val())) {
|
||||
let inputValue = input.val();
|
||||
inputValue = this.hasProtocol(inputValue) ? inputValue : `https://${inputValue}`;
|
||||
if (me.checkURL(inputValue)) {
|
||||
me.cleanError();
|
||||
const inputValue = input.val();
|
||||
if (inputValue != null && $.trim(inputValue) !== '') {
|
||||
model.setValue(inputValue);
|
||||
}
|
||||
@ -115,7 +116,16 @@ class LinkEditor extends BootstrapDialog {
|
||||
* @return {Boolean} true if the url is valid
|
||||
*/
|
||||
checkURL(url) {
|
||||
const regex = /^(http|https|ftp):\/\/[a-z0-9]+([-.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/i;
|
||||
const regex = /^(http|https):\/\/[a-z0-9]+([-.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/i;
|
||||
return (regex.test(url));
|
||||
}
|
||||
|
||||
/**
|
||||
* checks whether the input is a valid url
|
||||
* @return {Boolean} true if the url is valid
|
||||
*/
|
||||
hasProtocol(url) {
|
||||
const regex = /^(http|https):\/\//i;
|
||||
return (regex.test(url));
|
||||
}
|
||||
|
||||
|
@ -40,8 +40,8 @@ class LinkIconTooltip extends FloatingTip {
|
||||
|
||||
static _buildContent(linkIcon) {
|
||||
const url = linkIcon.getModel().getUrl();
|
||||
const linkText = `URL: ${url}`;
|
||||
const linkPreview = `http://free.pagepeeker.com/v2/thumbs.php?size=m&url=${url}`;
|
||||
const linkText = `${url}`;
|
||||
const linkPreview = `https://free.pagepeeker.com/v2/thumbs.php?size=m&url=${url}`;
|
||||
|
||||
const result = $('<div></div>').css({
|
||||
padding: '5px',
|
||||
|
Loading…
Reference in New Issue
Block a user