diff --git a/apps/documenteditor/main/app/controller/DocumentHolder.js b/apps/documenteditor/main/app/controller/DocumentHolder.js index 616d2fa71..bb8e521f1 100644 --- a/apps/documenteditor/main/app/controller/DocumentHolder.js +++ b/apps/documenteditor/main/app/controller/DocumentHolder.js @@ -802,13 +802,13 @@ define([ }, onHyperlinkClick: function(url) { - var me = this; if (url) { - if (me.api.asc_getUrlType(url)>0) + var type = this.api.asc_getUrlType(url); + if (type===AscCommon.c_oAscUrlType.Http || type===AscCommon.c_oAscUrlType.Email) window.open(url); else Common.UI.warning({ - msg: me.documentHolder.txtWarnUrl, + msg: this.documentHolder.txtWarnUrl, buttons: ['yes', 'no'], primary: 'yes', callback: function(btn) { diff --git a/apps/documenteditor/main/app/view/HyperlinkSettingsDialog.js b/apps/documenteditor/main/app/view/HyperlinkSettingsDialog.js index e5212662d..9fc36273c 100644 --- a/apps/documenteditor/main/app/view/HyperlinkSettingsDialog.js +++ b/apps/documenteditor/main/app/view/HyperlinkSettingsDialog.js @@ -98,6 +98,7 @@ define([ this.options.tpl = _.template(this.template)(this.options); this.api = this.options.api; this._originalProps = null; + this.urlType = AscCommon.c_oAscUrlType.Invalid; Common.UI.Window.prototype.initialize.call(this, this.options); }, @@ -135,9 +136,8 @@ define([ var trimmed = $.trim(value); if (trimmed.length>2083) return me.txtSizeLimit; - var urltype = me.api.asc_getUrlType(trimmed); - me.isEmail = (urltype==2); - return (urltype>0) ? true : me.txtNotUrl; + me.urlType = me.api.asc_getUrlType(trimmed); + return (me.urlType!==AscCommon.c_oAscUrlType.Invalid) ? true : me.txtNotUrl; } }); me.inputUrl._input.on('input', function (e) { @@ -377,8 +377,8 @@ define([ if (type==c_oHyperlinkType.WebLink) {//WebLink var url = $.trim(me.inputUrl.getValue()); - if (! /(((^https?)|(^ftp)):\/\/)|(^mailto:)/i.test(url) ) - url = ( (me.isEmail) ? 'mailto:' : 'http://' ) + url; + if (me.urlType!==AscCommon.c_oAscUrlType.Unsafe && ! /(((^https?)|(^ftp)):\/\/)|(^mailto:)/i.test(url) ) + url = ( (me.urlType==AscCommon.c_oAscUrlType.Email) ? 'mailto:' : 'http://' ) + url; url = url.replace(new RegExp("%20",'g')," "); props.put_Value(url); diff --git a/apps/presentationeditor/main/app/controller/DocumentHolder.js b/apps/presentationeditor/main/app/controller/DocumentHolder.js index c8fdd94b8..e4988371d 100644 --- a/apps/presentationeditor/main/app/controller/DocumentHolder.js +++ b/apps/presentationeditor/main/app/controller/DocumentHolder.js @@ -759,13 +759,13 @@ define([ }, onHyperlinkClick: function(url) { - var me = this; if (url) { - if (me.api.asc_getUrlType(url)>0) + var type = this.api.asc_getUrlType(url); + if (type===AscCommon.c_oAscUrlType.Http || type===AscCommon.c_oAscUrlType.Email) window.open(url); else Common.UI.warning({ - msg: me.documentHolder.txtWarnUrl, + msg: this.documentHolder.txtWarnUrl, buttons: ['yes', 'no'], primary: 'yes', callback: function(btn) { diff --git a/apps/presentationeditor/main/app/view/HyperlinkSettingsDialog.js b/apps/presentationeditor/main/app/view/HyperlinkSettingsDialog.js index 0b98ddbe8..ba97812f9 100644 --- a/apps/presentationeditor/main/app/view/HyperlinkSettingsDialog.js +++ b/apps/presentationeditor/main/app/view/HyperlinkSettingsDialog.js @@ -100,6 +100,7 @@ define([ this.options.tpl = _.template(this.template)(this.options); this.slides = this.options.slides; this.api = this.options.api; + this.urlType = AscCommon.c_oAscUrlType.Invalid; Common.UI.Window.prototype.initialize.call(this, this.options); }, @@ -137,9 +138,8 @@ define([ var trimmed = $.trim(value); if (trimmed.length>2083) return me.txtSizeLimit; - var urltype = me.api.asc_getUrlType(trimmed); - me.isEmail = (urltype==2); - return (urltype>0) ? true : me.txtNotUrl; + me.urlType = me.api.asc_getUrlType(trimmed); + return (me.urlType!==AscCommon.c_oAscUrlType.Invalid) ? true : me.txtNotUrl; } }); me.inputUrl._input.on('input', function (e) { @@ -236,8 +236,8 @@ define([ def_display = tip; } else { var url = $.trim(me.inputUrl.getValue()); - if (! /(((^https?)|(^ftp)):\/\/)|(^mailto:)/i.test(url) ) - url = ( (me.isEmail) ? 'mailto:' : 'http://' ) + url; + if (me.urlType!==AscCommon.c_oAscUrlType.Unsafe && ! /(((^https?)|(^ftp)):\/\/)|(^mailto:)/i.test(url) ) + url = ( (me.urlType==AscCommon.c_oAscUrlType.Email) ? 'mailto:' : 'http://' ) + url; url = url.replace(new RegExp("%20",'g')," "); props.put_Value( url ); props.put_ToolTip(me.inputTip.getValue()); diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index be63a942a..43ddd22eb 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -1662,7 +1662,8 @@ define([ }); return; } - if (this.api.asc_getUrlType(url)>0) + var type = this.api.asc_getUrlType(url); + if (type===AscCommon.c_oAscUrlType.Http || type===AscCommon.c_oAscUrlType.Email) window.open(url, '_blank'); else Common.UI.warning({ diff --git a/apps/spreadsheeteditor/main/app/view/HyperlinkSettingsDialog.js b/apps/spreadsheeteditor/main/app/view/HyperlinkSettingsDialog.js index f9a263282..ebc109d30 100644 --- a/apps/spreadsheeteditor/main/app/view/HyperlinkSettingsDialog.js +++ b/apps/spreadsheeteditor/main/app/view/HyperlinkSettingsDialog.js @@ -107,6 +107,7 @@ define([ this.api = this.options.api; this.appOptions = options.appOptions; this.dataRangeValid = ''; + this.urlType = AscCommon.c_oAscUrlType.Invalid; Common.UI.Window.prototype.initialize.call(this, this.options); }, @@ -144,9 +145,8 @@ define([ var trimmed = $.trim(value); if (me.api.asc_getFullHyperlinkLength(trimmed)>2083) return me.txtSizeLimit; - var urltype = me.api.asc_getUrlType(trimmed); - me.isEmail = (urltype==2); - return (urltype>0) ? true : me.txtNotUrl; + me.urlType = me.api.asc_getUrlType(trimmed); + return (me.urlType!==AscCommon.c_oAscUrlType.Invalid) ? true : me.txtNotUrl; } }); me.inputUrl._input.on('input', function (e) { @@ -326,8 +326,8 @@ define([ } } else { var url = this.inputUrl.getValue().replace(/^\s+|\s+$/g,''); - if (! /(((^https?)|(^ftp)):\/\/)|(^mailto:)/i.test(url) ) - url = ( (this.isEmail) ? 'mailto:' : 'http://' ) + url; + if (me.urlType!==AscCommon.c_oAscUrlType.Unsafe && ! /(((^https?)|(^ftp)):\/\/)|(^mailto:)/i.test(url) ) + url = ( (me.urlType==AscCommon.c_oAscUrlType.Email) ? 'mailto:' : 'http://' ) + url; url = url.replace(new RegExp("%20",'g')," "); props.asc_setHyperlinkUrl(url); def_display = url;