Your IP : 3.138.32.104


Current Path : /home/bitrix/ext_www/rk_shared_core/bitrix/js/landing/ui/
Upload File :
Current File : /home/bitrix/ext_www/rk_shared_core/bitrix/js/landing/ui/style_node.min.js

(function(){"use strict";BX.namespace("BX.Landing.UI");var e=BX.Landing.Utils.isString;BX.Landing.UI.Style=function(e){this.node="node"in e?e.node:null;this.id="id"in e?e.id:null;this.selector="selector"in e?e.selector:null;this.relativeSelector="relativeSelector"?e.relativeSelector:null;this.clickHandler="onClick"in e?e.onClick:function(){};this.iframe="iframe"in e?e.iframe:null;this.affects=new BX.Landing.Collection.BaseCollection;this.onFrameLoad()};BX.Landing.UI.Style.prototype={onFrameLoad:function(){if(!this.node){this.node=this.getNode(true);this.currentTarget=this.node[0]}this.node.forEach(function(e){e.addEventListener("click",this.onClick.bind(this));e.addEventListener("mouseover",this.onMouseEnter.bind(this));e.addEventListener("mouseleave",this.onMouseLeave.bind(this))},this);this.value=this.getValue()},getNode:function(e){var t=[].slice.call(this.iframe.document.querySelectorAll(this.relativeSelector));if(this.isSelectGroup()||e){return t}return this.currentTarget?[t[this.getElementIndex(this.currentTarget)]]:[]},getElementIndex:function(e){return[].indexOf.call(this.getNode(true),e)},onClick:function(e){if(BX.Landing.UI.Panel.StylePanel.getInstance().isShown()){e.preventDefault();e.stopPropagation();this.currentTarget=e.currentTarget;this.clickHandler()}},onMouseEnter:function(e){e.preventDefault();e.stopPropagation();this.highlight(e.currentTarget)},onMouseLeave:function(e){e.preventDefault();e.stopPropagation();this.unHighlight();var t=BX.type.isArray(this.node)&&this.node.length?this.node[0]:this.node;BX.fireEvent(t.parentNode,"mouseenter")},isSelectGroup:function(){return window.localStorage.getItem("selectGroup")==="true"},highlight:function(e){if(BX.Landing.UI.Panel.StylePanel.getInstance().isShown()){if(this.isSelectGroup()){e=this.node}BX.Landing.UI.Highlight.getInstance().show(e)}},unHighlight:function(){BX.Landing.UI.Highlight.getInstance().hide()},isChanged:function(){return JSON.stringify(this.value)!==JSON.stringify(this.getValue())},setValue:function(e,t,i,n,s){this.lastValue=this.lastValue||this.getValue();if(!!e&&BX.type.isArray(t)){n=!!n?n:"";if(typeof e==="object"){if("from"in e&&"to"in e){e.from+="-min";e.to+="-max"}var o=Object.keys(e);e=o.map(function(t){return e[t]})}else{e=[e]}if(n.length){if(n!=="background-image"){this.affects.add(n)}}this.getNode().forEach(function(i){e.forEach(function(s){t.forEach(function(t){if(e.indexOf(t.value)===-1&&e.indexOf(t.value+"-min")===-1&&e.indexOf(t.value+"-max")===-1){i.classList.remove(t.value);i.classList.remove(t.value+"-min");i.classList.remove(t.value+"-max")}});if(n){i.style[n]=null;if(n!=="background-image"){[].slice.call(i.querySelectorAll("*")).forEach(function(e){e.style[n]=null;if(n==="color"){e.removeAttribute("color")}})}}i.classList.add(s)},this);if(s){s.items.forEach(function(e){i.classList.remove(e.value)})}})}},getValue:function(){return{classList:this.getNode().length?this.getNode()[0].className.split(" "):[],affect:this.affects.toArray()}}}})();