From 137c4f5d76b55c3dd3c4f593de484aadfcf5e6da Mon Sep 17 00:00:00 2001 From: dbh Date: Thu, 2 Feb 2017 15:01:49 +0530 Subject: [PATCH] [IMP] web_editor: improve icon color edition - Make sure icon colors can be edited the same way as text - Improve recent color behavior --- .../static/src/js/rte.summernote.js | 7 +-- addons/web_editor/static/src/js/summernote.js | 62 ++++++++++++++----- addons/web_editor/static/src/js/tour.rte.js | 4 +- 3 files changed, 50 insertions(+), 23 deletions(-) diff --git a/addons/web_editor/static/src/js/rte.summernote.js b/addons/web_editor/static/src/js/rte.summernote.js index 8ff0effb86b..811c3e23a9f 100644 --- a/addons/web_editor/static/src/js/rte.summernote.js +++ b/addons/web_editor/static/src/js/rte.summernote.js @@ -67,8 +67,8 @@ renderer.createPalette = function ($container, options) { var $palettes = $container.find(".note-color .note-color-palette"); $palettes.prepend(html); - var $bg = $palettes.first().find("button:not(.note-color-btn)").addClass("note-color-btn"); - var $fore = $palettes.last().find("button:not(.note-color-btn)").addClass("note-color-btn"); + var $bg = $palettes.filter(":even").find("button:not(.note-color-btn)").addClass("note-color-btn"); + var $fore = $palettes.filter(":odd").find("button:not(.note-color-btn)").addClass("note-color-btn"); $bg.each(function () { var $el = $(this); var className = 'bg-' + $el.data('color'); @@ -146,10 +146,7 @@ renderer.tplPopovers = function (lang, options) { })).appendTo($resizefa); } var $colorfa = $airPopover.find('.note-color').clone(); - $colorfa.find(".btn-group:first").remove(); $colorfa.find("ul.dropdown-menu").css('min-width', '172px'); - $colorfa.find('button[data-event="color"]').attr('data-value', '{"foreColor": "#f00"}') - .find("i").css({'background': '', 'color': '#f00'}); $resizefa.after($colorfa); // show dialog box and delete diff --git a/addons/web_editor/static/src/js/summernote.js b/addons/web_editor/static/src/js/summernote.js index 71647828cc6..c2e2ea54dca 100644 --- a/addons/web_editor/static/src/js/summernote.js +++ b/addons/web_editor/static/src/js/summernote.js @@ -1872,23 +1872,51 @@ $.summernote.pluginEvents.removeFormat = function (event, editor, layoutInfo, va var fn_boutton_updateRecentColor = eventHandler.modules.toolbar.button.updateRecentColor; eventHandler.modules.toolbar.button.updateRecentColor = function (elBtn, sEvent, sValue) { fn_boutton_updateRecentColor.call(this, elBtn, sEvent, sValue); - var font = $(elBtn).closest('.note-color').find('.note-recent-color i')[0]; + var $recentcolor = $.find('.note-recent-color i'); + var $recentcolorbtn = $.find('.note-recent-color'); - if (sEvent === "foreColor") { - if (sValue.indexOf('text-') !== -1) { - font.className += ' ' + sValue; - font.style.color = ''; + //find last used color for fonts or for icons + //set this color into recentcolor button of both font and icon + for (var i in $recentcolor) { + var $font = $recentcolor[i]; + var $button = $($recentcolorbtn[i]); + var className = $font.className.split(/\s+/); + if (sEvent === "foreColor") { + //set class for forecolor to recentcolor button font-icon + for (var k=2; k section .row > div:first h1 font:eq(2)', @@ -218,7 +218,7 @@ odoo.define('web_editor.tour', function (require) { }, { content: "add ul content", trigger: '#editable_area > section .row > div:first', - extra_trigger: 'body:not(:has(#editable_area > section .row > div:first p:eq(4), #editable_area > section .row > div:eq(3))) #editable_area > section .row > div:first p:eq(3)', + extra_trigger: 'body:not(:has(#editable_area > section .row > div:first p:eq(5), #editable_area > section .row > div:eq(3))) #editable_area > section .row > div:first p:eq(3)', run: function () { var html = '