annotate libervia/web/pages/_browser/tools.py @ 1624:fd421f1be8f5 default tip

browser (blog): blog redesign first draft: Redesign the blog in the same spirit as the chat, with a left panel to search/open new blogs, so there is no "selection" page anymore. Reactions are now managed.
author Goffi <goffi@goffi.org>
date Wed, 21 May 2025 15:58:56 +0200
parents 3a60bf3762ef
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1574
4ab4bc3ae462 browser: new `tools` module with a first method to detect touch devices
Goffi <goffi@goffi.org>
parents:
diff changeset
1 """Common useful tools"""
4ab4bc3ae462 browser: new `tools` module with a first method to detect touch devices
Goffi <goffi@goffi.org>
parents:
diff changeset
2 from browser import window
4ab4bc3ae462 browser: new `tools` module with a first method to detect touch devices
Goffi <goffi@goffi.org>
parents:
diff changeset
3
4ab4bc3ae462 browser: new `tools` module with a first method to detect touch devices
Goffi <goffi@goffi.org>
parents:
diff changeset
4
4ab4bc3ae462 browser: new `tools` module with a first method to detect touch devices
Goffi <goffi@goffi.org>
parents:
diff changeset
5 def is_touch_device():
4ab4bc3ae462 browser: new `tools` module with a first method to detect touch devices
Goffi <goffi@goffi.org>
parents:
diff changeset
6 return hasattr(window, 'ontouchstart')
1620
3a60bf3762ef browser: threads and replies implementation:
Goffi <goffi@goffi.org>
parents: 1574
diff changeset
7
3a60bf3762ef browser: threads and replies implementation:
Goffi <goffi@goffi.org>
parents: 1574
diff changeset
8
3a60bf3762ef browser: threads and replies implementation:
Goffi <goffi@goffi.org>
parents: 1574
diff changeset
9
3a60bf3762ef browser: threads and replies implementation:
Goffi <goffi@goffi.org>
parents: 1574
diff changeset
10 def remove_ids(element):
3a60bf3762ef browser: threads and replies implementation:
Goffi <goffi@goffi.org>
parents: 1574
diff changeset
11 """Recursively remove "id" attribute of element and all its descendants."""
3a60bf3762ef browser: threads and replies implementation:
Goffi <goffi@goffi.org>
parents: 1574
diff changeset
12 element.removeAttribute('id')
3a60bf3762ef browser: threads and replies implementation:
Goffi <goffi@goffi.org>
parents: 1574
diff changeset
13
3a60bf3762ef browser: threads and replies implementation:
Goffi <goffi@goffi.org>
parents: 1574
diff changeset
14 for child in element.children:
3a60bf3762ef browser: threads and replies implementation:
Goffi <goffi@goffi.org>
parents: 1574
diff changeset
15 remove_ids(child)