Browse Source

[8.0][website_mail_bg_color] Color picker for mail snippets

This module extends the functionality of the website mail designer to
support
setting a custom background color to any snippet and allow you to
customize it.
pull/40/head
Jairo Llopis 8 years ago
parent
commit
1be20c9342
  1. 75
      website_mail_snippet_bg_color/README.rst
  2. 0
      website_mail_snippet_bg_color/__init__.py
  3. 26
      website_mail_snippet_bg_color/__openerp__.py
  4. 23
      website_mail_snippet_bg_color/i18n/es.po
  5. BIN
      website_mail_snippet_bg_color/images/click_option.png
  6. BIN
      website_mail_snippet_bg_color/images/color_chooser.png
  7. BIN
      website_mail_snippet_bg_color/images/color_set.png
  8. BIN
      website_mail_snippet_bg_color/static/description/icon.png
  9. 35
      website_mail_snippet_bg_color/static/src/js/bg_color_chooser.js
  10. 16
      website_mail_snippet_bg_color/views/assets.xml
  11. 26
      website_mail_snippet_bg_color/views/snippets.xml

75
website_mail_snippet_bg_color/README.rst

@ -0,0 +1,75 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
=======================================
Email Snippets Background Color Chooser
=======================================
This module extends the functionality of the website mail designer to support
setting a custom background color to any snippet and allow you to customize it.
Usage
=====
To use this module, you need to:
#. Install any module that makes use of the website mail designer, such as
``mass_mailing``.
#. Edit an email with the website mail designer.
#. Drag & drop any snippet into the mail body.
#. Choose *Customize > Choose Background Color*.
#. Pick any color, or enter its HTML code in the box, or press *Clear* to
remove it.
#. Press OK.
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/205/8.0
Known issues / Roadmap
======================
* Add the same functionality to all website snipppets. It would not be very
hard, just another XML template.
Bug Tracker
===========
Bugs are tracked on `GitHub Issues
<https://github.com/OCA/social/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smashing it by providing a detailed and welcomed `feedback
<https://github.com/OCA/
social/issues/new?body=module:%20
website_mail_snippet_bg_color%0Aversion:%20
8.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Credits
=======
Images
------
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
Contributors
------------
* Rafael Blasco <rafabn@antiun.com>
* Jairo Llopis <yajo.sk8@gmail.com>
Maintainer
----------
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
To contribute to this module, please visit https://odoo-community.org.

0
website_mail_snippet_bg_color/__init__.py

26
website_mail_snippet_bg_color/__openerp__.py

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
# © 2016 Antiun Ingeniería S.L. - Jairo Llopis
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Email Snippets Background Color Chooser",
"summary": "Set any background color for any mail editor snippet",
"version": "8.0.1.0.0",
"category": "Marketing",
"website": "http://www.antiun.com",
"author": "Antiun Ingeniería S.L., Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
"installable": True,
"images": [
"images/click_option.png",
"images/color_chooser.png",
"images/color_set.png",
],
"depends": [
"website_mail",
],
"data": [
"views/assets.xml",
"views/snippets.xml",
],
}

23
website_mail_snippet_bg_color/i18n/es.po

@ -0,0 +1,23 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * website_mail_snippet_bg_color
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-02-09 16:32+0000\n"
"PO-Revision-Date: 2016-02-09 17:33+0100\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: \n"
"Language: es\n"
"X-Generator: Poedit 1.8.6\n"
#. module: website_mail_snippet_bg_color
#: view:website:website_mail.email_designer_snippets
msgid "Choose Background Color"
msgstr "Escoger el color de fondo"

BIN
website_mail_snippet_bg_color/images/click_option.png

After

Width: 872  |  Height: 495  |  Size: 50 KiB

BIN
website_mail_snippet_bg_color/images/color_chooser.png

After

Width: 868  |  Height: 496  |  Size: 41 KiB

BIN
website_mail_snippet_bg_color/images/color_set.png

After

Width: 869  |  Height: 486  |  Size: 49 KiB

BIN
website_mail_snippet_bg_color/static/description/icon.png

After

Width: 128  |  Height: 128  |  Size: 9.2 KiB

35
website_mail_snippet_bg_color/static/src/js/bg_color_chooser.js

@ -0,0 +1,35 @@
/* © 2016 Antiun Ingeniería S.L. - Jairo Llopis
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). */
"use strict";
(function ($) {
var snippet = openerp.website.snippet;
snippet.options.bg_color_chooser = snippet.Option.extend({
start: function () {
var self = this;
self._super();
return self.$el.find(".js_bg_color_chooser").click(function(){
return self.choose();
});
},
choose: function() {
var self = this;
return CKEDITOR.instances.wrapwrap.getColorFromDialog(
function(color){
return self.change(color);
}
);
},
change: function(color) {
this.$target.css("background-color", color);
// Old-school bgcolor attribute if the element already had one
if (this.$target.attr("bgcolor")) {
this.$target.attr("bgcolor", color);
}
},
});
})(jQuery);

16
website_mail_snippet_bg_color/views/assets.xml

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- © 2016 Antiun Ingeniería S.L. - Jairo Llopis
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
<openerp>
<data>
<template id="assets_editor" inherit_id="website.assets_editor">
<xpath expr=".">
<script type="text/javascript"
src="/website_mail_snippet_bg_color/static/src/js/bg_color_chooser.js"/>
</xpath>
</template>
</data>
</openerp>

26
website_mail_snippet_bg_color/views/snippets.xml

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- © 2016 Antiun Ingeniería S.L. - Jairo Llopis
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
<openerp>
<data>
<template id="email_designer_snippets"
inherit_id="website_mail.email_designer_snippets">
<xpath expr="//div[@id='snippet_options']">
<div
data-snippet-option-id='bg_color_chooser'
data-selector="[data-oe-field='body_html'] > div, .oe_snippet_body"
data-selector-siblings="[data-oe-field='body_html'] > *"
data-selector-children="[data-oe-field='body_html']">
<li>
<a href="#" class="button js_bg_color_chooser">
Choose Background Color
</a>
</li>
</div>
</xpath>
</template>
</data>
</openerp>
Loading…
Cancel
Save