summaryrefslogtreecommitdiff
path: root/addons/website/static/src/js/website.editor.js
diff options
context:
space:
mode:
authorFabien Meghazi <fme@openerp.com>2013-10-31 17:51:17 +0100
committerFabien Meghazi <fme@openerp.com>2013-10-31 17:51:17 +0100
commit35d469d51f52d1dac7c99e8bab42d0b0a22122c5 (patch)
treeca2bbdecfd6a231f9be98c2059cda88f6a341415 /addons/website/static/src/js/website.editor.js
parent9f97b243181bf38e701de7c43ab79f57cc149a2c (diff)
[FIX] Reuse website.editor.LinkDialog#bind_data()
bzr revid: fme@openerp.com-20131031165117-13yo8nrfg1ru4cp8
Diffstat (limited to 'addons/website/static/src/js/website.editor.js')
-rw-r--r--addons/website/static/src/js/website.editor.js25
1 files changed, 17 insertions, 8 deletions
diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js
index cd45f771a24..4781a639b66 100644
--- a/addons/website/static/src/js/website.editor.js
+++ b/addons/website/static/src/js/website.editor.js
@@ -806,10 +806,13 @@
this.text = null;
},
start: function () {
+ var self = this;
return $.when(
this.fetch_pages().done(this.proxy('fill_pages')),
this._super()
- ).done(this.proxy('bind_data'));
+ ).done(function () {
+ self.bind_data();
+ });
},
save: function () {
var self = this, _super = this._super.bind(this);
@@ -840,17 +843,24 @@
},
make_link: function (url, new_window, label) {
},
- bind_data: function () {
- var href = this.element && (this.element.data( 'cke-saved-href')
+ bind_data: function (text, href, new_window) {
+ href = href || this.element && (this.element.data( 'cke-saved-href')
|| this.element.getAttribute('href'));
if (!href) { return; }
+ if (new_window === undefined) {
+ new_window = this.element.getAttribute('target') === '_blank';
+ }
+ if (text === undefined) {
+ text = this.element.getText();
+ }
+
var match, $control;
- if (match = /mailto:(.+)/.exec(href)) {
+ if ((match = /mailto:(.+)/.exec(href))) {
$control = this.$('input.email-address').val(match[1]);
} else if (href in this.pages) {
$control = this.$('select.existing').val(href);
- } else if (match = /\/page\/(.+)/.exec(href)) {
+ } else if ((match = /\/page\/(.+)/.exec(href))) {
var actual_href = '/page/website.' + match[1];
if (actual_href in this.pages) {
$control = this.$('select.existing').val(actual_href);
@@ -862,9 +872,8 @@
this.changed($control);
- this.$('input#link-text').val(this.element.getText());
- this.$('input.window-new').prop(
- 'checked', this.element.getAttribute('target') === '_blank');
+ this.$('input#link-text').val(text);
+ this.$('input.window-new').prop('checked', new_window);
},
changed: function ($e) {
this.$('.url-source').not($e).val('');