Class: H_ui_completer

H_ui_completer

Common base of the completion widgets (H_ui_autocomplete, H_ui_precomplete).
It holds what both do in the same way: the instance registry and its life cycle, the opening and closing of the suggestion list with the click outside, the active (highlighted) row and the scrolling that keeps it visible.
What differs stays in the subclass: where the rows come from, how they are rendered and how the keyboard drives them. A subclass gives the base three settings: the id prefix of its fields, the id suffix of its list (the input and the hidden field are always input_search and current_id) and the CSS class of the active row.
A subclass MUST declare its own `static instances = {}`: a static field is inherited by reference, so a subclass without its own registry would share the one of its parent.
Used as a base only, never instantiated directly.

new H_ui_completer()

ui.js, line 2420

Members

instances

All instances of one widget, by dom_id. Each subclass owns its own registry.

Methods

staticH_ui_completer.clean_instances()

ui.js, line 2591
Cleans up all instances that no longer exist.

staticH_ui_completer.create_instance(dom_id, settings){H_ui_completer}

ui.js, line 2576
Creates a new instance of the widget for a given dom_id.
Cleans up any existing instance for the same dom_id, then the instances that left the DOM.
Name Type Description
dom_id string The DOM id suffix.
settings Object Settings for the instance.
Returns:
Type Description
H_ui_completer The created instance.

add_active(elem)

ui.js, line 2484
Highlights a row of the list.
Without argument the row is the one returned by get_active_element(), which is how a subclass keeping an index works.
Name Type Default Description
elem HTMLElement null optional The row to highlight, when the caller has it.

can_open(){boolean}

ui.js, line 2524
Whether the list may be opened: a widget with no row to suggest keeps it closed.
Returns:
Type Description
boolean

clean()

ui.js, line 2565
Cleans up the instance.
Nothing to release here, a subclass overrides when it holds something.

close()

ui.js, line 2544
Closes the suggestion list.
Removes click outside event.

exist(){boolean}

ui.js, line 2557
Checks if the widget input still exists in the DOM.
Returns:
Type Description
boolean True if exists.

get_active_element(){HTMLElement|false}

ui.js, line 2474
The row currently highlighted in the list.
Overridden by a subclass that holds its active row by position rather than by reference.
Returns:
Type Description
HTMLElement | false The active row, false when there is none.

remove_active()

ui.js, line 2494
Removes the highlight from the active row and forgets it.

scroll_to_active()

ui.js, line 2503
Scrolls the list to bring the active row into view when it is out of the list box.

show()

ui.js, line 2532
Shows the suggestion list.
Adds click outside event to close it.

H_ui_completer

new H_ui_completer(dom_id, settings, options)

ui.js, line 2445
Name Type Description
dom_id string dom_id of the widget.
settings Object settings of the widget, only name is read here.
options Object prefix, list_suffix, active_class and clear_active_on_close.

Members

instances

All instances of one widget, by dom_id. Each subclass owns its own registry.

Methods

staticH_ui_completer.clean_instances()

ui.js, line 2591
Cleans up all instances that no longer exist.

staticH_ui_completer.create_instance(dom_id, settings){H_ui_completer}

ui.js, line 2576
Creates a new instance of the widget for a given dom_id.
Cleans up any existing instance for the same dom_id, then the instances that left the DOM.
Name Type Description
dom_id string The DOM id suffix.
settings Object Settings for the instance.
Returns:
Type Description
H_ui_completer The created instance.

add_active(elem)

ui.js, line 2484
Highlights a row of the list.
Without argument the row is the one returned by get_active_element(), which is how a subclass keeping an index works.
Name Type Default Description
elem HTMLElement null optional The row to highlight, when the caller has it.

can_open(){boolean}

ui.js, line 2524
Whether the list may be opened: a widget with no row to suggest keeps it closed.
Returns:
Type Description
boolean

clean()

ui.js, line 2565
Cleans up the instance.
Nothing to release here, a subclass overrides when it holds something.

close()

ui.js, line 2544
Closes the suggestion list.
Removes click outside event.

exist(){boolean}

ui.js, line 2557
Checks if the widget input still exists in the DOM.
Returns:
Type Description
boolean True if exists.

get_active_element(){HTMLElement|false}

ui.js, line 2474
The row currently highlighted in the list.
Overridden by a subclass that holds its active row by position rather than by reference.
Returns:
Type Description
HTMLElement | false The active row, false when there is none.

remove_active()

ui.js, line 2494
Removes the highlight from the active row and forgets it.

scroll_to_active()

ui.js, line 2503
Scrolls the list to bring the active row into view when it is out of the list box.

show()

ui.js, line 2532
Shows the suggestion list.
Adds click outside event to close it.