%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/bitrix/www/bitrix/components/bitrix/voting.uf/templates/.default/
Upload File :
Create Path :
Current File : //home/bitrix/www/bitrix/components/bitrix/voting.uf/templates/.default/script.min.js

(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 o=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 o,a,n;this.errorNode=e.findChild(this.node,{attribute:{"data-bx-vote-role":"error"}},true);for(var r in this.buttons){if(this.buttons.hasOwnProperty(r)){o=e.findChild(this.node,{attribute:{"data-bx-vote-button":r}},true);if(o&&e.type.isFunction(this[r])){this[r]=e.delegate(this[r],this);this.buttons[r]=o;e.bind(o,"click",this[r])}}}o=e.findChildren(this.node,{tagName:"TR"},true);while(o&&(a=o.pop())&&a&&a.hasAttribute("data-bx-vote-answer")){if(t["app"]){e.bind(a,"click",e.proxy(this.checkMobileUsers,this))}else{n=e.findChild(a,{tagName:"A",attribute:{"data-bx-vote-result":"counter"}},true);e.bind(n,"click",e.proxy(this.checkUsers,this));e.adjust(n,{attrs:{"data-bx-vote-answer":a.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)}};o.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.ballot);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")}},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,o){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(o))o.apply(this,arguments)}},this),onfailure:e.proxy(function(){e.removeClass(i,"ui-btn-clock");if(e.type.isFunction(o))o.apply(this,arguments)},this)})},adjustBallot:function(t,i){var s,o,a,n,r,u={},p,h,l=t["QUESTIONS"];for(s in l){if(l.hasOwnProperty(s)){for(o in l[s]["ANSWERS"]){if(l[s]["ANSWERS"].hasOwnProperty(o)){p=l[s]["ANSWERS"][o];p["FIELD_NAME"]+=p["FIELD_TYPE"]==1||p["FIELD_TYPE"]==3?"[]":"";if(this.form.elements[p["FIELD_NAME"]]){if(p["FIELD_TYPE"]>=4){this.form.elements[p["FIELD_NAME"]].value=i[s]&&i[s][o]&&i[s][o]["MESSAGE"]?i[s][o]["MESSAGE"]:""}else{h=i[s]||{};r=e(this.form.elements[p["FIELD_NAME"]])?[this.form.elements[p["FIELD_NAME"]]]:this.form.elements[p["FIELD_NAME"]];if(u[p["FIELD_NAME"]]!==true){u[p["FIELD_NAME"]]=true;for(n=0;n<r.length;n++){delete r[n].checked}}for(n=0;n<r.length;n++){if(h[r[n].value]){r[n].checked="checked"}}}}}}}}},adjustResults:function(t){var i=t["QUESTIONS"];e.onCustomEvent(this.node,"OnBeforeChangeData");var s,o,a,n,r,u;for(n in i){if(i.hasOwnProperty(n)){s=e.findChild(this.node,{attr:{id:"question"+n}},true);if(s){for(a in i[n]["ANSWERS"]){if(i[n]["ANSWERS"].hasOwnProperty(a)){o=e.findChild(s,{attr:{"data-bx-vote-answer":a}},true);if(!!o){r=parseInt(i[n]["ANSWERS"][a]["PERCENT"]);r=isNaN(r)?0:r;u=e.findChild(o,{tagName:"A",attribute:{"data-bx-vote-result":"counter"}},true);e.adjust(u,{html:i[n]["ANSWERS"][a]["COUNTER"]+""});delete u["VOTED_USER_OBJ"];e.adjust(e.findChild(o,{tagName:"SPAN",attribute:{"data-bx-vote-result":"percent"}},true),{html:r+"%"});e.adjust(e.findChild(o,{tagName:"DIV",attribute:{"data-bx-vote-result":"bar"}},true),{style:{width:r+"%"}})}}}}}}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(){var t=e(e.proxy_context),i=null;if(t&&parseInt(t.innerHTML)>0&&t.hasAttribute("data-bx-vote-answer")){if(!t.VOTED_USER_OBJ)t.VOTED_USER_OBJ=new s(t.getAttribute("data-bx-vote-answer"),t,{nameTemplate:this.params["nameTemplate"],urlTemplate:this.params["urlTemplate"],attachId:this.id});i=t.VOTED_USER_OBJ;i.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 o=0;o<t.length;o++){s.push(t[o]["message"])}s=s.join("<br />");i=s===""?"Unknown error":s}this.errorNode.innerHTML=i}};return o}();var s=function(){var t=function(t,e,i){this.id="vote-"+t+(new Date).getTime();this.answerId=t;this.node=e;this.setStatus("ready");this.iNumPage=0;this.urlTemplate=i["urlTemplate"];this.nameTemplate=i["nameTemplate"];this.attachId=i["attachId"];this.data=[];this.queue=[];this.popup=null};t.prototype={url:i,click:function(){if(parseInt(this.node.innerHTML)>0){this.show();if(this.data.length>0)this.make();this.send()}},init:function(t){var i=e.proxy_context;if(!!i.timeoutOver){clearTimeout(i.timeoutOver);i.timeoutOver=false}if(t.type=="mouseover"){i.timeoutOver=setTimeout(e.proxy(function(){this.get(i);if(this.popup){e.bind(this.popup.popupContainer,"mouseout",e.proxy(function(){this.popup.timeoutOut=setTimeout(e.proxy(function(){if(this.node==i&&!!this.popup){this.popup.close()}},this),400)},this));e.bind(this.popup.popupContainer,"mouseover",e.proxy(function(){if(this.popup.timeoutOut)clearTimeout(this.popup.timeoutOut)},this))}},this),400)}},make:function(){if(!this.popup)return true;var t=this.data,i=this.getStatus()!="done",s=this.popup&&this.popup.contentContainer?this.popup.contentContainer:e("popup-window-content-bx-vote-popup-cont-"+this.id),o=false,a=false,n;if(this.popup.isNew){o=e.create("SPAN",{props:{className:"bx-ilike-popup"},children:[e.create("SPAN",{props:{className:"bx-ilike-bottom_scroll"}})]});a=e.create("SPAN",{props:{className:"bx-ilike-wrap-block"},children:[o]})}else{o=e.findChild(this.popup.contentContainer,{className:"bx-ilike-popup"},true)}if(o&&t.length>0){var r=null;for(n=0;n<t.length;n++){if(!e.findChild(o,{tag:"A",attr:{id:"a"+this.answerId+"u"+t[n]["ID"]}},true)){if(t[n]["PHOTO_SRC"].length>0){r=e.create("IMG",{attrs:{src:t[n]["PHOTO_SRC"]},props:{className:"bx-ilike-popup-avatar-img"}})}else{r=e.create("IMG",{attrs:{src:"/bitrix/images/main/blank.gif"},props:{className:"bx-ilike-popup-avatar-img bx-ilike-popup-avatar-img-default"}})}o.appendChild(e.create("A",{attrs:{id:"a"+this.answerId+"u"+t[n]["ID"]},props:{href:this.urlTemplate.replace("#ID#",t[n]["ID"]),target:"_blank",className:"bx-ilike-popup-img"+(!!t[n]["TYPE"]?" bx-ilike-popup-img-"+t[n]["TYPE"]:"")},text:"",children:[e.create("SPAN",{props:{className:"bx-ilike-popup-avatar-new"},children:[r,e.create("SPAN",{props:{className:"bx-ilike-popup-avatar-status-icon"}})]}),e.create("SPAN",{props:{className:"bx-ilike-popup-name-new"},html:t[n]["FULL_NAME"]})]}))}}}if(this.popup.isNew){this.popup.isNew=false;if(s){try{s.removeChild(s.firstChild)}catch(t){}s.appendChild(a)}}this.adjustWindow();if(i)this.popupScroll();return true},makeError:function(t){if(!this.popup)return true;var i=this.popup&&this.popup.contentContainer?this.popup.contentContainer:e("popup-window-content-bx-vote-popup-cont-"+this.id),s="";if(e.type.isArray(t)){for(var o=0;o<t.length;o++){s+=t[o].message}}if(i){i.innerHTML='<div class="bx-vote-popup-error-block">'+(s==""?e.message("VOTE_ERROR_DEFAULT"):s)+"</div>"}this.adjustWindow();return true},show:function(){if(this.popup!=null)this.popup.close();if(this.popup==null){this.popup=new e.PopupWindow("bx-vote-popup-cont-"+this.id,this.node,{lightShadow:true,offsetTop:-2,offsetLeft:3,autoHide:true,closeByEsc:true,bindOptions:{position:"top"},events:{onPopupClose:function(){this.destroy()},onPopupDestroy:e.proxy(function(){this.popup=null},this)},content:e.create("SPAN",{props:{className:"bx-ilike-wait"}})});this.popup.isNew=true;this.popup.show()}this.popup.setAngle({position:"bottom"});this.adjustWindow()},adjustWindow:function(){if(this.popup!=null){this.popup.bindOptions.forceBindPosition=true;this.popup.adjustPosition();this.popup.bindOptions.forceBindPosition=false}},popupScroll:function(){if(this.popup){var t=e.findChild(this.popup.contentContainer,{className:"bx-ilike-popup"},true);e.bind(t,"scroll",e.proxy(this.popupScrollCheck,this))}},popupScrollCheck:function(){var t=e.proxy_context;if(t.scrollTop>(t.scrollHeight-t.offsetHeight)/1.5){e.unbind(t,"scroll",e.proxy(this.popupScrollCheck,this));this.send()}},getStatus:function(){return this.status},setStatus:function(t){this.status=t},send:function(){if(this.getStatus()!=="ready"){if(this.getStatus()=="busy")this.queue.push(e.proxy(this.send,this));return}this.setStatus("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:e.proxy(function(t){if(t&&t.status=="success"){t=t.data;if(t["statusPage"]=="done"||t.items.length<=0)this.setStatus("done");else this.setStatus("ready");for(var i=0;i<t.items.length;i++)this.data.push(t.items[i]);this.make();if(this.queue.length>0){var s=this.queue.shift();this.queue=[];if(e.type.isFunction(s))s()}}else{this.setStatus("error");this.makeError(t.errors)}},this),onfailure:e.proxy(function(){this.setStatus("error");this.makeError()},this)})}};return t}()})(window);

Zerion Mini Shell 1.0