--- a/src/pyams_content/skin/resources/js/pyams_content.js Wed Nov 15 17:29:30 2017 +0100
+++ b/src/pyams_content/skin/resources/js/pyams_content.js Sun Nov 26 09:49:57 2017 +0100
@@ -7,25 +7,25 @@
var PyAMS_content = {
/**
- * Replace given form with new content
+ * Custom widgets management
*/
- refreshForm: function(changes) {
- var parent = $('#' + changes.object_name);
- parent.replaceWith($(changes.form));
- parent = $('#' + changes.object_name);
- MyAMS.initContent(parent);
- return parent;
+ widget: {
+
+ /** Treeview widget */
+ treeview: {
+
+ selectFolder: function(event, node) {
+ var target = $(event.target);
+ target.siblings('input[type="hidden"]').val(node.id);
+ },
+
+ unselectFolder: function(event, node) {
+ var target = $(event.target);
+ target.siblings('input[type="hidden"]').val(null);
+ }
+ }
},
- refreshTable: function(changes) {
- var widget = $('#' + changes.object_name).parent('.ams-widget');
- widget.replaceWith($(changes.table));
- widget = $('#' + changes.object_name).parent('.ams-widget');
- MyAMS.initContent(widget);
- return widget;
- },
-
-
/**
* TinyMCE editor configuration
*/
@@ -57,28 +57,6 @@
},
/**
- * User profile management
- */
- profile: {
-
- switchFavorite: function() {
- var star = $(this);
- var oid = star.data('sequence-oid');
- MyAMS.ajax.post('switch-user-favorite.json',
- {oid: oid},
- function(result, status) {
- if (result.favorite) {
- star.removeClass('fa-star-o')
- .addClass('fa-star');
- } else {
- star.removeClass('fa-star')
- .addClass('fa-star-o');
- }
- });
- }
- },
-
- /**
* Galleries management
*/
galleries: {
@@ -147,38 +125,20 @@
}
},
-
/**
- * Image map management
+ * Illustrations management
*/
- imgmap: {
+ illustration: {
- init: function() {
- var image = $(this);
- MyAMS.ajax.check($.fn.canvasAreaDraw,
- '/--static--/pyams_content/js/jquery-canvasAreaDraw' + MyAMS.devext + '.js',
- function() {
- image.canvasAreaDraw({imageUrl: image.data('ams-image-url')});
- });
- },
-
- initSummary: function() {
- var image = $(this);
- MyAMS.ajax.check($.fn.mapster,
- '/--static--/pyams_content/js/jquery-imagemapster-1.2.10' + MyAMS.devext + '.js',
- function() {
- image.mapster({
- fillColor: 'ff0000',
- fillOpacity: 0.35,
- selected: true,
- highlight: true,
- staticState: true
- });
- });
+ addIllustration: function() {
+ var source = $(this);
+ var group = source.parents('.btn-group');
+ var legend = group.siblings('legend.switcher');
+ $('i.fa-plus', legend).click();
+ source.hide();
}
},
-
/**
* Associations management
*/
@@ -186,7 +146,7 @@
refreshAssociations: function(options) {
// Reload widget
- var widget = PyAMS_content.refreshTable(options);
+ var widget = MyAMS.skin.refreshTable(options);
// Check fieldset state
var legend = widget.siblings('legend');
if (legend.parents('fieldset:first').hasClass('switched')) {
@@ -212,46 +172,6 @@
}
},
-
- /**
- * Types management
- */
- types: {
-
- switchSubtypes: function(element) {
- var source = $(this);
- var switcher = $('i.switch', source);
- var td = source.parents('td');
- var subtypes = $('.subtypes', td);
- var datatype = source.parents('tr');
- if (switcher.hasClass('fa-plus-square-o')) {
- var container = datatype.parents('table');
- subtypes.html('<h1 class="loading"><i class="fa fa-2x fa-gear fa-spin"></i></h1>');
- MyAMS.ajax.post(container.data('ams-location') + '/get-subtypes-table.json',
- {object_name: datatype.data('ams-element-name')},
- function(result) {
- subtypes.html(result);
- if (result) {
- MyAMS.initContent(subtypes);
- switcher.removeClass('fa-plus-square-o')
- .addClass('fa-minus-square-o');
- }
- });
- } else {
- MyAMS.skin.cleanContainer(subtypes);
- subtypes.empty();
- switcher.removeClass('fa-minus-square-o')
- .addClass('fa-plus-square-o');
- }
- },
-
- refreshSubtypes: function(options) {
- // Reload widget
- PyAMS_content.refreshTable(options);
- }
- },
-
-
/**
* Paragraphs management
*/
@@ -264,7 +184,7 @@
postReload: function() {
$(PyAMS_content.paragraphs.switched).each(function() {
- $('i.switch.fa-plus-square-o', '[id="' + this + '"]').parents('div:first').click();
+ $('i.switch.fa-plus-square-o', '[id="' + this + '"]').parents('div').first().click();
});
delete PyAMS_content.paragraphs.switched;
},
@@ -288,7 +208,7 @@
refreshParagraphs: function(options) {
// Reload widget
- var widget = PyAMS_content.refreshTable(options);
+ var widget = MyAMS.skin.refreshTable(options);
// Check fieldset state
var legend = widget.siblings('legend');
if (legend.parents('fieldset:first').hasClass('switched')) {
@@ -398,52 +318,6 @@
}
},
-
- /**
- * Illustrations management
- */
- illustration: {
-
- addIllustration: function() {
- var source = $(this);
- var group = source.parents('.btn-group');
- var legend = group.siblings('legend.switcher');
- $('i.fa-plus', legend).click();
- source.hide();
- }
- },
-
-
- /**
- * Form fields management
- */
- fields: {
-
- refreshField: function(changes) {
- var container = $('table[id="form_fields_list"]');
- var para = $('tr[data-ams-element-name="' + changes.object_name + '"]', container);
- $('td:nth-child(4)', para).html(changes.title);
- },
-
- switchVisibility: function (element) {
- return function () {
- var source = $(this);
- var association = source.parents('tr');
- var container = association.parents('table');
- MyAMS.ajax.post(container.data('ams-location') + '/set-form-field-visibility.json',
- {object_name: association.data('ams-element-name')},
- function (result, status) {
- if (result.visible) {
- $('i', source).attr('class', 'fa fa-fw fa-eye');
- } else {
- $('i', source).attr('class', 'fa fa-fw fa-eye-slash text-danger');
- }
- });
- };
- }
- },
-
-
/**
* Themes management
*/
@@ -490,6 +364,97 @@
}
},
+ /**
+ * Form fields management
+ */
+ fields: {
+
+ refreshField: function(changes) {
+ var container = $('table[id="form_fields_list"]');
+ var para = $('tr[data-ams-element-name="' + changes.object_name + '"]', container);
+ $('td:nth-child(4)', para).html(changes.title);
+ },
+
+ switchVisibility: function (element) {
+ return function () {
+ var source = $(this);
+ var association = source.parents('tr');
+ var container = association.parents('table');
+ MyAMS.ajax.post(container.data('ams-location') + '/set-form-field-visibility.json',
+ {object_name: association.data('ams-element-name')},
+ function (result, status) {
+ if (result.visible) {
+ $('i', source).attr('class', 'fa fa-fw fa-eye');
+ } else {
+ $('i', source).attr('class', 'fa fa-fw fa-eye-slash text-danger');
+ }
+ });
+ };
+ }
+ },
+
+ /**
+ * Image map management
+ */
+ imgmap: {
+
+ init: function() {
+ var image = $(this);
+ MyAMS.ajax.check($.fn.canvasAreaDraw,
+ '/--static--/pyams_content/js/jquery-canvasAreaDraw' + MyAMS.devext + '.js',
+ function() {
+ image.canvasAreaDraw({imageUrl: image.data('ams-image-url')});
+ });
+ },
+
+ initSummary: function() {
+ var image = $(this);
+ MyAMS.ajax.check($.fn.mapster,
+ '/--static--/pyams_content/js/jquery-imagemapster-1.2.10' + MyAMS.devext + '.js',
+ function() {
+ image.mapster({
+ fillColor: 'ff0000',
+ fillOpacity: 0.35,
+ selected: true,
+ highlight: true,
+ staticState: true
+ });
+ });
+ }
+ },
+
+ /**
+ * Types management
+ */
+ types: {
+
+ switchSubtypes: function(element) {
+ var source = $(this);
+ var switcher = $('i.switch', source);
+ var td = source.parents('td');
+ var subtypes = $('.subtypes', td);
+ var datatype = source.parents('tr');
+ if (switcher.hasClass('fa-plus-square-o')) {
+ var container = datatype.parents('table');
+ subtypes.html('<h1 class="loading"><i class="fa fa-2x fa-gear fa-spin"></i></h1>');
+ MyAMS.ajax.post(container.data('ams-location') + '/get-subtypes-table.json',
+ {object_name: datatype.data('ams-element-name')},
+ function(result) {
+ subtypes.html(result);
+ if (result) {
+ MyAMS.initContent(subtypes);
+ switcher.removeClass('fa-plus-square-o')
+ .addClass('fa-minus-square-o');
+ }
+ });
+ } else {
+ MyAMS.skin.cleanContainer(subtypes);
+ subtypes.empty();
+ switcher.removeClass('fa-minus-square-o')
+ .addClass('fa-plus-square-o');
+ }
+ }
+ },
/**
* Review comments management
@@ -570,19 +535,37 @@
chat.animate({scrollTop: chat[0].scrollHeight}, 1000);
$('.badge', 'nav a[href="#review-comments.html"]').text(options.count).removeClass('hidden');
}
+ },
+
+ /**
+ * User profile management
+ */
+ profile: {
+
+ switchFavorite: function() {
+ var star = $(this);
+ var oid = star.data('sequence-oid');
+ MyAMS.ajax.post('switch-user-favorite.json',
+ {oid: oid},
+ function(result, status) {
+ if (result.favorite) {
+ star.removeClass('fa-star-o')
+ .addClass('fa-star');
+ } else {
+ star.removeClass('fa-star')
+ .addClass('fa-star-o');
+ }
+ });
+ }
}
};
- globals.PyAMS_content = PyAMS_content;
-
- $(globals.document).on('PyAMS_content.changed_item', function(event, settings) {
- MyAMS.executeFunctionByName(settings.handler, document, settings);
- });
-
var badge = $('.badge', 'nav a[href="#review-comments.html"]');
if (badge.exists()) {
PyAMS_content.review.timer = setInterval(PyAMS_content.review.updateComments,
PyAMS_content.review.timer_duration.general);
}
+ globals.PyAMS_content = PyAMS_content;
+
})(jQuery, this);
--- a/src/pyams_content/skin/resources/js/pyams_content.min.js Wed Nov 15 17:29:30 2017 +0100
+++ b/src/pyams_content/skin/resources/js/pyams_content.min.js Sun Nov 26 09:49:57 2017 +0100
@@ -1,1 +1,1 @@
-!function(a,e){"use strict";var t=e.MyAMS,s={refreshForm:function(e){var s=a("#"+e.object_name);return s.replaceWith(a(e.form)),s=a("#"+e.object_name),t.initContent(s),s},refreshTable:function(e){var s=a("#"+e.object_name).parent(".ams-widget");return s.replaceWith(a(e.table)),s=a("#"+e.object_name).parent(".ams-widget"),t.initContent(s),s},TinyMCE:{initEditor:function(a){return a.image_list=s.TinyMCE.getImagesList,a.link_list=s.TinyMCE.getLinksList,a},getImagesList:function(e){var s=a(document.activeElement).parents("form");if(s.exists()){var n=s.attr("data-ams-form-handler")||s.attr("action"),i=n.substr(0,n.lastIndexOf("/")+1);return t.ajax.post(i+"get-images-list.json",{},e)}},getLinksList:function(e){var s=a(document.activeElement).parents("form");if(s.exists()){var n=s.attr("data-ams-form-handler")||s.attr("action"),i=n.substr(0,n.lastIndexOf("/")+1);return t.ajax.post(i+"get-links-list.json",{},e)}}},profile:{switchFavorite:function(){var e=a(this),s=e.data("sequence-oid");t.ajax.post("switch-user-favorite.json",{oid:s},function(a,t){a.favorite?e.removeClass("fa-star-o").addClass("fa-star"):e.removeClass("fa-star").addClass("fa-star-o")})}},galleries:{updateImageTitle:function(e){a('img[id="'+e.image_id+'"]').attr("original-title",e.title)},switchImageVisibility:function(e){return function(){var e=a(this),s=e.parents(".image"),n=s.parents(".gallery");t.ajax.post(n.data("ams-location")+"/set-image-visibility.json",{object_name:s.data("ams-element-name")},function(t,s){t.visible?(a("i",e).attr("class","fa fa-fw fa-eye"),e.parents(".btn-group").siblings("a.fancyimg").removeClass("not-visible")):(a("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,s){if(!s||!s.item.hasClass("already-dropped")){var n=s.item.parents(".gallery"),i=a(".image",n).listattr("data-ams-element-name");t.ajax.post(n.data("ams-location")+"/set-images-order.json",{images:JSON.stringify(i)})}},removeFile:function(e){return function(){var e=a(this);t.skin.bigBox({title:t.i18n.WARNING,content:'<i class="text-danger fa fa-2x fa-bell shake animated"></i> '+t.i18n.DELETE_WARNING,buttons:t.i18n.BTN_OK_CANCEL},function(a){if(a===t.i18n.BTN_OK){var s=e.parents(".gallery").data("ams-location"),n=e.parents(".image"),i=n.data("ams-element-name");t.ajax.post(s+"/delete-element.json",{object_name:i},function(a,e){n.remove()})}})}},afterFancyboxLoad:function(a,e){a.element.hasClass("not-visible")&&a.inner.prepend('<div class="hidden-mask"></div>')}},imgmap:{init:function(){var e=a(this);t.ajax.check(a.fn.canvasAreaDraw,"/--static--/pyams_content/js/jquery-canvasAreaDraw"+t.devext+".js",function(){e.canvasAreaDraw({imageUrl:e.data("ams-image-url")})})},initSummary:function(){var e=a(this);t.ajax.check(a.fn.mapster,"/--static--/pyams_content/js/jquery-imagemapster-1.2.10"+t.devext+".js",function(){e.mapster({fillColor:"ff0000",fillOpacity:.35,selected:!0,highlight:!0,staticState:!0})})}},associations:{refreshAssociations:function(a){var e=s.refreshTable(a).siblings("legend");e.parents("fieldset:first").hasClass("switched")&&e.click()},switchVisibility:function(e){return function(){var e=a(this),s=e.parents("tr"),n=s.parents("table");t.ajax.post(n.data("ams-location")+"/set-association-visibility.json",{object_name:s.data("ams-element-name")},function(t,s){t.visible?a("i",e).attr("class","fa fa-fw fa-eye"):a("i",e).attr("class","fa fa-fw fa-eye-slash text-danger")})}}},types:{switchSubtypes:function(e){var s=a(this),n=a("i.switch",s),i=s.parents("td"),r=a(".subtypes",i),o=s.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>'),t.ajax.post(l.data("ams-location")+"/get-subtypes-table.json",{object_name:o.data("ams-element-name")},function(a){r.html(a),a&&(t.initContent(r),n.removeClass("fa-plus-square-o").addClass("fa-minus-square-o"))})}else t.skin.cleanContainer(r),r.empty(),n.removeClass("fa-minus-square-o").addClass("fa-plus-square-o")},refreshSubtypes:function(a){s.refreshTable(a)}},paragraphs:{preReload:function(){s.paragraphs.switched=a("i.switch.fa-minus-square-o","#paragraphs_list").parents("tr").listattr("id")},postReload:function(){a(s.paragraphs.switched).each(function(){a("i.switch.fa-plus-square-o",'[id="'+this+'"]').parents("div:first").click()}),delete s.paragraphs.switched},switchVisibility:function(e){return function(){var e=a(this),s=e.parents("tr"),n=s.parents("table");t.ajax.post(n.data("ams-location")+"/set-paragraph-visibility.json",{object_name:s.data("ams-element-name")},function(t,s){t.visible?a("i",e).attr("class","fa fa-fw fa-eye"):a("i",e).attr("class","fa fa-fw fa-eye-slash text-danger")})}},refreshParagraphs:function(a){var e=s.refreshTable(a).siblings("legend");e.parents("fieldset:first").hasClass("switched")&&e.click()},refreshParagraph:function(e){var t=a('table[id="paragraphs_list"]'),s=a('tr[data-ams-element-name="'+e.object_name+'"]',t);a("span.title",s).html(e.title||" - - - - - - - -")},switchEditor:function(e){var s=a(this),n=a("i.switch",s),i=s.parents("td"),r=a(".editor",i),o=s.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>'),t.ajax.post(l.data("ams-location")+"/get-paragraph-editor.json",{object_name:o.data("ams-element-name")},function(a){r.html(a),a&&(t.initContent(r),n.removeClass("fa-plus-square-o").addClass("fa-minus-square-o"),o.data("ams-disabled-handlers",!0))})}else t.skin.cleanContainer(r),r.empty(),n.removeClass("fa-minus-square-o").addClass("fa-plus-square-o"),o.removeData("ams-disabled-handlers")},switchAllEditors:function(e){var s=a(this),n=a("i",s),i=s.parents("table");n.hasClass("fa-plus-square-o")?(n.removeClass("fa-plus-square-o").addClass("fa-cog fa-spin"),t.ajax.post(i.data("ams-location")+"/get-paragraphs-editors.json",{},function(e){for(var s in e)if(e.hasOwnProperty(s)){var r=a('tr[data-ams-element-name="'+s+'"]',i),o=a(".editor",r);o.is(":empty")&&(o.html(e[s]),t.initContent(o)),a(".fa-plus-square-o",r).removeClass("fa-plus-square-o").addClass("fa-minus-square-o"),r.data("ams-disabled-handlers",!0)}a("i.fa-plus-square-o",a("tbody",i)).exists()||n.removeClass("fa-cog fa-spin").addClass("fa-minus-square-o")})):(a(".editor",i).each(function(){t.skin.cleanContainer(a(this)),a(this).empty()}),a(".fa-minus-square-o",i).removeClass("fa-minus-square-o").addClass("fa-plus-square-o"),a("tr",i).removeData("ams-disabled-handlers"))},updateToolbar:function(e){var s=a('table[id="paragraphs_list"]'),n=a('tr[data-ams-element-name="'+e.object_name+'"]',s),i=a(".title-toolbar",n);i.replaceWith(e.toolbar_tag),i=a(".title-toolbar",n),t.initContent(i)},updateMarkers:function(e){var s=a('table[id="paragraphs_list"]'),n=a('tr[data-ams-element-name="'+e.object_name+'"]',s),i=a(".title-toolbar",n),r=a("DIV.action."+e.marker_type,i);r.exists()?r.replaceWith(e.marker_tag):a(e.marker_tag).appendTo(i),e.marker_tag&&(r=a("DIV.action."+e.marker_type,i),t.initContent(r)),t.helpers.sort(i,"weight")}},illustration:{addIllustration:function(){var e=a(this),t=e.parents(".btn-group").siblings("legend.switcher");a("i.fa-plus",t).click(),e.hide()}},fields:{refreshField:function(e){var t=a('table[id="form_fields_list"]'),s=a('tr[data-ams-element-name="'+e.object_name+'"]',t);a("td:nth-child(4)",s).html(e.title)},switchVisibility:function(e){return function(){var e=a(this),s=e.parents("tr"),n=s.parents("table");t.ajax.post(n.data("ams-location")+"/set-form-field-visibility.json",{object_name:s.data("ams-element-name")},function(t,s){t.visible?a("i",e).attr("class","fa fa-fw fa-eye"):a("i",e).attr("class","fa fa-fw fa-eye-slash text-danger")})}}},themes:{initExtracts:function(e){var s=a('select[name="form.widgets.thesaurus_name:list"]',e).val(),n=a('select[name="form.widgets.extract_name:list"]',e),i=n.val();s&&t.jsonrpc.post("getExtracts",{thesaurus_name:s},{url:"/api/thesaurus/json"},function(e){n.empty(),a(e.result).each(function(){a("<option></option>").attr("value",this.id).attr("selected",this.id===i).text(this.text).appendTo(n)})}),n.attr("data-ams-events-handlers",'{"select2-open": "PyAMS_content.themes.getExtracts"}')},getExtracts:function(e){var s=a(e.currentTarget).parents("form"),n=a('select[name="form.widgets.thesaurus_name:list"]',s).val();n&&t.jsonrpc.post("getExtracts",{thesaurus_name:n},{url:"/api/thesaurus/json"},function(e){var t=a('select[name="form.widgets.extract_name:list"]',s).data("select2");t.results.empty(),t.opts.populateResults.call(t,t.results,e.result,{term:""})})}},review:{timer:null,timer_duration:{general:3e4,chat:5e3},initComments:function(e){var n=a(".chat-body",e);n.animate({scrollTop:n[0].scrollHeight},1e3),clearInterval(s.review.timer),s.review.timer=setInterval(s.review.updateComments,s.review.timer_duration.chat),t.skin.registerCleanCallback(s.review.cleanCommentsCallback)},cleanCommentsCallback:function(){clearInterval(s.review.timer),s.review.timer=setInterval(s.review.updateComments,s.review.timer_duration.general)},updateComments:function(){var e,s=a(".badge",'nav a[href="#review-comments.html"]'),n=a(".chat-body",".widget-body");e=n.exists()?a(".message",n).length:parseInt(s.text()),t.ajax.post("get-last-review-comments.json",{count:e},function(t){n.exists()&&s.removeClass("bg-color-danger").addClass("bg-color-info"),e!==t.count&&(s.text(t.count).removeClass("hidden"),n.exists()&&(a(".messages",n).append(t.content),n.animate({scrollTop:n[0].scrollHeight},1e3)),n.exists()||s.removeClass("bg-color-info").addClass("bg-color-danger").animate({padding:"3px 12px 2px","margin-right":"9px"},"slow",function(){a(this).animate({padding:"3px 6px 2px","margin-right":"15px"},"slow")}))})},initCommentData:function(e){var t=a(".chat-body",".widget-body");return{count:a(".message",t).length}},addCommentAction:function(){return function(){a('textarea[name="comment"]').focus()}},addCommentCallback:function(e){var t=a(this),s=t.parents(".widget-body");a(".messages",s).append(e.content),a('textarea[name="comment"]',t).val("");var n=a(".chat-body",s);n.animate({scrollTop:n[0].scrollHeight},1e3),a(".badge",'nav a[href="#review-comments.html"]').text(e.count).removeClass("hidden")}}};e.PyAMS_content=s,a(e.document).on("PyAMS_content.changed_item",function(a,e){t.executeFunctionByName(e.handler,document,e)}),a(".badge",'nav a[href="#review-comments.html"]').exists()&&(s.review.timer=setInterval(s.review.updateComments,s.review.timer_duration.general))}(jQuery,this);
+!function(a,t){"use strict";var e=t.MyAMS,s={widget:{treeview:{selectFolder:function(t,e){a(t.target).siblings('input[type="hidden"]').val(e.id)},unselectFolder:function(t,e){a(t.target).siblings('input[type="hidden"]').val(null)}}},TinyMCE:{initEditor:function(a){return a.image_list=s.TinyMCE.getImagesList,a.link_list=s.TinyMCE.getLinksList,a},getImagesList:function(t){var s=a(document.activeElement).parents("form");if(s.exists()){var i=s.attr("data-ams-form-handler")||s.attr("action"),n=i.substr(0,i.lastIndexOf("/")+1);return e.ajax.post(n+"get-images-list.json",{},t)}},getLinksList:function(t){var s=a(document.activeElement).parents("form");if(s.exists()){var i=s.attr("data-ams-form-handler")||s.attr("action"),n=i.substr(0,i.lastIndexOf("/")+1);return e.ajax.post(n+"get-links-list.json",{},t)}}},galleries:{updateImageTitle:function(t){a('img[id="'+t.image_id+'"]').attr("original-title",t.title)},switchImageVisibility:function(t){return function(){var t=a(this),s=t.parents(".image"),i=s.parents(".gallery");e.ajax.post(i.data("ams-location")+"/set-image-visibility.json",{object_name:s.data("ams-element-name")},function(e,s){e.visible?(a("i",t).attr("class","fa fa-fw fa-eye"),t.parents(".btn-group").siblings("a.fancyimg").removeClass("not-visible")):(a("i",t).attr("class","fa fa-fw fa-eye-slash text-danger"),t.parents(".btn-group").siblings("a.fancyimg").addClass("not-visible"))})}},setOrder:function(t,s){if(!s||!s.item.hasClass("already-dropped")){var i=s.item.parents(".gallery"),n=a(".image",i).listattr("data-ams-element-name");e.ajax.post(i.data("ams-location")+"/set-images-order.json",{images:JSON.stringify(n)})}},removeFile:function(t){return function(){var t=a(this);e.skin.bigBox({title:e.i18n.WARNING,content:'<i class="text-danger fa fa-2x fa-bell shake animated"></i> '+e.i18n.DELETE_WARNING,buttons:e.i18n.BTN_OK_CANCEL},function(a){if(a===e.i18n.BTN_OK){var s=t.parents(".gallery").data("ams-location"),i=t.parents(".image"),n=i.data("ams-element-name");e.ajax.post(s+"/delete-element.json",{object_name:n},function(a,t){i.remove()})}})}},afterFancyboxLoad:function(a,t){a.element.hasClass("not-visible")&&a.inner.prepend('<div class="hidden-mask"></div>')}},illustration:{addIllustration:function(){var t=a(this),e=t.parents(".btn-group").siblings("legend.switcher");a("i.fa-plus",e).click(),t.hide()}},associations:{refreshAssociations:function(a){var t=e.skin.refreshTable(a).siblings("legend");t.parents("fieldset:first").hasClass("switched")&&t.click()},switchVisibility:function(t){return function(){var t=a(this),s=t.parents("tr"),i=s.parents("table");e.ajax.post(i.data("ams-location")+"/set-association-visibility.json",{object_name:s.data("ams-element-name")},function(e,s){e.visible?a("i",t).attr("class","fa fa-fw fa-eye"):a("i",t).attr("class","fa fa-fw fa-eye-slash text-danger")})}}},paragraphs:{preReload:function(){s.paragraphs.switched=a("i.switch.fa-minus-square-o","#paragraphs_list").parents("tr").listattr("id")},postReload:function(){a(s.paragraphs.switched).each(function(){a("i.switch.fa-plus-square-o",'[id="'+this+'"]').parents("div").first().click()}),delete s.paragraphs.switched},switchVisibility:function(t){return function(){var t=a(this),s=t.parents("tr"),i=s.parents("table");e.ajax.post(i.data("ams-location")+"/set-paragraph-visibility.json",{object_name:s.data("ams-element-name")},function(e,s){e.visible?a("i",t).attr("class","fa fa-fw fa-eye"):a("i",t).attr("class","fa fa-fw fa-eye-slash text-danger")})}},refreshParagraphs:function(a){var t=e.skin.refreshTable(a).siblings("legend");t.parents("fieldset:first").hasClass("switched")&&t.click()},refreshParagraph:function(t){var e=a('table[id="paragraphs_list"]'),s=a('tr[data-ams-element-name="'+t.object_name+'"]',e);a("span.title",s).html(t.title||" - - - - - - - -")},switchEditor:function(t){var s=a(this),i=a("i.switch",s),n=s.parents("td"),r=a(".editor",n),o=s.parents("tr");if(i.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>'),e.ajax.post(l.data("ams-location")+"/get-paragraph-editor.json",{object_name:o.data("ams-element-name")},function(a){r.html(a),a&&(e.initContent(r),i.removeClass("fa-plus-square-o").addClass("fa-minus-square-o"),o.data("ams-disabled-handlers",!0))})}else e.skin.cleanContainer(r),r.empty(),i.removeClass("fa-minus-square-o").addClass("fa-plus-square-o"),o.removeData("ams-disabled-handlers")},switchAllEditors:function(t){var s=a(this),i=a("i",s),n=s.parents("table");i.hasClass("fa-plus-square-o")?(i.removeClass("fa-plus-square-o").addClass("fa-cog fa-spin"),e.ajax.post(n.data("ams-location")+"/get-paragraphs-editors.json",{},function(t){for(var s in t)if(t.hasOwnProperty(s)){var r=a('tr[data-ams-element-name="'+s+'"]',n),o=a(".editor",r);o.is(":empty")&&(o.html(t[s]),e.initContent(o)),a(".fa-plus-square-o",r).removeClass("fa-plus-square-o").addClass("fa-minus-square-o"),r.data("ams-disabled-handlers",!0)}a("i.fa-plus-square-o",a("tbody",n)).exists()||i.removeClass("fa-cog fa-spin").addClass("fa-minus-square-o")})):(a(".editor",n).each(function(){e.skin.cleanContainer(a(this)),a(this).empty()}),a(".fa-minus-square-o",n).removeClass("fa-minus-square-o").addClass("fa-plus-square-o"),a("tr",n).removeData("ams-disabled-handlers"))},updateToolbar:function(t){var s=a('table[id="paragraphs_list"]'),i=a('tr[data-ams-element-name="'+t.object_name+'"]',s),n=a(".title-toolbar",i);n.replaceWith(t.toolbar_tag),n=a(".title-toolbar",i),e.initContent(n)},updateMarkers:function(t){var s=a('table[id="paragraphs_list"]'),i=a('tr[data-ams-element-name="'+t.object_name+'"]',s),n=a(".title-toolbar",i),r=a("DIV.action."+t.marker_type,n);r.exists()?r.replaceWith(t.marker_tag):a(t.marker_tag).appendTo(n),t.marker_tag&&(r=a("DIV.action."+t.marker_type,n),e.initContent(r)),e.helpers.sort(n,"weight")}},themes:{initExtracts:function(t){var s=a('select[name="form.widgets.thesaurus_name:list"]',t).val(),i=a('select[name="form.widgets.extract_name:list"]',t),n=i.val();s&&e.jsonrpc.post("getExtracts",{thesaurus_name:s},{url:"/api/thesaurus/json"},function(t){i.empty(),a(t.result).each(function(){a("<option></option>").attr("value",this.id).attr("selected",this.id===n).text(this.text).appendTo(i)})}),i.attr("data-ams-events-handlers",'{"select2-open": "PyAMS_content.themes.getExtracts"}')},getExtracts:function(t){var s=a(t.currentTarget).parents("form"),i=a('select[name="form.widgets.thesaurus_name:list"]',s).val();i&&e.jsonrpc.post("getExtracts",{thesaurus_name:i},{url:"/api/thesaurus/json"},function(t){var e=a('select[name="form.widgets.extract_name:list"]',s).data("select2");e.results.empty(),e.opts.populateResults.call(e,e.results,t.result,{term:""})})}},fields:{refreshField:function(t){var e=a('table[id="form_fields_list"]'),s=a('tr[data-ams-element-name="'+t.object_name+'"]',e);a("td:nth-child(4)",s).html(t.title)},switchVisibility:function(t){return function(){var t=a(this),s=t.parents("tr"),i=s.parents("table");e.ajax.post(i.data("ams-location")+"/set-form-field-visibility.json",{object_name:s.data("ams-element-name")},function(e,s){e.visible?a("i",t).attr("class","fa fa-fw fa-eye"):a("i",t).attr("class","fa fa-fw fa-eye-slash text-danger")})}}},imgmap:{init:function(){var t=a(this);e.ajax.check(a.fn.canvasAreaDraw,"/--static--/pyams_content/js/jquery-canvasAreaDraw"+e.devext+".js",function(){t.canvasAreaDraw({imageUrl:t.data("ams-image-url")})})},initSummary:function(){var t=a(this);e.ajax.check(a.fn.mapster,"/--static--/pyams_content/js/jquery-imagemapster-1.2.10"+e.devext+".js",function(){t.mapster({fillColor:"ff0000",fillOpacity:.35,selected:!0,highlight:!0,staticState:!0})})}},types:{switchSubtypes:function(t){var s=a(this),i=a("i.switch",s),n=s.parents("td"),r=a(".subtypes",n),o=s.parents("tr");if(i.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>'),e.ajax.post(l.data("ams-location")+"/get-subtypes-table.json",{object_name:o.data("ams-element-name")},function(a){r.html(a),a&&(e.initContent(r),i.removeClass("fa-plus-square-o").addClass("fa-minus-square-o"))})}else e.skin.cleanContainer(r),r.empty(),i.removeClass("fa-minus-square-o").addClass("fa-plus-square-o")}},review:{timer:null,timer_duration:{general:3e4,chat:5e3},initComments:function(t){var i=a(".chat-body",t);i.animate({scrollTop:i[0].scrollHeight},1e3),clearInterval(s.review.timer),s.review.timer=setInterval(s.review.updateComments,s.review.timer_duration.chat),e.skin.registerCleanCallback(s.review.cleanCommentsCallback)},cleanCommentsCallback:function(){clearInterval(s.review.timer),s.review.timer=setInterval(s.review.updateComments,s.review.timer_duration.general)},updateComments:function(){var t,s=a(".badge",'nav a[href="#review-comments.html"]'),i=a(".chat-body",".widget-body");t=i.exists()?a(".message",i).length:parseInt(s.text()),e.ajax.post("get-last-review-comments.json",{count:t},function(e){i.exists()&&s.removeClass("bg-color-danger").addClass("bg-color-info"),t!==e.count&&(s.text(e.count).removeClass("hidden"),i.exists()&&(a(".messages",i).append(e.content),i.animate({scrollTop:i[0].scrollHeight},1e3)),i.exists()||s.removeClass("bg-color-info").addClass("bg-color-danger").animate({padding:"3px 12px 2px","margin-right":"9px"},"slow",function(){a(this).animate({padding:"3px 6px 2px","margin-right":"15px"},"slow")}))})},initCommentData:function(t){var e=a(".chat-body",".widget-body");return{count:a(".message",e).length}},addCommentAction:function(){return function(){a('textarea[name="comment"]').focus()}},addCommentCallback:function(t){var e=a(this),s=e.parents(".widget-body");a(".messages",s).append(t.content),a('textarea[name="comment"]',e).val("");var i=a(".chat-body",s);i.animate({scrollTop:i[0].scrollHeight},1e3),a(".badge",'nav a[href="#review-comments.html"]').text(t.count).removeClass("hidden")}},profile:{switchFavorite:function(){var t=a(this),s=t.data("sequence-oid");e.ajax.post("switch-user-favorite.json",{oid:s},function(a,e){a.favorite?t.removeClass("fa-star-o").addClass("fa-star"):t.removeClass("fa-star").addClass("fa-star-o")})}}};a(".badge",'nav a[href="#review-comments.html"]').exists()&&(s.review.timer=setInterval(s.review.updateComments,s.review.timer_duration.general)),t.PyAMS_content=s}(jQuery,this);