summaryrefslogtreecommitdiff
path: root/addons/website/static/src/js/website.editor.js
diff options
context:
space:
mode:
authorchm@openerp.com <>2014-03-26 15:16:29 +0100
committerchm@openerp.com <>2014-03-26 15:16:29 +0100
commitaa63c564629e6f3ecb72f1d8039e353158a1754d (patch)
treecdba68855851d2519e14dff8c14abe1e2c5965c3 /addons/website/static/src/js/website.editor.js
parentb39be63a8b8e20ae30ed62ecce4f4f677e7e8e01 (diff)
[IMP] website editor: add style button on image
bzr revid: chm@openerp.com-20140326141629-diz4rk0789no7yyl
Diffstat (limited to 'addons/website/static/src/js/website.editor.js')
-rw-r--r--addons/website/static/src/js/website.editor.js34
1 files changed, 29 insertions, 5 deletions
diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js
index ae126ad16ab..96cc53546b0 100644
--- a/addons/website/static/src/js/website.editor.js
+++ b/addons/website/static/src/js/website.editor.js
@@ -636,15 +636,26 @@
* @param {String} [classes] additional classes to set on the button
* @returns {jQuery}
*/
- make_hover_button: function (label, editfn, classes) {
- return $(openerp.qweb.render('website.editor.hoverbutton', {
+ make_hover_button: function (label, editfn, classes, styleButton) {
+ var $div = $(openerp.qweb.render('website.editor.hoverbutton', {
label: label,
classes: classes,
- })).hide().appendTo(document.body).click(function (e) {
+ styleButton: styleButton
+ })).hide().appendTo(document.body);
+
+ $div.find("button.hover-edition-button").click(function (e) {
e.preventDefault();
e.stopPropagation();
editfn.call(this, e);
});
+ if (styleButton) {
+ $div.find("button.hover-style-button").click(function (e) {
+ e.preventDefault();
+ e.stopPropagation();
+ styleButton.call(this, e);
+ });
+ }
+ return $div;
},
/**
* For UI clarity, during RTE edition when the user hovers links and
@@ -665,11 +676,23 @@
$link_button.hide();
previous = null;
}, 'btn-xs');
+
var $image_button = this.make_hover_button(_t("Change"), function () {
image_dialog(editor, new CKEDITOR.dom.element(previous));
$image_button.hide();
previous = null;
- }, 'btn-sm');
+ }, 'btn-sm', function () {
+ var prev = previous;
+ var sel = new CKEDITOR.dom.element(prev);
+ var $sel = $(sel.$);
+ if ($sel.data('transfo')) {
+ $sel.transfo("destroy");
+ $(this).addClass("btn-primary").removeClass("btn-default");
+ } else {
+ $sel.transfo();
+ $(this).removeClass("btn-primary").addClass("btn-default");
+ }
+ });
function is_icons_widget(element) {
var w = editor.widgets.getByElement(element);
@@ -724,7 +747,8 @@
}
}).on('mouseleave', 'a, img, .fa', function (e) {
var current = document.elementFromPoint(e.clientX, e.clientY);
- if (current === $link_button[0] || current === $image_button[0]) {
+ if (current === $link_button[0] || $(current).parent()[0] === $link_button[0] ||
+ current === $image_button[0] || $(current).parent()[0] === $image_button[0]) {
return;
}
$image_button.add($link_button).hide();