summaryrefslogtreecommitdiff
path: root/addons/website/static/src
diff options
context:
space:
mode:
authorXavier Morel <xmo@openerp.com>2013-09-02 12:54:11 +0200
committerXavier Morel <xmo@openerp.com>2013-09-02 12:54:11 +0200
commit2f97feb322221dc047004af0b9f28bb592b760f3 (patch)
tree822d5ef6f8e3f6f89d3552975eb8b3fbe63fd7aa /addons/website/static/src
parent1916b769ac64d99e200f4ed597444b1c0e585f02 (diff)
[ADD] interaction between RTE and bootstrap image modal
bzr revid: xmo@openerp.com-20130902105411-ni3klun0k8v1tmjg
Diffstat (limited to 'addons/website/static/src')
-rw-r--r--addons/website/static/src/js/website.editor.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js
index 5562bf2ca66..ee14b113e8e 100644
--- a/addons/website/static/src/js/website.editor.js
+++ b/addons/website/static/src/js/website.editor.js
@@ -471,6 +471,34 @@
},
'change input[type=file]': 'file_selection',
}),
+ start: function () {
+ var selection = this.editor.getSelection();
+ var el = selection && selection.getSelectedElement();
+ this.element = null;
+ if (el && el.is('img')) {
+ this.element = el;
+ this.$('input.url').val(el.getAttribute('src'));
+ }
+
+ return this._super();
+ },
+ save: function () {
+ var url = this.$('input.url').val();
+ var element, editor = this.editor;
+ if (!(element = this.element)) {
+ element = editor.document.createElement('img');
+ // focus event handler interactions between bootstrap (modal)
+ // and ckeditor (RTE) lead to blowing the stack in Safari and
+ // Chrome (but not FF) when this is done synchronously =>
+ // defer insertion so modal has been hidden & destroyed before
+ // it happens
+ setTimeout(function () {
+ editor.insertElement(element);
+ }, 0);
+ }
+ element.setAttribute('src', url);
+ this._super();
+ },
file_selection: function (e) {
this.$('button.filepicker').removeClass('btn-danger btn-success');