Added "anchor" attribute to paragraphs
authorThierry Florac <thierry.florac@onf.fr>
Fri, 13 Jul 2018 09:23:53 +0200
changeset 844 36af332b6dd0
parent 843 11e06690bc32
child 845 6b039f09a91c
Added "anchor" attribute to paragraphs
src/pyams_content/component/paragraph/__init__.py
src/pyams_content/component/paragraph/interfaces/__init__.py
src/pyams_content/component/paragraph/zmi/audio.py
src/pyams_content/component/paragraph/zmi/contact.py
src/pyams_content/component/paragraph/zmi/container.py
src/pyams_content/component/paragraph/zmi/frame.py
src/pyams_content/component/paragraph/zmi/header.py
src/pyams_content/component/paragraph/zmi/html.py
src/pyams_content/component/paragraph/zmi/keypoint.py
src/pyams_content/component/paragraph/zmi/milestone.py
src/pyams_content/component/paragraph/zmi/pictogram.py
src/pyams_content/component/paragraph/zmi/verbatim.py
src/pyams_content/component/paragraph/zmi/video.py
src/pyams_content/skin/resources/js/pyams_content.js
src/pyams_content/skin/resources/js/pyams_content.min.js
--- a/src/pyams_content/component/paragraph/__init__.py	Fri Jul 13 08:51:55 2018 +0200
+++ b/src/pyams_content/component/paragraph/__init__.py	Fri Jul 13 09:23:53 2018 +0200
@@ -82,6 +82,7 @@
     icon_hint = ''
 
     visible = FieldProperty(IBaseParagraph['visible'])
+    anchor = FieldProperty(IBaseParagraph['anchor'])
     title = FieldProperty(IBaseParagraph['title'])
 
     empty_title = ' -' * 8
--- a/src/pyams_content/component/paragraph/interfaces/__init__.py	Fri Jul 13 08:51:55 2018 +0200
+++ b/src/pyams_content/component/paragraph/interfaces/__init__.py	Fri Jul 13 09:23:53 2018 +0200
@@ -46,10 +46,18 @@
                    required=True,
                    default=True)
 
+    anchor = Bool(title=_("Anchor?"),
+                  description=_("Is this paragraph a navigation anchor?"),
+                  required=True,
+                  default=False)
+
     title = I18nTextLineField(title=_("§ Title"),
                               required=False)
 
 
+PARAGRAPH_HIDDEN_FIELDS = ('__parent__', '__name__', 'visible', 'anchor')
+
+
 class IParagraphContainer(IOrderedContainer):
     """Paragraphs container"""
 
--- a/src/pyams_content/component/paragraph/zmi/audio.py	Fri Jul 13 08:51:55 2018 +0200
+++ b/src/pyams_content/component/paragraph/zmi/audio.py	Fri Jul 13 09:23:53 2018 +0200
@@ -17,7 +17,8 @@
 
 # import interfaces
 from pyams_content.component.association.zmi.interfaces import IAssociationsParentForm
-from pyams_content.component.paragraph.interfaces import IParagraphContainerTarget, IParagraphContainer
+from pyams_content.component.paragraph.interfaces import IParagraphContainerTarget, IParagraphContainer, \
+    PARAGRAPH_HIDDEN_FIELDS
 from pyams_content.component.paragraph.interfaces.audio import IAudioParagraph, AUDIO_PARAGRAPH_TYPE
 from pyams_content.component.paragraph.zmi.interfaces import IParagraphInnerEditor, IParagraphContainerView
 from pyams_content.interfaces import MANAGE_CONTENT_PERMISSION
@@ -67,7 +68,7 @@
     dialog_class = 'modal-large'
     icon_css_class = 'fa fa-fw fa-volume-up'
 
-    fields = field.Fields(IAudioParagraph).omit('__parent__', '__name__', 'visible')
+    fields = field.Fields(IAudioParagraph).omit(*PARAGRAPH_HIDDEN_FIELDS)
     edit_permission = MANAGE_CONTENT_PERMISSION
 
     def create(self, data):
@@ -89,7 +90,7 @@
     dialog_class = 'modal-large'
     icon_css_class = 'fa fa-fw fa-volume-up'
 
-    fields = field.Fields(IAudioParagraph).omit('__parent__', '__name__', 'visible')
+    fields = field.Fields(IAudioParagraph).omit(*PARAGRAPH_HIDDEN_FIELDS)
     fields['renderer'].widgetFactory = RendererFieldWidget
 
     edit_permission = MANAGE_CONTENT_PERMISSION
--- a/src/pyams_content/component/paragraph/zmi/contact.py	Fri Jul 13 08:51:55 2018 +0200
+++ b/src/pyams_content/component/paragraph/zmi/contact.py	Fri Jul 13 09:23:53 2018 +0200
@@ -17,7 +17,7 @@
 
 # import interfaces
 from pyams_content.component.paragraph.interfaces import IParagraphContainerTarget, IParagraphContainer, \
-    IBaseParagraph
+    IBaseParagraph, PARAGRAPH_HIDDEN_FIELDS
 from pyams_content.component.paragraph.interfaces.contact import CONTACT_PARAGRAPH_TYPE, IContactParagraph
 from pyams_content.component.paragraph.zmi.interfaces import IParagraphContainerView, IParagraphInnerEditor
 from pyams_content.interfaces import MANAGE_CONTENT_PERMISSION
@@ -67,7 +67,7 @@
     dialog_class = 'modal-large'
     icon_css_class = 'fa fa-fw fa-id-card-o'
 
-    fields = field.Fields(IContactParagraph).omit('__parent__', '__name__', 'visible')
+    fields = field.Fields(IContactParagraph).omit(*PARAGRAPH_HIDDEN_FIELDS)
     edit_permission = MANAGE_CONTENT_PERMISSION
 
     def create(self, data):
@@ -89,7 +89,7 @@
     legend = _("Edit contact card properties")
     icon_css_class = 'fa fa-fw fa-id-card-o'
 
-    fields = field.Fields(IContactParagraph).omit('__parent__', '__name__', 'visible')
+    fields = field.Fields(IContactParagraph).omit(*PARAGRAPH_HIDDEN_FIELDS)
     fields['renderer'].widgetFactory = RendererFieldWidget
 
     edit_permission = MANAGE_CONTENT_PERMISSION
--- a/src/pyams_content/component/paragraph/zmi/container.py	Fri Jul 13 08:51:55 2018 +0200
+++ b/src/pyams_content/component/paragraph/zmi/container.py	Fri Jul 13 09:23:53 2018 +0200
@@ -41,7 +41,7 @@
 from pyams_content.skin import pyams_content
 from pyams_form.security import ProtectedFormObjectMixin
 from pyams_pagelet.pagelet import pagelet_config
-from pyams_skin.container import switch_element_visibility
+from pyams_skin.container import switch_element_visibility, switch_element_attribute
 from pyams_skin.page import DefaultPageHeaderAdapter
 from pyams_skin.table import BaseTable, I18nColumn, TrashColumn, SorterColumn, ImageColumn, \
     VisibilitySwitcherColumn
@@ -108,7 +108,8 @@
             'data-ams-post-reload': 'PyAMS_content.paragraphs.postReload',
             'data-ams-tablednd-drag-handle': 'td.sorter',
             'data-ams-tablednd-drop-target': 'set-paragraphs-order.json',
-            'data-ams-visibility-switcher': 'switch-paragraph-visibility.json'
+            'data-ams-visibility-switcher': 'switch-paragraph-visibility.json',
+            'data-ams-anchor-switcher': 'switch-paragraph-anchor.json'
         })
         return attributes
 
@@ -183,12 +184,40 @@
     return column.table.context
 
 
+@adapter_config(name='anchor', context=(IParagraphContainerTarget, IPyAMSLayer, ParagraphContainerBaseTable),
+                provides=IColumn)
+class ParagraphContainerAnchorColumn(ProtectedFormObjectMixin, VisibilitySwitcherColumn):
+    """Paragraphs container anchor switcher column"""
+
+    switch_attribute = 'anchor'
+    visible_icon_class = 'fa fa-fw fa-anchor'
+    hidden_icon_class = 'fa fa-fw fa-anchor txt-color-silver opacity-50'
+
+    icon_hint = _("Set navigation anchor")
+
+    url = 'PyAMS_content.paragraphs.switchAnchor'
+    weight = 6
+
+
+@view_config(name='switch-paragraph-anchor.json', context=IParagraphContainer, request_type=IPyAMSLayer,
+             permission=MANAGE_CONTENT_PERMISSION, renderer='json', xhr=True)
+def switch_paragraph_anchor(request):
+    """Switch paragraph anchor"""
+    return switch_element_attribute(request, IParagraphContainer, attribute_name='anchor')
+
+
+@adapter_config(context=ParagraphContainerAnchorColumn, provides=IFormSecurityContext)
+def anchor_column_security_context_factory(column):
+    """Anchor column security context factory"""
+    return column.table.context
+
+
 @adapter_config(name='pictogram', context=(IParagraphContainerTarget, IPyAMSLayer, ParagraphContainerBaseTable),
                 provides=IColumn)
 class ParagraphContainerPictogramColumn(ImageColumn):
     """Paragraph container pictogram column"""
 
-    weight = 6
+    weight = 8
 
     def get_icon_class(self, item):
         return item.icon_class
--- a/src/pyams_content/component/paragraph/zmi/frame.py	Fri Jul 13 08:51:55 2018 +0200
+++ b/src/pyams_content/component/paragraph/zmi/frame.py	Fri Jul 13 09:23:53 2018 +0200
@@ -18,7 +18,8 @@
 # import interfaces
 from pyams_content.component.association.interfaces import IAssociationContainerTarget
 from pyams_content.component.association.zmi.interfaces import IAssociationsParentForm
-from pyams_content.component.paragraph.interfaces import IParagraphContainerTarget, IParagraphContainer
+from pyams_content.component.paragraph.interfaces import IParagraphContainerTarget, IParagraphContainer, \
+    PARAGRAPH_HIDDEN_FIELDS
 from pyams_content.component.paragraph.interfaces.frame import IFrameParagraph, FRAME_PARAGRAPH_TYPE
 from pyams_content.component.paragraph.zmi.interfaces import IParagraphInnerEditor, IParagraphContainerView
 from pyams_content.interfaces import MANAGE_CONTENT_PERMISSION
@@ -101,7 +102,7 @@
     label_css_class = 'control-label col-md-2'
     input_css_class = 'col-md-10'
 
-    fields = field.Fields(IFrameParagraph).omit('__parent__', '__name__', 'visible')
+    fields = field.Fields(IFrameParagraph).omit(*PARAGRAPH_HIDDEN_FIELDS)
     edit_permission = MANAGE_CONTENT_PERMISSION
 
     def create(self, data):
@@ -127,7 +128,7 @@
     label_css_class = 'control-label col-md-2'
     input_css_class = 'col-md-10'
 
-    fields = field.Fields(IFrameParagraph).omit('__parent__', '__name__', 'visible')
+    fields = field.Fields(IFrameParagraph).omit(*PARAGRAPH_HIDDEN_FIELDS)
     fields['renderer'].widgetFactory = RendererFieldWidget
 
     edit_permission = MANAGE_CONTENT_PERMISSION
--- a/src/pyams_content/component/paragraph/zmi/header.py	Fri Jul 13 08:51:55 2018 +0200
+++ b/src/pyams_content/component/paragraph/zmi/header.py	Fri Jul 13 09:23:53 2018 +0200
@@ -69,7 +69,7 @@
     def updateWidgets(self, prefix=None):
         super(HeaderParagraphAddForm, self).updateWidgets(prefix)
         if 'header' in self.widgets:
-            self.widgets['header'].widget_css_class = 'textarea height-100'
+            self.widgets['header'].widget_css_class = 'input height-100'
 
     def create(self, data):
         return HeaderParagraph()
@@ -98,7 +98,7 @@
     def updateWidgets(self, prefix=None):
         super(HeaderParagraphPropertiesEditForm, self).updateWidgets(prefix)
         if 'header' in self.widgets:
-            self.widgets['header'].widget_css_class = 'textarea height-100'
+            self.widgets['header'].widget_css_class = 'input height-100'
 
     def get_ajax_output(self, changes):
         output = super(self.__class__, self).get_ajax_output(changes)
--- a/src/pyams_content/component/paragraph/zmi/html.py	Fri Jul 13 08:51:55 2018 +0200
+++ b/src/pyams_content/component/paragraph/zmi/html.py	Fri Jul 13 09:23:53 2018 +0200
@@ -19,7 +19,7 @@
 from pyams_content.component.association.interfaces import IAssociationContainerTarget
 from pyams_content.component.association.zmi.interfaces import IAssociationsParentForm
 from pyams_content.component.paragraph.interfaces import IParagraphContainerTarget, IParagraphFactorySettings, \
-    IParagraphContainer
+    IParagraphContainer, PARAGRAPH_HIDDEN_FIELDS
 from pyams_content.component.paragraph.interfaces.html import IHTMLParagraph, IRawParagraph, RAW_PARAGRAPH_TYPE, \
     HTML_PARAGRAPH_TYPE
 from pyams_content.component.paragraph.zmi.interfaces import IParagraphInnerEditor, IParagraphContainerView
@@ -92,13 +92,13 @@
     label_css_class = 'control-label col-md-2'
     input_css_class = 'col-md-10'
 
-    fields = field.Fields(IRawParagraph).omit('__parent__', '__name__', 'visible')
+    fields = field.Fields(IRawParagraph).omit(*PARAGRAPH_HIDDEN_FIELDS)
     edit_permission = MANAGE_CONTENT_PERMISSION
 
     def updateWidgets(self, prefix=None):
         super(RawParagraphAddForm, self).updateWidgets(prefix)
         if 'body' in self.widgets:
-            self.widgets['body'].widget_css_class = 'textarea height-100'
+            self.widgets['body'].widget_css_class = 'input height-100'
 
     def create(self, data):
         return RawParagraph()
@@ -119,7 +119,7 @@
     legend = _("Edit raw HTML paragraph properties")
     icon_css_class = 'fa fa-fw fa-code'
 
-    fields = field.Fields(IRawParagraph).omit('__parent__', '__name__', 'visible')
+    fields = field.Fields(IRawParagraph).omit(*PARAGRAPH_HIDDEN_FIELDS)
     fields['renderer'].widgetFactory = RendererFieldWidget
 
     edit_permission = MANAGE_CONTENT_PERMISSION
@@ -127,7 +127,7 @@
     def updateWidgets(self, prefix=None):
         super(RawParagraphPropertiesEditForm, self).updateWidgets(prefix)
         if 'body' in self.widgets:
-            self.widgets['body'].widget_css_class = 'textarea height-100'
+            self.widgets['body'].widget_css_class = 'input height-100'
 
 
 @adapter_config(context=(IRawParagraph, IPyAMSLayer), provides=IParagraphInnerEditor)
@@ -175,7 +175,7 @@
     label_css_class = 'control-label col-md-2'
     input_css_class = 'col-md-10'
 
-    fields = field.Fields(IHTMLParagraph).omit('__parent__', '__name__', 'visible')
+    fields = field.Fields(IHTMLParagraph).omit(*PARAGRAPH_HIDDEN_FIELDS)
     edit_permission = MANAGE_CONTENT_PERMISSION
 
     def create(self, data):
@@ -200,7 +200,7 @@
     label_css_class = 'control-label col-md-2'
     input_css_class = 'col-md-10'
 
-    fields = field.Fields(IHTMLParagraph).omit('__parent__', '__name__', 'visible')
+    fields = field.Fields(IHTMLParagraph).omit(*PARAGRAPH_HIDDEN_FIELDS)
     fields['renderer'].widgetFactory = RendererFieldWidget
 
     edit_permission = MANAGE_CONTENT_PERMISSION
--- a/src/pyams_content/component/paragraph/zmi/keypoint.py	Fri Jul 13 08:51:55 2018 +0200
+++ b/src/pyams_content/component/paragraph/zmi/keypoint.py	Fri Jul 13 09:23:53 2018 +0200
@@ -16,7 +16,8 @@
 # import standard library
 
 # import interfaces
-from pyams_content.component.paragraph.interfaces import IParagraphContainerTarget, IParagraphContainer
+from pyams_content.component.paragraph.interfaces import IParagraphContainerTarget, IParagraphContainer, \
+    PARAGRAPH_HIDDEN_FIELDS
 from pyams_content.component.paragraph.interfaces.keypoint import IKeypointsParagraph, KEYPOINTS_PARAGRAPH_TYPE
 from pyams_content.component.paragraph.zmi.interfaces import IParagraphInnerEditor, IParagraphContainerView
 from pyams_content.interfaces import MANAGE_CONTENT_PERMISSION
@@ -64,13 +65,13 @@
     legend = _("Add new key points paragraph")
     icon_css_class = 'fa fa-fw fa-list-ol'
 
-    fields = field.Fields(IKeypointsParagraph).omit('__parent__', '__name__', 'visible')
+    fields = field.Fields(IKeypointsParagraph).omit(*PARAGRAPH_HIDDEN_FIELDS)
     edit_permission = MANAGE_CONTENT_PERMISSION
 
     def updateWidgets(self, prefix=None):
         super(KeypointsParagraphAddForm, self).updateWidgets(prefix)
         if 'body' in self.widgets:
-            self.widgets['body'].widget_css_class = 'textarea height-100'
+            self.widgets['body'].widget_css_class = 'input height-100'
 
     def create(self, data):
         return KeypointsParagraph()
@@ -91,7 +92,7 @@
     legend = _("Edit key points paragraph properties")
     icon_css_class = 'fa fa-fw fa-list-ol'
 
-    fields = field.Fields(IKeypointsParagraph).omit('__parent__', '__name__', 'visible')
+    fields = field.Fields(IKeypointsParagraph).omit(*PARAGRAPH_HIDDEN_FIELDS)
     fields['renderer'].widgetFactory = RendererFieldWidget
 
     edit_permission = MANAGE_CONTENT_PERMISSION
@@ -99,7 +100,7 @@
     def updateWidgets(self, prefix=None):
         super(KeypointsParagraphPropertiesEditForm, self).updateWidgets(prefix)
         if 'body' in self.widgets:
-            self.widgets['body'].widget_css_class = 'textarea height-100'
+            self.widgets['body'].widget_css_class = 'input height-100'
 
 
 @adapter_config(context=(IKeypointsParagraph, IPyAMSLayer), provides=IParagraphInnerEditor)
--- a/src/pyams_content/component/paragraph/zmi/milestone.py	Fri Jul 13 08:51:55 2018 +0200
+++ b/src/pyams_content/component/paragraph/zmi/milestone.py	Fri Jul 13 09:23:53 2018 +0200
@@ -17,7 +17,8 @@
 import json
 
 # import interfaces
-from pyams_content.component.paragraph.interfaces import IParagraphContainerTarget, IParagraphContainer
+from pyams_content.component.paragraph.interfaces import IParagraphContainerTarget, IParagraphContainer, \
+    PARAGRAPH_HIDDEN_FIELDS
 from pyams_content.component.paragraph.interfaces.milestone import MILESTONE_PARAGRAPH_TYPE, IMilestoneParagraph, \
     IMilestoneContainer, IMilestoneContainerTarget, IMilestone
 from pyams_content.component.paragraph.zmi import IParagraphContainerView, IParagraphEditFormButtons
@@ -312,7 +313,7 @@
     legend = _("Add new milestone")
     icon_css_class = 'fa fa-fw fa-arrow-h'
 
-    fields = field.Fields(IMilestone).omit('__parent__', '__name__', 'visible')
+    fields = field.Fields(IMilestone).omit(*PARAGRAPH_HIDDEN_FIELDS)
     edit_permission = MANAGE_CONTENT_PERMISSION
 
     def create(self, data):
@@ -339,7 +340,7 @@
     legend = _("Edit milestone properties")
     icon_css_class = 'fa fa-fw fa-arrows-h'
 
-    fields = field.Fields(IMilestone).omit('__parent__', '__name__', 'visible')
+    fields = field.Fields(IMilestone).omit(*PARAGRAPH_HIDDEN_FIELDS)
     edit_permission = MANAGE_CONTENT_PERMISSION
 
     def get_ajax_output(self, changes):
--- a/src/pyams_content/component/paragraph/zmi/pictogram.py	Fri Jul 13 08:51:55 2018 +0200
+++ b/src/pyams_content/component/paragraph/zmi/pictogram.py	Fri Jul 13 09:23:53 2018 +0200
@@ -17,7 +17,8 @@
 import json
 
 # import interfaces
-from pyams_content.component.paragraph.interfaces import IParagraphContainerTarget, IParagraphContainer
+from pyams_content.component.paragraph.interfaces import IParagraphContainerTarget, IParagraphContainer, \
+    PARAGRAPH_HIDDEN_FIELDS
 from pyams_content.component.paragraph.interfaces.pictogram import PICTOGRAM_PARAGRAPH_TYPE, IPictogramParagraph, \
     IPictogramContainer, IPictogramContainerTarget, IPictogramItem
 from pyams_content.component.paragraph.zmi import IParagraphContainerView, IParagraphEditFormButtons
@@ -317,7 +318,7 @@
     legend = _("Add new pictogram")
     icon_css_class = 'fa fa-fw fa-arrow-h'
 
-    fields = field.Fields(IPictogramItem).omit('__parent__', '__name__', 'visible')
+    fields = field.Fields(IPictogramItem).omit(*PARAGRAPH_HIDDEN_FIELDS)
     fields['pictogram_name'].widgetFactory = PictogramSelectFieldWidget
 
     edit_permission = MANAGE_CONTENT_PERMISSION
@@ -325,7 +326,7 @@
     def updateWidgets(self, prefix=None):
         super(PictogramAddForm, self).updateWidgets(prefix)
         if 'body' in self.widgets:
-            self.widgets['body'].widget_css_class = 'textarea height-100'
+            self.widgets['body'].widget_css_class = 'input height-100'
 
     def create(self, data):
         return PictogramItem()
@@ -359,7 +360,7 @@
     legend = _("Edit pictogram properties")
     icon_css_class = 'fa fa-fw fa-linode'
 
-    fields = field.Fields(IPictogramItem).omit('__parent__', '__name__', 'visible')
+    fields = field.Fields(IPictogramItem).omit(*PARAGRAPH_HIDDEN_FIELDS)
     fields['pictogram_name'].widgetFactory = PictogramSelectFieldWidget
 
     edit_permission = MANAGE_CONTENT_PERMISSION
@@ -367,7 +368,7 @@
     def updateWidgets(self, prefix=None):
         super(PictogramPropertiesEditForm, self).updateWidgets(prefix)
         if 'body' in self.widgets:
-            self.widgets['body'].widget_css_class = 'textarea height-100'
+            self.widgets['body'].widget_css_class = 'input height-100'
 
     def get_ajax_output(self, changes):
         output = super(self.__class__, self).get_ajax_output(changes)
--- a/src/pyams_content/component/paragraph/zmi/verbatim.py	Fri Jul 13 08:51:55 2018 +0200
+++ b/src/pyams_content/component/paragraph/zmi/verbatim.py	Fri Jul 13 09:23:53 2018 +0200
@@ -17,7 +17,8 @@
 
 # import interfaces
 from pyams_content.component.association.zmi.interfaces import IAssociationsParentForm
-from pyams_content.component.paragraph.interfaces import IParagraphContainerTarget, IParagraphContainer
+from pyams_content.component.paragraph.interfaces import IParagraphContainerTarget, IParagraphContainer, \
+    PARAGRAPH_HIDDEN_FIELDS
 from pyams_content.component.paragraph.interfaces.verbatim import IVerbatimParagraph, VERBATIM_PARAGRAPH_TYPE
 from pyams_content.component.paragraph.zmi.interfaces import IParagraphInnerEditor, IParagraphContainerView
 from pyams_content.interfaces import MANAGE_CONTENT_PERMISSION
@@ -69,7 +70,7 @@
     legend = _("Add new verbatim paragraph")
     icon_css_class = 'fa fa-fw fa-quote-right'
 
-    fields = field.Fields(IVerbatimParagraph).omit('__parent__', '__name__', 'visible')
+    fields = field.Fields(IVerbatimParagraph).omit(*PARAGRAPH_HIDDEN_FIELDS)
     edit_permission = MANAGE_CONTENT_PERMISSION
 
     def create(self, data):
@@ -91,7 +92,7 @@
     legend = _("Edit verbatim paragraph properties")
     icon_css_class = 'fa fa-fw fa-quote-right'
 
-    fields = field.Fields(IVerbatimParagraph).omit('__parent__', '__name__', 'visible')
+    fields = field.Fields(IVerbatimParagraph).omit(*PARAGRAPH_HIDDEN_FIELDS)
     fields['renderer'].widgetFactory = RendererFieldWidget
 
     edit_permission = MANAGE_CONTENT_PERMISSION
--- a/src/pyams_content/component/paragraph/zmi/video.py	Fri Jul 13 08:51:55 2018 +0200
+++ b/src/pyams_content/component/paragraph/zmi/video.py	Fri Jul 13 09:23:53 2018 +0200
@@ -17,7 +17,8 @@
 
 # import interfaces
 from pyams_content.component.association.zmi.interfaces import IAssociationsParentForm
-from pyams_content.component.paragraph.interfaces import IParagraphContainerTarget, IParagraphContainer
+from pyams_content.component.paragraph.interfaces import IParagraphContainerTarget, IParagraphContainer, \
+    PARAGRAPH_HIDDEN_FIELDS
 from pyams_content.component.paragraph.interfaces.video import IVideoParagraph, VIDEO_PARAGRAPH_TYPE
 from pyams_content.component.paragraph.zmi.interfaces import IParagraphInnerEditor, IParagraphContainerView
 from pyams_content.interfaces import MANAGE_CONTENT_PERMISSION
@@ -67,7 +68,7 @@
     dialog_class = 'modal-large'
     icon_css_class = 'fa fa-fw fa-film'
 
-    fields = field.Fields(IVideoParagraph).omit('__parent__', '__name__', 'visible')
+    fields = field.Fields(IVideoParagraph).omit(*PARAGRAPH_HIDDEN_FIELDS)
     edit_permission = MANAGE_CONTENT_PERMISSION
 
     def create(self, data):
@@ -90,7 +91,7 @@
     dialog_class = 'modal-large'
     icon_css_class = 'fa fa-fw fa-film'
 
-    fields = field.Fields(IVideoParagraph).omit('__parent__', '__name__', 'visible')
+    fields = field.Fields(IVideoParagraph).omit(*PARAGRAPH_HIDDEN_FIELDS)
     fields['renderer'].widgetFactory = RendererFieldWidget
 
     edit_permission = MANAGE_CONTENT_PERMISSION
--- a/src/pyams_content/skin/resources/js/pyams_content.js	Fri Jul 13 08:51:55 2018 +0200
+++ b/src/pyams_content/skin/resources/js/pyams_content.js	Fri Jul 13 09:23:53 2018 +0200
@@ -350,6 +350,24 @@
 					MyAMS.initContent(marker);
 				}
 				MyAMS.helpers.sort(toolbar, 'weight');
+			},
+
+			switchAnchor: function() {
+				return function () {
+					var source = $(this);
+					var element = source.parents('tr').first();
+					var container = element.parents('table');
+					MyAMS.ajax.post(container.data('ams-location') + '/' +
+									container.data('ams-anchor-switcher'),
+						{object_name: element.data('ams-element-name')},
+						function (result, status) {
+							if (result.anchor) {
+								$('i', source).attr('class', 'fa fa-fw fa-anchor');
+							} else {
+								$('i', source).attr('class', 'fa fa-fw fa-anchor txt-color-silver opacity-50');
+							}
+						});
+				}
 			}
 		},
 
--- a/src/pyams_content/skin/resources/js/pyams_content.min.js	Fri Jul 13 08:51:55 2018 +0200
+++ b/src/pyams_content/skin/resources/js/pyams_content.min.js	Fri Jul 13 09:23:53 2018 +0200
@@ -1,1 +1,1 @@
-!function(t,e){"use strict";var a=e.MyAMS,i={widget:{treeview:{selectFolder:function(e,a){t(e.target).siblings('input[type="hidden"]').val(a.id)},unselectFolder:function(e,a){t(e.target).siblings('input[type="hidden"]').val(null)}}},TinyMCE:{initEditor:function(t){return tinyMCE.addI18n("fr",{"Link list":"Liste de liens","Toggle h3 header":"En-tête H3","Toggle h4 header":"En-tête H4","Insert internal link":"Insérer un lien interne","Link title":"Texte à afficher","Internal number":"N° interne"}),tinymce.PluginManager.add("internal_links",function(t,e){t.addButton("internal_links",{icon:"cloud-check",tooltip:"Insert internal link",image:"/--static--/pyams_content/img/internal-link.png",onclick:function(){t.windowManager.open({title:"Insert internal link",body:[{type:"textbox",name:"oid",label:"Internal number"},{type:"textbox",name:"title",label:"Link title",value:t.selection.getContent()}],onsubmit:function(e){t.insertContent('<a href="oid://'+e.data.oid+'">'+e.data.title+"</a>")}})}})}),tinyMCE.PluginManager.add("headers",function(t,e){["h3","h4"].forEach(function(e){t.addButton("header-"+e,{tooltip:"Toggle "+e+" header",text:e.toUpperCase(),onClick:function(){t.execCommand("mceToggleFormat",!1,e)},onPostRender:function(){var a=this,i=function(){t.formatter.formatChanged(e,function(t){a.active(t)})};t.formatter?i():t.on("init",i)}})})}),t.image_list=i.TinyMCE.getImagesList,t.link_list=i.TinyMCE.getLinksList,t.style_formats=[{title:"Inline",items:[{title:"Bold",icon:"bold",format:"bold"},{title:"Italic",icon:"italic",format:"italic"},{title:"Underline",icon:"underline",format:"underline"},{title:"Strikethrough",icon:"strikethrough",format:"strikethrough"},{title:"Superscript",icon:"superscript",format:"superscript"},{title:"Subscript",icon:"subscript",format:"subscript"},{title:"Code",icon:"code",format:"code"}]},{title:"Blocks",items:[{title:"Paragraph",format:"p"},{title:"Blockquote",format:"blockquote"},{title:"Div",format:"div"},{title:"Pre",format:"pre"}]},{title:"Alignment",items:[{title:"Left",icon:"alignleft",format:"alignleft"},{title:"Center",icon:"aligncenter",format:"aligncenter"},{title:"Right",icon:"alignright",format:"alignright"},{title:"Justify",icon:"alignjustify",format:"alignjustify"}]}],t.plugins+=" internal_links headers",t.toolbar1&&(t.toolbar1="undo redo | header-h3 header-h4 styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent"),t.toolbar2&&(t.toolbar2="forecolor backcolor | charmap internal_links link | fullscreen preview print | code"),t},getImagesList:function(e){var i=t(document.activeElement).parents("form");if(i.exists()){var n=i.attr("data-ams-form-handler")||i.attr("action"),s=n.substr(0,n.lastIndexOf("/")+1);return a.ajax.post(s+"get-images-list.json",{},e)}},getLinksList:function(e){var i=t(document.activeElement).parents("form");if(i.exists()){var n=i.attr("data-ams-form-handler")||i.attr("action"),s=n.substr(0,n.lastIndexOf("/")+1);return a.ajax.post(s+"get-links-list.json",{},e)}}},galleries:{updateMediaTitle:function(e){t('img[id="'+e.media_id+'"]').attr("original-title",e.title)},switchMediaVisibility:function(e){return function(){var e=t(this),i=e.parents(".media"),n=i.parents(".gallery");a.ajax.post(n.data("ams-location")+"/set-media-visibility.json",{object_name:i.data("ams-element-name")},function(a,i){a.visible?(t("i",e).attr("class","fa fa-fw fa-eye"),e.parents(".btn-group").siblings("a.fancyimg").removeClass("not-visible")):(t("i",e).attr("class","fa fa-fw fa-eye-slash text-danger"),e.parents(".btn-group").siblings("a.fancyimg").addClass("not-visible"))})}},setOrder:function(e,i){if(!i||!i.item.hasClass("already-dropped")){var n=i.item.parents(".gallery"),s=t(".media",n).listattr("data-ams-element-name");a.ajax.post(n.data("ams-location")+"/set-medias-order.json",{medias:JSON.stringify(s)})}},removeMedia:function(e){return function(){var e=t(this);a.skin.bigBox({title:a.i18n.WARNING,content:'<i class="text-danger fa fa-2x fa-bell shake animated"></i>&nbsp; '+a.i18n.DELETE_WARNING,buttons:a.i18n.BTN_OK_CANCEL},function(t){if(t===a.i18n.BTN_OK){var i=e.parents(".gallery").data("ams-location"),n=e.parents(".media"),s=n.data("ams-element-name");a.ajax.post(i+"/delete-element.json",{object_name:s},function(t,e){n.remove()})}})}},afterFancyboxLoad:function(t,e){t.element.hasClass("not-visible")&&t.inner.prepend('<div class="hidden-mask"></div>')}},paragraphs:{preReload:function(){i.paragraphs.switched=t("i.switch.fa-minus-square-o","#paragraphs_list").parents("tr").listattr("id")},postReload:function(){t(i.paragraphs.switched).each(function(){t("i.switch.fa-plus-square-o",'[id="'+this+'"]').parents("div").first().click()}),delete i.paragraphs.switched},refreshParagraph:function(e){var a=t('tr[id="'+e.object_id+'"]');t("span.title",a).html(e.title||" - - - - - - - -")},switchEditor:function(e){var i=t(this),n=t("i.switch",i),s=i.parents("td"),r=t(".editor",s),o=i.parents("tr");if(n.hasClass("fa-plus-square-o")){var l=o.parents("table");r.html('<h1 class="loading"><i class="fa fa-2x fa-gear fa-spin"></i></h1>'),a.ajax.post(l.data("ams-location")+"/get-paragraph-editor.json",{object_name:o.data("ams-element-name")},function(t){r.html(t),t&&(a.initContent(r),n.removeClass("fa-plus-square-o").addClass("fa-minus-square-o"),o.data("ams-disabled-handlers",!0),a.skin.scrollTo(r,{offset:r.height()-o.height()}))})}else a.skin.cleanContainer(r),r.empty(),n.removeClass("fa-minus-square-o").addClass("fa-plus-square-o"),o.removeData("ams-disabled-handlers")},switchLastEditor:function(e){var a=t('table[id="'+e+'"]'),i=t("tr:last",a);t('[data-ams-click-handler="PyAMS_content.paragraphs.switchEditor"]',i).click()},switchAllEditors:function(e){var i=t(this),n=t("i",i),s=i.parents("table");n.hasClass("fa-plus-square-o")?(n.removeClass("fa-plus-square-o").addClass("fa-cog fa-spin"),a.ajax.post(s.data("ams-location")+"/get-paragraphs-editors.json",{},function(e){for(var i in e)if(e.hasOwnProperty(i)){var r=t('tr[data-ams-element-name="'+i+'"]',s),o=t(".editor",r);o.is(":empty")&&o.html(e[i]),t(".fa-plus-square-o",r).removeClass("fa-plus-square-o").addClass("fa-minus-square-o"),r.data("ams-disabled-handlers",!0)}t("i.fa-plus-square-o",t("tbody",s)).exists()||n.removeClass("fa-cog fa-spin").addClass("fa-minus-square-o"),a.initContent(s)})):(t(".editor",s).each(function(){a.skin.cleanContainer(t(this)),t(this).empty()}),t(".fa-minus-square-o",s).removeClass("fa-minus-square-o").addClass("fa-plus-square-o"),t("tr",s).removeData("ams-disabled-handlers"))},updateToolbar:function(e){var i=t('tr[id="'+e.object_id+'"]'),n=t(".title-toolbar",i);n.replaceWith(e.toolbar_tag),n=t(".title-toolbar",i),a.initContent(n)},updateMarkers:function(e){var i=t('tr[id="'+e.object_id+'"]'),n=t(".title-toolbar",i),s=t("DIV.action."+e.marker_type,n);s.exists()?s.replaceWith(e.marker_tag):t(e.marker_tag).appendTo(n),e.marker_tag&&(s=t("DIV.action."+e.marker_type,n),a.initContent(s)),a.helpers.sort(n,"weight")}},pictograms:{initManagerSelection:function(){var e=t(this),a=t('input[type="hidden"]',t(".selected-pictograms",e)).listattr("value");return{selected:JSON.stringify(a)}},switchPictogram:function(){var e=t(this),a=e.parents(".pictograms"),i=a.parents(".pictograms-manager");a.hasClass("available-pictograms")?t(".selected-pictograms",i).append(e):t(".available-pictograms",i).append(e)}},themes:{initExtracts:function(e){var i=t('select[name="manager_themes.widgets.thesaurus_name:list"]',e).val(),n=t('select[name="manager_themes.widgets.extract_name:list"]',e),s=n.val();i&&a.jsonrpc.post("getExtracts",{thesaurus_name:i},{url:"/api/thesaurus/json"},function(e){n.empty(),t(e.result).each(function(){t("<option></option>").attr("value",this.id).attr("selected",this.id===s).text(this.text).appendTo(n)})})},getExtracts:function(e){var i=t(e.currentTarget).parents("form"),n=t('select[name="manager_themes.widgets.thesaurus_name:list"]',i).val(),s=t('select[name="manager_themes.widgets.extract_name:list"]',i),r=s.data("select2");n&&"--NOVALUE--"!==n?a.jsonrpc.post("getExtracts",{thesaurus_name:n},{url:"/api/thesaurus/json"},function(t){r.results.empty(),r.opts.populateResults.call(r,r.results,t.result,{term:""})}):(s.select2("data",null),r.results.empty(),r.opts.populateResults.call(r,r.results,[],{term:""}))}},fields:{refreshField:function(e){var a=t('table[id="form_fields_list"]'),i=t('tr[data-ams-element-name="'+e.object_name+'"]',a);t("td:nth-child(4)",i).html(e.title)}},imgmap:{init:function(){var e=t(this);a.ajax.check(t.fn.canvasAreaDraw,"/--static--/pyams_content/js/jquery-canvasAreaDraw"+a.devext+".js",function(){e.canvasAreaDraw({imageUrl:e.data("ams-image-url")})})},initPreview:function(){var e=t(this);a.ajax.check(t.fn.mapster,"/--static--/pyams_content/js/jquery-imagemapster-1.2.10"+a.devext+".js",function(){e.mapster({fillColor:"ff0000",fillOpacity:.35,selected:!0,highlight:!0,staticState:!0})})}},site:{switchVisibility:function(){return function(){var e=t(this),i=e.parents("tr").first();a.ajax.post(i.data("ams-location")+"/switch-content-visibility.json",{object_name:i.data("ams-element-name")},function(a,i){var n="fa-eye";a.visible||(n+="-slash"),a.published||(n+=" text-danger"),t("i",e).attr("class","fa fa-fw "+n)})}}},review:{timer:null,timer_duration:{general:3e4,chat:5e3},initComments:function(e){var n=t(".chat-body",e);n.animate({scrollTop:n[0].scrollHeight},1e3),clearInterval(i.review.timer),i.review.timer=setInterval(i.review.updateComments,i.review.timer_duration.chat),a.skin.registerCleanCallback(i.review.cleanCommentsCallback)},cleanCommentsCallback:function(){clearInterval(i.review.timer),i.review.timer=setInterval(i.review.updateComments,i.review.timer_duration.general)},updateComments:function(){var e,i=t(".badge",'nav a[href="#review-comments.html"]'),n=t(".chat-body",".widget-body");e=n.exists()?t(".message",n).length:parseInt(i.text()),a.ajax.post("get-last-review-comments.json",{count:e},function(a){n.exists()&&i.removeClass("bg-color-danger").addClass("bg-color-info"),e!==a.count&&(i.text(a.count).removeClass("hidden"),n.exists()&&(t(".messages",n).append(a.content),n.animate({scrollTop:n[0].scrollHeight},1e3)),n.exists()||i.removeClass("bg-color-info").addClass("bg-color-danger").animate({padding:"3px 12px 2px","margin-right":"9px"},"slow",function(){t(this).animate({padding:"3px 6px 2px","margin-right":"15px"},"slow")}))})},initCommentData:function(e){var a=t(".chat-body",".widget-body");return{count:t(".message",a).length}},addCommentAction:function(){return function(){t('textarea[name="comment"]').focus()}},addCommentCallback:function(e){var a=t(this),i=a.parents(".widget-body");t(".messages",i).append(e.content),t('textarea[name="comment"]',a).val("");var n=t(".chat-body",i);n.animate({scrollTop:n[0].scrollHeight},1e3),t(".badge",'nav a[href="#review-comments.html"]').text(e.count).removeClass("hidden")}},header:{submitEditForm:function(){var e=t(this).parents("form").first();a.form.submit(e,{form_data:{autosubmit:!0}})}},footer:{submitEditForm:function(){var e=t(this).parents("form").first();a.form.submit(e,{form_data:{autosubmit:!0}})}},profile:{switchFavorite:function(){var e=t(this),i=e.data("sequence-oid");a.ajax.post("switch-user-favorite.json",{oid:i},function(t,a){t.favorite?e.removeClass("fa-star-o").addClass("fa-star"):e.removeClass("fa-star").addClass("fa-star-o")})}}};t(".badge",'nav a[href="#review-comments.html"]').exists()&&(i.review.timer=setInterval(i.review.updateComments,i.review.timer_duration.general)),e.PyAMS_content=i}(jQuery,this);
+!function(t,e){"use strict";var a=e.MyAMS,i={widget:{treeview:{selectFolder:function(e,a){t(e.target).siblings('input[type="hidden"]').val(a.id)},unselectFolder:function(e,a){t(e.target).siblings('input[type="hidden"]').val(null)}}},TinyMCE:{initEditor:function(t){return tinyMCE.addI18n("fr",{"Link list":"Liste de liens","Toggle h3 header":"En-tête H3","Toggle h4 header":"En-tête H4","Insert internal link":"Insérer un lien interne","Link title":"Texte à afficher","Internal number":"N° interne"}),tinymce.PluginManager.add("internal_links",function(t,e){t.addButton("internal_links",{icon:"cloud-check",tooltip:"Insert internal link",image:"/--static--/pyams_content/img/internal-link.png",onclick:function(){t.windowManager.open({title:"Insert internal link",body:[{type:"textbox",name:"oid",label:"Internal number"},{type:"textbox",name:"title",label:"Link title",value:t.selection.getContent()}],onsubmit:function(e){t.insertContent('<a href="oid://'+e.data.oid+'">'+e.data.title+"</a>")}})}})}),tinyMCE.PluginManager.add("headers",function(t,e){["h3","h4"].forEach(function(e){t.addButton("header-"+e,{tooltip:"Toggle "+e+" header",text:e.toUpperCase(),onClick:function(){t.execCommand("mceToggleFormat",!1,e)},onPostRender:function(){var a=this,i=function(){t.formatter.formatChanged(e,function(t){a.active(t)})};t.formatter?i():t.on("init",i)}})})}),t.image_list=i.TinyMCE.getImagesList,t.link_list=i.TinyMCE.getLinksList,t.style_formats=[{title:"Inline",items:[{title:"Bold",icon:"bold",format:"bold"},{title:"Italic",icon:"italic",format:"italic"},{title:"Underline",icon:"underline",format:"underline"},{title:"Strikethrough",icon:"strikethrough",format:"strikethrough"},{title:"Superscript",icon:"superscript",format:"superscript"},{title:"Subscript",icon:"subscript",format:"subscript"},{title:"Code",icon:"code",format:"code"}]},{title:"Blocks",items:[{title:"Paragraph",format:"p"},{title:"Blockquote",format:"blockquote"},{title:"Div",format:"div"},{title:"Pre",format:"pre"}]},{title:"Alignment",items:[{title:"Left",icon:"alignleft",format:"alignleft"},{title:"Center",icon:"aligncenter",format:"aligncenter"},{title:"Right",icon:"alignright",format:"alignright"},{title:"Justify",icon:"alignjustify",format:"alignjustify"}]}],t.plugins+=" internal_links headers",t.toolbar1&&(t.toolbar1="undo redo | header-h3 header-h4 styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent"),t.toolbar2&&(t.toolbar2="forecolor backcolor | charmap internal_links link | fullscreen preview print | code"),t},getImagesList:function(e){var i=t(document.activeElement).parents("form");if(i.exists()){var n=i.attr("data-ams-form-handler")||i.attr("action"),s=n.substr(0,n.lastIndexOf("/")+1);return a.ajax.post(s+"get-images-list.json",{},e)}},getLinksList:function(e){var i=t(document.activeElement).parents("form");if(i.exists()){var n=i.attr("data-ams-form-handler")||i.attr("action"),s=n.substr(0,n.lastIndexOf("/")+1);return a.ajax.post(s+"get-links-list.json",{},e)}}},galleries:{updateMediaTitle:function(e){t('img[id="'+e.media_id+'"]').attr("original-title",e.title)},switchMediaVisibility:function(e){return function(){var e=t(this),i=e.parents(".media"),n=i.parents(".gallery");a.ajax.post(n.data("ams-location")+"/set-media-visibility.json",{object_name:i.data("ams-element-name")},function(a,i){a.visible?(t("i",e).attr("class","fa fa-fw fa-eye"),e.parents(".btn-group").siblings("a.fancyimg").removeClass("not-visible")):(t("i",e).attr("class","fa fa-fw fa-eye-slash text-danger"),e.parents(".btn-group").siblings("a.fancyimg").addClass("not-visible"))})}},setOrder:function(e,i){if(!i||!i.item.hasClass("already-dropped")){var n=i.item.parents(".gallery"),s=t(".media",n).listattr("data-ams-element-name");a.ajax.post(n.data("ams-location")+"/set-medias-order.json",{medias:JSON.stringify(s)})}},removeMedia:function(e){return function(){var e=t(this);a.skin.bigBox({title:a.i18n.WARNING,content:'<i class="text-danger fa fa-2x fa-bell shake animated"></i>&nbsp; '+a.i18n.DELETE_WARNING,buttons:a.i18n.BTN_OK_CANCEL},function(t){if(t===a.i18n.BTN_OK){var i=e.parents(".gallery").data("ams-location"),n=e.parents(".media"),s=n.data("ams-element-name");a.ajax.post(i+"/delete-element.json",{object_name:s},function(t,e){n.remove()})}})}},afterFancyboxLoad:function(t,e){t.element.hasClass("not-visible")&&t.inner.prepend('<div class="hidden-mask"></div>')}},paragraphs:{preReload:function(){i.paragraphs.switched=t("i.switch.fa-minus-square-o","#paragraphs_list").parents("tr").listattr("id")},postReload:function(){t(i.paragraphs.switched).each(function(){t("i.switch.fa-plus-square-o",'[id="'+this+'"]').parents("div").first().click()}),delete i.paragraphs.switched},refreshParagraph:function(e){var a=t('tr[id="'+e.object_id+'"]');t("span.title",a).html(e.title||" - - - - - - - -")},switchEditor:function(e){var i=t(this),n=t("i.switch",i),s=i.parents("td"),r=t(".editor",s),o=i.parents("tr");if(n.hasClass("fa-plus-square-o")){var l=o.parents("table");r.html('<h1 class="loading"><i class="fa fa-2x fa-gear fa-spin"></i></h1>'),a.ajax.post(l.data("ams-location")+"/get-paragraph-editor.json",{object_name:o.data("ams-element-name")},function(t){r.html(t),t&&(a.initContent(r),n.removeClass("fa-plus-square-o").addClass("fa-minus-square-o"),o.data("ams-disabled-handlers",!0),a.skin.scrollTo(r,{offset:r.height()-o.height()}))})}else a.skin.cleanContainer(r),r.empty(),n.removeClass("fa-minus-square-o").addClass("fa-plus-square-o"),o.removeData("ams-disabled-handlers")},switchLastEditor:function(e){var a=t('table[id="'+e+'"]'),i=t("tr:last",a);t('[data-ams-click-handler="PyAMS_content.paragraphs.switchEditor"]',i).click()},switchAllEditors:function(e){var i=t(this),n=t("i",i),s=i.parents("table");n.hasClass("fa-plus-square-o")?(n.removeClass("fa-plus-square-o").addClass("fa-cog fa-spin"),a.ajax.post(s.data("ams-location")+"/get-paragraphs-editors.json",{},function(e){for(var i in e)if(e.hasOwnProperty(i)){var r=t('tr[data-ams-element-name="'+i+'"]',s),o=t(".editor",r);o.is(":empty")&&o.html(e[i]),t(".fa-plus-square-o",r).removeClass("fa-plus-square-o").addClass("fa-minus-square-o"),r.data("ams-disabled-handlers",!0)}t("i.fa-plus-square-o",t("tbody",s)).exists()||n.removeClass("fa-cog fa-spin").addClass("fa-minus-square-o"),a.initContent(s)})):(t(".editor",s).each(function(){a.skin.cleanContainer(t(this)),t(this).empty()}),t(".fa-minus-square-o",s).removeClass("fa-minus-square-o").addClass("fa-plus-square-o"),t("tr",s).removeData("ams-disabled-handlers"))},updateToolbar:function(e){var i=t('tr[id="'+e.object_id+'"]'),n=t(".title-toolbar",i);n.replaceWith(e.toolbar_tag),n=t(".title-toolbar",i),a.initContent(n)},updateMarkers:function(e){var i=t('tr[id="'+e.object_id+'"]'),n=t(".title-toolbar",i),s=t("DIV.action."+e.marker_type,n);s.exists()?s.replaceWith(e.marker_tag):t(e.marker_tag).appendTo(n),e.marker_tag&&(s=t("DIV.action."+e.marker_type,n),a.initContent(s)),a.helpers.sort(n,"weight")},switchAnchor:function(){return function(){var e=t(this),i=e.parents("tr").first(),n=i.parents("table");a.ajax.post(n.data("ams-location")+"/"+n.data("ams-anchor-switcher"),{object_name:i.data("ams-element-name")},function(a,i){a.anchor?t("i",e).attr("class","fa fa-fw fa-anchor"):t("i",e).attr("class","fa fa-fw fa-anchor txt-color-silver opacity-50")})}}},pictograms:{initManagerSelection:function(){var e=t(this),a=t('input[type="hidden"]',t(".selected-pictograms",e)).listattr("value");return{selected:JSON.stringify(a)}},switchPictogram:function(){var e=t(this),a=e.parents(".pictograms"),i=a.parents(".pictograms-manager");a.hasClass("available-pictograms")?t(".selected-pictograms",i).append(e):t(".available-pictograms",i).append(e)}},themes:{initExtracts:function(e){var i=t('select[name="manager_themes.widgets.thesaurus_name:list"]',e).val(),n=t('select[name="manager_themes.widgets.extract_name:list"]',e),s=n.val();i&&a.jsonrpc.post("getExtracts",{thesaurus_name:i},{url:"/api/thesaurus/json"},function(e){n.empty(),t(e.result).each(function(){t("<option></option>").attr("value",this.id).attr("selected",this.id===s).text(this.text).appendTo(n)})})},getExtracts:function(e){var i=t(e.currentTarget).parents("form"),n=t('select[name="manager_themes.widgets.thesaurus_name:list"]',i).val(),s=t('select[name="manager_themes.widgets.extract_name:list"]',i),r=s.data("select2");n&&"--NOVALUE--"!==n?a.jsonrpc.post("getExtracts",{thesaurus_name:n},{url:"/api/thesaurus/json"},function(t){r.results.empty(),r.opts.populateResults.call(r,r.results,t.result,{term:""})}):(s.select2("data",null),r.results.empty(),r.opts.populateResults.call(r,r.results,[],{term:""}))}},fields:{refreshField:function(e){var a=t('table[id="form_fields_list"]'),i=t('tr[data-ams-element-name="'+e.object_name+'"]',a);t("td:nth-child(4)",i).html(e.title)}},imgmap:{init:function(){var e=t(this);a.ajax.check(t.fn.canvasAreaDraw,"/--static--/pyams_content/js/jquery-canvasAreaDraw"+a.devext+".js",function(){e.canvasAreaDraw({imageUrl:e.data("ams-image-url")})})},initPreview:function(){var e=t(this);a.ajax.check(t.fn.mapster,"/--static--/pyams_content/js/jquery-imagemapster-1.2.10"+a.devext+".js",function(){e.mapster({fillColor:"ff0000",fillOpacity:.35,selected:!0,highlight:!0,staticState:!0})})}},site:{switchVisibility:function(){return function(){var e=t(this),i=e.parents("tr").first();a.ajax.post(i.data("ams-location")+"/switch-content-visibility.json",{object_name:i.data("ams-element-name")},function(a,i){var n="fa-eye";a.visible||(n+="-slash"),a.published||(n+=" text-danger"),t("i",e).attr("class","fa fa-fw "+n)})}}},review:{timer:null,timer_duration:{general:3e4,chat:5e3},initComments:function(e){var n=t(".chat-body",e);n.animate({scrollTop:n[0].scrollHeight},1e3),clearInterval(i.review.timer),i.review.timer=setInterval(i.review.updateComments,i.review.timer_duration.chat),a.skin.registerCleanCallback(i.review.cleanCommentsCallback)},cleanCommentsCallback:function(){clearInterval(i.review.timer),i.review.timer=setInterval(i.review.updateComments,i.review.timer_duration.general)},updateComments:function(){var e,i=t(".badge",'nav a[href="#review-comments.html"]'),n=t(".chat-body",".widget-body");e=n.exists()?t(".message",n).length:parseInt(i.text()),a.ajax.post("get-last-review-comments.json",{count:e},function(a){n.exists()&&i.removeClass("bg-color-danger").addClass("bg-color-info"),e!==a.count&&(i.text(a.count).removeClass("hidden"),n.exists()&&(t(".messages",n).append(a.content),n.animate({scrollTop:n[0].scrollHeight},1e3)),n.exists()||i.removeClass("bg-color-info").addClass("bg-color-danger").animate({padding:"3px 12px 2px","margin-right":"9px"},"slow",function(){t(this).animate({padding:"3px 6px 2px","margin-right":"15px"},"slow")}))})},initCommentData:function(e){var a=t(".chat-body",".widget-body");return{count:t(".message",a).length}},addCommentAction:function(){return function(){t('textarea[name="comment"]').focus()}},addCommentCallback:function(e){var a=t(this),i=a.parents(".widget-body");t(".messages",i).append(e.content),t('textarea[name="comment"]',a).val("");var n=t(".chat-body",i);n.animate({scrollTop:n[0].scrollHeight},1e3),t(".badge",'nav a[href="#review-comments.html"]').text(e.count).removeClass("hidden")}},header:{submitEditForm:function(){var e=t(this).parents("form").first();a.form.submit(e,{form_data:{autosubmit:!0}})}},footer:{submitEditForm:function(){var e=t(this).parents("form").first();a.form.submit(e,{form_data:{autosubmit:!0}})}},profile:{switchFavorite:function(){var e=t(this),i=e.data("sequence-oid");a.ajax.post("switch-user-favorite.json",{oid:i},function(t,a){t.favorite?e.removeClass("fa-star-o").addClass("fa-star"):e.removeClass("fa-star").addClass("fa-star-o")})}}};t(".badge",'nav a[href="#review-comments.html"]').exists()&&(i.review.timer=setInterval(i.review.updateComments,i.review.timer_duration.general)),e.PyAMS_content=i}(jQuery,this);