[ADD] interaction between RTE and bootstrap image modal

bzr revid: xmo@openerp.com-20130902105411-ni3klun0k8v1tmjg
This commit is contained in:
Xavier Morel
2013-09-02 12:54:11 +02:00
parent 1916b769ac
commit 2f97feb322
@@ -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');