Added 'hint_gravity' attribute to toolbar actions
authorThierry Florac <thierry.florac@onf.fr>
Mon, 11 Sep 2017 12:30:02 +0200
changeset 197 1094ad8e3e1b
parent 196 1ec15633d058
child 198 64511592fb27
Added 'hint_gravity' attribute to toolbar actions
src/pyams_skin/interfaces/viewlet.py
src/pyams_skin/viewlet/toolbar/__init__.py
src/pyams_skin/viewlet/toolbar/toolbar-item.pt
--- a/src/pyams_skin/interfaces/viewlet.py	Thu Jul 13 12:48:37 2017 +0200
+++ b/src/pyams_skin/interfaces/viewlet.py	Mon Sep 11 12:30:02 2017 +0200
@@ -353,6 +353,9 @@
     css_class = TextLine(title="Menu CSS class",
                          default='')
 
+    hint_gravity = TextLine(title="Hint gravity",
+                            default='sw')
+
     stop_propagation = Bool(title="Stop click event propagation",
                             required=True,
                             default=False)
--- a/src/pyams_skin/viewlet/toolbar/__init__.py	Thu Jul 13 12:48:37 2017 +0200
+++ b/src/pyams_skin/viewlet/toolbar/__init__.py	Mon Sep 11 12:30:02 2017 +0200
@@ -118,6 +118,7 @@
 
     label = FieldProperty(IToolbarMenuItem['label'])
     label_css_class = FieldProperty(IToolbarMenuItem['label_css_class'])
+    hint_gravity = FieldProperty(IToolbarActionItem['hint_gravity'])
     css_class = FieldProperty(IToolbarMenuItem['css_class'])
     click_handler = FieldProperty(IToolbarMenuItem['click_handler'])
     url = FieldProperty(IToolbarMenuItem['url'])
@@ -128,6 +129,13 @@
         return absolute_url(self.context, self.request, self.url)
 
 
+class JsToolbarActionItem(ToolbarActionItem):
+    """Javascript call toolbar action item"""
+
+    def get_url(self):
+        return self.url
+
+
 @template_config(template='menu-item.pt', layer=IPyAMSLayer)
 @implementer(IToolbarMenuItem)
 class ToolbarMenuItem(ToolbarActionItem):
--- a/src/pyams_skin/viewlet/toolbar/toolbar-item.pt	Thu Jul 13 12:48:37 2017 +0200
+++ b/src/pyams_skin/viewlet/toolbar/toolbar-item.pt	Mon Sep 11 12:30:02 2017 +0200
@@ -5,6 +5,8 @@
 				   data-ams-stop-propagation 'true' if view.stop_propagation else None;
 				   data-toggle 'modal' if view.modal_target else None;">
 	<i tal:attributes="class string:${view.label_css_class} hint opaque align-base;
+					   data-ams-hint-gravity view.hint_gravity;
+					   data-ams-hint-html 'true' if view.label.startswith('<') else 'false';
 					   title view.label"
 	   i18n:attributes="title"
 	   data-ams-hint-offset="5"></i>