--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/skin/resources/js/jquery-canvasAreaDraw.js Fri Jan 20 15:40:59 2017 +0100
@@ -0,0 +1,273 @@
+(function ($) {
+
+ $.fn.canvasAreaDraw = function (options) {
+
+ this.each(function (index, element) {
+ init.apply(element, [index, element, options]);
+ });
+
+ }
+
+ var init = function (index, input, options) {
+
+ var points, activePoint, settings;
+ var $reset, $canvas, ctx, image;
+ var draw, mousedown, stopdrag, move, moveall, resize, reset, rightclick, record;
+ var dragpoint;
+ var startpoint = false;
+
+ settings = $.extend({
+ imageUrl: $(this).attr('data-image-url')
+ }, options);
+
+ var v = $(input).val().replace(/[^0-9\,]/ig, '');
+ if (v.length) {
+ points = v.split(',').map(function (point) {
+ return parseInt(point, 10);
+ });
+ } else {
+ points = [];
+ }
+
+ // $reset = $('<button type="button" class="btn"><i class="icon-trash"></i>Очистить</button>');
+ $reset = $('<i class="fa fa-fw fa-trash"></i>');
+ $canvas = $('<canvas>');
+ ctx = $canvas[0].getContext('2d');
+
+ image = new Image();
+ resize = function () {
+ $canvas.attr('height', image.height).attr('width', image.width);
+ draw();
+ };
+ $(image).load(resize);
+ image.src = settings.imageUrl;
+ if (image.loaded) {
+ resize();
+ }
+ $canvas.css({background: 'url(' + image.src + ')'});
+
+ if (input.type !== 'hidden') {
+ $(input).after('<br />');
+ }
+ $(input).after($canvas, '<br />', $reset);
+
+ reset = function () {
+ points = [];
+ draw();
+ };
+
+ move = function (e) {
+ if (!e.offsetX) {
+ e.offsetX = (e.pageX - $(e.target).offset().left);
+ e.offsetY = (e.pageY - $(e.target).offset().top);
+ }
+ points[activePoint] = Math.round(e.offsetX);
+ points[activePoint + 1] = Math.round(e.offsetY);
+ draw();
+ };
+
+ moveall = function (e) {
+ if (!e.offsetX) {
+ e.offsetX = (e.pageX - $(e.target).offset().left);
+ e.offsetY = (e.pageY - $(e.target).offset().top);
+ }
+ if (!startpoint) {
+ startpoint = {x: Math.round(e.offsetX), y: Math.round(e.offsetY)};
+ }
+ var sdvpoint = {x: Math.round(e.offsetX), y: Math.round(e.offsetY)};
+ for (var i = 0; i < points.length; i++) {
+ points[i] = (sdvpoint.x - startpoint.x) + points[i];
+ points[++i] = (sdvpoint.y - startpoint.y) + points[i];
+ }
+ startpoint = sdvpoint;
+ draw();
+ };
+
+ stopdrag = function () {
+ $(this).off('mousemove');
+ record();
+ activePoint = null;
+ };
+
+ rightclick = function (e) {
+ e.preventDefault();
+ if (!e.offsetX) {
+ e.offsetX = (e.pageX - $(e.target).offset().left);
+ e.offsetY = (e.pageY - $(e.target).offset().top);
+ }
+ var x = e.offsetX, y = e.offsetY;
+ for (var i = 0; i < points.length; i += 2) {
+ dis = Math.sqrt(Math.pow(x - points[i], 2) + Math.pow(y - points[i + 1], 2));
+ if (dis < 6) {
+ points.splice(i, 2);
+ draw();
+ record();
+ return false;
+ }
+ }
+ return false;
+ };
+
+ mousedown = function (e) {
+ var x, y, dis, lineDis, insertAt = points.length;
+
+ if (e.which === 3) {
+ return false;
+ }
+
+ e.preventDefault();
+ if (!e.offsetX) {
+ e.offsetX = (e.pageX - $(e.target).offset().left);
+ e.offsetY = (e.pageY - $(e.target).offset().top);
+ }
+ x = e.offsetX;
+ y = e.offsetY;
+
+ if (points.length >= 6) {
+ var c = getCenter();
+ ctx.fillRect(c.x - 4, c.y - 4, 8, 8);
+ dis = Math.sqrt(Math.pow(x - c.x, 2) + Math.pow(y - c.y, 2));
+ if (dis < 6) {
+ startpoint = false;
+ $(this).on('mousemove', moveall);
+ return false;
+ }
+ }
+
+ for (var i = 0; i < points.length; i += 2) {
+ dis = Math.sqrt(Math.pow(x - points[i], 2) + Math.pow(y - points[i + 1], 2));
+ if (dis < 6) {
+ activePoint = i;
+ $(this).on('mousemove', move);
+ return false;
+ }
+ }
+
+ for (var i = 0; i < points.length; i += 2) {
+ if (i > 1) {
+ lineDis = dotLineLength(
+ x, y,
+ points[i], points[i + 1],
+ points[i - 2], points[i - 1],
+ true
+ );
+ if (lineDis < 6) {
+ insertAt = i;
+ }
+ }
+ }
+
+ points.splice(insertAt, 0, Math.round(x), Math.round(y));
+ activePoint = insertAt;
+ $(this).on('mousemove', move);
+
+ draw();
+ record();
+
+ return false;
+ };
+
+ draw = function () {
+ ctx.canvas.width = ctx.canvas.width;
+
+ record();
+ if (points.length < 2) {
+ return;
+ }
+ ctx.globalCompositeOperation = 'destination-over';
+ ctx.fillStyle = 'rgb(255,255,255)';
+ ctx.strokeStyle = 'rgb(255,20,20)';
+ ctx.lineWidth = 1;
+ if (points.length >= 6) {
+ var c = getCenter();
+ ctx.fillRect(c.x - 4, c.y - 4, 8, 8);
+ }
+ ctx.beginPath();
+ ctx.moveTo(points[0], points[1]);
+ for (var i = 0; i < points.length; i += 2) {
+ ctx.fillRect(points[i] - 2, points[i + 1] - 2, 4, 4);
+ ctx.strokeRect(points[i] - 2, points[i + 1] - 2, 4, 4);
+ if (points.length > 2 && i > 1) {
+ ctx.lineTo(points[i], points[i + 1]);
+ }
+ }
+ ctx.closePath();
+ ctx.fillStyle = 'rgba(255,0,0,0.3)';
+ ctx.fill();
+ ctx.stroke();
+
+ };
+
+ record = function () {
+ $(input).val(points.join(','));
+ };
+
+ getCenter = function () {
+ var ptc = [];
+ for (i = 0; i < points.length; i++) {
+ ptc.push({x: points[i], y: points[++i]});
+ }
+ var first = ptc[0], last = ptc[ptc.length - 1];
+ if (first.x != last.x || first.y != last.y) ptc.push(first);
+ var twicearea = 0,
+ x = 0, y = 0,
+ nptc = ptc.length,
+ p1, p2, f;
+ for (var i = 0, j = nptc - 1; i < nptc; j = i++) {
+ p1 = ptc[i];
+ p2 = ptc[j];
+ f = p1.x * p2.y - p2.x * p1.y;
+ twicearea += f;
+ x += ( p1.x + p2.x ) * f;
+ y += ( p1.y + p2.y ) * f;
+ }
+ f = twicearea * 3;
+ return {x: x / f, y: y / f};
+ };
+
+ $(input).on('change', function () {
+ var v = $(input).val().replace(/[^0-9\,]/ig, '');
+ if (v.length) {
+ points = v.split(',').map(function (point) {
+ return parseInt(point, 10);
+ });
+ } else {
+ points = [];
+ }
+ draw();
+ });
+
+ $(document).find($reset).click(reset);
+ $(document).find($canvas).on('mousedown', mousedown);
+ $(document).find($canvas).on('contextmenu', rightclick);
+ $(document).find($canvas).on('mouseup', stopdrag);
+
+ };
+
+ $(document).ready(function () {
+ $('.canvas-area[data-image-url]').canvasAreaDraw();
+ });
+
+ var dotLineLength = function (x, y, x0, y0, x1, y1, o) {
+ function lineLength(x, y, x0, y0) {
+ return Math.sqrt((x -= x0) * x + (y -= y0) * y);
+ }
+
+ if (o && !(o = function (x, y, x0, y0, x1, y1) {
+ if (!(x1 - x0)) return {x: x0, y: y};
+ else if (!(y1 - y0)) return {x: x, y: y0};
+ var left, tg = -1 / ((y1 - y0) / (x1 - x0));
+ return {
+ x: left = (x1 * (x * tg - y + y0) + x0 * (x * -tg + y - y1)) / (tg * (x1 - x0) + y0 - y1),
+ y: tg * left - tg * x + y
+ };
+ }(x, y, x0, y0, x1, y1), o.x >= Math.min(x0, x1) && o.x <= Math.max(x0, x1) && o.y >= Math.min(y0, y1) && o.y <= Math.max(y0, y1))) {
+ var l1 = lineLength(x, y, x0, y0), l2 = lineLength(x, y, x1, y1);
+ return l1 > l2 ? l2 : l1;
+ }
+ else {
+ var a = y0 - y1, b = x1 - x0, c = x0 * y1 - y0 * x1;
+ return Math.abs(a * x + b * y + c) / Math.sqrt(a * a + b * b);
+ }
+ };
+})(jQuery);
--- a/src/pyams_content/skin/resources/js/pyams_content.min.js Fri Jan 20 15:39:58 2017 +0100
+++ b/src/pyams_content/skin/resources/js/pyams_content.min.js Fri Jan 20 15:40:59 2017 +0100
@@ -1,1 +1,1 @@
-(function(c,b){var e=b.MyAMS;var d={TinyMCE:{initEditor:function(f){f.image_list=d.TinyMCE.getImagesList;f.link_list=d.TinyMCE.getLinksList;return f},getImagesList:function(f){return e.ajax.post("get-images-list.json",{},f)},getLinksList:function(f){return e.ajax.post("get-links-list.json",{},f)}},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")}})}},extfiles:{refresh:function(g){if(typeof(g)==="string"){g=JSON.parse(g)}var f=c('select[name="form.widgets.files:list"]');var h=f.data("select2");c("<option></option>").attr("value",g.new_file.id).attr("selected","selected").text(g.new_file.text).appendTo(f);var i=f.select2("data");i.push(g.new_file);f.select2("data",i);h.results.empty();h.opts.populateResults.call(h,h.results,g.files,{term:""})},refreshContainer:function(h){var f=c('tr[data-ams-element-name="'+h.object_name+'"]');var g=c("span.count",c("div.action.extfiles",f));if(h.nb_files>0){g.text("("+h.nb_files+")")}else{g.text("")}}},links:{refresh:function(g){if(typeof(g)==="string"){g=JSON.parse(g)}var f=c('select[name="form.widgets.links:list"]');var h=f.data("select2");c("<option></option>").attr("value",g.new_link.id).attr("selected","selected").text(g.new_link.text).appendTo(f);var i=f.select2("data");i.push(g.new_link);f.select2("data",i);h.results.empty();h.opts.populateResults.call(h,h.results,g.links,{term:""})},refreshContainer:function(h){var f=c('tr[data-ams-element-name="'+h.object_name+'"]');var g=c("span.count",c("div.action.links",f));if(h.nb_links>0){g.text("("+h.nb_links+")")}else{g.text("")}}},galleries:{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> '+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("")}}},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);if(h.visible){c("i",c("td.switcher",f)).removeClass("fa-eye-slash text-danger").addClass("fa-eye")}else{c("i",c("td.switcher",f)).removeClass("fa-eye").addClass("fa-eye-slash text-danger")}c("span.title",f).text(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")}}},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"paragraph":d.paragraphs.refreshParagraph(f);break;case"extfiles_container":d.extfiles.refreshContainer(f);break;case"links_container":d.links.refreshContainer(f);break;case"galleries_container":d.galleries.refreshContainer(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={TinyMCE:{initEditor:function(f){f.image_list=d.TinyMCE.getImagesList;f.link_list=d.TinyMCE.getLinksList;return f},getImagesList:function(f){return e.ajax.post("get-images-list.json",{},f)},getLinksList:function(f){return e.ajax.post("get-links-list.json",{},f)}},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")}})}},extfiles:{refresh:function(g){if(typeof(g)==="string"){g=JSON.parse(g)}var f=c('select[name="form.widgets.files:list"]');var h=f.data("select2");c("<option></option>").attr("value",g.new_file.id).attr("selected","selected").text(g.new_file.text).appendTo(f);var i=f.select2("data");i.push(g.new_file);f.select2("data",i);h.results.empty();h.opts.populateResults.call(h,h.results,g.files,{term:""})},refreshContainer:function(h){var f=c('tr[data-ams-element-name="'+h.object_name+'"]');var g=c("span.count",c("div.action.extfiles",f));if(h.nb_files>0){g.text("("+h.nb_files+")")}else{g.text("")}}},links:{init:function(){function g(j,h){var i=f.data("select2");i.results.empty();i.opts.populateResults.call(i,i.results,j,{term:""})}var f=c(this);e.ajax.post("get-links.json",{keyFieldName:"id",valueFieldName:"text"},g)},refresh:function(g){if(typeof(g)==="string"){g=JSON.parse(g)}var f=c('input[name="form.widgets.link"], select[name="form.widgets.links:list"]');var h=f.data("select2");if(f.attr("type")==="select"){c("<option></option>").attr("value",g.new_link.id).attr("selected","selected").text(g.new_link.text).appendTo(f)}var i;if(f.prop("multiple")){i=f.select2("data");i.push(g.new_link);f.select2("data",i);h.results.empty();h.opts.populateResults.call(h,h.results,g.links,{term:""})}else{f.select2("data",[g.new_link]);h.results.empty();h.opts.populateResults.call(h,h.results,g.links,{term:""});f.val(g.new_link.id)}},refreshContainer:function(h){var f=c('tr[data-ams-element-name="'+h.object_name+'"]');var g=c("span.count",c("div.action.links",f));if(h.nb_links>0){g.text("("+h.nb_links+")")}else{g.text("")}}},galleries:{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> '+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")})})}},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);if(h.visible){c("i",c("td.switcher",f)).removeClass("fa-eye-slash text-danger").addClass("fa-eye")}else{c("i",c("td.switcher",f)).removeClass("fa-eye").addClass("fa-eye-slash text-danger")}c("span.title",f).text(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")}}},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"paragraph":d.paragraphs.refreshParagraph(f);break;case"extfiles_container":d.extfiles.refreshContainer(f);break;case"links_container":d.links.refreshContainer(f);break;case"galleries_container":d.galleries.refreshContainer(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