summaryrefslogtreecommitdiff
path: root/addons/website/static/src/js
diff options
context:
space:
mode:
authorChristophe Matthieu <chm@odoo.com>2014-07-10 15:25:44 +0200
committerChristophe Matthieu <chm@odoo.com>2014-07-10 15:25:44 +0200
commit886d6101ac8e5e1778b822ac49176cd9109494b6 (patch)
treec7df330a3454c74f9aa11170cd881e4c4d0fc792 /addons/website/static/src/js
parent0effbe3ca628460b9a0c257ea0bd6060c3eeb253 (diff)
[IMP] website editor: change link editor modal layout
Diffstat (limited to 'addons/website/static/src/js')
-rw-r--r--addons/website/static/src/js/website.editor.js27
1 files changed, 11 insertions, 16 deletions
diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js
index bfe084898de..178dee1e024 100644
--- a/addons/website/static/src/js/website.editor.js
+++ b/addons/website/static/src/js/website.editor.js
@@ -948,9 +948,7 @@
this.text = $(e.target).val();
},
'change select.link-style': function (e) {
- if (this.$("input.url-source[value!='']").val()) {
- this.preview();
- }
+ this.preview();
},
}),
init: function (editor) {
@@ -994,14 +992,14 @@
});
return this._super().then(this.proxy('bind_data'));
},
- get_data: function () {
+ get_data: function (test) {
var self = this,
def = new $.Deferred(),
$e = this.$('.active input.url-source').filter(':input'),
val = $e.val(),
label = this.$('#link-text').val() || val;
- if (!val || !$e[0].checkValidity()) {
+ if (test !== false && (!val || !$e[0].checkValidity())) {
// FIXME: error message
$e.closest('.form-group').addClass('has-error');
$e.focus();
@@ -1014,7 +1012,7 @@
if ($e.hasClass('email-address') && $e.val().indexOf("@") !== -1) {
def.resolve('mailto:' + val, false, label);
- } else if ($e.hasClass('page')) {
+ } else if ($e.val() && $e.val().length && $e.hasClass('page')) {
var data = $e.select2('data');
if (!data.create) {
def.resolve(data.id, false, data.text);
@@ -1066,15 +1064,15 @@
});
}
- if (!href) { return; }
var match, $control;
- if ((match = /mailto:(.+)/.exec(href))) {
+ if (href && (match = /mailto:(.+)/.exec(href))) {
this.$('input.email-address').val(match[1]).change();
}
- if (!$control) {
+ if (href && !$control) {
this.$('input.url').val(href).change();
this.$('input.window-new').closest("div").show();
}
+ this.preview();
},
changed: function (e) {
var $e = $(e.target);
@@ -1085,9 +1083,7 @@
.addClass('active')
.siblings().removeClass('active')
.addBack().removeClass('has-error');
- if ($e.val() && $e.val().length) {
- this.preview();
- }
+ this.preview();
},
call: function (method, args, kwargs) {
var self = this;
@@ -1123,10 +1119,9 @@
},
preview: function () {
var $preview = this.$("#link-preview");
- this.get_data().then(function (url, new_window, label, classes) {
- $preview.attr("href", url)
- .attr("target", new_window ? '_blank' : "")
- .text(label && label.length ? label : url)
+ this.get_data(false).then(function (url, new_window, label, classes) {
+ $preview.attr("target", new_window ? '_blank' : "")
+ .text((label && label.length ? label : url))
.attr("class", classes);
});
}