changeset 2383:a37457da2bb7

tools (common/data_objects): new OnClick class OnClick is used to specify what do to when clicking on element. For now it only handles target URL.
author Goffi <goffi@goffi.org>
date Mon, 16 Oct 2017 07:41:36 +0200
parents a49a19f06e38
children d14c1a3e3244
files src/tools/common/data_objects.py
diffstat 1 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/tools/common/data_objects.py	Mon Oct 16 07:39:54 2017 +0200
+++ b/src/tools/common/data_objects.py	Mon Oct 16 07:41:36 2017 +0200
@@ -195,3 +195,17 @@
 
     def __contains__(self, jid_str):
         return jid_str in self.identities
+
+
+class OnClick(object):
+    """Class to handle clickable elements targets"""
+
+    def __init__(self, url=None):
+        self.url = url
+
+    def formatUrl(self, item):
+        """Use an item to format URL
+
+        item will be formatted using "item=item" in format()
+        """
+        return self.url.format(item=item)