Mercurial > libervia-web
comparison libervia/web/pages/_browser/tools.py @ 1625:698eaabfca0e
browser (chat): side/panel and keyword handling:
- `dialog.Modal` can now be used with a `position` argument. The default `center` keeps
the old behaviour of modal in the middle of the screen, while using one of the
direction makes the modal appear from top/bottom/right/left with an animation. The
closing cross has been removed in favor of clicking/touching any part outside of the
modal.
- A method to create mockup clones of elements is now used to make placeholders. It is
used for the input panel in the main area when it is moved to a sub-panel modal, this
way there is not element disappearing.
- Clicking on a keyword now shows a sub-messages panel with all messages with this
keyword, in a similar way as for threads. Writing a messages there will add the keyword
automatically.
- Sub-messages panel will auto-scroll when messages are added.
rel 458
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 06 Jun 2025 11:08:05 +0200 |
parents | 3a60bf3762ef |
children |
comparison
equal
deleted
inserted
replaced
1624:fd421f1be8f5 | 1625:698eaabfca0e |
---|---|
1 """Common useful tools""" | 1 """Common useful tools""" |
2 from browser import window | 2 from browser import window, html |
3 | 3 |
4 | 4 |
5 def is_touch_device(): | 5 def is_touch_device(): |
6 return hasattr(window, 'ontouchstart') | 6 return hasattr(window, 'ontouchstart') |
7 | |
8 | 7 |
9 | 8 |
10 def remove_ids(element): | 9 def remove_ids(element): |
11 """Recursively remove "id" attribute of element and all its descendants.""" | 10 """Recursively remove "id" attribute of element and all its descendants.""" |
12 element.removeAttribute('id') | 11 element.removeAttribute('id') |
13 | 12 |
14 for child in element.children: | 13 for child in element.children: |
15 remove_ids(child) | 14 remove_ids(child) |
15 | |
16 | |
17 def make_placeholder(original_elt, placeholder_class="visual-placeholder"): | |
18 """Create a visual placeholder that matches an element's appearance. | |
19 | |
20 The placeholder will be a clone of the original element but without any ID attributes | |
21 to prevent DOM conflicts. | |
22 | |
23 @param original_elt: Element to create placeholder for. | |
24 @param placeholder_class: CSS class to add to placeholder element. | |
25 @return: Placeholder element. | |
26 """ | |
27 placeholder = original_elt.cloneNode(True) | |
28 remove_ids(placeholder) | |
29 placeholder.classList.add(placeholder_class) | |
30 placeholder.attrs["aria-hidden"] = "true" | |
31 placeholder.attrs["data-placeholder-for"] = original_elt.id or "" | |
32 return placeholder |