1.started removal of CDNs.\n 2. Improved modular structure for all parts of project including database.
This commit is contained in:
41
static/js/components/textarea.js
Normal file
41
static/js/components/textarea.js
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
function removeBlankTextAreaLines(textarea) {
|
||||
textarea.val(textarea.val.replace(/(?:(?:\r\n|\r|\n)\s*){2}/gm, ''));
|
||||
}
|
||||
|
||||
function fitTextAreasToContent(parent) {
|
||||
var textareas = parent.querySelector('textarea');
|
||||
|
||||
if (!isEmpty(textareas)) {
|
||||
for (var t = 0; t < textareas.length; t++) {
|
||||
fitTextAreaToContent(document.querySelectorAll(textareas[t]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function fitTextAreaToContent(textarea) {
|
||||
// Trim new text
|
||||
var txtNew = textarea.val().trim();
|
||||
textarea.val(txtNew);
|
||||
|
||||
var elTextarea = textarea[0];
|
||||
|
||||
// Clear style height and set rows = 1
|
||||
elTextarea.style.removeProperty('height');
|
||||
textarea.attr('rows', 1);
|
||||
|
||||
const paddingTop = parseCSSPropertyToFloat(textarea, 'padding-top');
|
||||
const paddingBottom= parseCSSPropertyToFloat(textarea, 'padding-bottom');
|
||||
const borderTop = parseCSSPropertyToFloat(textarea, 'border-top');
|
||||
const borderBottom = parseCSSPropertyToFloat(textarea, 'border-bottom');
|
||||
let heightDelta = paddingTop + paddingBottom + borderTop + borderBottom;
|
||||
let heightNew = elTextarea.scrollHeight + heightDelta;
|
||||
|
||||
// If new height is less than 1 linem default to single line height
|
||||
const heightSingleLine = parseCSSPropertyToFloat(textarea, 'line-height') + heightDelta;
|
||||
if (heightNew < heightSingleLine) heightNew = heightSingleLine;
|
||||
|
||||
elTextarea.style.height = heightNew + 'px';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user