diff --git a/forms/HtmlEditorField.php b/forms/HtmlEditorField.php index a43b1cee4..19fd81c73 100644 --- a/forms/HtmlEditorField.php +++ b/forms/HtmlEditorField.php @@ -351,7 +351,7 @@ class HtmlEditorField_Toolbar extends RequestHandler { $fromWeb = new CompositeField( new LiteralField('headerURL', '

' . sprintf($numericLabelTmpl, '1', _t('HtmlEditorField.ADDURL', 'Add URL')) . '

'), - $remoteURL = new TextField('RemoteURL', 'http://'), + $remoteURL = new TextField('RemoteURL', ''), new LiteralField('addURLImage', '') diff --git a/javascript/HtmlEditorField.js b/javascript/HtmlEditorField.js index 023e599c0..34a7fd5d5 100644 --- a/javascript/HtmlEditorField.js +++ b/javascript/HtmlEditorField.js @@ -1142,7 +1142,6 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE; var val = this.val(), orig = val; val = $.trim(val); - val = val.replace(/^https?:\/\//i, ''); if (orig !== val) this.val(val); this.getAddButton().button(!!val ? 'enable' : 'disable'); @@ -1160,10 +1159,17 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE; onclick: function(e) { var urlField = this.getURLField(), container = this.closest('.CompositeField'), form = this.closest('form'); + var val = urlField.val(); if (urlField.validate()) { container.addClass('loading'); - form.showFileView('http://' + urlField.val()).done(function() { + + // add "http://" if a protocol is missing from the url + if (val.match(/^https?:\/\//i) == void 0) { + val = 'http://' + val; + } + + form.showFileView(val).done(function() { container.removeClass('loading'); }); form.redraw();