Your IP : 18.118.146.157
(function(t){if(BX.BlockEditorManager)return;BX.BlockEditorManager={list:{},blockList:{},get:function(t){if(this.list[t]){return this.list[t]}return null},add:function(t){if(!t.blockTypeList){t.blockTypeList=this.getBlockList()}this.list[t.id]=new BXBlockEditor(t);BX.onCustomEvent(this,"onEditorAdd",[this.list[t.id]]);return this.list[t.id]},create:function(t){if(!this.get(t.id)){return this.add(t)}else{return this.get(t.id)}},setBlockList:function(t){this.blockList=t},getBlockList:function(){return this.blockList}}})(window);function BXBlockEditor(t){this.id=t.id;this.context=t.context;this.iframe=t.iframe;this.charset=t.charset;this.previewUrl=t.previewUrl;this.saveFileUrl=t.saveFileUrl;this.site=t.site;this.resultNode=t.resultNode;this.blockTypeList=t.blockTypeList;this.disableScroll=t.disableScroll||false;this.panelList={};this.blockList=[];this.placeList=[];this.dragdrop=null;this.preview=null;this.stylistContainerNode=null;this.stylistInitedValues={};this.isInited=false;this.isTemplateMode=!!t.isTemplateMode;this.CONST_ATTR_BLOCK="data-bx-block-editor-block-type";this.CONST_ATTR_PLACE="data-bx-block-editor-place";this.CONST_ATTR_BLOCK_STATUS="data-bx-block-editor-block-status";this.CONST_ATTR_STYLIST_TAG="data-bx-stylist-container";this.CONST_ATTR_TMP_RESOURSE="data-bx-resource-temp";this.CONST_ATTR_ID_STYLIST="bxStylist";this.content=new BX.BlockEditor.Content({caller:this,textarea:this.resultNode});this.statusManager=new BXBlockEditorStatusManager({caller:this});this.cssParser=new BXBlockEditorCssParser;this.shadowNode=BX.findChild(this.context,{className:"shadow"},true);BX.addCustomEvent(this,"onLoadBefore",BX.delegate(function(){BX.addClass(this.shadowNode,"active")},this));BX.addCustomEvent(this,"onLoadAfter",BX.delegate(function(){BX.removeClass(this.shadowNode,"active")},this));BX.ready(BX.delegate(function(){if(t.url){this.load(t.url)}},this));if(this.disableScroll){BX.bind(this.iframe,"load",setTimeout(this.initResize.bind(this),1e3))}}BXBlockEditor.prototype.initResize=function(){this.resize();BX.bind(this.iframe.contentWindow,"resize",BX.throttle(this.resize.bind(this),200))};BXBlockEditor.prototype.resize=function(){if(!this.disableScroll){return}var t=this.iframe.contentDocument;var e=Math.max(t.body.scrollHeight,t.documentElement.scrollHeight,t.body.offsetHeight,t.documentElement.offsetHeight,t.body.clientHeight,t.documentElement.clientHeight);if(e<=0){return}this.iframe.style.height=e+"px"};BXBlockEditor.prototype.init=function(){if(!this.isInited){this.helper=new BXBlockEditorHelper;this.initControls();this.initDragDrop();this.initEditDialog();this.initPreview();this.initTabsBlockAndStyles()}this.initPhpSlices();this.initBlockPlaces();this.initBlocks();this.initStylist();this.save();if(!this.isInited){BX.onCustomEvent(this,"onInit",[this])}this.isInited=true};BXBlockEditor.prototype.initPhpSlices=function(){this.phpParser.resetItems();var t=BX.findChildren(this.iframe.contentDocument.body,{attribute:this.phpParser.getAttrName()},true);for(var e in t){var i=t[e];var o=i.getAttribute(this.phpParser.getAttrName());var n=this.phpParser.getPhpSliceDescription(o);i.innerHTML=n.name;i.setAttribute("title",n.title);this.phpParser.addItem(i.id,o,i.outerHTML)}};BXBlockEditor.prototype.initControls=function(){this.buttonMin=BX.findChild(this.context,{className:"bx-editor-block-btn-close"},true);this.buttonMax=BX.findChild(this.context,{className:"bx-editor-block-btn-full"},true);BX.bind(this.buttonMin,"click",BX.delegate(this.close,this));BX.bind(this.buttonMax,"click",BX.delegate(this.open,this));var t=this;this.panelList["edit"]={};this.panelList["edit"].button=BX.findChildByClassName(this.context,"bx-editor-block-btn-"+"edit",true);this.panelList["edit"].panel=BX.findChildByClassName(this.context,"edit"+"-panel",true);BX.bind(this.panelList["edit"].button,"click",function(){t.showPanel("edit")});BX.addClass(this.panelList["edit"].button,"bx-editor-block-btn-active");this.panelList["edit"].panel.style.display=null;this.panelList["preview"]={};this.panelList["preview"].button=BX.findChildByClassName(this.context,"bx-editor-block-btn-"+"preview",true);this.panelList["preview"].panel=BX.findChildByClassName(this.context,"preview"+"-panel",true);BX.bind(this.panelList["preview"].button,"click",function(){t.showPreview("preview")});var e=this.context.querySelector('[data-role="block-editor-tab-btn-get-html"]');BX.clipboard.bindCopyClick(e,{text:this.getContent.bind(this)})};BXBlockEditor.prototype.initBlocks=function(){this.blockList=[];var t=BX.findChildren(this.iframe.contentDocument.body,{attribute:this.CONST_ATTR_BLOCK},true);for(var e in t){this.addBlock(t[e])}};BXBlockEditor.prototype.initStylist=function(){var t=this.iframe.contentDocument.head;this.stylistContainerNode=false;this.helper.each(t.childNodes,function(t){var e=t.nodeName;if(e=="SCRIPT"||e=="STYLE"||e=="LINK"){if(t.attributes&&t.hasAttribute&&t.hasAttribute(this.CONST_ATTR_STYLIST_TAG)){this.stylistContainerNode=t}}},this);if(!this.stylistContainerNode){this.stylistContainerNode=BX.create("STYLE");this.stylistContainerNode.setAttribute(this.CONST_ATTR_STYLIST_TAG,"item");this.stylistContainerNode.setAttribute("type","text/css");t.appendChild(this.stylistContainerNode)}this.stylistInitedValues=this.cssParser.parse(this.stylistContainerNode.innerHTML);if(!this.isInited){this.content.getStyles().forEach(function(t){var e;if(t.block){e=t.block.parameters}else if(t.value){e=this.cssParser.parse(t.value)}var i=this.cssParser.parse(this.stylistContainerNode.innerHTML);e=this.cssParser.mergeStyles(i,e);this.stylistContainerNode.innerHTML=this.cssParser.getCssString(e)},this)}this.placeList=[];var e=this.findStylistPlaces();for(var i in e){var o=e[i];var n=new BXBlockEditorStylist;BX.onCustomEvent(this,"onPlaceBlockCreate",[n]);n.init(o,{caller:this,type:i,controls:{}});n.styleNode=this.stylistContainerNode;n.placeNode=o;this.placeList.push(n)}BX.addCustomEvent(this.editDialog,"onPlaceEdit",BX.delegate(this.onPlaceEdit,this));BX.addCustomEvent(this.editDialog,"onPlaceHover",BX.delegate(this.onPlaceHover,this))};BXBlockEditor.prototype.findStylistPlaces=function(){var t={};var e=BX.findChild(this.iframe.contentDocument.body,{attribute:{id:this.CONST_ATTR_ID_STYLIST+"Page"}},true);if(!e){e=this.iframe.contentDocument.body}t["page"]=e;var i=this.iframe.contentDocument.body.querySelectorAll("[id^="+this.CONST_ATTR_ID_STYLIST+"]");for(var o=0;o<i.length;o++){var n=i.item(o);if(n&&n.id){var s=n.id.substr(this.CONST_ATTR_ID_STYLIST.length);if(s){t[s]=n}}}return t};BXBlockEditor.prototype.onPlaceHover=function(t,e){for(var i in this.placeList){var o=this.placeList[i];if(t!=o.type){continue}var n=o.node;if(e){BX.addClass(n,"bx-stylist-enter")}else{BX.removeClass(n,"bx-stylist-enter")}break}};BXBlockEditor.prototype.onPlaceEdit=function(t){for(var e in this.placeList){var i=this.placeList[e];if(t!=i.type){continue}this.editBlock(i);break}};BXBlockEditor.prototype.initBlockPlaces=function(){var t,e;var i=null;var o;var n=this.findBlockPlaces();if(this.isTemplateMode){var s={};for(o in n){e=n[o];if(!s[o]){s[o]={node:e,html:""}}if(!i){i=o}}this.content.getBlocks().forEach(function(t){var e=null;if(s[t.place]){e=t.place}else if(s["body"]){e="body"}else if(s[i]){e=i}else{return}var o=s[e];var n="";if(t.block){n=this.getBlockHtml(t.block.type,t.block.parameters)}else{n=this.phpParser.replacePhpByLayout(t.value)}var r="<div "+this.CONST_ATTR_BLOCK+'="text">';if(n.indexOf(r)===0&&n.length<r.length+10){n=" "}o.html+=n},this);this.helper.each(s,function(t){if(t.html.length>0){t.node.innerHTML=""}},this);this.helper.each(s,function(t){var e=false;if(t.html.length>0){t.node.innerHTML=t.html;e=true}BX.onCustomEvent(this,"onPlaceInitBlocksContent",[t.node,e])},this)}for(o in n){e=n[o];if(e.innerHTML){e.innerHTML=e.innerHTML.trim()}this.actualizeBlockPlace(e)}};BXBlockEditor.prototype.findBlockPlaces=function(){var t={};var e={attribute:this.CONST_ATTR_PLACE};var i=BX.findChildren(this.iframe.contentDocument.body,e,true);this.helper.each(i,function(e){var i=e.getAttribute(this.CONST_ATTR_PLACE);t[i]=e},this);return t};BXBlockEditor.prototype.actualizeBlockPlace=function(t){if(!t.hasAttribute(this.CONST_ATTR_PLACE)){return false}var e;var i=BX.findChildren(t,{attribute:this.CONST_ATTR_BLOCK},true);if(i.length==0){BX.cleanNode(t)}for(var o=0;o<t.childNodes.length;o++){var n=t.childNodes.item(o);if(n&&n.nodeName=="#text"){BX.remove(n)}}if(t.childNodes.length==0){e=BX.create("DIV",{text:BX.message("BLOCK_EDITOR_PLACE_DROP_ZONE")});BX.addClass(e,"bx-editor-place");t.appendChild(e);this.dragdrop.dragdrop.addCatcher(e)}else{e=BX.findChild(t,{className:"bx-editor-place"});if(e&&t.childNodes.length>1){this.dragdrop.dragdrop.removeCatcher(e);BX.remove(e)}}return true};BXBlockEditor.prototype.initPreview=function(){this.preview=new BXBlockEditorPreview({context:this.context,caller:this,site:this.site,url:this.previewUrl})};BXBlockEditor.prototype.initTabsBlockAndStyles=function(){var t=BX.findChildByClassName(this.context,"bx-editor-block-tabs",true);var e=BX.findChildByClassName(t,"blocks",true);var i=BX.findChildByClassName(t,"styles",true);var o=BX.findChildByClassName(this.context,"edit-panel-tabs-block",true);var n=BX.findChildByClassName(this.context,"edit-panel-tabs-style",true);var s=function(){if(BX.hasClass(this,"blocks")){BX.removeClass(i,"active");o.style.display="block";n.style.display="none"}else{BX.removeClass(e,"active");o.style.display="none";n.style.display="block"}BX.addClass(this,"active")};BX.bind(e,"click",s);BX.bind(i,"click",s);var r=BX.findChildByClassName(this.context,"adm-nav-page-prev",true);var l=BX.findChildByClassName(this.context,"adm-nav-page-next",true);var a=function(t,e){var i=t.querySelector("ul.bx-block-editor-i-block-list");while(i){if(BX.style(i,"display")=="block"){break}i=i.nextElementSibling}if(i){var o;if(e){o=i.nextElementSibling}else{o=i.previousElementSibling}if(o){var n=new BX.easing({duration:200,start:{opacity:1},finish:{opacity:0},transition:BX.easing.transitions.quart,step:function(t){i.style.opacity=t.opacity},complete:function(){i.style.display="none";i.style.opacity=1;o.style.display="block"}});n.animate()}}};var c=this.context;BX.bind(r,"click",function(){a(c,false)});BX.bind(l,"click",function(){a(c,true)})};BXBlockEditor.prototype.showPanel=function(t){for(var e in this.panelList){if(e!=t){this.panelList[e].panel.style.display="none";BX.removeClass(this.panelList[e].button,"bx-editor-block-btn-active")}}BX.addClass(this.panelList[t].button,"bx-editor-block-btn-active");this.panelList[t].panel.removeAttribute("style")};BXBlockEditor.prototype.showPreview=function(t,e){if(e==undefined){e=false}this.preview.show({content:this.getContent(e)});this.showPanel(t)};BXBlockEditor.prototype.showHtml=function(t){var e=BX.findChild(this.panelList[t].panel,{tag:"textarea"},true);e.value=this.getContent();this.showPanel(t)};BXBlockEditor.prototype.initEditDialog=function(){this.editDialog=new BXBlockEditorEditDialog({context:this.context,caller:this,saveFileUrl:this.saveFileUrl});this.editDialog.caller=this;this.phpParser=new BXBlockEditorPHPParser({htmlEditor:this.editDialog.htmlEditor});this.editDialog.phpParser=this.phpParser;BX.addCustomEvent(this.editDialog,"controlChangeValue",BX.delegate(this.onEditDialogControlChangeValue,this));BX.addCustomEvent(this.editDialog,"onSave",BX.delegate(this.editBlockEnd,this));BX.addCustomEvent(this.editDialog,"onCancel",BX.delegate(this.editBlockEnd,this));BX.addCustomEvent(this,"onClose",BX.delegate(this.editDialog.save,this.editDialog));var t=BX.findParent(this.resultNode,{tag:"form"});var e=this;BX.bind(t,"submit",function(i){if(e.isFinalSave){e.isFinalSave=false;return}i.preventDefault();i.stopPropagation();e.editDialog.save(function(){e.isFinalSave=true;e.save();BX.submit(t)})})};BXBlockEditor.prototype.initDragDrop=function(){this.dragdrop=new BXBlockEditorDragDrop;BX.addCustomEvent(this.dragdrop,"onZoneEnter",this.showDragDropZone);BX.addCustomEvent(this.dragdrop,"onZoneLeave",this.hideDragDropZone);BX.addCustomEvent(this.dragdrop,"onItemAdd",BX.delegate(this.onDragDropItemAdd,this));BX.addCustomEvent(this.dragdrop,"onItemMove",BX.delegate(this.onDragDropItemMove,this))};BXBlockEditor.prototype.open=function(){BX.addClass(this.context,"editing")};BXBlockEditor.prototype.close=function(){BX.onCustomEvent(this,"onClose");BX.removeClass(this.context,"editing")};BXBlockEditor.prototype.save=function(){var t=this.getContentForSave();BX.onCustomEvent(this,"onSave",[t]);if(!this.resultNode){return}this.resultNode.value=t};BXBlockEditor.prototype.load=function(t,e){BX.onCustomEvent(this,"onLoadBefore",[t,e,this]);BX.unbindAll(this.iframe);BX.bind(this.iframe,"load",BX.delegate(function(){var i=BX.loadCSS("/bitrix/js/fileman/block_editor/editor.css?r="+Math.random(),this.iframe.contentDocument,this.iframe.contentWindow);if(i){var o={attrs:{}};o["attrs"][this.CONST_ATTR_TMP_RESOURSE]="bx-editor";BX.adjust(i,o)}this.init();if(BX.type.isFunction(e)){e.apply(this)}BX.onCustomEvent(this,"onLoadAfter",[t,e,this])},this));if(this.charset){t=t+"&template_charset="+this.charset}this.iframe.src=t};BXBlockEditor.prototype.getSortedBlockListWithReplacedEmptyPlaces=function(){this.helper.each(this.findBlockPlaces(),function(t,e){var i=t.querySelectorAll("["+this.CONST_ATTR_BLOCK+"]");if(i.length>0){return}if(t.children.length!=1){return}var o=this.getBlockNodeByType("text");if(o){var n=this.addBlockByNode(o,t.children[0],true);n.setContentHtml("")}},this);return this.getSortedBlockList()};BXBlockEditor.prototype.getSortedBlockList=function(){var t=[];var e=this.iframe.contentDocument.body.querySelectorAll("["+this.CONST_ATTR_BLOCK+"]");e=BX.convert.nodeListToArray(e);var i=this.statusManager.getPlaceNameList(e);e.forEach(function(e,o){if(!e.parentNode||!BX.util.in_array(e.parentNode.getAttribute(this.CONST_ATTR_PLACE),i)){return}this.helper.each(this.blockList,function(i){if(i.node!==e){return}i.sort=o;t.push(i)},this)},this);return t};BXBlockEditor.prototype.getContentForSave=function(){if(!this.isTemplateMode){return this.getContent()}else{var t=[];if(this.stylistContainerNode&&this.stylistContainerNode.innerHTML){var e=this.stylistContainerNode.innerHTML.trim();if(e){var i=this.cssParser.diffStylesAll(this.stylistInitedValues,this.cssParser.parse(e));if(i){e='<style type="text/css">'+"\n"+this.cssParser.getCssString(i)+"\n"+"</style>";t.push({type:"STYLES",place:"page",value:e,block:{type:"stylist",parameters:i}})}}}var o=this.isFinalSave?this.getSortedBlockListWithReplacedEmptyPlaces():this.getSortedBlockList();t=t.concat(o.map(function(t){return{type:"BLOCKS",place:t.getPlaceHolderCode(),value:t.getContentHtmlOuter(),block:{type:t.type,parameters:t.getEditValues()}}},this));return this.content.getString(t)}};BXBlockEditor.prototype.getContent=function(t){t=!!(t||null);var e=this.iframe.contentDocument.cloneNode(true);if(e.head)for(var i=e.head.childNodes.length-1;i>=0;i--){var o=e.head.childNodes.item(i);var n=o.nodeName;n=n||"";n=n.toUpperCase();if(n=="SCRIPT"||n=="STYLE"||n=="LINK"){if(o.attributes&&o.hasAttribute){if(o.hasAttribute(this.CONST_ATTR_TMP_RESOURSE)){BX.remove(o)}else if(o.hasAttribute(this.CONST_ATTR_STYLIST_TAG)){}}if(o.href&&o.href.indexOf("/bitrix/js/fileman/block_editor/editor.css")>-1){BX.remove(o)}}}var s=BX.findChildren(e.body,{attribute:this.CONST_ATTR_PLACE},true);for(var r in s){var l=s[r];var a=BX.findChildren(l,{attribute:this.CONST_ATTR_BLOCK},true);if(a.length==0){BX.cleanNode(l)}}var c=[];if(e.body){c=BX.findChildren(e.body,{attribute:this.CONST_ATTR_BLOCK},true)}for(var d in c){var h=c[d];var p=BX.findChild(h,{className:"bx-content"},true);var u=BX.convert.nodeListToArray(p.childNodes);if(t&&h&&h.getAttribute&&h.getAttribute(this.CONST_ATTR_BLOCK)=="component"){u=BX.findChildren(h,{className:"bx-component"},true)}BX.cleanNode(h);BX.adjust(h,{children:u});for(var B=h.attributes.length;B>=0;B--){if(h.attributes[B]&&h.attributes[B].name!=this.CONST_ATTR_BLOCK){h.removeAttribute(h.attributes[B].name)}}}if(!t){this.phpParser.replaceLayoutBySurrogate(e.body)}var f=e.documentElement.outerHTML;if(!t){f=this.phpParser.replaceSurrogateByPhp(f)}return f};BXBlockEditor.prototype.showDragDropZone=function(t,e){{BX.addClass(t,"bx-dd-enter");if(e){BX.removeClass(t,"bx-dd-enter-bottom");BX.addClass(t,"bx-dd-enter-top")}else{BX.removeClass(t,"bx-dd-enter-top");BX.addClass(t,"bx-dd-enter-bottom")}}};BXBlockEditor.prototype.hideDragDropZone=function(t){{BX.removeClass(t,"bx-dd-enter");BX.removeClass(t,"bx-dd-enter-top");BX.removeClass(t,"bx-dd-enter-bottom")}};BXBlockEditor.prototype.onDragDropItemMove=function(t,e,i){var o=t.parentNode;var n;for(var s in this.blockList){if(this.blockList[s]&&this.blockList[s].node==t){n=this.blockList[s];break}}n.onMoveHandler(e);this.helper.appendChildNode(t,e,i);this.actualizeBlockPlace(o);this.actualizeBlockPlace(e.parentNode);BX.onCustomEvent(this,"onBlockMoveAfter",[n]);this.save()};BXBlockEditor.prototype.onDragDropItemAdd=function(t,e,i){this.addBlockByNode(this.getBlockNodeByType(t),e,i);this.save()};BXBlockEditor.prototype.onEditDialogControlChangeValue=function(t,e,i){if(this.currentEditingBlock){this.currentEditingBlock.setEditValue(t,e,i)}};BXBlockEditor.prototype.getCurrentEditingBlock=function(){return this.currentEditingBlock};BXBlockEditor.prototype.getBlockHtml=function(t,e){var i=this.getBlockNodeByType(t);var o;if(t==="component"){o=new BXBlockEditorBlockComponent}else{o=new BXBlockEditorBlock}o.init(i,{caller:this,type:t});o.setEditValues(e);return o.getContentHtmlOuter()};BXBlockEditor.prototype.getBlockHtmlByCode=function(t){var e=this.blockTypeList[t].TYPE;var i=this.blockTypeList[t].HTML;if(e=="component"){i=this.phpParser.getComponentInclude(t)}return this.phpParser.replacePhpByLayout(i)};BXBlockEditor.prototype.getBlockNodeByType=function(t){var e={};var i=this.blockTypeList[t].TYPE;var o=this.getBlockHtmlByCode(t);e[this.CONST_ATTR_BLOCK]=i;return BX.create({tag:"DIV",attrs:e,html:o})};BXBlockEditor.prototype.addBlockByNode=function(t,e,i){var o=this.addBlock(t);o.onMoveHandler(e);this.helper.appendChildNode(t,e,i);this.actualizeBlockPlace(e.parentNode);BX.onCustomEvent(o,"onBlockCreateAfter");BX.onCustomEvent(this,"onBlockCreateAfter",[o]);return o};BXBlockEditor.prototype.addBlockByHtml=function(t,e,i){var o=BX.create({tag:"DIV",html:t});return this.addBlockByNode(o.children[0],e,i)};BXBlockEditor.prototype.addBlock=function(t){var e=t.getAttribute(this.CONST_ATTR_BLOCK);var i;BX.addClass(t,"bx-editor-block");BX.addClass(t,"bx-type-"+e);if(e==="component"){i=new BXBlockEditorBlockComponent}else{i=new BXBlockEditorBlock}BX.onCustomEvent(this,"onBlockCreate",[i]);i.init(t,{caller:this,type:t.getAttribute(this.CONST_ATTR_BLOCK),controls:{drag:BX.delegate(function(){},this),clone:BX.delegate(function(t){this.cloneBlock(i);return BX.PreventDefault(t)},this),edit:BX.delegate(function(t){this.editBlock(i);return BX.PreventDefault(t)},this),remove:BX.delegate(function(t){this.removeBlock(i);return BX.PreventDefault(t)},this)}});this.blockList.push(i);this.dragdrop.addItem(i.node);return i};BXBlockEditor.prototype.removeBlock=function(t){BX.onCustomEvent(this,"onBlockRemove",[t]);for(var e in this.blockList){if(t==this.blockList[e]){this.blockList.splice(e,1)}}this.dragdrop.removeItem(t.node);var i=t.node.parentNode;BX.remove(t.node);this.actualizeBlockPlace(i);BX.onCustomEvent(this,"onBlockRemoveAfter",[i]);this.save();this.editDialog.hide()};BXBlockEditor.prototype.cloneBlock=function(t){var e={};e[this.CONST_ATTR_BLOCK]=t.type;var i=BX.create({tag:"DIV",attrs:e,html:this.phpParser.replacePhpByLayout(t.getContentHtml())});t.node.parentNode.insertBefore(i,t.node);var o=this.addBlock(i);BX.onCustomEvent(this,"onBlockClone",[o]);this.save()};BXBlockEditor.prototype.editBlockEnd=function(t){if(!this.currentEditingBlock){return}BX.onCustomEvent(this,"onBlockEditEnd",[this.currentEditingBlock,t]);this.save();BX.removeClass(this.currentEditingBlock.node,"bx-editor-block-current-edit");this.currentEditingBlock=null};BXBlockEditor.prototype.editBlock=function(t){BX.onCustomEvent(this,"onBlockEdit",[t]);var e=this;this.editDialog.save(function(){e.currentEditingBlock=t;BX.addClass(e.currentEditingBlock.node,"bx-editor-block-current-edit");e.editDialog.load(t.getEditPropList());e.editDialog.show()})};function BXBlockEditorBlock(){this.caller=null;this.type="";this.node={};this.nodeContent={};this.editHandlerList={}}BXBlockEditorBlock.prototype.init=function(t,e){this.caller=e.caller;this.type=e.type;this.node=t;this.helper=new BXBlockEditorHelper;this.initStructure();if(e.controls){this.initControls(e.controls)}this.initEditHandlers();this.initDependencies()};BXBlockEditorBlock.prototype.initEditHandlers=function(){BX.onCustomEvent(this.caller,"onBlockInitHandlers",[this,this.type])};BXBlockEditorBlock.prototype.getPlaceHolderCode=function(){return this.node.parentNode.getAttribute(this.caller.CONST_ATTR_PLACE)};BXBlockEditorBlock.prototype.setContentHtml=function(t,e){e=!!(e||null);if(!e){t=this.caller.phpParser.replacePhpByLayout(t)}this.nodeContent.innerHTML=t};BXBlockEditorBlock.prototype.getContentHtml=function(t){t=!!(t||null);var e=BX.clone(this.nodeContent);if(!t){this.caller.phpParser.replaceLayoutBySurrogate(e)}var i=e.innerHTML;if(!i){i=""}if(!t){i=this.caller.phpParser.replaceSurrogateByPhp(i)}i=i.trim();return i};BXBlockEditorBlock.prototype.getContentHtmlOuter=function(t){var e=this.getContentHtml(t);e="<div "+this.caller.CONST_ATTR_BLOCK+'="'+this.type+'">\n'+e+"\n</div>";return e};BXBlockEditorBlock.prototype.findEditHandler=function(t){if(this.editHandlerList&&this.editHandlerList[t]){return this.editHandlerList[t]}return null};BXBlockEditorBlock.prototype.initDependencies=function(){var t={};for(var e in this.editHandlerList){var i=this.editHandlerList[e];if(!BX.type.isArray(i.reload_dependence)){continue}for(var o in i.reload_dependence){var n=i.reload_dependence[o];if(!BX.type.isArray(t[n])){t[n]=[]}t[n].push(e)}}this.dependencies=t};BXBlockEditorBlock.prototype.onMoveHandler=function(t){var e=this.node;this.helper.each(this.editHandlerList,BX.delegate(function(i){if(BX.type.isFunction(i.onMove)){this.findEditNodeList(i.className);i.onMove.apply(this,[e,t])}},this));if(BX.type.isFunction(this.onMove)){this.onMove.apply(this,[e,t])}};BXBlockEditorBlock.prototype.findEditNodeList=function(t,e){var i=[];var o=[];var n=0;if(e){e=parseInt(e)}if(t){o=BX.findChildren(this.nodeContent,{className:t},true)}else{o.push(this.nodeContent)}for(var s in o){if(e){n++;if(n<e)continue;if(n>e)break}i.push(o[s])}return i};BXBlockEditorBlock.prototype.columnToolName="column-count";BXBlockEditorBlock.prototype.getEditValues=function(){var t=[];var e=this.getEditValue(this.columnToolName);e=e>0?e:1;for(var i in this.editHandlerList){if(!this.editHandlerList.hasOwnProperty(i)){continue}for(var o=1;o<=e;o++){var n=this.getEditValue(i,o);if(n===null||n===""){continue}t.push({code:i,value:n,column:o})}}return t};BXBlockEditorBlock.prototype.setEditValues=function(t){var e=t.filter(function(t){return t.code==this.columnToolName},this);if(e&&e[0]){var i=e[0].value;i=i>0?i:1;this.setEditValue(this.columnToolName,i)}t.forEach(function(t){this.setEditValue(t.code,t.value,t.column>0?t.column:1)},this)};BXBlockEditorBlock.prototype.setEditValue=function(t,e,i){var o=this.findEditHandler(t);if(!o){return}var n=this.findEditNodeList(o.className,i);if(!BX.type.isFunction(o.func)){return}for(var s in n){var r=n[s];o.func.apply(this,[r,t,e])}};BXBlockEditorBlock.prototype.getEditValue=function(t,e){var i=null;var o=this.findEditHandler(t);if(!o){return i}var n=this.findEditNodeList(o.className,e);if(!BX.type.isFunction(o.func)){return i}var s=n[0];if(!s){return i}i=o.func.apply(this,[s,t]);return i};BXBlockEditorBlock.prototype.getEditPropList=function(t){var e=[];t=t||[];for(var i in this.editHandlerList){if(t.length>0&&!BX.util.in_array(i,t)){continue}var o=this.editHandlerList[i];e.push({code:i,params:o["params"]?o["params"]:{},value:this.getEditValue(i),dependence:this.dependencies[i]?this.dependencies[i]:[]})}return e};BXBlockEditorBlock.prototype.initStructure=function(){var t=this.node;var e;var i=document.createElement("div");BX.addClass(i,"bx-shadow");var o=document.createElement("div");BX.addClass(o,"bx-controls");o.innerHTML=""+'<span title="'+BX.message("BLOCK_EDITOR_BLOCK_ACTION_MOVE")+'" class="bx-editor-block-controls-btn bx-drag"></span>'+'<span title="'+BX.message("BLOCK_EDITOR_BLOCK_ACTION_REMOVE")+'" class="bx-editor-block-controls-btn bx-remove"></span>'+'<span title="'+BX.message("BLOCK_EDITOR_BLOCK_ACTION_COPY")+'" class="bx-editor-block-controls-btn bx-clone"></span>'+'<span title="'+BX.message("BLOCK_EDITOR_BLOCK_ACTION_EDIT")+'" class="bx-editor-block-controls-btn bx-edit"></span>'+"";var n=t.innerHTML;var s=BX.create({tag:"DIV",props:{className:"bx-content"},html:n});t.innerHTML="";this.nodeContent=s;e=BX.create({tag:"DIV",props:{className:"bx-block-inside"},children:[i,s,o],style:{display:"none"}});var r=document.createElement("div");BX.addClass(r,"bx-dropzone");r.innerHTML=BX.message("BLOCK_EDITOR_PLACE_DROP_ZONE");var l=document.createElement("div");BX.addClass(l,"bx-dropzone");l.innerHTML=BX.message("BLOCK_EDITOR_PLACE_DROP_ZONE");t.appendChild(r);t.appendChild(e);t.appendChild(l);e.style.display="block"};BXBlockEditorBlock.prototype.initControls=function(t){var e=BX.findChild(this.node,{className:"bx-controls"},true);var i=BX.findChild(e,{className:"bx-remove"},true);var o=BX.findChild(e,{className:"bx-drag"},true);var n=BX.findChild(e,{className:"bx-clone"},true);var s=BX.findChild(e,{className:"bx-edit"},true);BX.bind(i,"click",t.remove);BX.bind(o,"click",t.drag);BX.bind(n,"click",t.clone);BX.bind(s,"click",t.edit);BX.bind(this.node,"click",t.edit)};function BXBlockEditorBlockComponent(){BXBlockEditorBlockComponent.superclass.constructor.call(this);this.componentDescriptionNode=null;this.init=function(t,e){e.controls.edit=BX.delegate(this.onEdit,this);BXBlockEditorBlockComponent.superclass.init.call(this,t,e);this.setContentClearPhp(this.getContentClearPhp());var i=BX.create({tag:"DIV",props:{className:"bx-component-header"}});var o=BX.create({tag:"DIV",props:{className:"bx-component-icon"}});var n=BX.create({tag:"DIV",props:{className:"bx-component-description"}});var s=BX.create({tag:"DIV",props:{className:"bx-component"},children:[i,o,n]});this.nodeContent.parentNode.insertBefore(s,this.nodeContent.nextSibling);this.componentIconNode=BX.findChildByClassName(this.node,"bx-component-icon",true);this.componentDescriptionNode=BX.findChildByClassName(this.node,"bx-component-description",true);this.componentHeaderNode=BX.findChildByClassName(this.node,"bx-component-header",true);var r=this.caller.phpParser.getPhpSliceDescription(this.getContentClearPhp());this.componentHeaderNode.innerHTML=r?r.name:this.type;this.componentDescriptionNode.innerHTML=r?r.title:this.type;BX.addCustomEvent(this,"onBlockCreateAfter",this.onBlockCreateAfter)};this.setContentClearPhp=function(t){t='<div class="bxBlockPadding">'+t+"</div>";this.setContentHtml(t)};this.getContentClearPhp=function(){return this.getContentHtml().split(/<[^?>]+>/g).join("")};this.onBlockCreateAfter=function(){this.showComponentPropertiesDialog()};this.onEdit=function(){this.showComponentPropertiesDialog()};this.showComponentPropertiesDialog=function(){this.caller.currentEditingBlock=this;var t=this;this.caller.editDialog.save();this.caller.currentEditingBlock=this;this.caller.phpParser.showComponentPropertiesDialog(this.getContentClearPhp(),function(e){t.setContentClearPhp(e);t.caller.editBlockEnd(true)},function(){t.caller.editBlockEnd(false)})}}BX.extend(BXBlockEditorBlockComponent,BXBlockEditorBlock);function BXBlockEditorStylist(){BXBlockEditorStylist.superclass.constructor.call(this);this.styleNode=null;this.placeNode=null;this.selectorTextList=[".bxBlockContentText",".bxBlockContentText p",".bxBlockContentSocial",".bxBlockContentSocial p",".bxBlockContentBoxedText",".bxBlockContentBoxedText p"];this.selectorAList=[".bxBlockSocial a",".bxBlockContentText a",".bxBlockContentBoxedText a"];this.getPlaceHolderCode=function(){};this.initStructure=function(){};this.initControls=function(){};this.getContentHtml=function(){};this.getContentHtmlOuter=function(){};this.findEditNodeList=function(t){return[this.styleNode]};this.initEditHandlers=function(){if(this.type=="page"){this.editHandlerList={"bx-stylist-bgcolor":{className:"",func:function(t,e,i){return this.css("",[""],t,"background",i)}}};var t=function(){return function(t,e){t["bx-stylist-"+e+"-color"]={className:"",func:function(t,i,o){if(o){o+=" !important"}var n=this.css("",[e],t,"color",o);if(n){resultList=n.split(" ");n=resultList[0]}return n}};t["bx-stylist-"+e+"-font-size"]={className:"",func:function(t,i,o){if(o){o+=" !important"}var n=this.css("",[e],t,"font-size",o);if(n){resultList=n.split(" ");n=resultList[0]}return n}};t["bx-stylist-"+e+"-font-weight"]={className:"",func:function(t,i,o){if(o){o+=" !important"}var n=this.css("",[e],t,"font-weight",o);if(n){resultList=n.split(" ");n=resultList[0]}return n}};t["bx-stylist-"+e+"-font-weight"]={className:"",func:function(t,i,o){if(o){o+=" !important"}var n=this.css("",[e],t,"font-weight",o);if(n){resultList=n.split(" ");n=resultList[0]}return n}};t["bx-stylist-"+e+"-line-height"]={className:"",func:function(t,i,o){if(o){o+=" !important"}var n=this.css("",[e],t,"line-height",o);if(n){resultList=n.split(" ");n=resultList[0]}return n}};t["bx-stylist-"+e+"-text-align"]={className:"",func:function(t,i,o){if(o){o+=" !important"}var n=this.css("",[e],t,"text-align",o);if(n){resultList=n.split(" ");n=resultList[0]}return n}};return t}}();for(var e=1;e<=4;e++){this.editHandlerList=t(this.editHandlerList,"h"+e)}}else{this.editHandlerList={"bx-stylist-bgcolor":{className:"",func:function(t,e,i){return this.css("",[""],t,"background",i)}},"bx-stylist-padding-top":{className:"",func:function(t,e,i){return this.css("",[""],t,"padding-top",i)}},"bx-stylist-padding-bottom":{className:"",func:function(t,e,i){return this.css("",[""],t,"padding-bottom",i)}},"bx-stylist-text-color":{className:"",func:function(t,e,i){return this.cssTextBlock(t,"color",i)}},"bx-stylist-text-font-family":{className:"",func:function(t,e,i){return this.cssTextBlock(t,"font-family",i)}},"bx-stylist-text-font-size":{className:"",func:function(t,e,i){return this.cssTextBlock(t,"font-size",i)}},"bx-stylist-text-font-weight":{className:"",func:function(t,e,i){return this.cssTextBlock(t,"font-weight",i)}},"bx-stylist-text-line-height":{className:"",func:function(t,e,i){return this.cssTextBlock(t,"line-height",i)}},"bx-stylist-text-text-align":{className:"",func:function(t,e,i){return this.cssTextBlock(t,"text-align",i)}},"bx-stylist-a-color":{className:"",func:function(t,e,i){return this.cssATag(t,"color",i)}},"bx-stylist-a-font-weight":{className:"",func:function(t,e,i){return this.cssATag(t,"font-weight",i)}},"bx-stylist-a-text-decoration":{className:"",func:function(t,e,i){return this.cssATag(t,"text-decoration",i)}}}}};this.getSelector=function(t){var e=this.type;e=e[0].toUpperCase()+e.substring(1);var i=[];for(var o in t){var n=t[o];if(this.type=="page"){i.push("body"+(n?" ":"")+n)}i.push("#"+this.caller.CONST_ATTR_ID_STYLIST+e+(n?" ":"")+n)}return i.join(", ")};this.cssHeadTag=function(t,e,i,o){return this.css("",[t],e,i,o)};this.css=function(t,e,i,o,n){var s=this.getSelector(e);var r;if(typeof n!=="undefined"){var l={};l[o]=n;r=i.innerHTML;if(i.styleSheet){r=i.styleSheet.cssText}r=this.caller.cssParser.setStyle(r,t,s,l);i.innerHTML=r;if(i.styleSheet){i.styleSheet.cssText=r}}r=i.innerHTML;if(i.styleSheet){r=i.styleSheet.cssText}var a=this.caller.cssParser.getStyle(r,t,s,[o]);return a[o]};this.cssTextBlock=function(t,e,i){return this.css("",this.selectorTextList,t,e,i)};this.cssATag=function(t,e,i){return this.css("",this.selectorAList,t,e,i)}}BX.extend(BXBlockEditorStylist,BXBlockEditorBlock);function BXBlockEditorPHPParser(t){this.phpList=[];this.htmlEditor=t.htmlEditor;this.componentPropertiesDialogHandler=null;this.componentPropertiesDialogHandlerCancel=null;BX.addCustomEvent(this.htmlEditor,"OnContentChanged",BX.delegate(this.handleComponentPropertiesChange,this))}BXBlockEditorPHPParser.prototype.handleComponentPropertiesClose=function(){if(BX.type.isFunction(this.componentPropertiesDialogHandlerCancel)){this.componentPropertiesDialogHandlerCancel.call(this)}this.componentPropertiesDialogHandler=null;this.componentPropertiesDialogHandlerCancel=null};BXBlockEditorPHPParser.prototype.handleComponentPropertiesChange=function(t){if(BX.type.isFunction(this.componentPropertiesDialogHandler)){this.componentPropertiesDialogHandler.call(this,t)}this.componentPropertiesDialogHandler=null;this.componentPropertiesDialogHandlerCancel=null};BXBlockEditorPHPParser.prototype.showComponentPropertiesDialog=function(t,e,i){if(!this.htmlEditor.components.IsComponent(t)){return}this.htmlEditor.SetContent(t,true);var o=this.htmlEditor.phpParser.GetAllSurrogates();if(!o[0]){return}var n=o[0];var s=this.htmlEditor.GetBxTag(n.node);var r=this.htmlEditor.GetBxTag(s.surrogateId);this.componentPropertiesDialogHandler=e;this.componentPropertiesDialogHandlerCancel=i;this.htmlEditor.components.ShowPropertiesDialog(s.params,r);BX.addCustomEvent(this.htmlEditor.components.oPropertiesDialog.oDialog,"onWindowUnRegister",BX.proxy(this.handleComponentPropertiesClose,this))};BXBlockEditorPHPParser.prototype.replaceLayoutBySurrogate=function(t){for(var e in this.phpList){var i=this.phpList[e];var o=BX.findChild(t,{attribute:{id:i.id}},true);if(o){o.outerHTML="#"+i.id+"#"}}};BXBlockEditorPHPParser.prototype.replaceSurrogateByPhp=function(t){var e=t;for(var i in this.phpList){var o=this.phpList[i];e=e.replace("#"+o.id+"#",o.content)}return e};BXBlockEditorPHPParser.prototype.replaceLayoutByPhp=function(t){var e=t;var i=this.phpList.length;for(var o=i-1;o>=0;o--){var n=this.phpList[o];e=e.replace(n.layout,n.content)}return e};BXBlockEditorPHPParser.prototype.resetItems=function(){this.phpList=[]};BXBlockEditorPHPParser.prototype.addItem=function(t,e,i){this.phpList.push({id:t,content:e,layout:i})};BXBlockEditorPHPParser.prototype.getAttrName=function(){return"data-bx-editor-php-slice"};BXBlockEditorPHPParser.prototype.getPhpSliceDescription=function(t){var e={name:"PHP",title:"PHP"};var i=this.htmlEditor.components.IsComponent(t);if(i&&this.htmlEditor.components.components){var o=this.htmlEditor.components.GetComponentData(i.name);var n=o.title||i.name;var s=o.params&&o.params.DESCRIPTION?o.params.DESCRIPTION:s;e={name:n,title:s}}return e};BXBlockEditorPHPParser.prototype.replacePhpByLayout=function(t){var e=this.htmlEditor.phpParser.ReplacePhpBySymCode(t);for(var i in this.htmlEditor.phpParser.arScripts){var o=this.htmlEditor.phpParser.GetPhpPattern(i);var n="bx_block_php_"+Math.random();var s=this.htmlEditor.phpParser.arScripts[i];var r=this.getPhpSliceDescription(s);var l=s.replace(/&/g,"&").replace(/"/g,""");var a='<span id="'+n+'" '+this.getAttrName()+'="'+l+'" class="bxhtmled-surrogate" title="'+r.title+'">'+r.name+"</span>";this.addItem(n,s,a);e=e.replace(o,a)}return e};BXBlockEditorPHPParser.prototype.getComponentInclude=function(t,e){e=e||false;var i=this.htmlEditor.components.GetOnDropHtml({name:t});if(e){i=this.replacePhpByLayout(i)}return i};
//# sourceMappingURL=editor.map.js