summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src/js/transcoder.js
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2018-02-14 16:34:13 +0100
committerChristophe Simonis <chs@odoo.com>2018-02-14 16:34:13 +0100
commitd24bdbde81be971be27e39ef7a2e1a1b2371074e (patch)
tree5c1cc64cf0fadcf1879ef10f233a3793c47b6bfb /addons/web_editor/static/src/js/transcoder.js
parent33e7c8d60c58c98d2f679b66abae5af7ef224726 (diff)
parent9d0de6111471860bc541058be351df4abb8ea167 (diff)
[MERGE] forward port branch saas-14 up to 9d0de611147
Diffstat (limited to 'addons/web_editor/static/src/js/transcoder.js')
-rw-r--r--addons/web_editor/static/src/js/transcoder.js31
1 files changed, 20 insertions, 11 deletions
diff --git a/addons/web_editor/static/src/js/transcoder.js b/addons/web_editor/static/src/js/transcoder.js
index 265ca5ab3f0..a5cf20575d4 100644
--- a/addons/web_editor/static/src/js/transcoder.js
+++ b/addons/web_editor/static/src/js/transcoder.js
@@ -9,17 +9,12 @@ var getMatchedCSSRules = function (a) {
var sheets = document.styleSheets;
for(var i = sheets.length-1; i >= 0 ; i--) {
var rules;
- if (sheets[i].hasOwnProperty('rules')) {
- rules = sheets[i].rules;
- } else {
- //try...catch because Firefox not able to enumerate document.styleSheets[].cssRules[] for cross-domain stylesheets.
- try {
- rules = sheets[i].cssRules;
- } catch(e) {
- console.warn("Can't read the css rules of: " + sheets[i].href, e);
- continue;
- }
- rules = sheets[i].cssRules;
+ // try...catch because browser may not able to enumerate rules for cross-domain sheets
+ try {
+ rules = sheets[i].rules || sheets[i].cssRules;
+ } catch (e) {
+ console.warn("Can't read the css rules of: " + sheets[i].href, e);
+ continue;
}
if (rules) {
for(var r = rules.length-1; r >= 0; r--) {
@@ -131,6 +126,20 @@ var getMatchedCSSRules = function (a) {
delete style['text-decoration-style'];
}
+ // text-align inheritance does not seem to get past <td> elements on some
+ // mail clients
+ if (style['text-align'] === 'inherit') {
+ var $el = $(a).parent();
+ do {
+ var align = $el.css('text-align');
+ if (_.indexOf(['left', 'right', 'center', 'justify'], align) >= 0) {
+ style['text-align'] = align;
+ break;
+ }
+ $el = $el.parent();
+ } while (!$el.is('html'));
+ }
+
return style;
};