Sha256: 32cd277846e67617b8ffb93e05918ef2055649322a205aa81baa8e4db272bbf6
Contents?: true
Size: 1.35 KB
Versions: 12
Compression:
Stored size: 1.35 KB
Contents
export const checkTitles = (parentElement, saveButton) => { let everyItemHasTitle = true; Array.from(parentElement.children).forEach((item) => { const title = item.querySelector("input[type='text']").value; const noTitleErrorSpan = item.querySelector(".no-title-error"); if (!title || title.length === 0) { everyItemHasTitle = false; saveButton.disabled = true; noTitleErrorSpan.classList.add("is-visible"); item.appendChild(noTitleErrorSpan); } else { noTitleErrorSpan.classList.remove("is-visible"); } }); if (everyItemHasTitle) { saveButton.disabled = false; } } export const truncateFilename = (filename, maxLength = 31) => { if (filename.length <= maxLength) { return filename; } const charactersFromBegin = Math.floor(maxLength / 2) - 3; const charactersFromEnd = maxLength - charactersFromBegin - 3; return `${filename.slice(0, charactersFromBegin)}...${filename.slice(-charactersFromEnd)}`; } export const createHiddenInput = (elClasses, elName, elValue) => { const el = document.createElement("input"); el.type = "hidden"; if (elClasses) { if (typeof (elClasses) === "string") { el.className = elClasses; } else { el.className = elClasses.join(" ") } } if (elName) { el.name = elName; } if (elValue) { el.value = elValue; } return el; }
Version data entries
12 entries across 12 versions & 1 rubygems