%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/bitrix/www/bitrix/components/bitrix/main.post.list/templates/mobile_app/
Upload File :
Create Path :
Current File : //home/bitrix/www/bitrix/components/bitrix/main.post.list/templates/mobile_app/script.min.js

(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:{}},a=function(t,e,i){if(!!i&&typeof i=="object"){for(var n in i){if(i.hasOwnProperty(n)){a(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 r=function(t,e,i){this.id=t;this.text=e||"";this.attachments=i||[];this.mentions={}};r.prototype={text:"",attachments:[],node:null,getText:function(){return this.text}};r.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 r(i,n,s);o.___id=i.join("-");e["comments"][i.join("-")]=o}return o};r.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(e,i,n,s){if(this.entitiesId[e]){if(s==="EDIT"){this.show([e,i],n["messageBBCode"],n["messageFields"])}else if(s==="MODERATE"){t.onCustomEvent(window,"OnUCAfterRecordAdd",[n.messageId[0],n.messageId[1],this,n,{node:t("record-"+n.messageId[0]+"-"+n.messageId[1])}])}else if(n["errorMessage"]){this.showError([e,i],n["errorMessage"])}else if(n["okMessage"]){this.showNote([e,i],n["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"]||"";r.removeInstance(t);return this.initComment(e,i,[])},initComment:function(e,i,n){var s=r.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){r.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")}),r=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)){a(d,l,o[l])}}if(n){for(var m=0;m<n.length;m++){a(d,n[m]["fieldName"],n[m]["fieldValue"])}}var h=s["url"];h=t.util.add_url_param(h,{b24statAction:e.id[1]>0?"editComment":"addComment",b24statContext:"mobile"});r.Wrap({method:"POST",url:h,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)});r.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,a){a=a||window.event;var r=window.app.enableInVersion(14)&&window.platform=="ios"?window.BXMobileAppContext.isKeyboardShown():o.keyBoardIsShown;if(r){return true}if(a&&a.target&&a.target.tagName&&(a.target.tagName.toUpperCase()=="A"||a.target.tagName.toUpperCase()=="IMG"&&t.type.isNotEmptyString(a.target.getAttribute("data-bx-image")))){return true}t.eventCancelBubble(a);a.preventDefault();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(){var i=d.getAttribute("bx-mpl-moderate-url").replace("#action#",c?"show":"hide").replace("#ACTION#",c?"SHOW":"HIDE");if(t.type.isNotEmptyString(i)){i=t.util.add_url_param(i,{b24statAction:c?"showComment":"hideComment",b24statContext:"mobile"})}e["list"][n].act(i,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"){var u=d.getAttribute("bx-mpl-comment-entity-type"),f=d.getAttribute("bx-mpl-post-entity-type");l.push({title:t.message("BPC_MES_CREATETASK"),callback:function(){if(typeof oMSL!="undefined"){oMSL.createTask({postEntityType:t.type.isNotEmptyString(f)?f:"BLOG_POST",entityType:t.type.isNotEmptyString(u)?u:"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);n.preventDefault();e["list"][i].reply(n.target);return false};window.mobileExpand=function(e,i){t.eventCancelBubble(i);i.preventDefault();var n=t(e)?t.findChild(e.previousSibling,{className:"post-comment-text"},true):null;if(t(n)){var s=n.parentNode,o=200,a=parseInt(n.offsetHeight),r={height:o},d={height:a};t.remove(e);var l=(a-o)/(2e3-o);l=l<.3?.3:l>.8?.8:l;s.style.maxHeight=r.height+"px";s.style.overflow="hidden";new t["easing"]({duration:l*1e3,start:r,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 a=[t,e>0?e:"new_"+this.postCounter++];this.makeThumb(a,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)}this.recalcMoreButtonsList();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 a=n.node||t("record-"+e.join("-")+"-cover");if(!a){var r=t.type.isString(s)?s:"";r=t.util.htmlspecialchars(r).replace(/\n/gi,"<br />");r=r.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:r,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);a=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(a);var m=a,h=t.pos(m),c=h.top;i.scrollTo(0,c);new t["easing"]({duration:500,start:{opacity:0,height:0},finish:{opacity:100,height:m.scrollHeight},transition:t.easing.makeEaseInOut(t.easing.transitions.quad),step:function(t){m.style.height=t.height+"px";m.style.opacity=t.opacity/100;i.scrollTo(0,c+t.height)},complete:function(){if(m.style.display!=="none"){m.style.cssText=""}}}).animate();var u=0,f=function(){u++;if(u<100){var i=t("record-"+e.join("-")+"-cover");if(i&&i.childNodes.length>0)t.ajax.processScripts(l.SCRIPT);else t.defer(f,this)()}};t.defer(f,this)()}t.addClass(a,"feed-com-block-cover-wait");n.node=a;return a};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)){var e=t.findChild(this.nav,{className:"post-comments-button-waiter"});if(e){t.addClass(e,"post-comments-button-waiter-active")}}t.MPL.superclass.send.apply(this,arguments)};t.MPL.prototype.build=function(){if(t(this.nav)){var e=t.findChild(this.nav,{className:"post-comments-button-waiter"});if(e){t.removeClass(e,"post-comments-button-waiter-active")}}t.MPL.superclass.build.apply(this,arguments)};t.MPL.prototype.complete=function(){if(t(this.nav)){var e=t.findChild(this.nav,{className:"post-comments-button-waiter"});if(e){t.removeClass(e,"post-comments-button-waiter-active")}}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.prototype.recalcMoreButtonsList=function(e){if(!t(e)){e=t.findParent(t("record-"+this.ENTITY_XML_ID+"-new"),{className:"post-comments-wrap"})}if(e){var i=t.findChildren(e,{className:"post-comment-more"},true);for(var n=0;n<i.length;n++){this.recalcMoreButton(i[n])}}};t.MPL.prototype.recalcMoreButton=function(e){if(t(e)){var i=t.findChild(t(e).parentNode,{className:"post-comment-wrap"});if(i){var n=t.findChild(i,{className:"post-comment-text"});if(n){var s=t.pos(n);var o=t.pos(i);if(o.height>=s.height){t.cleanNode(t(e),true)}}}}};t.MPL.prototype.findMoreButton=function(e){return t.findChild(t(e),{className:"post-comment-more"},true)};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)})();

Zerion Mini Shell 1.0