Updated review comments presentation
authorThierry Florac <thierry.florac@onf.fr>
Mon, 02 Oct 2017 14:43:28 +0200
changeset 188 4a7679f7f16c
parent 187 a94f92bb4839
child 189 85bbfd8dcd65
Updated review comments presentation
src/pyams_content/shared/common/zmi/review.py
src/pyams_content/shared/common/zmi/templates/review-add-comment.pt
src/pyams_content/shared/common/zmi/templates/review-comments-json.pt
src/pyams_content/shared/common/zmi/templates/review-comments.pt
src/pyams_content/shared/common/zmi/templates/review-notification.pt
src/pyams_content/skin/resources/js/pyams_content.js
src/pyams_content/skin/resources/js/pyams_content.min.js
--- a/src/pyams_content/shared/common/zmi/review.py	Fri Sep 29 16:23:09 2017 +0200
+++ b/src/pyams_content/shared/common/zmi/review.py	Mon Oct 02 14:43:28 2017 +0200
@@ -21,7 +21,7 @@
 from pyams_content.shared.common.interfaces import IWfSharedContent
 from pyams_security.interfaces import ISecurityManager
 from pyams_security.interfaces.profile import IPublicProfile
-from pyams_skin.interfaces.viewlet import IContextActions
+from pyams_skin.interfaces.viewlet import IContextActions, IWidgetTitleViewletManager
 from pyams_skin.layer import IPyAMSLayer
 from pyams_zmi.interfaces.menu import IContentManagementMenu
 from pyams_zmi.layer import IAdminLayer
@@ -34,9 +34,9 @@
 from pyams_pagelet.pagelet import pagelet_config
 from pyams_security.schema import PrincipalsSet
 from pyams_skin.viewlet.menu import MenuItem
-from pyams_skin.viewlet.toolbar import ToolbarMenuItem
+from pyams_skin.viewlet.toolbar import ToolbarMenuItem, JsToolbarAction
 from pyams_template.template import template_config, get_view_template
-from pyams_utils.date import get_age
+from pyams_utils.date import get_age, format_datetime
 from pyams_utils.registry import get_utility, query_utility
 from pyams_viewlet.viewlet import viewlet_config
 from pyams_zmi.form import AdminDialogAddForm
@@ -192,10 +192,23 @@
     def get_avatar(self, principal):
         return IPublicProfile(principal).avatar
 
+    def get_date(self, comment):
+        return format_datetime(comment.creation_date)
+
     def get_age(self, comment):
         return get_age(comment.creation_date)
 
 
+@viewlet_config(name='add-review-comment.action', context=IWfSharedContent, layer=IAdminLayer,
+                view=SharedContentReviewCommentsView, manager=IWidgetTitleViewletManager,
+                permission=COMMENT_CONTENT_PERMISSION)
+class SharedContentReviewAddCommentAction(JsToolbarAction):
+    """Shared content review add comment action"""
+
+    label = _("Add comment...")
+    url = 'PyAMS_content.review.addCommentAction'
+
+
 @view_config(name='get-last-review-comments.json', context=IWfSharedContent, request_type=IPyAMSLayer,
              permission=COMMENT_CONTENT_PERMISSION, renderer='json', xhr=True)
 @template_config(template='templates/review-comments-json.pt')
--- a/src/pyams_content/shared/common/zmi/templates/review-add-comment.pt	Fri Sep 29 16:23:09 2017 +0200
+++ b/src/pyams_content/shared/common/zmi/templates/review-add-comment.pt	Mon Oct 02 14:43:28 2017 +0200
@@ -8,8 +8,19 @@
 			<i class="fa fa-lg fa-user img"></i>
 		</tal:if>
 		<span class="message-text">
-			<time i18n:translate="">just now</time>
-			<a class="username" tal:content="request.principal.title">Owner</a>
+			<a class="username">
+				<tal:if condition="comment.comment_type=='request'">
+					<span class="txt-color-text nobold"
+						  i18n:translate="">Review query from</span>&nbsp;
+				</tal:if>
+				<tal:var content="request.principal.title">Owner</tal:var>
+				<tal:if condition="comment.owner in context.readers">
+					&nbsp;
+					<span class="txt-color-text nobold"
+						  i18n:translate="">(as reviewer)</span>
+				</tal:if>
+				<time class="margin-left-10" i18n:translate="">just now</time>
+			</a>
 			<tal:var content="structure extension:html(comment.comment)" />
 		</span>
 	</tal:var>
--- a/src/pyams_content/shared/common/zmi/templates/review-comments-json.pt	Fri Sep 29 16:23:09 2017 +0200
+++ b/src/pyams_content/shared/common/zmi/templates/review-comments-json.pt	Mon Oct 02 14:43:28 2017 +0200
@@ -9,8 +9,22 @@
 			<i class="fa fa-lg fa-user img"></i>
 		</tal:if>
 		<span class="message-text">
-			<time tal:content="view.get_age(comment)">age</time>
-			<a class="username" tal:content="principal.title">Owner</a>
+			<a class="username">
+				<tal:if condition="comment.comment_type=='request'">
+					<span class="txt-color-text nobold"
+						  i18n:translate="">Review query from</span>&nbsp;
+				</tal:if>
+				<tal:var content="principal.title">Owner</tal:var>
+				<tal:if condition="comment.owner in context.readers">
+					&nbsp;
+					<span class="txt-color-text nobold"
+						  i18n:translate="">(as reviewer)</span>
+				</tal:if>
+				<time class="margin-left-10 hint opaque align-base"
+					  data-ams-hint-gravity="w" data-ams-hint-offset="5"
+					  tal:attributes="title view.get_date(comment)"
+					  tal:content="view.get_age(comment).lower()">age</time>
+			</a>
 			<tal:var content="structure extension:html(comment.comment)" />
 		</span>
 	</tal:var>
--- a/src/pyams_content/shared/common/zmi/templates/review-comments.pt	Fri Sep 29 16:23:09 2017 +0200
+++ b/src/pyams_content/shared/common/zmi/templates/review-comments.pt	Mon Oct 02 14:43:28 2017 +0200
@@ -26,8 +26,22 @@
 							<i class="fa fa-lg fa-user img"></i>
 						</tal:if>
 						<span class="message-text">
-							<time tal:content="view.get_age(comment)">age</time>
-							<a class="username" tal:content="principal.title">Owner</a>
+							<a class="username">
+								<tal:if condition="comment.comment_type=='request'">
+									<span class="txt-color-text nobold"
+										  i18n:translate="">Review query from</span>&nbsp;
+								</tal:if>
+								<tal:var content="principal.title">Owner</tal:var>
+								<tal:if condition="comment.owner in context.readers">
+									&nbsp;
+									<span class="txt-color-text nobold"
+										  i18n:translate="">(as reviewer)</span>
+								</tal:if>
+								<time class="margin-left-10 hint opaque align-base"
+									  data-ams-hint-gravity="w" data-ams-hint-offset="5"
+									  tal:attributes="title view.get_date(comment)"
+									  tal:content="view.get_age(comment).lower()">age</time>
+							</a>
 							<tal:var content="structure extension:html(comment.comment)" />
 						</span>
 					</tal:var>
--- a/src/pyams_content/shared/common/zmi/templates/review-notification.pt	Fri Sep 29 16:23:09 2017 +0200
+++ b/src/pyams_content/shared/common/zmi/templates/review-notification.pt	Mon Oct 02 14:43:28 2017 +0200
@@ -7,21 +7,45 @@
 	</title>
 	<meta http-equiv="CONTENT-TYPE" content="text/html; charset=utf-8" />
 	<meta charset="utf-8" />
+	<style>
+		html,
+		body,
+		p,
+		pre {
+			font-family: Ubuntu, Verdana, Arial, Helvetica, sans-serif;
+			font-size: 13px;
+			color: #333;
+		}
+		pre {
+			border-left: 2px solid #346597;
+			padding-left: 10px;
+		}
+		pre.noborder {
+			border-left: none;
+			padding-left: 0;
+		}
+	</style>
 </head>
 <body>
 	<p i18n:translate="">Hello,</p>
 	<p i18n:translate="">
-		You have been requested by <span i18n:name="sender" tal:content="options['sender']">sender</span>
-		to make a review of a content called « <strong i18n:name="title" tal:content="i18n:context.title">title</strong> »
-		which has been created on publication platform « <span i18n:name="service_name"
-			tal:content="options['settings'].service_name">Service name</span> ».
+		You have been requested by <span i18n:name="sender" tal:content="options['sender']">sender</span>, contributor
+		of « <span i18n:name="service_name" tal:content="options['settings'].service_name">Service name</span> »
+		website, to make a review of a content.
 	</p>
-	<p i18n:translate="">Comment associated with this request is:</p>
+	<p i18n:translate="">
+		<span i18n:name="sender" tal:content="options['sender']">sender</span> added the following message to his
+		request:
+	</p>
 	<pre style="padding: 5px 20px;" tal:content="options['comment']">comment</pre>
 	<p i18n:translate="">To review and comment this publication, please use the following link: <a i18n:name="target"
 			tal:attributes="href extension:absolute_url(context, 'admin')"
-			tal:content="i18n:context.title"></a></p>
+			tal:content="i18n:context.title"></a>.</p>
+	<p i18n:translate="">After reading this content, please use the « Comments » menu entry.</p>
+	<p i18n:translate="">If you don't want to reply to this request, please contact
+		<span i18n:name="sender" tal:content="options['sender']">sender</span> directly by replying to this mail.</p>
+	<p i18n:translate="">Thank you.</p>
 	<br />
-	<pre tal:content="options['settings'].signature">signature</pre>
+	<pre class="noborder" tal:content="options['settings'].signature">signature</pre>
 </body>
 </html>
--- a/src/pyams_content/skin/resources/js/pyams_content.js	Fri Sep 29 16:23:09 2017 +0200
+++ b/src/pyams_content/skin/resources/js/pyams_content.js	Mon Oct 02 14:43:28 2017 +0200
@@ -467,6 +467,12 @@
 				return {count: $('.message', chat).length};
 			},
 
+			addCommentAction: function() {
+				return function() {
+					$('textarea[name="comment"]').focus();
+				};
+			},
+
 			addCommentCallback: function(options) {
 				var form = $(this);
 				var widget = form.parents('.widget-body');
--- a/src/pyams_content/skin/resources/js/pyams_content.min.js	Fri Sep 29 16:23:09 2017 +0200
+++ b/src/pyams_content/skin/resources/js/pyams_content.min.js	Mon Oct 02 14:43:28 2017 +0200
@@ -1,1 +1,1 @@
-(function(c,b){var e=b.MyAMS;var d={refreshForm:function(g){var f=c("#"+g.object_name);f.replaceWith(c(g.form));f=c("#"+g.object_name);e.initContent(f);return f},refreshTable:function(f){var g=c("#"+f.object_name).parent(".ams-widget");g.replaceWith(c(f.table));g=c("#"+f.object_name).parent(".ams-widget");e.initContent(g);return g},TinyMCE:{initEditor:function(f){f.image_list=d.TinyMCE.getImagesList;f.link_list=d.TinyMCE.getLinksList;return f},getImagesList:function(i){var f=c(document.activeElement).parents("form");if(f.exists()){var g=f.attr("data-ams-form-handler")||f.attr("action");var h=g.substr(0,g.lastIndexOf("/")+1);return e.ajax.post(h+"get-images-list.json",{},i)}},getLinksList:function(i){var f=c(document.activeElement).parents("form");if(f.exists()){var g=f.attr("data-ams-form-handler")||f.attr("action");var h=g.substr(0,g.lastIndexOf("/")+1);return e.ajax.post(h+"get-links-list.json",{},i)}}},profile:{switchFavorite:function(){var g=c(this);var f=g.data("sequence-oid");e.ajax.post("switch-user-favorite.json",{oid:f},function(h,i){if(h.favorite){g.removeClass("fa-star-o").addClass("fa-star")}else{g.removeClass("fa-star").addClass("fa-star-o")}})}},galleries:{switchImageVisibility:function(f){return function(){var h=c(this);var i=h.parents(".image");var g=i.parents(".gallery");e.ajax.post(g.data("ams-location")+"/set-image-visibility.json",{object_name:i.data("ams-element-name")},function(j,k){if(j.visible){c("i",h).attr("class","fa fa-fw fa-eye")}else{c("i",h).attr("class","fa fa-fw fa-eye-slash text-danger")}})}},refresh:function(g){if(typeof(g)==="string"){g=JSON.parse(g)}var f=c('select[name="form.widgets.galleries:list"]');var h=f.data("select2");c("<option></option>").attr("value",g.new_gallery.id).attr("selected","selected").text(g.new_gallery.text).appendTo(f);var i=f.select2("data");i.push(g.new_gallery);f.select2("data",i);h.results.empty();h.opts.populateResults.call(h,h.results,g.galleries,{term:""})},setOrder:function(h,i){if(i&&i.item.hasClass("already-dropped")){return}var f=i.item.parents(".gallery");var g=c(".image",f).listattr("data-ams-element-name");e.ajax.post(f.data("ams-location")+"/set-images-order.json",{images:JSON.stringify(g)})},removeFile:function(f){return function(){var g=c(this);e.skin.bigBox({title:e.i18n.WARNING,content:'<i class="text-danger fa fa-2x fa-bell shake animated"></i>&nbsp; '+e.i18n.DELETE_WARNING,buttons:e.i18n.BTN_OK_CANCEL},function(k){if(k===e.i18n.BTN_OK){var j=g.parents(".gallery");var i=j.data("ams-location");var l=g.parents(".image");var h=l.data("ams-element-name");e.ajax.post(i+"/delete-element.json",{object_name:h},function(m,n){l.remove()})}})}},refreshContainer:function(h){var f=c('tr[data-ams-element-name="'+h.object_name+'"]');var g=c("span.count",c("div.action.galleries",f));if(h.nb_galleries>0){g.text("("+h.nb_galleries+")")}else{g.text("")}}},imgmap:{init:function(){var f=c(this);e.ajax.check(c.fn.canvasAreaDraw,"/--static--/pyams_content/js/jquery-canvasAreaDraw"+e.devext+".js",function(){f.canvasAreaDraw({imageUrl:f.data("ams-image-url")})})},initSummary:function(){var f=c(this);e.ajax.check(c.fn.mapster,"/--static--/pyams_content/js/jquery-imagemapster-1.2.10"+e.devext+".js",function(){f.mapster({fillColor:"ff0000",fillOpacity:0.35,selected:true,highlight:true,staticState:true})})}},associations:{refreshAssociations:function(f){var h=d.refreshTable(f);var g=h.siblings("legend");if(g.parents("fieldset:first").hasClass("switched")){g.click()}},switchVisibility:function(f){return function(){var i=c(this);var h=i.parents("tr");var g=h.parents("table");e.ajax.post(g.data("ams-location")+"/set-association-visibility.json",{object_name:h.data("ams-element-name")},function(j,k){if(j.visible){c("i",i).attr("class","fa fa-fw fa-eye")}else{c("i",i).attr("class","fa fa-fw fa-eye-slash text-danger")}})}}},paragraphs:{switchVisibility:function(f){return function(){var i=c(this);var g=i.parents("tr");var h=g.parents("table");e.ajax.post(h.data("ams-location")+"/set-paragraph-visibility.json",{object_name:g.data("ams-element-name")},function(j,k){if(j.visible){c("i",i).attr("class","fa fa-fw fa-eye")}else{c("i",i).attr("class","fa fa-fw fa-eye-slash text-danger")}})}},refreshParagraph:function(h){var g=c('table[id="paragraphs_list"]');var f=c('tr[data-ams-element-name="'+h.object_name+'"]',g);c("span.title",f).html(h.title||" - - - - - - - -")},switchEditor:function(h){var k=c(this);var j=c("i",k);var l=k.parents("td");var i=c(".editor",l);var f=k.parents("tr");if(j.hasClass("fa-plus-square-o")){var g=f.parents("table");i.html('<h1 class="loading"><i class="fa fa-2x fa-gear fa-spin"></i></h1>');e.ajax.post(g.data("ams-location")+"/get-paragraph-editor.json",{object_name:f.data("ams-element-name")},function(m){i.html(m);if(m){e.initContent(i);j.removeClass("fa-plus-square-o").addClass("fa-minus-square-o");f.data("ams-disabled-handlers",true)}})}else{e.skin.cleanContainer(i);i.empty();j.removeClass("fa-minus-square-o").addClass("fa-plus-square-o");f.removeData("ams-disabled-handlers")}},switchAllEditors:function(g){var i=c(this);var h=c("i",i);var f=i.parents("table");if(h.hasClass("fa-plus-square-o")){h.removeClass("fa-plus-square-o").addClass("fa-cog fa-spin");e.ajax.post(f.data("ams-location")+"/get-paragraphs-editors.json",{},function(k){for(var l in k){if(!k.hasOwnProperty(l)){continue}var j=c('tr[data-ams-element-name="'+l+'"]',f);var m=c(".editor",j);if(m.is(":empty")){m.html(k[l]);e.initContent(m)}c(".fa-plus-square-o",j).removeClass("fa-plus-square-o").addClass("fa-minus-square-o");j.data("ams-disabled-handlers",true)}if(!c("i.fa-plus-square-o",c("tbody",f)).exists()){h.removeClass("fa-cog fa-spin").addClass("fa-minus-square-o")}})}else{c(".editor",f).each(function(){e.skin.cleanContainer(c(this));c(this).empty()});c(".fa-minus-square-o",f).removeClass("fa-minus-square-o").addClass("fa-plus-square-o");c("tr",f).removeData("ams-disabled-handlers")}}},fields:{refreshField:function(h){var g=c('table[id="form_fields_list"]');var f=c('tr[data-ams-element-name="'+h.object_name+'"]',g);c("td:nth-child(4)",f).html(h.title)},switchVisibility:function(f){return function(){var i=c(this);var h=i.parents("tr");var g=h.parents("table");e.ajax.post(g.data("ams-location")+"/set-form-field-visibility.json",{object_name:h.data("ams-element-name")},function(j,k){if(j.visible){c("i",i).attr("class","fa fa-fw fa-eye")}else{c("i",i).attr("class","fa fa-fw fa-eye-slash text-danger")}})}}},themes:{initExtracts:function(h){var g=c('select[name="form.widgets.thesaurus_name:list"]',h);var f=g.val();var j=c('select[name="form.widgets.extract_name:list"]',h);var i=j.val();if(f){e.jsonrpc.post("getExtracts",{thesaurus_name:f},{url:"/api/thesaurus/json"},function(k){j.empty();c(k.result).each(function(){c("<option></option>").attr("value",this.id).attr("selected",this.id===i).text(this.text).appendTo(j)})})}j.attr("data-ams-events-handlers",'{"select2-open": "PyAMS_content.themes.getExtracts"}')},getExtracts:function(i){var f=c(i.currentTarget);var h=f.parents("form");var g=c('select[name="form.widgets.thesaurus_name:list"]',h).val();if(g){e.jsonrpc.post("getExtracts",{thesaurus_name:g},{url:"/api/thesaurus/json"},function(l){var k=c('select[name="form.widgets.extract_name:list"]',h);var j=k.data("select2");j.results.empty();j.opts.populateResults.call(j,j.results,l.result,{term:""})})}}},review:{timer:null,timer_duration:{general:30000,chat:5000},initComments:function(g){var f=c(".chat-body",g);f.animate({scrollTop:f[0].scrollHeight},1000);clearInterval(d.review.timer);d.review.timer=setInterval(d.review.updateComments,d.review.timer_duration.chat);e.skin.registerCleanCallback(d.review.cleanCommentsCallback)},cleanCommentsCallback:function(){clearInterval(d.review.timer);d.review.timer=setInterval(d.review.updateComments,d.review.timer_duration.general)},updateComments:function(){var f=c(".badge",'nav a[href="#review-comments.html"]'),h;var g=c(".chat-body",".widget-body");if(g.exists()){h=c(".message",g).length}else{h=parseInt(f.text())}e.ajax.post("get-last-review-comments.json",{count:h},function(i){if(g.exists()){f.removeClass("bg-color-danger").addClass("bg-color-info")}if(h!==i.count){f.text(i.count).removeClass("hidden");if(g.exists()){c(".messages",g).append(i.content);g.animate({scrollTop:g[0].scrollHeight},1000)}if(!g.exists()){f.removeClass("bg-color-info").addClass("bg-color-danger").animate({padding:"3px 12px 2px","margin-right":"9px"},"slow",function(){c(this).animate({padding:"3px 6px 2px","margin-right":"15px"},"slow")})}}})},initCommentData:function(f){var g=c(".chat-body",".widget-body");return{count:c(".message",g).length}},addCommentCallback:function(g){var h=c(this);var i=h.parents(".widget-body");c(".messages",i).append(g.content);c('textarea[name="comment"]',h).val("");var f=c(".chat-body",i);f.animate({scrollTop:f[0].scrollHeight},1000);c(".badge",'nav a[href="#review-comments.html"]').text(g.count).removeClass("hidden")}}};b.PyAMS_content=d;c(b.document).on("PyAMS_content.changed_item",function(g,f){switch(f.object_type){case"form":d.refreshForm(f);break;case"associations":d.associations.refreshAssociations(f);break;case"paragraph":d.paragraphs.refreshParagraph(f);break;case"form_field":d.fields.refreshField(f);break;case"review_comments":d.review.updateComments();break}});var a=c(".badge",'nav a[href="#review-comments.html"]');if(a.exists()){d.review.timer=setInterval(d.review.updateComments,d.review.timer_duration.general)}})(jQuery,this);
\ No newline at end of file
+(function(c,b){var e=b.MyAMS;var d={refreshForm:function(g){var f=c("#"+g.object_name);f.replaceWith(c(g.form));f=c("#"+g.object_name);e.initContent(f);return f},refreshTable:function(f){var g=c("#"+f.object_name).parent(".ams-widget");g.replaceWith(c(f.table));g=c("#"+f.object_name).parent(".ams-widget");e.initContent(g);return g},TinyMCE:{initEditor:function(f){f.image_list=d.TinyMCE.getImagesList;f.link_list=d.TinyMCE.getLinksList;return f},getImagesList:function(i){var f=c(document.activeElement).parents("form");if(f.exists()){var g=f.attr("data-ams-form-handler")||f.attr("action");var h=g.substr(0,g.lastIndexOf("/")+1);return e.ajax.post(h+"get-images-list.json",{},i)}},getLinksList:function(i){var f=c(document.activeElement).parents("form");if(f.exists()){var g=f.attr("data-ams-form-handler")||f.attr("action");var h=g.substr(0,g.lastIndexOf("/")+1);return e.ajax.post(h+"get-links-list.json",{},i)}}},profile:{switchFavorite:function(){var g=c(this);var f=g.data("sequence-oid");e.ajax.post("switch-user-favorite.json",{oid:f},function(h,i){if(h.favorite){g.removeClass("fa-star-o").addClass("fa-star")}else{g.removeClass("fa-star").addClass("fa-star-o")}})}},galleries:{switchImageVisibility:function(f){return function(){var h=c(this);var i=h.parents(".image");var g=i.parents(".gallery");e.ajax.post(g.data("ams-location")+"/set-image-visibility.json",{object_name:i.data("ams-element-name")},function(j,k){if(j.visible){c("i",h).attr("class","fa fa-fw fa-eye")}else{c("i",h).attr("class","fa fa-fw fa-eye-slash text-danger")}})}},refresh:function(g){if(typeof(g)==="string"){g=JSON.parse(g)}var f=c('select[name="form.widgets.galleries:list"]');var h=f.data("select2");c("<option></option>").attr("value",g.new_gallery.id).attr("selected","selected").text(g.new_gallery.text).appendTo(f);var i=f.select2("data");i.push(g.new_gallery);f.select2("data",i);h.results.empty();h.opts.populateResults.call(h,h.results,g.galleries,{term:""})},setOrder:function(h,i){if(i&&i.item.hasClass("already-dropped")){return}var f=i.item.parents(".gallery");var g=c(".image",f).listattr("data-ams-element-name");e.ajax.post(f.data("ams-location")+"/set-images-order.json",{images:JSON.stringify(g)})},removeFile:function(f){return function(){var g=c(this);e.skin.bigBox({title:e.i18n.WARNING,content:'<i class="text-danger fa fa-2x fa-bell shake animated"></i>&nbsp; '+e.i18n.DELETE_WARNING,buttons:e.i18n.BTN_OK_CANCEL},function(k){if(k===e.i18n.BTN_OK){var j=g.parents(".gallery");var i=j.data("ams-location");var l=g.parents(".image");var h=l.data("ams-element-name");e.ajax.post(i+"/delete-element.json",{object_name:h},function(m,n){l.remove()})}})}},refreshContainer:function(h){var f=c('tr[data-ams-element-name="'+h.object_name+'"]');var g=c("span.count",c("div.action.galleries",f));if(h.nb_galleries>0){g.text("("+h.nb_galleries+")")}else{g.text("")}}},imgmap:{init:function(){var f=c(this);e.ajax.check(c.fn.canvasAreaDraw,"/--static--/pyams_content/js/jquery-canvasAreaDraw"+e.devext+".js",function(){f.canvasAreaDraw({imageUrl:f.data("ams-image-url")})})},initSummary:function(){var f=c(this);e.ajax.check(c.fn.mapster,"/--static--/pyams_content/js/jquery-imagemapster-1.2.10"+e.devext+".js",function(){f.mapster({fillColor:"ff0000",fillOpacity:0.35,selected:true,highlight:true,staticState:true})})}},associations:{refreshAssociations:function(f){var h=d.refreshTable(f);var g=h.siblings("legend");if(g.parents("fieldset:first").hasClass("switched")){g.click()}},switchVisibility:function(f){return function(){var i=c(this);var h=i.parents("tr");var g=h.parents("table");e.ajax.post(g.data("ams-location")+"/set-association-visibility.json",{object_name:h.data("ams-element-name")},function(j,k){if(j.visible){c("i",i).attr("class","fa fa-fw fa-eye")}else{c("i",i).attr("class","fa fa-fw fa-eye-slash text-danger")}})}}},paragraphs:{switchVisibility:function(f){return function(){var i=c(this);var g=i.parents("tr");var h=g.parents("table");e.ajax.post(h.data("ams-location")+"/set-paragraph-visibility.json",{object_name:g.data("ams-element-name")},function(j,k){if(j.visible){c("i",i).attr("class","fa fa-fw fa-eye")}else{c("i",i).attr("class","fa fa-fw fa-eye-slash text-danger")}})}},refreshParagraph:function(h){var g=c('table[id="paragraphs_list"]');var f=c('tr[data-ams-element-name="'+h.object_name+'"]',g);c("span.title",f).html(h.title||" - - - - - - - -")},switchEditor:function(h){var k=c(this);var j=c("i",k);var l=k.parents("td");var i=c(".editor",l);var f=k.parents("tr");if(j.hasClass("fa-plus-square-o")){var g=f.parents("table");i.html('<h1 class="loading"><i class="fa fa-2x fa-gear fa-spin"></i></h1>');e.ajax.post(g.data("ams-location")+"/get-paragraph-editor.json",{object_name:f.data("ams-element-name")},function(m){i.html(m);if(m){e.initContent(i);j.removeClass("fa-plus-square-o").addClass("fa-minus-square-o");f.data("ams-disabled-handlers",true)}})}else{e.skin.cleanContainer(i);i.empty();j.removeClass("fa-minus-square-o").addClass("fa-plus-square-o");f.removeData("ams-disabled-handlers")}},switchAllEditors:function(g){var i=c(this);var h=c("i",i);var f=i.parents("table");if(h.hasClass("fa-plus-square-o")){h.removeClass("fa-plus-square-o").addClass("fa-cog fa-spin");e.ajax.post(f.data("ams-location")+"/get-paragraphs-editors.json",{},function(k){for(var l in k){if(!k.hasOwnProperty(l)){continue}var j=c('tr[data-ams-element-name="'+l+'"]',f);var m=c(".editor",j);if(m.is(":empty")){m.html(k[l]);e.initContent(m)}c(".fa-plus-square-o",j).removeClass("fa-plus-square-o").addClass("fa-minus-square-o");j.data("ams-disabled-handlers",true)}if(!c("i.fa-plus-square-o",c("tbody",f)).exists()){h.removeClass("fa-cog fa-spin").addClass("fa-minus-square-o")}})}else{c(".editor",f).each(function(){e.skin.cleanContainer(c(this));c(this).empty()});c(".fa-minus-square-o",f).removeClass("fa-minus-square-o").addClass("fa-plus-square-o");c("tr",f).removeData("ams-disabled-handlers")}}},fields:{refreshField:function(h){var g=c('table[id="form_fields_list"]');var f=c('tr[data-ams-element-name="'+h.object_name+'"]',g);c("td:nth-child(4)",f).html(h.title)},switchVisibility:function(f){return function(){var i=c(this);var h=i.parents("tr");var g=h.parents("table");e.ajax.post(g.data("ams-location")+"/set-form-field-visibility.json",{object_name:h.data("ams-element-name")},function(j,k){if(j.visible){c("i",i).attr("class","fa fa-fw fa-eye")}else{c("i",i).attr("class","fa fa-fw fa-eye-slash text-danger")}})}}},themes:{initExtracts:function(h){var g=c('select[name="form.widgets.thesaurus_name:list"]',h);var f=g.val();var j=c('select[name="form.widgets.extract_name:list"]',h);var i=j.val();if(f){e.jsonrpc.post("getExtracts",{thesaurus_name:f},{url:"/api/thesaurus/json"},function(k){j.empty();c(k.result).each(function(){c("<option></option>").attr("value",this.id).attr("selected",this.id===i).text(this.text).appendTo(j)})})}j.attr("data-ams-events-handlers",'{"select2-open": "PyAMS_content.themes.getExtracts"}')},getExtracts:function(i){var f=c(i.currentTarget);var h=f.parents("form");var g=c('select[name="form.widgets.thesaurus_name:list"]',h).val();if(g){e.jsonrpc.post("getExtracts",{thesaurus_name:g},{url:"/api/thesaurus/json"},function(l){var k=c('select[name="form.widgets.extract_name:list"]',h);var j=k.data("select2");j.results.empty();j.opts.populateResults.call(j,j.results,l.result,{term:""})})}}},review:{timer:null,timer_duration:{general:30000,chat:5000},initComments:function(g){var f=c(".chat-body",g);f.animate({scrollTop:f[0].scrollHeight},1000);clearInterval(d.review.timer);d.review.timer=setInterval(d.review.updateComments,d.review.timer_duration.chat);e.skin.registerCleanCallback(d.review.cleanCommentsCallback)},cleanCommentsCallback:function(){clearInterval(d.review.timer);d.review.timer=setInterval(d.review.updateComments,d.review.timer_duration.general)},updateComments:function(){var f=c(".badge",'nav a[href="#review-comments.html"]'),h;var g=c(".chat-body",".widget-body");if(g.exists()){h=c(".message",g).length}else{h=parseInt(f.text())}e.ajax.post("get-last-review-comments.json",{count:h},function(i){if(g.exists()){f.removeClass("bg-color-danger").addClass("bg-color-info")}if(h!==i.count){f.text(i.count).removeClass("hidden");if(g.exists()){c(".messages",g).append(i.content);g.animate({scrollTop:g[0].scrollHeight},1000)}if(!g.exists()){f.removeClass("bg-color-info").addClass("bg-color-danger").animate({padding:"3px 12px 2px","margin-right":"9px"},"slow",function(){c(this).animate({padding:"3px 6px 2px","margin-right":"15px"},"slow")})}}})},initCommentData:function(f){var g=c(".chat-body",".widget-body");return{count:c(".message",g).length}},addCommentAction:function(){return function(){c('textarea[name="comment"]').focus()}},addCommentCallback:function(g){var h=c(this);var i=h.parents(".widget-body");c(".messages",i).append(g.content);c('textarea[name="comment"]',h).val("");var f=c(".chat-body",i);f.animate({scrollTop:f[0].scrollHeight},1000);c(".badge",'nav a[href="#review-comments.html"]').text(g.count).removeClass("hidden")}}};b.PyAMS_content=d;c(b.document).on("PyAMS_content.changed_item",function(g,f){switch(f.object_type){case"form":d.refreshForm(f);break;case"associations":d.associations.refreshAssociations(f);break;case"paragraph":d.paragraphs.refreshParagraph(f);break;case"form_field":d.fields.refreshField(f);break;case"review_comments":d.review.updateComments();break}});var a=c(".badge",'nav a[href="#review-comments.html"]');if(a.exists()){d.review.timer=setInterval(d.review.updateComments,d.review.timer_duration.general)}})(jQuery,this);
\ No newline at end of file