From 5407bd1611900b53049a61698424365d415e6ef8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Sat, 9 Dec 2023 08:51:25 +0100 Subject: [PATCH] configured_plots: detect mobile and disable panning tool by default --- app/plot_app/configured_plots.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/plot_app/configured_plots.py b/app/plot_app/configured_plots.py index be8854b30..f3b2deaf0 100644 --- a/app/plot_app/configured_plots.py +++ b/app/plot_app/configured_plots.py @@ -1,5 +1,6 @@ """ This contains the list of all drawn plots on the log plotting page """ +import re from html import escape from bokeh.layouts import column @@ -1009,6 +1010,12 @@ def param_changes_button_clicked(): param_changes_button.on_click(param_changes_button_clicked) + user_agent = curdoc().session_context.request.headers.get("User-Agent", "") + is_mobile = re.search(r'Mobile|iP(hone|od|ad)|Android|BlackBerry|' + r'IEMobile|Kindle|NetFront|Silk-Accelerated|(hpw|web)OS|Fennec|' + r'Minimo|Opera M(obi|ini)|Blazer|Dolfin|' + r'Dolphin|Skyfire|Zune', user_agent) + jinja_plot_data = [] for i in range(len(plots)): if plots[i] is None: @@ -1027,6 +1034,9 @@ def param_changes_button_clicked(): 'fragment': fragment, 'title': plot_title }) + if is_mobile is not None and hasattr(plots[i], 'toolbar'): + # Disable panning on mobile by default + plots[i].toolbar.active_drag = None # changed parameters