Browse Source

Merge pull request #40 from Yajo/website_mail_snippet_bg_color

[8.0][website_mail_bg_color] Color picker for mail snippets
pull/43/head
Rafael Blasco 9 years ago
parent
commit
7156bec749
  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_picker.png
  7. BIN
      website_mail_snippet_bg_color/images/color_set.png
  8. BIN
      website_mail_snippet_bg_color/static/description/icon.png
  9. 45
      website_mail_snippet_bg_color/static/src/js/bg_color_picker.js
  10. 16
      website_mail_snippet_bg_color/views/assets.xml
  11. 28
      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 Picker
=======================================
This module extends the functionality of the website mail designer to support
setting a custom background color to any snippet allowing 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.
#. Click on *Customize > Pick Background Color*.
#. Pick any color, or enter its HTML code in the box. 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 Picker",
"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_picker.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 "Pick 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_picker.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

45
website_mail_snippet_bg_color/static/src/js/bg_color_picker.js

@ -0,0 +1,45 @@
/* © 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_picker = snippet.Option.extend({
start: function () {
var self = this;
self._super();
return self.$el.find(".js_bg_color_picker").click(function(){
return self.pick();
});
},
pick: function() {
var self = this;
return CKEDITOR.instances.wrapwrap.getColorFromDialog(
function(color){
return self.change(color);
}
);
},
change: function(color) {
var oldcolor = this.$target.css("background-color"),
sides = ["top", "bottom", "left", "right"];
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);
}
// Match border colors if it was the same
for (var n in sides) {
var property = "border-" + sides[n] + "-color";
if (this.$target.css(property) == oldcolor) {
this.$target.css(property, 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_picker.js"/>
</xpath>
</template>
</data>
</openerp>

28
website_mail_snippet_bg_color/views/snippets.xml

@ -0,0 +1,28 @@
<?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_picker'
data-selector="[data-oe-field='body_html'] > div,
.oe_snippet_body,
.bg_color_picker"
data-selector-siblings="[data-oe-field='body_html'] > *"
data-selector-children="[data-oe-field='body_html']">
<li>
<a href="#" class="button js_bg_color_picker">
Pick Background Color
</a>
</li>
</div>
</xpath>
</template>
</data>
</openerp>
Loading…
Cancel
Save