Class: H_ui_window

H_ui_window

UI class for modal windows and dialogs.
Handles modal logic, alignment, content, and close behavior.
Possible settings for H_ui_window:
- title: {string|HTMLElement|Array} Accepts string, DOM element, or array to add a title on top - class: string (additional CSS classes for the modal)
- modal: boolean (show as modal with background mask)
- close: string|boolean (label for the close button, or true for default)
- on_close: function (callback executed when the modal is closed)
- hidden: boolean (start hidden)
- content_resizable: boolean to make the window partialy resizable (it depends its CSS, if there is min-width or min-height set)
- remove_on_close: boolean (remove from DOM when closed)
- nodrag: boolean (disable drag)
- disable_background_click: boolean (disable closing by clicking background and pressing ESC key)
- auto_alignement: boolean (enable auto-alignment on content change)
- special: boolean (special modal, higher z-index)
- special_level: number|string (priority level / css z_index for special modals, or 'err' for error modals with +100 as z_index)
Used as h.libs.ui_window.

new H_ui_window()

ui.js, line 1028

Members

_screen_resize_bound

True once the screen resize listener is bound: every displayed window has to be brought back on screen when the screen shrinks, and one listener is enough for all of them.

close

Sets the close button for the modal window.

current_open_z_indexnumber

Current open z-index for modals.
Adds or removes the modal mask as needed. if the special_level is not an int but 'err' like error, the z_index += 100 !

visible

Gets the visibility state of the modal window.

zindex

Change the zindex for the modal and overlay

Methods

staticH_ui_window.bind_screen_resize()

ui.js, line 1071
Registers the screen resize reaction once, for every window.
A window dragged near an edge would stay out of the screen after a resize. The handler is registered through H_event (add_resize_handler), which fans the window resize out to every handler in order: a direct window.addEventListener here would be a second, unordered listener next to the one H_event already owns.

staticH_ui_window.handle_key_press(evt)

ui.js, line 1616
Handle key event for all the modal, determine wich modal will receive the event. (generally the last opened)
Name Type Description
evt KeyboardEvent

hide(at_start)

ui.js, line 1467
Hides the modal window.
Optionally triggers on_close callback.
Name Type Default Description
at_start boolean false optional If true, hides at start.

mutation(records)

ui.js, line 1276
Mutation observer callback for modal content changes.
Name Type Description
records Array Mutation records.

on_double_click_mask(event)

ui.js, line 1532
Handles double click on the modal mask.
Hides the modal.
Name Type Description
event Event The double click event.

on_key_press(evt)

ui.js, line 1176
Handles key press events for the modal.
Closes modal on ESC key.
Name Type Description
evt KeyboardEvent The keyboard event.

remove()

ui.js, line 1510
Removes the modal window from the DOM.
Cleans up event handlers and observers.

set_alignment(align_vertical, align_horizontal)

ui.js, line 1296
Sets the alignment of the modal window.
The reference frame is the parent node: the page for a window in document.body, the module container for a window living in a module. A container without a box (inactive tab) defers the alignment, see H_ui.realign_windows().
Name Type Description
align_vertical number Vertical alignment.
align_horizontal number Horizontal alignment.

set_content(content)

ui.js, line 1189
Sets the content of the modal window.
Accepts string, DOM element, or array.
Name Type Description
content string | HTMLElement | Array Content to display.

set_parent(parentNode, align_horizontal, align_vertical)

ui.js, line 1240
Sets the parent node for the modal window.
In document.body the mask keeps the fixed positioning of the theme and covers the page. Anywhere else (a module container) the mask is scoped to that container: it is positioned absolutely on it, so the rest of the page - tabs, hierarchy, other modules - stays reachable, and the window is aligned on the container instead of the viewport.
Name Type Description
parentNode HTMLElement Parent node.
align_horizontal number optional Horizontal alignment.
align_vertical number optional Vertical alignment.

set_title(title)

ui.js, line 1212
Sets the title of the modal window if it's set in the settings
Accepts string, DOM element, or array.
Name Type Description
title string | HTMLElement | Array Content to display.

show()

ui.js, line 1486
Shows the modal window.
Makes the modal visible and brings it to front.

toggle()

ui.js, line 1453
Toggles the modal window's visibility.
Shows or hides the modal.

H_ui_window

new H_ui_window(settings)

ui.js, line 1100
Name Type Description
settings Object Window's settings
Name Type Description
title String | Array | HTMLElement Add a title on top
class String Additional CSS classes for the modal
modal Boolean Display as modal with background mask
close Boolean | String Label for the close button, or true for default
on_close function | String Callback executed when closed
hidden Boolean Hide it on create
content_resizable Boolean Make the window partialy resizable. Depends its CSS, if there is min-width or min-height set
remove_on_close Boolean Remove from DOM when closed
nodrag Boolean Disable drag of whole modal
disable_background_click Boolean Disable closing by clicking background and pressing ESC key
auto_alignement Boolean Enable auto-alignment on content change
special Boolean special modal, higher z-index
special_level Number | String Priority level for special modals, or 'err' for error modals

Members

_screen_resize_bound

True once the screen resize listener is bound: every displayed window has to be brought back on screen when the screen shrinks, and one listener is enough for all of them.

close

Sets the close button for the modal window.

current_open_z_indexnumber

Current open z-index for modals.
Adds or removes the modal mask as needed. if the special_level is not an int but 'err' like error, the z_index += 100 !

visible

Gets the visibility state of the modal window.

zindex

Change the zindex for the modal and overlay

Methods

staticH_ui_window.bind_screen_resize()

ui.js, line 1071
Registers the screen resize reaction once, for every window.
A window dragged near an edge would stay out of the screen after a resize. The handler is registered through H_event (add_resize_handler), which fans the window resize out to every handler in order: a direct window.addEventListener here would be a second, unordered listener next to the one H_event already owns.

staticH_ui_window.handle_key_press(evt)

ui.js, line 1616
Handle key event for all the modal, determine wich modal will receive the event. (generally the last opened)
Name Type Description
evt KeyboardEvent

hide(at_start)

ui.js, line 1467
Hides the modal window.
Optionally triggers on_close callback.
Name Type Default Description
at_start boolean false optional If true, hides at start.

mutation(records)

ui.js, line 1276
Mutation observer callback for modal content changes.
Name Type Description
records Array Mutation records.

on_double_click_mask(event)

ui.js, line 1532
Handles double click on the modal mask.
Hides the modal.
Name Type Description
event Event The double click event.

on_key_press(evt)

ui.js, line 1176
Handles key press events for the modal.
Closes modal on ESC key.
Name Type Description
evt KeyboardEvent The keyboard event.

remove()

ui.js, line 1510
Removes the modal window from the DOM.
Cleans up event handlers and observers.

set_alignment(align_vertical, align_horizontal)

ui.js, line 1296
Sets the alignment of the modal window.
The reference frame is the parent node: the page for a window in document.body, the module container for a window living in a module. A container without a box (inactive tab) defers the alignment, see H_ui.realign_windows().
Name Type Description
align_vertical number Vertical alignment.
align_horizontal number Horizontal alignment.

set_content(content)

ui.js, line 1189
Sets the content of the modal window.
Accepts string, DOM element, or array.
Name Type Description
content string | HTMLElement | Array Content to display.

set_parent(parentNode, align_horizontal, align_vertical)

ui.js, line 1240
Sets the parent node for the modal window.
In document.body the mask keeps the fixed positioning of the theme and covers the page. Anywhere else (a module container) the mask is scoped to that container: it is positioned absolutely on it, so the rest of the page - tabs, hierarchy, other modules - stays reachable, and the window is aligned on the container instead of the viewport.
Name Type Description
parentNode HTMLElement Parent node.
align_horizontal number optional Horizontal alignment.
align_vertical number optional Vertical alignment.

set_title(title)

ui.js, line 1212
Sets the title of the modal window if it's set in the settings
Accepts string, DOM element, or array.
Name Type Description
title string | HTMLElement | Array Content to display.

show()

ui.js, line 1486
Shows the modal window.
Makes the modal visible and brings it to front.

toggle()

ui.js, line 1453
Toggles the modal window's visibility.
Shows or hides the modal.