From ca4897038a43d657be8318e4bfccd6e7ee107731 Mon Sep 17 00:00:00 2001 From: RainLoop Team Date: Wed, 26 Oct 2016 01:10:36 +0300 Subject: [PATCH] Fix strange quoting behaviour (#1225) --- dev/Common/Globals.js | 3 +++ dev/Common/Utils.js | 14 +++++++++++++- dev/Stores/User/Message.js | 12 ++++++++++-- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/dev/Common/Globals.js b/dev/Common/Globals.js index f979ee9a1..e0d6eb0d7 100644 --- a/dev/Common/Globals.js +++ b/dev/Common/Globals.js @@ -21,6 +21,9 @@ export const $body = $('body'); export const $div = $('
'); +export const $hcont = $('
'); +$hcont.attr('area', 'hidden').css({position: 'absolute', left: -5000}).appendTo($body); + export const startMicrotime = (new window.Date()).getTime(); /** diff --git a/dev/Common/Utils.js b/dev/Common/Utils.js index 40cec8b3b..f566cc70b 100644 --- a/dev/Common/Utils.js +++ b/dev/Common/Utils.js @@ -5,7 +5,7 @@ import _ from '_'; import ko from 'ko'; import Autolinker from 'Autolinker'; -import {$win, $div, dropdownVisibility, data as GlobalsData} from 'Common/Globals'; +import {$win, $div, $hcont, dropdownVisibility, data as GlobalsData} from 'Common/Globals'; import {ComposeType, EventKeyCode, SaveSettingsStep, FolderType} from 'Common/Enums'; import {Mime} from 'Common/Mime'; import {jassl} from 'Common/Jassl'; @@ -1450,6 +1450,18 @@ export function mimeContentType(fileName) return result; } +/** + * @param {Object} $el + * @returns {number} + */ +export function getRealHeight($el) +{ + $el.clone().show().appendTo($hcont); + const result = $hcont.height(); + $hcont.empty(); + return result; +} + /** * @param {string} url * @param {number} value diff --git a/dev/Stores/User/Message.js b/dev/Stores/User/Message.js index 54fb26c06..cc014b05a 100644 --- a/dev/Stores/User/Message.js +++ b/dev/Stores/User/Message.js @@ -14,7 +14,8 @@ import { import { trim, isNormal, isArray, inArray, pInt, pString, plainToHtml, - windowResize, findEmailAndLinks + windowResize, findEmailAndLinks, + getRealHeight } from 'Common/Utils'; import { @@ -459,7 +460,14 @@ class MessageUserStore { $oList.each(function() { const $this = $(this); // eslint-disable-line no-invalid-this - if ('' !== trim($this.text())) + + let h = $this.height(); + if (0 === h) + { + h = getRealHeight($this); + } + + if ('' !== trim($this.text()) && (0 === h || 100 < h)) { $this.addClass('rl-bq-switcher hidden-bq'); $('')