File manager - Edit - /home/c14075/dragmet-ural.ru/www/bitrix/components/bitrix/voting.uf/templates/.default/script.min.js
Back
(function(t){var e=t.BX;if(e["Vote"])return;var i=t["app"]?e.message("SITE_DIR")+"mobile/?mobile_action=vote":"/bitrix/tools/vote/uf.php";e.Vote=function(){var a=function(i,s){this.node=i;this.form=e.findChild(this.node,{tagName:"FORM"},true);this.id=s["id"];this.voteId=s["voteId"];this.params=s;var a,o,r;this.errorNode=e.findChild(this.node,{attribute:{"data-bx-vote-role":"error"}},true);for(var n in this.buttons){if(this.buttons.hasOwnProperty(n)){a=e.findChild(this.node,{attribute:{"data-bx-vote-button":n}},true);if(a&&e.type.isFunction(this[n])){this[n]=e.delegate(this[n],this);this.buttons[n]=a;e.bind(a,"click",this[n])}}}a=e.findChildren(this.node,{tagName:"TR"},true);while(a&&(o=a.pop())&&o&&o.hasAttribute("data-bx-vote-answer")){r=e.findChild(o,{tagName:"A",attribute:{"data-bx-vote-result":"counter"}},true);if(r){if(t["app"]){e.bind(o,"click",e.proxy(this.checkMobileUsers,this))}else{e.bind(r,"click",e.proxy(this.checkUsers,this));e.adjust(r,{attrs:{"data-bx-vote-answer":o.getAttribute("data-bx-vote-answer")}})}}}this.onPullEvent=e.delegate((function(t,i){if(t=="voting"&&!!i&&i["VOTE_ID"]==this.voteId&&e(this.node)){this.adjustResults(i)}}),this);if(t["app"]){app.onCustomEvent("onPullExtendWatch",{id:"VOTE_"+this.voteId});e.addCustomEvent("onPull-vote",this.onPullEvent)}else if(e["PULL"]){e.PULL.extendWatch("VOTE_"+this.voteId);e.addCustomEvent("onPullEvent-vote",this.onPullEvent)}};a.prototype={buttons:{showVoteForm:null,showResults:null,actVoting:null,stopOrResume:null,exportXls:null},params:{},url:i,showVoteForm:function(t){if(this.node.getAttribute("data-bx-vote-lamp")=="green"){var i=e.proxy((function(t){if(t&&t.data&&t.data.event)this.adjustBallot(t.data.attach,t.data.event);this.node.setAttribute("data-bx-vote-form","shown")}),this),s=e.proxy((function(t){this.node.setAttribute("data-bx-vote-form","shown")}),this);this.send({action:"getBallot"},t.target,i,s)}e.eventCancelBubble(t);return e.PreventDefault(t)},showResults:function(t){this.node.setAttribute("data-bx-vote-result",this.node.getAttribute("data-bx-vote-result")=="shown"?"hidden":"shown");e.eventCancelBubble(t);return e.PreventDefault(t)},stopOrResume:function(t){this.send({action:this.node.getAttribute("data-bx-vote-lamp")=="red"?"resume":"stop"},t.target,e.proxy((function(t){if(t["action"]=="stop"){this.node.setAttribute("data-bx-vote-result","shown");this.node.setAttribute("data-bx-vote-form","hidden");this.node.setAttribute("data-bx-vote-lamp","red")}else{if(this.node.getAttribute("data-bx-vote-status")!=="voted")this.node.setAttribute("data-bx-vote-form","shown");this.node.setAttribute("data-bx-vote-lamp","green")}if(t["data"]&&t["data"]["attach"])this.adjustResults(t["data"]["attach"])}),this));e.eventCancelBubble(t);return e.PreventDefault(t)},exportXls:function(t){e.eventCancelBubble(t);top.location.href=e.util.add_url_param(this.url,{action:"exportXls",attachId:this.id,sessid:e.bitrix_sessid()});return e.PreventDefault(t)},actVoting:function(t){var i=e.ajax.prepareForm(this.form).data;i["action"]="vote";this.send(i,t.target,e.proxy((function(t){this.node.setAttribute("data-bx-vote-form","hidden");this.node.setAttribute("data-bx-vote-result","shown");this.adjustResults(t.data.attach)}),this),e.proxy((function(){this.node.setAttribute("data-bx-vote-form","shown")}),this));e.eventCancelBubble(t);return e.PreventDefault(t)},send:function(t,i,s,a){e.addClass(i,"ui-btn-clock");t["sessid"]=e.bitrix_sessid();t["attachId"]=this.id;e.ajax({method:"POST",url:e.util.add_url_param(this.url,{action:t["action"],attachId:this.id}),data:t,dataType:"json",onsuccess:e.proxy((function(t){e.removeClass(i,"ui-btn-clock");if(t.status=="success"){this.showError(null);if(e.type.isFunction(s))s.apply(this,arguments)}else{if(t.status=="error"&&t["errors"])this.showError(t["errors"]);if(e.type.isFunction(a))a.apply(this,arguments)}}),this),onfailure:e.proxy((function(){e.removeClass(i,"ui-btn-clock");if(e.type.isFunction(a))a.apply(this,arguments)}),this)})},adjustBallot:function(t,i){var s,a,o,r,n,u,l,h,p,d=t["QUESTIONS"],c=i["ballot"],f=i["extras"];for(s in d){if(d.hasOwnProperty(s)){l=d[s];o=[l["FIELD_NAME"],l["FIELD_NAME"]+"[]"];p=c[s]||{};while(r=o.shift()){if(this.form.elements[r]){u=e(this.form.elements[r])?[this.form.elements[r]]:this.form.elements[r];for(r=0;r<u.length;r++){if(p[u[r].value]){u[r].checked="checked"}else{delete u[r].checked}}}}for(a in d[s]["ANSWERS"]){if(d[s]["ANSWERS"].hasOwnProperty(a)){h=d[s]["ANSWERS"][a];if(h["FIELD_TYPE"]>=4){if(this.form.elements[h["MESSAGE_FIELD_NAME"]])this.form.elements[h["MESSAGE_FIELD_NAME"]].value=c[s]&&c[s][a]&&c[s][a]["MESSAGE"]?c[s][a]["MESSAGE"]:"";else this.form.elements[h["FIELD_NAME"]].value=c[s]&&c[s][a]&&c[s][a]["MESSAGE"]?c[s][a]["MESSAGE"]:""}}}}}for(r in f){if(f.hasOwnProperty(r)&&(s=e(this.form.elements[String(t["FIELD_NAME"]).replace("#ENTITY_ID#",r)]))){if(s.value==f[r])s.checked=true;else delete s.checked}}},adjustResults:function(t){var i=t["QUESTIONS"];e.onCustomEvent(this.node,"OnBeforeChangeData");var s,a,o,r,n,u;for(r in i){if(i.hasOwnProperty(r)){s=e.findChild(this.node,{attr:{id:"question"+r}},true);if(s){for(o in i[r]["ANSWERS"]){if(i[r]["ANSWERS"].hasOwnProperty(o)){a=e.findChild(s,{attr:{"data-bx-vote-answer":o}},true);if(!!a){n=parseInt(i[r]["ANSWERS"][o]["PERCENT"]);n=isNaN(n)?0:n;u=e.findChild(a,{attribute:{"data-bx-vote-result":"counter"}},true);e.adjust(u,{html:i[r]["ANSWERS"][o]["COUNTER"]+""});delete u["VOTED_USER_OBJ"];e.adjust(e.findChild(a,{tagName:"SPAN",attribute:{"data-bx-vote-result":"percent"}},true),{html:n+"%"});e.adjust(e.findChild(a,{tagName:"DIV",attribute:{"data-bx-vote-result":"bar"}},true),{style:{width:n+"%"}})}}}}}}u=e.findChild(this.node,{tagName:"DIV",attribute:{"data-bx-vote-result":"counter"}},true);e.adjust(u,{html:t["COUNTER"]+""});e.onCustomEvent(this.controller,"OnAfterChangeData")},checkUsers:function(t){var i=t?e(t.currentTarget):null;if(i.hasAttribute("data-bx-vote-answer")){if(!i["VOTED_USER_OBJ"]){i.VOTED_USER_OBJ=new s(i.getAttribute("data-bx-vote-answer"),i,{nameTemplate:this.params["nameTemplate"],urlTemplate:this.params["urlTemplate"],attachId:this.id})}i.VOTED_USER_OBJ.click()}},checkMobileUsers:function(t){if(this.node&&this.node.getAttribute("data-bx-vote-form")!=="shown"){var i=e.proxy_context,s=e.findChild(i,{tagName:"A",attribute:{"data-bx-vote-result":"counter"}},true);if(s&&parseInt(s.innerHTML)>0){e.PreventDefault(t);app.openBXTable({url:e.util.add_url_param(this.url,{action:"getMobileVoted",attachId:this.id,answerId:i.getAttribute("data-bx-vote-answer"),sessid:e.bitrix_sessid()}),TABLE_SETTINGS:{markmode:false,cache:false}});return false}}return true},showError:function(t){var i="";if(e.type.isArray(t)){var s=[];for(var a=0;a<t.length;a++){s.push(t[a]["message"])}s=s.join("<br />");i=s===""?"Unknown error":s;this.errorNode.innerHTML=i;this.node.setAttribute("data-bx-vote-error","shown")}else{this.errorNode.innerHTML="";this.node.setAttribute("data-bx-vote-error","hidden")}}};return a}();var s=function(){var t=function(t,e,i){this.id=["vote",t,(new Date).getTime()].join("-");this.answerId=t;this.node=e;this.status="ready";this.iNumPage=0;this.urlTemplate=i["urlTemplate"];this.nameTemplate=i["nameTemplate"];this.attachId=i["attachId"];this.data=[];this.queue=[];this.popup=null;this.popupScrollCheck=this.popupScrollCheck.bind(this)};t.prototype={url:i,click:function(){var t=parseInt(this.node.innerHTML);if(t>0){this.showPopup().then((()=>{if(this.data.length>0){this.buildVoters(this.data)}}))}},buildVoters:function(t){var i=this.popup?this.popup.getPopupContainer():null;if(i===null){return}var s=i.querySelector(".bx-ilike-popup");i.querySelector(".bx-ilike-wrap-block").removeAttribute("style");var a=false;t.forEach((t=>{var i=e.util.htmlspecialchars(t["ID"]);var o=e.util.htmlspecialchars(t["FULL_NAME"]);var r=e.type.isNotEmptyString(t["PHOTO_SRC"])?encodeURI(e.util.htmlspecialchars(t["PHOTO_SRC"])):null;var n=e.type.isNotEmptyString(t["TYPE"])?e.util.htmlspecialchars(t["TYPE"]):null;var u=["a",this.answerId,"u",i].join("");if(s.querySelector("a#"+u)===null){var l=['<span class="bx-ilike-popup-avatar-new">','<img src="',r??"/bitrix/images/main/blank.gif",'" class="bx-ilike-popup-avatar-img',r?"":" bx-ilike-popup-avatar-img-default",'" />','<span class="bx-ilike-popup-avatar-status-icon"></span>',"</span>",'<span class="bx-ilike-popup-name-new">',o,"</span>"].join("");s.appendChild(e.create(t["ID"]!=="HIDDEN"&&this.urlTemplate?"A":"SPAN",{attrs:{id:u},props:{href:this.urlTemplate.replace(/#(USER_ID|ID)#/i,i),target:"_blank",className:"bx-ilike-popup-img"+(n?" bx-ilike-popup-img-"+n:"")},html:l}))}a=true}));if(a){this.popup.adjustPosition({forceBindPosition:true});this.popupScrollCheck({currentTarget:s})}},makeError:function(t){var i=this.popup?this.popup.getPopupContainer():null;if(i===null){return}var s=(t||[{message:e.message("VOTE_ERROR_DEFAULT")}]).map((t=>t.message)).join("");i.innerHTML='<div class="bx-vote-popup-error-block">'+s+"</div>";this.popup.adjustPosition({forceBindPosition:true})},showPopup:function(){return new Promise((t=>{var e=this.getPopup();e.show();e.setAngle({position:"bottom"});e.adjustPosition({forceBindPosition:true});t(e)}))},getPopup:function(){if(this.popup){return this.popup}this.popup=new e.PopupWindow("bx-vote-popup-cont-"+this.id,this.node,{lightShadow:true,offsetTop:-2,offsetLeft:3,autoHide:true,closeByEsc:true,cacheable:false,bindOptions:{position:"top"},content:['<span class="bx-ilike-wrap-block" style="display: none;">'+'<span class="bx-ilike-popup"><span class="bx-ilike-bottom_scroll"></span></span>'+"</span>",'<span class="bx-ilike-wait"></span>'].join(""),events:{onFirstShow:()=>{this.send();e.bind(this.popup.contentContainer.querySelector(".bx-ilike-popup"),"scroll",this.popupScrollCheck)},onClose:()=>{this.popup=null}}});return this.popup},popupScrollCheck:function(){var t=this.popup?this.popup.contentContainer:null;if(t===null){return}var e=t.querySelector(".bx-ilike-popup");if(e.scrollTop>(e.scrollHeight-e.offsetHeight)/1.5||t.offsetHeight>e.offsetHeight){this.send()}},send:function(){if(this.status!=="ready"){if(this.status==="busy"){this.queue.push(this.send.bind(this))}else if(this.status==="done"){this.finalize()}return}this.status="busy";e.ajax({url:e.util.add_url_param(this.url,{action:"getVoted",attachId:this.attachId,answerId:this.answerId}),method:"POST",dataType:"json",data:{iNumPage:++this.iNumPage,nameTemplate:this.nameTemplate,sessid:e.bitrix_sessid()},onsuccess:function(t){if(t&&t.status==="success"){t=t.data;this.buildVoters(t.items);this.data=this.data.concat(t.items);if(t["statusPage"]==="done"||t.items.length<=0){this.status="done";this.finalize()}else{this.status="ready";var e=this.queue.shift();if(e){e.call(this)}}}else{this.status="error";this.makeError(t.errors);this.finalize()}}.bind(this),onfailure:function(){this.status="error";this.makeError();this.finalize()}.bind(this)})},finalize:function(){this.queue=[];var t=this.popup?this.popup.getPopupContainer():null;if(t===null){return}t.querySelector(".bx-ilike-wait").style.display="none";e.unbind(t.querySelector(".bx-ilike-popup"),"scroll",this.popupScrollCheck)}};return t}()})(window); //# sourceMappingURL=script.map.js
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.27 |
proxy
|
phpinfo
|
Settings