Files
MajoorWaldi-ComfyUI-Majoor-…/js/utils/tooltipShortcuts.js
T
MajoorWaldi dc72be0139 feat: enhance JS testing and linting setup
- Added coverage reporting for Vitest with configuration in vitest.config.mjs
- Updated package.json to include new scripts for JS coverage, linting, and formatting
- Modified run_quality_gate.py to allow skipping ESLint and Prettier checks
- Introduced .prettierrc for consistent code formatting
- Created .prettierignore to exclude specific files and directories from formatting
2026-03-28 14:14:28 +01:00

36 lines
973 B
JavaScript

export function appendTooltipHint(label, hint) {
const base = String(label || "").trim();
const suffix = String(hint || "").trim();
if (!suffix) return base;
if (!base) return suffix;
if (suffix.length === 1) {
const escaped = suffix.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
if (new RegExp(`\\(${escaped}\\)|\\b${escaped}\\b`, "i").test(base)) {
return base;
}
} else if (base.toLowerCase().includes(suffix.toLowerCase())) {
return base;
}
return `${base} (${suffix})`;
}
export function setTooltipHint(
element,
label,
hint,
{ setAriaLabel = true, ariaLabel = null } = {},
) {
if (!element) return "";
const title = appendTooltipHint(label, hint);
element.title = title;
if (setAriaLabel) {
const ariaBase = ariaLabel == null ? label : ariaLabel;
element.setAttribute("aria-label", appendTooltipHint(ariaBase, hint));
}
return title;
}