Page 1 of 1

[Added] Help Icons (nuBuilder 4.9.x)

Posted: Sat Aug 23, 2025 9:47 am
by admin
Add small "help" icons next to form objects that have a nu-help-icon-text attribute.
Hover shows a tooltip with your help text; you can also handle clicks, set different positions and use themes.

help_icon.png

:arrow: Demo Page

Good for
  • Quickly adding inline help to e.g. inputs, textareas, and selects
  • Keeping forms clean while still offering guidance
How it works
  1. You add a nu-help-icon-text attribute to any form object.
  2. Optionally add nu-help-icon-position to override tooltip position per element.
  3. Help icons appear automatically when the form loads - no JavaScript required!
  4. An icon appears to the right; hover to see a custom tooltip with precise arrow positioning. (Click support is optional.)
obj_properties.png

Automatic initialisation
The system runs automatically when forms are loaded, so you typically don't need any JavaScript. Just add the attributes to your form fields and you're done!

Refreshing (dynamic forms)
If you add or remove fields later, call:

Code: Select all

nuAttachHelpIconsToObjects(); // to attach to any new fields
nuAttachHelpIconsToObjects.refresh(); // to reposition existing icons

What to put in nu-help-icon-text
  • Short, actionable guidance (HTML allowed).
  • Keep it concise; the tooltip wraps at ~250px width.

Code: Select all

nu-help-icon-text="<b>Username</b>: 4–20 chars, letters & digits only."
Styling notes
  • Icon color defaults to #53a1c4. Override via CSS on .nuHelpOverlay i.
  • Tooltip is a lightweight custom element (.nuHelpToolTip) with a dark theme; override with CSS.
  • The overlay (.nuHelpOverlay) and tooltip are created once per page.
  • Tooltip arrows always point directly to the help icon regardless of tooltip size or position.
Performance & behavior
  • Icons automatically reposition on window scroll and resize.
  • Each field is watched with ResizeObserver to keep alignment accurate.
  • Changing nu-help-icon-text or nu-help-icon-position updates the tooltip on next hover.
  • Removing a field cleans up its observers and icon automatically.
  • Tooltips are viewport-aware and adjust position to stay on screen while maintaining arrow alignment.


Override icon settings

In the form's Custom Code field:

Code: Select all

function nuOnAddHelpIcon(element, settings) {
    // custom tooltip settings for object with element ID 'critical_input'
    if (element.id === 'critical_input') {
        settings.theme = 'red';
        settings.iconSize = 20;
        settings.gapRight = 12;
        settings.tooltipPosition = 'top';
        settings.animationDuration = 300;
        settings.iconClasses = 'fa-solid fa-exclamation-triangle';
        settings.onClick = function(el, text) {
            alert('Critical field help: ' + text);
        };
    }
 };

Options
  • gapRight: Pixels to place the icon to the right of the field. Default: 8.
  • iconSize: Icon size in pixels. Default: 16.
  • zIndex: Base stacking context for the overlay (tooltip is +1). Default: 50.
  • iconClasses: Classes for the help icon. Default: 'fa-solid fa-circle-question'.
  • tooltipPosition: Default tooltip position for all elements. Can be overridden per element. Options: 'top', 'bottom', 'left', 'right'. Default: 'top'.
  • onClick: Optional handler to run when the icon is clicked. Receives:
    • el: the field element
    • helpText: the help text from nu-help-icon-text

Re: [Added] Help Icons (nuBuilder 4.9.x)

Posted: Thu Aug 28, 2025 4:30 pm
by kev1n
You can now add HTML tooltips directly to objects using the attribute nu-help-text.
This displays the tooltip on the object itself, without adding an extra icon.

Example:

Code: Select all

nu-help-text="<b<Help<b> text for button"

Example: Setting a tooltip with options by code:

Code: Select all

nuSetAdvancedToolTip('run_user', {
    text: '<b>Dummy Tooltip</b><br><i>This is some HTML</i>',
    theme: 'blue'
});
In this shorthand form you can just pass the HTML string directly (but without the possibility to set other options)

Code: Select all

nuSetAdvancedToolTip('run_user', '<u>Tooltip Title</u><br><small>Some extra info here</small>');

Re: [Added] Help Icons (nuBuilder 4.9.x)

Posted: Fri Aug 29, 2025 7:14 am
by kev1n
Note: This feature is still under development, and its implementation may change before the next release.