1. View, filter, and save Product Permutation. \n 2. Synchronised with Product Category page and all common functionality moved into base and base table css, js, and python files.
This commit is contained in:
44
static/js/components/common/inputs/textarea.js
Normal file
44
static/js/components/common/inputs/textarea.js
Normal file
@@ -0,0 +1,44 @@
|
||||
|
||||
import Validation from "../../../lib/validation.js";
|
||||
|
||||
export default class TextArea {
|
||||
removeBlankTextAreaLines(textarea) {
|
||||
textarea.val(textarea.val.replace(/(?:(?:\r\n|\r|\n)\s*){2}/gm, ''));
|
||||
}
|
||||
|
||||
fitTextAreasToContent(parent) {
|
||||
var textareas = parent.querySelector('textarea');
|
||||
|
||||
if (!Validation.isEmpty(textareas)) {
|
||||
for (var t = 0; t < textareas.length; t++) {
|
||||
fitTextAreaToContent(document.querySelectorAll(textareas[t]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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.getAttribute('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