src/pyams_content/shared/imagemap/paragraph.py
changeset 147 298fd55f6554
child 269 8af313b5b590
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/shared/imagemap/paragraph.py	Tue Sep 12 16:40:44 2017 +0200
@@ -0,0 +1,50 @@
+#
+# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+
+# import standard library
+
+# import interfaces
+from pyams_content.component.paragraph.interfaces import IParagraphFactory
+from pyams_content.shared.imagemap.interfaces import IImageMapParagraph
+
+# import packages
+from pyams_content.component.paragraph import BaseParagraph
+from pyams_sequence.utility import get_reference_target
+from pyams_utils.registry import utility_config
+from zope.interface import implementer
+from zope.schema.fieldproperty import FieldProperty
+
+from pyams_content import _
+
+
+@implementer(IImageMapParagraph)
+class ImageMapParagraph(BaseParagraph):
+    """Image map paragraph"""
+
+    icon_class = 'fa-location-arrow'
+    icon_hint = _("Image map")
+
+    reference = FieldProperty(IImageMapParagraph['reference'])
+
+    def get_target(self, state=None):
+        return get_reference_target(self.reference, state)
+
+
+@utility_config(name='ImageMap', provides=IParagraphFactory)
+class ImageMapParagraphFactory(object):
+    """Image map paragraph factory"""
+
+    name = _("Image map")
+    content_type = ImageMapParagraph