mirror of https://github.com/OCA/web.git
[MIG][web_editor_background_color] Migrate to v10
Now it fits into upstream's color picker, just adding a new tab at the end. All known issues have been addressed.pull/1725/head
parent
4f47b99ad9
commit
f248ca6ecb
|
@ -21,27 +21,14 @@ To use this module, you need to:
|
||||||
``mass_mailing`` or ``website``.
|
``mass_mailing`` or ``website``.
|
||||||
#. Use that module's facilities to edit some web content.
|
#. Use that module's facilities to edit some web content.
|
||||||
#. Drag & drop any snippet into the web editor body.
|
#. Drag & drop any snippet into the web editor body.
|
||||||
#. Click on *Customize > Color*.
|
#. Click on *Customize > Text-Image > Background Color > </> icon*.
|
||||||
#. Choose:
|
#. Choose a custom color by either:
|
||||||
|
* Writing any valid HTML color code in the text input.
|
||||||
* A color from the theme preset.
|
|
||||||
* A custom color by clicking on the text input and then either:
|
|
||||||
|
|
||||||
* Writing the HTML color code.
|
|
||||||
* Selecting a color from the color picker.
|
* Selecting a color from the color picker.
|
||||||
* Writing "transparent" to remove it.
|
|
||||||
|
|
||||||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
|
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
|
||||||
:alt: Try me on Runbot
|
:alt: Try me on Runbot
|
||||||
:target: https://runbot.odoo-community.org/runbot/162/9.0
|
:target: https://runbot.odoo-community.org/runbot/162/10.0
|
||||||
|
|
||||||
Known issues / Roadmap
|
|
||||||
======================
|
|
||||||
|
|
||||||
* When migrating to v10, adapt this option again to its brand new built-in
|
|
||||||
colorpicker.
|
|
||||||
* While you write to the text input, you may notice it disappears for a moment,
|
|
||||||
but don't worry, you are still writing.
|
|
||||||
|
|
||||||
Bug Tracker
|
Bug Tracker
|
||||||
===========
|
===========
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
{
|
{
|
||||||
"name": "Web Editor Background Color Picker",
|
"name": "Web Editor Background Color Picker",
|
||||||
"summary": "Set any background color for web editor snippets",
|
"summary": "Set any background color for web editor snippets",
|
||||||
"version": "9.0.1.0.0",
|
"version": "10.0.1.0.0",
|
||||||
"category": "Website",
|
"category": "Website",
|
||||||
"website": "https://www.tecnativa.com",
|
"website": "https://www.tecnativa.com",
|
||||||
"author": "Tecnativa, Odoo Community Association (OCA)",
|
"author": "Tecnativa, Odoo Community Association (OCA)",
|
||||||
|
@ -18,7 +18,6 @@
|
||||||
"web_editor",
|
"web_editor",
|
||||||
],
|
],
|
||||||
"data": [
|
"data": [
|
||||||
"views/assets.xml",
|
"templates/assets.xml",
|
||||||
"views/snippets.xml",
|
|
||||||
],
|
],
|
||||||
}
|
}
|
|
@ -12,13 +12,11 @@ msgstr ""
|
||||||
"PO-Revision-Date: 2017-03-30 08:28+0000\n"
|
"PO-Revision-Date: 2017-03-30 08:28+0000\n"
|
||||||
"Last-Translator: Marc Tormo i Bochaca <mtbochaca@gmail.com>, 2017\n"
|
"Last-Translator: Marc Tormo i Bochaca <mtbochaca@gmail.com>, 2017\n"
|
||||||
"Language-Team: Catalan (https://www.transifex.com/oca/teams/23907/ca/)\n"
|
"Language-Team: Catalan (https://www.transifex.com/oca/teams/23907/ca/)\n"
|
||||||
|
"Language: ca\n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
"Content-Transfer-Encoding: \n"
|
"Content-Transfer-Encoding: \n"
|
||||||
"Language: ca\n"
|
|
||||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||||
|
|
||||||
#. module: web_editor_background_color
|
#~ msgid "Color"
|
||||||
#: model:ir.ui.view,arch_db:web_editor_background_color.snippet_options
|
#~ msgstr "Color"
|
||||||
msgid "Color"
|
|
||||||
msgstr "Color"
|
|
||||||
|
|
|
@ -10,14 +10,12 @@ msgstr ""
|
||||||
"PO-Revision-Date: 2016-02-09 17:33+0100\n"
|
"PO-Revision-Date: 2016-02-09 17:33+0100\n"
|
||||||
"Last-Translator: <>\n"
|
"Last-Translator: <>\n"
|
||||||
"Language-Team: \n"
|
"Language-Team: \n"
|
||||||
|
"Language: es\n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
"Plural-Forms: \n"
|
"Plural-Forms: \n"
|
||||||
"Language: es\n"
|
|
||||||
"X-Generator: Poedit 1.8.6\n"
|
"X-Generator: Poedit 1.8.6\n"
|
||||||
|
|
||||||
#. module: website_mail_snippet_bg_color
|
#~ msgid "Pick Background Color"
|
||||||
#: view:website:website_mail.email_designer_snippets
|
#~ msgstr "Escoger el color de fondo"
|
||||||
msgid "Pick Background Color"
|
|
||||||
msgstr "Escoger el color de fondo"
|
|
||||||
|
|
|
@ -11,14 +11,13 @@ msgstr ""
|
||||||
"POT-Creation-Date: 2016-06-30 01:07+0000\n"
|
"POT-Creation-Date: 2016-06-30 01:07+0000\n"
|
||||||
"PO-Revision-Date: 2016-06-17 14:52+0000\n"
|
"PO-Revision-Date: 2016-06-17 14:52+0000\n"
|
||||||
"Last-Translator: Christophe CHAUVET <christophe.chauvet@gmail.com>\n"
|
"Last-Translator: Christophe CHAUVET <christophe.chauvet@gmail.com>\n"
|
||||||
"Language-Team: French (http://www.transifex.com/oca/OCA-social-8-0/language/fr/)\n"
|
"Language-Team: French (http://www.transifex.com/oca/OCA-social-8-0/language/"
|
||||||
|
"fr/)\n"
|
||||||
|
"Language: fr\n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
"Content-Transfer-Encoding: \n"
|
"Content-Transfer-Encoding: \n"
|
||||||
"Language: fr\n"
|
|
||||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||||
|
|
||||||
#. module: website_mail_snippet_bg_color
|
#~ msgid "Pick Background Color"
|
||||||
#: view:website:website_mail.email_designer_snippets
|
#~ msgstr "Mettre la couleur de fond"
|
||||||
msgid "Pick Background Color"
|
|
||||||
msgstr "Mettre la couleur de fond"
|
|
||||||
|
|
|
@ -11,14 +11,14 @@ msgstr ""
|
||||||
"POT-Creation-Date: 2016-02-27 01:40+0000\n"
|
"POT-Creation-Date: 2016-02-27 01:40+0000\n"
|
||||||
"PO-Revision-Date: 2016-02-27 16:56+0000\n"
|
"PO-Revision-Date: 2016-02-27 16:56+0000\n"
|
||||||
"Last-Translator: Matjaž Mozetič <m.mozetic@matmoz.si>\n"
|
"Last-Translator: Matjaž Mozetič <m.mozetic@matmoz.si>\n"
|
||||||
"Language-Team: Slovenian (http://www.transifex.com/oca/OCA-social-8-0/language/sl/)\n"
|
"Language-Team: Slovenian (http://www.transifex.com/oca/OCA-social-8-0/"
|
||||||
|
"language/sl/)\n"
|
||||||
|
"Language: sl\n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
"Content-Transfer-Encoding: \n"
|
"Content-Transfer-Encoding: \n"
|
||||||
"Language: sl\n"
|
"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n"
|
||||||
"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n"
|
"%100==4 ? 2 : 3);\n"
|
||||||
|
|
||||||
#. module: website_mail_snippet_bg_color
|
#~ msgid "Pick Background Color"
|
||||||
#: view:website:website_mail.email_designer_snippets
|
#~ msgstr "Izbira barve ozadja"
|
||||||
msgid "Pick Background Color"
|
|
||||||
msgstr "Izbira barve ozadja"
|
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
# Translation of Odoo Server.
|
||||||
|
# This file contains the translation of the following modules:
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: Odoo Server 10.0\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"Last-Translator: <>\n"
|
||||||
|
"Language-Team: \n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
"Content-Transfer-Encoding: \n"
|
||||||
|
"Plural-Forms: \n"
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 43 KiB |
|
@ -3,12 +3,21 @@
|
||||||
|
|
||||||
@colorpicker-img-path: "./";
|
@colorpicker-img-path: "./";
|
||||||
|
|
||||||
.colorpicker {
|
.colorpicker-element {
|
||||||
.bg-custom {
|
@colorpicker-width: 170px;
|
||||||
display: inherit;
|
@colorpicker-height: 118px;
|
||||||
.colorpicker-visible {
|
|
||||||
|
.colorpicker-inline {
|
||||||
min-width: initial;
|
min-width: initial;
|
||||||
padding: 1ex;
|
display: block;
|
||||||
}
|
margin-top: 3px !important;
|
||||||
|
}
|
||||||
|
.colorpicker-saturation {
|
||||||
|
width: @colorpicker-height;
|
||||||
|
height: @colorpicker-height;
|
||||||
|
}
|
||||||
|
.colorpicker-hue, .colorpicker-alpha {
|
||||||
|
width: (@colorpicker-width - @colorpicker-height) / 2;
|
||||||
|
height: @colorpicker-height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,54 +7,69 @@ odoo.define("web_editor_background_color.colorpicker", function (require) {
|
||||||
var core = require("web.core");
|
var core = require("web.core");
|
||||||
var options = require("web_editor.snippets.options");
|
var options = require("web_editor.snippets.options");
|
||||||
|
|
||||||
var ready = ajax.loadXML(
|
ajax.loadXML(
|
||||||
"/web_editor_background_color/static/src/xml/colorpicker.xml",
|
"/web_editor_background_color/static/src/xml/colorpicker.xml",
|
||||||
core.qweb
|
core.qweb
|
||||||
);
|
);
|
||||||
|
|
||||||
options.registry.colorpicker.include({
|
return options.registry.colorpicker.include({
|
||||||
bind_events: function () {
|
bind_events: function () {
|
||||||
this._super();
|
this._super();
|
||||||
// Remove inline background-color for normal class-based buttons
|
// Remove inline background-color for normal class-based buttons
|
||||||
this.$el.find(".colorpicker button").on(
|
this.$el.find(".o_colorpicker_section button[data-color]").on(
|
||||||
"click",
|
"click",
|
||||||
$.proxy(this.remove_inline_background_color, this)
|
$.proxy(this.remove_inline_background_color, this)
|
||||||
);
|
);
|
||||||
// Enable custom color picker
|
// Enable custom color picker
|
||||||
this.$custom = this.$el.find(".bg-custom");
|
this.$custom = this.$el.find('[data-name="custom_color"]');
|
||||||
this.$custom.colorpicker({
|
this.$custom.colorpicker({
|
||||||
color: this.$target.css("background-color"),
|
color: this.$target.css("background-color"),
|
||||||
container: true,
|
container: true,
|
||||||
|
inline: true,
|
||||||
|
sliders: {
|
||||||
|
saturation: {
|
||||||
|
maxLeft: 118,
|
||||||
|
maxTop: 118,
|
||||||
|
},
|
||||||
|
hue: {
|
||||||
|
maxTop: 118,
|
||||||
|
},
|
||||||
|
alpha: {
|
||||||
|
maxTop: 118,
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
this.$custom.on(
|
this.$custom.on(
|
||||||
"changeColor",
|
"changeColor",
|
||||||
$.proxy(this.set_inline_background_color, this)
|
$.proxy(this.set_inline_background_color, this));
|
||||||
);
|
|
||||||
this.$custom.on("click", $.proxy(this.custom_click, this));
|
|
||||||
this.$custom.on(
|
this.$custom.on(
|
||||||
|
"click keypress keyup keydown",
|
||||||
|
$.proxy(this.custom_abort_event, this));
|
||||||
|
this.$custom.on(
|
||||||
|
"click", "input",
|
||||||
|
$.proxy(this.input_select, this));
|
||||||
|
this.$el.find(".note-color-reset").on(
|
||||||
"click",
|
"click",
|
||||||
"input",
|
$.proxy(this.remove_inline_background_color, this));
|
||||||
$.proxy(this.input_select, this)
|
|
||||||
);
|
|
||||||
// Activate border color changes if it matches background's
|
// Activate border color changes if it matches background's
|
||||||
var style = this.$target.prop("style");
|
var style = this.$target.prop("style");
|
||||||
this.change_border =
|
this.change_border =
|
||||||
style["border-color"] &&
|
style["border-color"] &&
|
||||||
style["background-color"] === style["border-color"];
|
style["background-color"] === style["border-color"];
|
||||||
},
|
},
|
||||||
custom_click: function (event) {
|
custom_abort_event: function (event) {
|
||||||
// HACK Avoid dropdown disappearing when picking colors
|
// HACK Avoid dropdown disappearing when picking colors
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
},
|
},
|
||||||
input_select: function (event) {
|
input_select: function (event) {
|
||||||
$(event.target).focus().select();
|
$(event.target).focus().select();
|
||||||
this.$custom.colorpicker("show");
|
|
||||||
},
|
},
|
||||||
remove_inline_background_color: function (event) {
|
remove_inline_background_color: function (event) {
|
||||||
this.$target.css("background-color", "");
|
this.$target.css("background-color", "");
|
||||||
if (this.change_border) {
|
if (this.change_border) {
|
||||||
this.$target.css("border-color", "");
|
this.$target.css("border-color", "");
|
||||||
}
|
}
|
||||||
|
this.$target.trigger("background-color-event", event.type);
|
||||||
},
|
},
|
||||||
set_inline_background_color: function (event) {
|
set_inline_background_color: function (event) {
|
||||||
var color = String(event.color);
|
var color = String(event.color);
|
||||||
|
@ -62,11 +77,7 @@ odoo.define("web_editor_background_color.colorpicker", function (require) {
|
||||||
if (this.change_border) {
|
if (this.change_border) {
|
||||||
this.$target.css("border-color", color);
|
this.$target.css("border-color", color);
|
||||||
}
|
}
|
||||||
|
this.$target.trigger("background-color-event", event.type);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
|
||||||
ready: ready,
|
|
||||||
colorpicker: options.registry.colorpicker,
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -5,14 +5,13 @@
|
||||||
<templates>
|
<templates>
|
||||||
|
|
||||||
<t t-extend="web_editor.colorpicker">
|
<t t-extend="web_editor.colorpicker">
|
||||||
<t t-jquery=".colorpicker" t-operation="append">
|
<t t-jquery="colorpicker" t-operation="append">
|
||||||
<tr>
|
<div
|
||||||
<td colspan="6">
|
class="o_colorpicker_section"
|
||||||
<div class="bg-custom">
|
data-name="custom_color"
|
||||||
<input type="text" />
|
data-icon-class="fa fa-code">
|
||||||
|
<input type="text" class="form-control" />
|
||||||
</div>
|
</div>
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</t>
|
</t>
|
||||||
</t>
|
</t>
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
<odoo>
|
<odoo>
|
||||||
|
|
||||||
<template id="editor" inherit_id="web_editor.editor">
|
<template id="assets_editor" inherit_id="web_editor.assets_editor">
|
||||||
<xpath expr=".">
|
<xpath expr=".">
|
||||||
<!-- External library bootstrap-colorpicker -->
|
<!-- External library bootstrap-colorpicker -->
|
||||||
<link rel="stylesheet" href="/web_editor_background_color/static/src/lib/bootstrap-colorpicker/colorpicker.less"/>
|
<link rel="stylesheet" href="/web_editor_background_color/static/src/lib/bootstrap-colorpicker/colorpicker.less"/>
|
|
@ -1,25 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- Copyright 2017 Jairo Llopis <jairo.llopis@tecnativa.com>
|
|
||||||
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). -->
|
|
||||||
|
|
||||||
<odoo>
|
|
||||||
|
|
||||||
<template id="snippet_options"
|
|
||||||
inherit_id="web_editor.snippet_options">
|
|
||||||
|
|
||||||
<xpath expr=".">
|
|
||||||
<!-- The same option that already exists in website editor, but
|
|
||||||
enabled for mass mailing editor -->
|
|
||||||
<div data-js='colorpicker'
|
|
||||||
data-selector=".bg-color, #editable_area > div, a.o_default_snippet_text">
|
|
||||||
<li class="dropdown-submenu">
|
|
||||||
<a tabindex="-1" href="#">Color</a>
|
|
||||||
<ul class="dropdown-menu">
|
|
||||||
<li></li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
</div>
|
|
||||||
</xpath>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
</odoo>
|
|
Loading…
Reference in New Issue