Current Path : /var/www/u0635749/data/www/hobbyclick.ru/public/www/bitrix/js/sender/heatmap/ |
Current File : /var/www/u0635749/data/www/hobbyclick.ru/public/www/bitrix/js/sender/heatmap/script.min.js |
(function(t){t.BX=t.BX||{};if(t.BX.HeatMap){return}t.BX.HeatMapItem=function(t){this.caller=t.caller;this.document=t.document;this.value=t.value||0;this.color=t.color||"#000";this.textColor=t.textColor||"#000";this.text=t.text||this.value;this.baloon=t.baloon||"";this.anchorNode=t.anchorNode||"";this.id=t.id||Math.floor(Math.random()*(99999999-1e6+1))+1e6;this.valuePercent=0;this.currentSize=null;this.position={left:0,top:0,isActual:false};this.node=null};t.BX.HeatMapItem.prototype={initNodes:function(){if(this.node){return}this.node=this.caller.document.createElement("div");BX.addClass(this.node,"bx-heat-map-item");var t=this.caller.document.createElement("span");this.node.appendChild(t);this.nodeValue=this.caller.document.createElement("span");t.appendChild(this.nodeValue);this.nodePercent=this.caller.document.createElement("span");t.appendChild(this.nodePercent);this.caller.document.body.appendChild(this.node)},getRealAnchorNode:function(){return this.anchorNode.children.length>0?this.anchorNode.children[0]:this.anchorNode},resize:function(t){this.position.isActual=this.currentSize===t;this.currentSize=t||50;this.calcPosition()},calcPosition:function(){if(this.position.isActual){return}var t=BX.pos(this.getRealAnchorNode());this.position.top=t.top+Math.round(t.height/2);this.position.top-=Math.round(this.currentSize/2);this.position.left=t.left+Math.round(t.width/2);this.position.left-=Math.round(this.currentSize/2)},remove:function(){BX.remove(this.node)},draw:function(){this.initNodes();this.calcPosition();var t=String(this.valuePercent);if(t.substring(t.length-2,t.length)==".0"){t=t.substring(0,t.length-2)}this.nodeValue.innerText=t;this.nodePercent.innerText="%";this.node.style.width=this.currentSize+"px";this.node.style.height=this.currentSize+"px";this.node.style.fontSize=Math.round(this.currentSize/3)+"px";this.node.style.top=this.position.top+"px";this.node.style.left=this.position.left+"px"}};t.BX.HeatMap=function(t){this.document=t.document||document;this.color=t.color||[0,191,255,.5];this.maxSize=t.maxSize||90;this.minSize=t.minSize||30;this.valueSum=0;this.items=[];(t.items||[]).forEach(this.addItem,this)};t.BX.HeatMap.prototype={isItemsInited:false,draw:function(){if(this.document==document){BX.loadCSS("/bitrix/js/sender/heatmap/style.css",this.document)}else{var t=this.document.createElement("LINK");t.type="text/css";t.rel="stylesheet";t.href="/bitrix/js/sender/heatmap/style.css?"+1*new Date;this.document.head.appendChild(t)}this.resizeItems();this.items.forEach(function(t){t.draw()},this);if(!this.isItemsInited){this.items.forEach(function(t){var e=this;BX.bind(t.node,"mouseenter",function(){e.highLightItem(t,true)});BX.bind(t.node,"mouseleave",function(){e.highLightItem(t,false)})},this)}this.isItemsInited=true},resizeItems:function(){this.valueSum=0;this.items.forEach(function(t){this.valueSum+=parseFloat(t.value)},this);this.items.forEach(function(t){var e=parseFloat(t.value);var i=this.maxSize-this.minSize;var s=this.minSize+Math.ceil(e*i/this.valueSum);t.valuePercent=(e*100/this.valueSum).toFixed(1);t.resize(s)},this)},highLightItem:function(t,e){e=e||false;if(!this.shadowNode){this.shadowNode=this.document.createElement("div");BX.addClass(this.shadowNode,"bx-heat-map-shadow");this.document.body.appendChild(this.shadowNode)}if(e){BX.addClass(this.shadowNode,"bx-heat-map-shadow-show");BX.addClass(t.getRealAnchorNode(),"bx-heat-map-item-highlight")}else{BX.removeClass(this.shadowNode,"bx-heat-map-shadow-show");BX.removeClass(t.getRealAnchorNode(),"bx-heat-map-item-highlight")}},addItem:function(t){t.caller=this;t.document=this.document;var e=new BX.HeatMapItem(t);this.items.push(e);return e.id},getItemById:function(t){var e=this.items.filter(function(e){return e.id==t},this);return e.length>0?e[0]:null},removeItem:function(t){var e=this.getItemById(t);var i;this.items.forEach(function(e,s){if(e.id==t){i=s}},this);BX.util.deleteFromArray(this.items,i);e.remove();return e}}})(window);