Regression: role tag background, unread item font and message box autogrow (#11861)

pull/11820/merge
Guilherme Gazzo 7 years ago committed by Diego Sampaio
parent 186f791194
commit cfe77b6c07
  1. 1
      .eslintignore
  2. 3
      packages/rocketchat-theme/client/imports/general/base_old.css
  3. 2
      packages/rocketchat-theme/client/imports/general/variables.css
  4. 42
      packages/rocketchat-ui/client/lib/textarea-autogrow.js

@ -13,7 +13,6 @@ packages/rocketchat-theme/client/minicolors/jquery.minicolors.js
packages/rocketchat-ui/client/lib/customEventPolyfill.js packages/rocketchat-ui/client/lib/customEventPolyfill.js
packages/rocketchat-ui/client/lib/Modernizr.js packages/rocketchat-ui/client/lib/Modernizr.js
packages/rocketchat-ui/client/lib/recorderjs/recorder.js packages/rocketchat-ui/client/lib/recorderjs/recorder.js
packages/rocketchat-ui/client/lib/textarea-autogrow.js
packages/rocketchat-videobridge/client/public/external_api.js packages/rocketchat-videobridge/client/public/external_api.js
packages/rocketchat-theme/client/vendor/ packages/rocketchat-theme/client/vendor/
packages/tap-i18n/lib/tap_i18next/tap_i18next-1.7.3.js packages/tap-i18n/lib/tap_i18next/tap_i18next-1.7.3.js

@ -137,7 +137,7 @@
font-size: 0; font-size: 0;
-moz-box-orient: vertical; -moz-box-orient: vertical;
code & { code & {
float: left; float: left;
} }
@ -3117,6 +3117,7 @@
padding: 1px 4px; padding: 1px 4px;
border-radius: 4px; border-radius: 4px;
border-width: 1px; border-width: 1px;
background: #FFFFFF;
} }
} }

@ -205,7 +205,7 @@
--sidebar-item-active-background: var(--rc-color-primary-dark); --sidebar-item-active-background: var(--rc-color-primary-dark);
--sidebar-item-active-color: var(--sidebar-item-text-color); --sidebar-item-active-color: var(--sidebar-item-text-color);
--sidebar-item-unread-color: var(--color-white); --sidebar-item-unread-color: var(--color-white);
--sidebar-item-unread-font-weight: 700; --sidebar-item-unread-font-weight: 600;
--sidebar-item-popup-background: var(--color-dark-medium); --sidebar-item-popup-background: var(--color-dark-medium);
--sidebar-item-user-status-size: 6px; --sidebar-item-user-status-size: 6px;
--sidebar-item-user-status-radius: 50%; --sidebar-item-user-status-radius: 50%;

@ -1,4 +1,5 @@
import _ from 'underscore' import _ from 'underscore';
(function($) { (function($) {
/** /**
* Auto-growing textareas; technique ripped from Facebook * Auto-growing textareas; technique ripped from Facebook
@ -7,9 +8,9 @@ import _ from 'underscore'
* http://github.com/jaz303/jquery-grab-bag/tree/master/javascripts/jquery.autogrow-textarea.js * http://github.com/jaz303/jquery-grab-bag/tree/master/javascripts/jquery.autogrow-textarea.js
*/ */
$.fn.autogrow = function(options) { $.fn.autogrow = function(options) {
let shadow = $("body > #autogrow-shadow"); let shadow = $('body > #autogrow-shadow');
if (!shadow.length) { if (!shadow.length) {
shadow = $('<div id="autogrow-shadow"></div>').addClass("autogrow-shadow").appendTo(document.body); shadow = $('<div id="autogrow-shadow"></div>').addClass('autogrow-shadow').appendTo(document.body);
} }
return this.filter('textarea').each(function() { return this.filter('textarea').each(function() {
const self = this; const self = this;
@ -18,7 +19,7 @@ import _ from 'underscore'
const settings = { const settings = {
postGrowCallback: null, postGrowCallback: null,
...options ...options,
}; };
const maxHeight = window.getComputedStyle(self)['max-height'].replace('px', ''); const maxHeight = window.getComputedStyle(self)['max-height'].replace('px', '');
@ -35,29 +36,26 @@ import _ from 'underscore'
fontWeight: $self.css('fontWeight'), fontWeight: $self.css('fontWeight'),
lineHeight: $self.css('lineHeight'), lineHeight: $self.css('lineHeight'),
resize: 'none', resize: 'none',
wordWrap: 'break-word' wordWrap: 'break-word',
}); });
const trigger = _.debounce(() => $self.trigger('autogrow', []), 500) const trigger = _.debounce(() => $self.trigger('autogrow', []), 500);
const times = function(string, number) { const times = function(string, number) {
let r = ''; let r = '';
for (let i = 0; i < number; i++) r += string; for (let i = 0; i < number; i++) { r += string; }
return r; return r;
}; };
const runTimes = (space) => times('&nbsp;', space.length - 1) + ' '; const runTimes = (space) => `${ times('&nbsp;', space.length - 1) } `;
let lastWidth = width; let lastWidth = width;
let lastHeight = minHeight; let lastHeight = minHeight;
let lastVal = self.value;
let length = 0; let length = 0;
const update = function update(event) {
const update = function update (event) {
if (lastHeight >= maxHeight && length && length < self.value.length) { if (lastHeight >= maxHeight && length && length < self.value.length) {
lastVal = self.value;
return true; return true;
} }
@ -73,12 +71,15 @@ import _ from 'underscore'
val += '<br/>'; val += '<br/>';
} }
if (width < 10) {
width = $self.width();
}
if (width !== lastWidth) { if (width !== lastWidth) {
shadow.css('width', width); shadow.css('width', width);
lastWidth = width; lastWidth = width;
} }
lastVal = self.value;
shadow[0].innerHTML = val; shadow[0].innerHTML = val;
let newHeight = Math.max(shadow[0].clientHeight + 1, minHeight) + 1; let newHeight = Math.max(shadow[0].clientHeight + 1, minHeight) + 1;
@ -87,18 +88,17 @@ import _ from 'underscore'
if (newHeight >= maxHeight) { if (newHeight >= maxHeight) {
newHeight = maxHeight; newHeight = maxHeight;
overflow = '' overflow = '';
} else { } else {
length = self.value.length; length = self.value.length;
} }
if (newHeight == lastHeight) { if (newHeight === lastHeight) {
return true; return true;
} }
lastHeight = newHeight; lastHeight = newHeight;
$self.css({ overflow, height: newHeight }); $self.css({ overflow, height: newHeight });
trigger(); trigger();
@ -106,13 +106,15 @@ import _ from 'underscore'
if (settings.postGrowCallback !== null) { if (settings.postGrowCallback !== null) {
settings.postGrowCallback($self); settings.postGrowCallback($self);
} }
} };
const updateWidthDebounce = _.debounce(() => { const updateWidth = () => {
length = 0; length = 0;
width = $self.width(); width = $self.width();
update(); update();
}, 300); };
const updateWidthDebounce = _.debounce(updateWidth, 300);
const updateThrottle = _.throttle(update, 300); const updateThrottle = _.throttle(update, 300);
@ -124,4 +126,4 @@ import _ from 'underscore'
self.updateAutogrow = updateThrottle; self.updateAutogrow = updateThrottle;
}); });
}; };
})(jQuery); }(jQuery));

Loading…
Cancel
Save