text: (function(){if(!window["BX"]||window["BX"]["MPLForm"]||!window["app"])return;var t=window["BX"],e={entityId:0,text:"",form:{},list:{},comments:{},commentExemplarId:{}},i=function(t,e){return t+"-"+(e>0?e:"0")};var n=function(i){e.text=t.type.isNotEmptyString(i)?i:"";if(t["localStorage"]&&e.entityId){var n=t.localStorage.get("main.post.list/text");n=n||{};if(t.type.isNotEmptyString(e.text)){n[e.entityId]=e.text}else{delete n[e.entityId]}t.localStorage.set("main.post.list/text",n)}},s=function(e){var i="";if(t["localStorage"]&&e){var n=t.localStorage.get("main.post.list/text");if(n){i=n[e]||"";delete n[e];t.localStorage.set("main.post.list/text",n)}}return i};t.addCustomEvent(window,"OnUCFormSubmit",function(){n("")});BXMobileApp.addCustomEvent("main.post.form/text",function(e){e=t.type.isArray(e)?e[0]:e;n(e)});var o={keyBoardIsShown:false,mention:{}},r=function(t,e,i){if(!!i&&typeof i=="object"){for(var n in i){if(i.hasOwnProperty(n)){r(t,e+"["+n+"]",i[n])}}}else{t.append(e,!!i?i:"")}};window.app.exec("enableCaptureKeyboard",true);t.addCustomEvent("onKeyboardWillShow",function(){o.keyBoardIsShown=true});t.addCustomEvent("onKeyboardDidHide",function(){o.keyBoardIsShown=false});t.addCustomEvent("OnUCCommentWasRead",function(e){var i=t("record-"+e.join("-"));if(i){t.removeClass(i,"post-comment-block-new")}});var a=function(t,e,i){this.id=t;this.text=e||"";this.attachments=i||[];this.mentions={}};a.prototype={text:"",attachments:[],node:null,getText:function(){return this.text}};a.getInstance=function(i,n,s){var o=null;if(!t.type.isArray(i)&&i&&i["___id"]&&e["comments"][i["___id"]]){o=i}else if(e["comments"][i.join("-")]){o=e["comments"][i.join("-")]}else{o=new a(i,n,s);o.___id=i.join("-");e["comments"][i.join("-")]=o}return o};a.removeInstance=function(t){if(t&&t["___id"])delete e["comments"][t["___id"]]};var d=function(i){this.bindEvents();e["form"][this.handlerId]=this;this.entitiesId={};this.comment=null;this.handlerId=i;this.handler=null;this.handlerEvents={onMPFUserIsWriting:t.delegate(this.writing,this),onMPFHasBeenDestroyed:t.delegate(this.reboot,this)};this.visible=false;this.bindHandler=t.delegate(this.bindHandler,this);t.addCustomEvent(window,"onMPFIsInitialized",this.bindHandler);if(t["MPF"])this.bindHandler(t["MPF"].getInstance(this.handlerId));this.jsCommentId=t.util.getRandomString(20)};d.prototype={bindHandler:function(e){if(e&&e.id==this.handlerId){this.handler=e;t.removeCustomEvent(window,"onMPFIsInitialized",this.bindHandler);for(var i in this.handlerEvents){if(this.handlerEvents.hasOwnProperty(i)){t.addCustomEvent(this.handler,i,this.handlerEvents[i])}}this.closeWait();t.onCustomEvent(this,"OnUCFormInit",[this])}},bindEvents:function(){this.windowEvents={OnUCUserReply:t.delegate(function(t,e,i){if(this.entitiesId[t]){var n=[t,0];e=parseInt(e);if(e>0&&i){n=this.initComment(n,"",false);n.mentions[i]="[USER="+e+"]"+i+"[/USER]";var s=this.handler&&this.handler.simpleForm?this.handler.simpleForm.writingParams["~text"]:n.text;n.text=s+(s==""?"":" ")+"[USER="+e+"]"+i+"[/USER]"+", "}this.show(n,n.text,false)}},this),OnUCAfterRecordEdit:t.delegate(function(t,e,i,n){if(this.entitiesId[t]){if(n==="EDIT"){this.show([t,e],i["messageBBCode"],i["messageFields"])}else if(i["errorMessage"]){this.showError([t,e],i["errorMessage"])}else if(i["okMessage"]){this.showNote([t,e],i["okMessage"])}}},this)};t.addCustomEvent(window,"OnUCUserReply",this.windowEvents.OnUCUserReply);t.addCustomEvent(window,"OnUCAfterRecordEdit",this.windowEvents.OnUCAfterRecordEdit)},reboot:function(e,i,n){for(var s in this.handlerEvents){if(this.handlerEvents.hasOwnProperty(s)){t.removeCustomEvent(this.handler,s,this.handlerEvents[s])}}this.bindHandler(n)},linkEntity:function(i,n){if(this.handler===null){this._linkEntity=t.delegate(function(){this.linkEntity(i,n)},this);t.addCustomEvent(this,"OnUCFormInit",this._linkEntity)}else{if(this["_linkEntity"])t.removeCustomEvent(this,"OnUCFormInit",this["_linkEntity"]);this.entitiesId[i]=n;e.entityId=i;var o=t.proxy(function(t){this.comment=this.reinitComment({id:[i,0],text:t});this.comment.text=t;this.handler.init(this.comment)},this);if(false&&window["platform"]=="ios"){window.BXMobileApp.UI.Page.TextPanel.getText(o)}else{o(s(i))}}},writing:function(e){t.onCustomEvent(window,"OnUCUserIsWriting",[e["id"][0],e["id"][1],this.jsCommentId])},reinitComment:function(t){var e=[t["id"][0],0],i=t["text"]||"";a.removeInstance(t);return this.initComment(e,i,[])},initComment:function(e,i,n){var s=a.getInstance(e,i,n);if(s["bound"]!=="Y"){t.addCustomEvent(s,"onCancel",t.delegate(t.delegate(this.submitClear,this)));t.addCustomEvent(s,"onStart",t.delegate(t.delegate(this.submitStart,this)));t.addCustomEvent(s,"onSubmit",t.delegate(t.delegate(this.submit,this)));t.addCustomEvent(s,"onError",t.delegate(t.delegate(function(t,e){this.showError(s,e);this.submitClear(s)},this)));s["bound"]="Y"}return s},show:function(i,n,s){this.comment=this.initComment(i,n,s);this.jsCommentId=t.util.getRandomString(20);t.onCustomEvent(this.handler,"OnUCFormBeforeShow",[this,n,s]);e.entityId=i[0];this.handler.show(this.comment,!!s);t.onCustomEvent(this.handler,"OnUCFormAfterShow",[this,n,s]);return true},submitClear:function(i){a.removeInstance(i);this.jsCommentId=t.util.getRandomString(20);if(this.comment==i){this.comment=this.initComment([i.id[0],0],"",[]);e.entityId=i.id[0];this.handler.init(this.comment)}},submitStart:function(e,i,n){t.onCustomEvent(window,"OnUCFormBeforeSubmit",[e.id[0],e.id[1],e,this,i,n])},submit:function(e){var i=e.getText(),n=e.attachments,s=this.entitiesId[e.id[0]],o=this.handler.getForm({ENTITY_XML_ID:e.id[0],REVIEW_TEXT:i,NOREDIRECT:"Y",MODE:"RECORD",AJAX_POST:"Y",id:e.id,sessid:t.bitrix_sessid(),SITE_ID:t.message("SITE_ID"),LANGUAGE_ID:t.message("LANGUAGE_ID")}),a=new window.MobileAjaxWrapper,d=new window.FormData,l;if(this.jsCommentId!==null)o["COMMENT_EXEMPLAR_ID"]=this.jsCommentId;if(e.id[1]>0){o["REVIEW_ACTION"]="EDIT";o["FILTER"]={ID:e.id[1]};if(o["act"]){o["act"]="edit";o["edit_id"]=e.id[1]}}if(s["fields"]){for(l in s["fields"]){if(s["fields"].hasOwnProperty(l)){o[l]=s["fields"][l]}}}t.onCustomEvent(window,"OnUCFormSubmit",[e.id[0],e.id[1],this,o]);for(l in o){if(o.hasOwnProperty(l)){r(d,l,o[l])}}if(n){for(var m=0;m<n.length;m++){r(d,n[m]["fieldName"],n[m]["fieldValue"])}}a.Wrap({method:"POST",url:s["url"],data:{},type:"json",processData:true,start:false,preparePost:false,callback:t.proxy(function(i){t.onCustomEvent(window,"OnUCFormResponse",[e.id[0],e.id[1],this,i,e]);if(i["errorMessage"])this.showError(e,i["errorMessage"]);else t.onCustomEvent(window,"OnUCAfterRecordAdd",[e.id[0],e.id[1],this,i,e])},this),callback_failure:t.delegate(function(i){t.onCustomEvent(window,"OnUCFormResponse",[e.id[0],e.id[1],this,i,e]);this.showError(e,t.message("INCORRECT_SERVER_RESPONSE"))},this)});a.xhr.send(d);this.submitClear(e)},showError:function(e,i){if(t.type.isArray(e))e=this.initComment(e,"",[]);i='<div class="feed-add-info-text"><span class="feed-add-info-icon"></span>'+"<b>"+t.message("FC_ERROR")+"</b><br />"+i+"</div>";if(e&&e.node){t.addClass(e.node,"feed-com-block-cover-undelivered");var n=typeof e.attachments=="undefined"||e.attachments.length<=0;if(!n&&t.type.isArray(e.attachments)){n=true;for(var s=0;s<e.attachments.length;s++){if(t.type.isNotEmptyString(e.attachments[s].fieldValue)||t.type.isNotEmptyString(e.attachments[s].url)){n=false;break}}}if(n){t.bind(e.node,"click",t.proxy(function(i){t.unbindAll(e.node);t.removeClass(e.node,"feed-com-block-cover-undelivered");this.handler.comment=e;this.handler.simpleForm.handleAppData(e.text,true)},this))}}else if(i){}},showNote:function(t,e){},showWait:function(){this.handler.hide();this.handler.showWait()},closeWait:function(){this.handler.closeWait()}};d.link=function(t,i){var n=i["id"];e["form"][n]=e["form"][n]||new d(n);e["form"][n].linkEntity(t,i)};window.mobileShowActions=function(n,s,r){r=r||window.event;var a=window.app.enableInVersion(14)&&window.platform=="ios"?window.BXMobileAppContext.isKeyboardShown():o.keyBoardIsShown;if(a){return true}if(r&&r.target&&r.target.tagName&&(r.target.tagName.toUpperCase()=="A"||r.target.tagName.toUpperCase()=="IMG"&&t.type.isNotEmptyString(r.target.getAttribute("data-bx-image")))){return true}t.eventCancelBubble(r);t.PreventDefault(r);var d=t("record-"+i(n,s)),l=[],m;if(d.getAttribute("bx-mpl-reply-show")=="Y")l.push({title:t.message("BLOG_C_REPLY"),callback:function(){e["list"][n].reply(t("record-"+i(n,s)+"-reply-action"))}});var h;if(d.getAttribute("bx-mpl-vote-id")!="#VOTE_ID#"&&window["RatingLikeComments"]&&(h=window.RatingLikeComments.getById(d.getAttribute("bx-mpl-vote-id")))&&h){h["__delegatedVoteFunc"]=h["__delegatedVoteFunc"]||t.delegate(h.vote,h);l.push({title:h.voted?t.message("BPC_MES_VOTE2"):t.message("BPC_MES_VOTE1"),callback:h["__delegatedVoteFunc"]});l.push({title:t.message("BPC_MES_VOTE"),callback:function(){window.RatingLikeComments.List(d.getAttribute("bx-mpl-vote-id"))}})}if(d.getAttribute("bx-mpl-edit-show")=="Y")l.push({title:t.message("BPC_MES_EDIT"),callback:function(){e["list"][n].act(d.getAttribute("bx-mpl-edit-url"),s,"EDIT")}});if(d.getAttribute("bx-mpl-moderate-show")=="Y"){var c=d.getAttribute("bx-mpl-moderate-approved")=="hidden";l.push({title:c?t.message("BPC_MES_SHOW"):t.message("BPC_MES_HIDE"),callback:function(){e["list"][n].act(d.getAttribute("bx-mpl-moderate-url").replace("#action#",c?"show":"hide").replace("#ACTION#",c?"SHOW":"HIDE"),s,"MODERATE")}})}if(d.getAttribute("bx-mpl-delete-show")=="Y")l.push({title:t.message("BPC_MES_DELETE"),callback:function(){e["list"][n].act(d.getAttribute("bx-mpl-delete-url"),s,"DELETE")}});if(d.getAttribute("bx-mpl-createtask-show")=="Y")l.push({title:t.message("BPC_MES_CREATETASK"),callback:function(){if(typeof oMSL!="undefined"){oMSL.createTask({entityType:"BLOG_COMMENT",entityId:s})}}});if(l.length>0){m=new window.BXMobileApp.UI.ActionSheet({buttons:l},"commentSheet");m.show()}return false};window.mobileReply=function(i,n){t.eventCancelBubble(n);t.PreventDefault(n);e["list"][i].reply(n.target);return false};window.mobileExpand=function(e,i){t.eventCancelBubble(i);t.PreventDefault(i);var n=t(e)?e.previousSibling:null;if(t(n)){var s=n.parentNode,o=200,r=parseInt(n.offsetHeight),a={height:o},d={height:r};t.remove(e);var l=(r-o)/(2e3-o);l=l<.3?.3:l>.8?.8:l;s.style.maxHeight=a.height+"px";s.style.overflow="hidden";new t["easing"]({duration:l*1e3,start:a,finish:d,transition:t.easing.makeEaseOut(t.easing.transitions.quart),step:function(t){s.style.maxHeight=t.height+"px";s.style.opacity=t.opacity/100},complete:function(){s.style.cssText="";s.style.maxHeight="none";t.onCustomEvent(window,"OnUCRecordWasExpanded",[s]);t.LazyLoad.showImages(true)}}).animate()}return false};var l=function(i){t.MPL=function(n,s,o){t.MPL.superclass.constructor.apply(this,arguments);this.template=t.message("MPL_RECORD_TEMPLATE");this.thumb=t.message("MPL_RECORD_THUMB");this.thumbForFile=t.message("MPL_RECORD_THUMB_FILE");t.removeCustomEvent(i,"OnUCAfterRecordAdd",this.windowEvents["OnUCAfterRecordAdd"]);t.removeCustomEvent(i,"OnUCFormResponse",this.windowEvents["OnUCFormResponse"]);this.postCounter=0;this.windowEvents["OnUCFormBeforeSubmit"]=t.delegate(function(t,e,i,n,s,o){if(this.ENTITY_XML_ID==t){var r=[t,e>0?e:"new_"+this.postCounter++];this.makeThumb(r,i,s,o);this.pullNewRecords[t+"-"+e]="busy"}},this);this.windowEvents["OnUCAfterRecordAdd"]=t.delegate(function(t,e,i,n,s){if(this.ENTITY_XML_ID==t){this.add(s,n["messageId"],n,true,"simple")}},this);this.windowEvents["OnUCFormResponse"]=t.delegate(function(t,e,i,n,s){if(this.ENTITY_XML_ID==t){this.pullNewRecords[t+"-0"]="ready";this.pullNewRecords[t+"-"+e]="done";this.clearThumb(s)}},this);this.windowEvents["onPull-unicomments"]=t.delegate(function(i){var n=i.params;if(i.command=="comment_mobile"&&n["ENTITY_XML_ID"]==this.ENTITY_XML_ID&&(n["USER_ID"]+""!=t.message("USER_ID")+""||n["EXEMPLAR_ID"]&&n["EXEMPLAR_ID"]!=this.exemplarId||typeof n["AUX"]!="undefined"&&t.util.in_array(n["AUX"],["createtask","fileversion"]))){if(i.command=="comment_mobile"&&n["ID"]){if(n["COMMENT_EXEMPLAR_ID"])e.commentExemplarId[n["ENTITY_XML_ID"]+"_"+n["COMMENT_EXEMPLAR_ID"]]=true;this.pullNewRecord(n)}else if(i.command==="answer"&&n["USER_ID"]+""!==t.message("USER_ID")+""&&(!n["COMMENT_EXEMPLAR_ID"]||e.commentExemplarId[n["ENTITY_XML_ID"]+"_"+n["COMMENT_EXEMPLAR_ID"]]!==true)){this.pullNewAuthor(n["USER_ID"],n["NAME"],n["AVATAR"])}}},this);t.addCustomEvent(i,"OnUCFormResponse",this.windowEvents["OnUCFormResponse"]);t.addCustomEvent(i,"OnUCAfterRecordAdd",this.windowEvents["OnUCAfterRecordAdd"]);t.addCustomEvent(i,"OnUCFormBeforeSubmit",this.windowEvents["OnUCFormBeforeSubmit"]);BXMobileApp.addCustomEvent(i,"onPull-unicomments",this.windowEvents["onPull-unicomments"]);if(s["SHOW_POST_FORM"]=="Y")d.link(this.ENTITY_XML_ID,o);e["list"][this.ENTITY_XML_ID]=this;return this};t.extend(t.MPL,i["FCList"]);t.MPL.prototype.init=function(){};t.MPL.prototype.url["activity"]=t.message("SITE_DIR")+"mobile/?mobile_action=comment_activity";t.MPL.prototype.makeThumb=function(e,n,s,o){var r=n.node||t("record-"+e.join("-")+"-cover");if(!r){var a=t.type.isString(s)?s:"";a=t.util.htmlspecialchars(a).replace(/\n/gi,"<br />");a=a.replace(/\001/,"").replace(/(\[\/user\])/gi,"").replace(/\[user=(\d+)\]([^\001]?.+)(\001)/gi,"$2").replace(/\001/,"[/user]");var d=i.fcParseTemplate({messageFields:{FULL_ID:e,POST_MESSAGE_TEXT:a,POST_TIMESTAMP:(new Date).getTime()/1e3}},{DATE_TIME_FORMAT:this.params.DATE_TIME_FORMAT,RIGHTS:this.rights},t.type.isArray(o)&&o.length>0?this.thumbForFile:this.thumb),l;l=t.processHTML(d,false);r=t.create("DIV",{attrs:{id:"record-"+e.join("-")+"-cover",className:"feed-com-block-cover"},style:{opacity:0,height:0,overflow:"hidden"},html:l.HTML});t("record-"+e[0]+"-new").appendChild(r);var m=r,h=t.pos(m),c=t.GetWindowInnerSize(),u=h.top-c.innerHeight;if(t.GetWindowScrollPos()["scrollTop"]<u)i.scrollTo(0,u);var f=t.GetWindowScrollPos();new t["easing"]({duration:500,start:{opacity:0,height:0},finish:{opacity:100,height:m.scrollHeight},transition:t.easing.makeEaseOut(t.easing.transitions.quart),step:function(t){m.style.height=t.height+"px";m.style.opacity=t.opacity/100;if(f.scrollTop+c.innerHeight<h.top+t.height){i.scrollTo(0,u+t.height)}},complete:function(){if(m.style.display!=="none")m.style.cssText=""}}).animate();var p=0,E=function(){p++;if(p<100){var i=t("record-"+e.join("-")+"-cover");if(i&&i.childNodes.length>0)t.ajax.processScripts(l.SCRIPT);else t.defer(E,this)()}};t.defer(E,this)()}t.addClass(r,"feed-com-block-cover-wait");n.node=r;return r};t.MPL.prototype.clearThumb=function(e){if(e&&t(e.node)){t.removeClass(e.node,"feed-com-block-cover-wait")}};t.MPL.prototype.add=function(e,n,s){if(t.type.isArray(e)){t.MPL.superclass.add.apply(this,arguments)}else if(t(e["node"])){e["node"].setAttribute("id","record-"+n.join("-")+"-cover");t.MPL.superclass.add.apply(this,[n,s,true,"simple"])}else{t.MPL.superclass.add.apply(this,[n,s])}if(i["BitrixMobile"]&&i["BitrixMobile"]["LazyLoad"])setTimeout(function(){i.BitrixMobile.LazyLoad.showImages()},500)};t.MPL.prototype.send=function(){if(t(this.nav))t.addClass(this.nav.parentNode,"post-comments-button-waiter");t.MPL.superclass.send.apply(this,arguments)};t.MPL.prototype.build=function(){if(t(this.nav))t.removeClass(this.nav.parentNode,"post-comments-button-waiter");t.MPL.superclass.build.apply(this,arguments)};t.MPL.prototype.complete=function(){if(t(this.nav))t.removeClass(this.nav.parentNode,"post-comments-button-waiter");t.MPL.superclass.complete.apply(this,arguments)};t.MPL.prototype.showWait=function(e){var i=t("record-"+this.ENTITY_XML_ID+"-"+e+"-cover");if(e>0&&i)t.addClass(i,"feed-com-block-cover-wait")};t.MPL.prototype.closeWait=function(e){var i=t("record-"+this.ENTITY_XML_ID+"-"+e+"-cover");if(e>0&&i)t.removeClass(i,"feed-com-block-cover-wait")};t.MPL.createInstance=function(e,i,n){return new t.MPL(e,i,n)};t.MPL.getInstance=function(t){return e["list"][t]};t.addCustomEvent(i,"OnUCHasBeenDestroyed",function(t){delete e["list"][t]});t.onCustomEvent("main.post.list/mobile",["script.js"]);t.removeCustomEvent("main.post.list/default",function(){l(i)})};t.addCustomEvent("main.post.list/default",function(){l(window)});if(window["FCList"])l(window)})();