Calendar and tasks pack the most body text at the smallest default sizes, so those two gear-icon dialogs get a "Text size" card (Normal/ Large/X-Large) alongside the existing Border card -- a new Widget-level font_scale column with its own POST .../font-scale endpoint, same Widget-property-not-config-field shape as border_style. Threaded through every classic (calendar_render.py) and modern (html_render.py/ calendar_html_render.py) size calc via one shared panel_style. scaled_size() so row heights/max_rows already derived from font size re-fit around the bigger text automatically.
33 lines
1.5 KiB
JavaScript
33 lines
1.5 KiB
JavaScript
// Shared "Text size" card (models.Widget.font_scale,
|
|
// _widget_font_scale_fields.html) -- only present on the calendar/tasks
|
|
// dialogs (see frame_pages.py's widget_dialog), same "one shared init
|
|
// function" shape as initBorderFields, just not included on every
|
|
// dialog since it isn't relevant to every widget type.
|
|
|
|
function initFontScaleFields() {
|
|
const select = document.getElementById('widget_font_scale');
|
|
if (!select) return; // dialog fragment didn't render the font-scale card -- shouldn't happen
|
|
|
|
document.getElementById('font-scale-config-form').addEventListener('submit', async (e) => {
|
|
e.preventDefault();
|
|
try {
|
|
const resp = await fetch(`${window.FRAME_API}/font-scale`, {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ font_scale: Number(select.value) }),
|
|
});
|
|
if (!resp.ok) throw new Error(await apiError(resp));
|
|
showStatus(true, 'Text size saved.');
|
|
// Whichever dialog is actually open -- both loadCalendarPreview and
|
|
// loadTasksPreview are always defined (plain script tags, not
|
|
// module-scoped), so checking the function's existence isn't
|
|
// enough; check for the <img> it actually targets instead (calling
|
|
// the wrong one throws setting .src on a null element).
|
|
if (document.getElementById('calendar-preview')) loadCalendarPreview();
|
|
if (document.getElementById('tasks-preview')) loadTasksPreview();
|
|
} catch (err) {
|
|
showStatus(false, err.message);
|
|
}
|
|
});
|
|
}
|