Skip to content

Commit

Permalink
[FIX] web_editor, website: restore anchor link feature
Browse files Browse the repository at this point in the history
Following the new editor's merge at
22efdfb,
the anchor link feature was not working anymore.

This commit also fixes a feature behavior: when editing a link which
already contained an URL, the anchor field was not shown directly.

closes #30346
  • Loading branch information
qsm-odoo committed Jan 18, 2019
1 parent 139595d commit 6772c6c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
Expand Up @@ -208,9 +208,10 @@ var LinkDialog = Dialog.extend({
/**
* @private
*/
_onURLInput: function (ev) {
$(ev.currentTarget).closest('.form-group').removeClass('o_has_error').find('.form-control, .custom-select').removeClass('is-invalid');
var isLink = $(ev.currentTarget).val().indexOf('@') < 0;
_onURLInput: function () {
var $linkUrlInput = this.$('#o_link_dialog_url_input');
$linkUrlInput.closest('.form-group').removeClass('o_has_error').find('.form-control, .custom-select').removeClass('is-invalid');
var isLink = $linkUrlInput.val().indexOf('@') < 0;
this.$('input[name="is_new_window"]').closest('.form-group').toggleClass('d-none', !isLink);
},
});
Expand Down
4 changes: 2 additions & 2 deletions addons/web_editor/static/src/xml/wysiwyg.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<templates id="template" xml:space="preserve">

<!--=================-->
<!-- Edition Dialogs -->
<!--=================-->
Expand Down Expand Up @@ -263,7 +263,7 @@
<input type="text" name="label" class="form-control" id="o_link_dialog_label_input" required="required" t-att-value="widget.data.text"/>
</div>
</div>
<div class="form-group row">
<div class="form-group row o_url_input">
<label class="col-form-label col-md-3" for="o_link_dialog_url_input">URL or Email</label>
<div class="col-md-9">
<input type="text" name="url" class="form-control" id="o_link_dialog_url_input" required="required"/>
Expand Down
4 changes: 3 additions & 1 deletion addons/website/static/src/js/editor/widget_link.js
Expand Up @@ -22,8 +22,10 @@ weWidgets.LinkDialog.include({
* @override
*/
start: function () {
var def = this._super.apply(this, arguments);
wUtils.autocompleteWithPages(this, this.$('input[name="url"]'));
return this._super.apply(this, arguments);
this.opened(this._adaptPageAnchor.bind(this));
return def;
},

//--------------------------------------------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion addons/website/static/src/xml/website.editor.xml
Expand Up @@ -86,7 +86,8 @@
<span t-attf-class="o_color_preview bg-#{color}"/>
</button>
</t>
<t t-extend="web_editor.dialog.link">

<t t-extend="wysiwyg.widgets.link">
<t t-jquery="#o_link_dialog_url_input" t-operation="after">
<small class="form-text">Hint: Type '/' to link to an existing page and '#' to an anchor.</small>
</t>
Expand Down

0 comments on commit 6772c6c

Please sign in to comment.