Current Path : /var/www/www-root/data/www/www.monolith-realty.ru/bitrix/js/fileman/block_editor/ |
Current File : /var/www/www-root/data/www/www.monolith-realty.ru/bitrix/js/fileman/block_editor/editor.min.js |
(function(t){if(BX.BlockEditorManager)return;BX.BlockEditorManager={list:{},blockList:{},get:function(t){if(this.list[t]){this.list[t].resultNode=null;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()}if(this.isInited){this.resultNode.value=null}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 s=this.phpParser.getPhpSliceDescription(o);i.innerHTML=s.name;i.setAttribute("title",BX.util.htmlspecialchars(s.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 s=new BXBlockEditorStylist;BX.onCustomEvent(this,"onPlaceBlockCreate",[s]);s.init(o,{caller:this,type:i,controls:{}});s.styleNode=this.stylistContainerNode;s.placeNode=o;this.placeList.push(s)}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 s=i.item(o);if(s&&s.id){var n=s.id.substr(this.CONST_ATTR_ID_STYLIST.length);if(n){t[n]=s}}}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 s=o.node;if(e){BX.addClass(s,"bx-stylist-enter")}else{BX.removeClass(s,"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 s=this.findBlockPlaces();if(this.isTemplateMode){var n={};for(o in s){e=s[o];if(!n[o]){n[o]={node:e,html:""}}if(!i){i=o}}this.content.getBlocks().forEach((function(t){var e=null;if(n[t.place]){e=t.place}else if(n["body"]){e="body"}else if(n[i]){e=i}else{return}var o=n[e];var s="";if(t.block){s=this.getBlockHtml(t.block.type,t.block.parameters)}else{s=this.phpParser.replacePhpByLayout(t.value)}var r="<div "+this.CONST_ATTR_BLOCK+'="text">';if(s.indexOf(r)===0&&s.length<r.length+10){s=" "}o.html+=s}),this);this.helper.each(n,(function(t){if(t.html.length>0){t.node.innerHTML=""}}),this);this.helper.each(n,(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 s){e=s[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 s=t.childNodes.item(o);if(s&&s.nodeName=="#text"){BX.remove(s)}}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 s=BX.findChildByClassName(this.context,"edit-panel-tabs-style",true);var n=function(){if(BX.hasClass(this,"blocks")){BX.removeClass(i,"active");o.style.display="block";s.style.display="none"}else{BX.removeClass(e,"active");o.style.display="none";s.style.display="block"}BX.addClass(this,"active")};BX.bind(e,"click",n);BX.bind(i,"click",n);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 s=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"}});s.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(typeof e==="undefined"){e=false}this.preview.show({content:this.getContent(e,true)});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.createBlockListWithReplacedEmptyPlaces=function(){var t=[];this.helper.each(this.findBlockPlaces(),(function(e,i){var o=e.querySelectorAll("["+this.CONST_ATTR_BLOCK+"]");if(o.length>0){return}if(e.children.length!==1){return}var s=this.getBlockNodeByType("text");if(s){var n=this.addBlockByNode(s,e.children[0],true);n.setContentHtml("");t.push(n)}}),this);return t};BXBlockEditor.prototype.removeBlockListWithReplacedEmptyPlaces=function(t){t.forEach((function(t){this.removeBlock(t,true)}),this)};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.createBlockListWithReplacedEmptyPlaces();var s=this.getSortedBlockList();t=t.concat(s.map((function(t){return{type:"BLOCKS",place:t.getPlaceHolderCode(),value:t.getContentHtmlOuter(),block:{type:t.type,parameters:t.getEditValues()}}}),this));this.removeBlockListWithReplacedEmptyPlaces(o);return this.content.getString(t)}};BXBlockEditor.prototype.getContent=function(t,e){t=!!(t||null);var i=this.iframe.contentDocument.cloneNode(true);if(i.head)for(var o=i.head.childNodes.length-1;o>=0;o--){var s=i.head.childNodes.item(o);var n=s.nodeName;n=n||"";n=n.toUpperCase();if(n=="SCRIPT"||n=="STYLE"||n=="LINK"){if(s.attributes&&s.hasAttribute){if(s.hasAttribute(this.CONST_ATTR_TMP_RESOURSE)){BX.remove(s)}else if(s.hasAttribute(this.CONST_ATTR_STYLIST_TAG)){}}if(s.href&&s.href.indexOf("/bitrix/js/fileman/block_editor/editor.css")>-1){BX.remove(s)}}}var r=BX.findChildren(i.body,{attribute:this.CONST_ATTR_PLACE},true);for(var l in r){var a=r[l];var c=BX.findChildren(a,{attribute:this.CONST_ATTR_BLOCK},true);if(c.length===0){BX.cleanNode(a);if(e){var d=this.getBlockNodeByType("text");if(d){var h=i.createTextNode("");a.appendChild(h);var p=this.addBlockByNode(d,h,true);p.setContentHtml("")}}}}var u=[];if(i.body){u=BX.findChildren(i.body,{attribute:this.CONST_ATTR_BLOCK},true)}for(var B in u){var p=u[B];var f=BX.findChild(p,{className:"bx-content"},true);var m=BX.convert.nodeListToArray(f.childNodes);if(t&&p&&p.getAttribute&&p.getAttribute(this.CONST_ATTR_BLOCK)=="component"){m=BX.findChildren(p,{className:"bx-component"},true)}BX.cleanNode(p);BX.adjust(p,{children:m});for(var v=p.attributes.length;v>=0;v--){if(p.attributes[v]&&p.attributes[v].name!=this.CONST_ATTR_BLOCK){p.removeAttribute(p.attributes[v].name)}}}if(!t){this.phpParser.replaceLayoutBySurrogate(i.body)}var C=i.documentElement.outerHTML;if(!t){C=this.phpParser.replaceSurrogateByPhp(C)}return C};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 s;for(var n in this.blockList){if(this.blockList[n]&&this.blockList[n].node==t){s=this.blockList[n];break}}s.onMoveHandler(e);this.helper.appendChildNode(t,e,i);this.actualizeBlockPlace(o);this.actualizeBlockPlace(e.parentNode);BX.onCustomEvent(this,"onBlockMoveAfter",[s]);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,e){BX.onCustomEvent(this,"onBlockRemove",[t]);for(var i in this.blockList){if(t==this.blockList[i]){this.blockList.splice(i,1)}}this.dragdrop.removeItem(t.node);var o=t.node.parentNode;BX.remove(t.node);this.actualizeBlockPlace(o);BX.onCustomEvent(this,"onBlockRemoveAfter",[o]);if(!e){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 s=i.reload_dependence[o];if(!BX.type.isArray(t[s])){t[s]=[]}t[s].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 s=0;if(e){e=parseInt(e)}if(t){o=BX.findChildren(this.nodeContent,{className:t},true)}else{o.push(this.nodeContent)}for(var n in o){if(e){s++;if(s<e)continue;if(s>e)break}i.push(o[n])}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 s=this.getEditValue(i,o);if(s===null||s===""){continue}t.push({code:i,value:s,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 s=this.findEditNodeList(o.className,i);if(!BX.type.isFunction(o.func)){return}for(var n in s){var r=s[n];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 s=this.findEditNodeList(o.className,e);if(!BX.type.isFunction(o.func)){return i}var n=s[0];if(!n){return i}i=o.func.apply(this,[n,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 s=t.innerHTML;var n=BX.create({tag:"DIV",props:{className:"bx-content"},html:s});t.innerHTML="";this.nodeContent=n;e=BX.create({tag:"DIV",props:{className:"bx-block-inside"},children:[i,n,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 s=BX.findChild(e,{className:"bx-clone"},true);var n=BX.findChild(e,{className:"bx-edit"},true);BX.bind(i,"click",t.remove);BX.bind(o,"click",t.drag);BX.bind(s,"click",t.clone);BX.bind(n,"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 s=BX.create({tag:"DIV",props:{className:"bx-component-description"}});var n=BX.create({tag:"DIV",props:{className:"bx-component"},children:[i,o,s]});this.nodeContent.parentNode.insertBefore(n,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 s=this.css("",[e],t,"color",o);if(s){resultList=s.split(" ");s=resultList[0]}return s}};t["bx-stylist-"+e+"-font-size"]={className:"",func:function(t,i,o){if(o){o+=" !important"}var s=this.css("",[e],t,"font-size",o);if(s){resultList=s.split(" ");s=resultList[0]}return s}};t["bx-stylist-"+e+"-font-weight"]={className:"",func:function(t,i,o){if(o){o+=" !important"}var s=this.css("",[e],t,"font-weight",o);if(s){resultList=s.split(" ");s=resultList[0]}return s}};t["bx-stylist-"+e+"-font-weight"]={className:"",func:function(t,i,o){if(o){o+=" !important"}var s=this.css("",[e],t,"font-weight",o);if(s){resultList=s.split(" ");s=resultList[0]}return s}};t["bx-stylist-"+e+"-line-height"]={className:"",func:function(t,i,o){if(o){o+=" !important"}var s=this.css("",[e],t,"line-height",o);if(s){resultList=s.split(" ");s=resultList[0]}return s}};t["bx-stylist-"+e+"-text-align"]={className:"",func:function(t,i,o){if(o){o+=" !important"}var s=this.css("",[e],t,"text-align",o);if(s){resultList=s.split(" ");s=resultList[0]}return s}};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 s=t[o];if(this.type=="page"){i.push("body"+(s?" ":"")+s)}i.push("#"+this.caller.CONST_ATTR_ID_STYLIST+e+(s?" ":"")+s)}return i.join(", ")};this.cssHeadTag=function(t,e,i,o){return this.css("",[t],e,i,o)};this.css=function(t,e,i,o,s){var n=this.getSelector(e);var r;if(typeof s!=="undefined"){var l={};l[o]=s;r=i.innerHTML;if(i.styleSheet){r=i.styleSheet.cssText}r=this.caller.cssParser.setStyle(r,t,n,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,n,[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 s=o[0];var n=this.htmlEditor.GetBxTag(s.node);var r=this.htmlEditor.GetBxTag(n.surrogateId);this.componentPropertiesDialogHandler=e;this.componentPropertiesDialogHandlerCancel=i;this.htmlEditor.components.ShowPropertiesDialog(n.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 s=this.phpList[o];e=e.replace(s.layout,s.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 s=o.title||i.name;var n=o.params&&o.params.DESCRIPTION?o.params.DESCRIPTION:n;e={name:s,title:n}}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 s="bx_block_php_"+Math.random();var n=this.htmlEditor.phpParser.arScripts[i];var r=this.getPhpSliceDescription(n);var l=n.replace(/&/g,"&").replace(/"/g,""");var a='<span id="'+s+'" '+this.getAttrName()+'="'+l+'" class="bxhtmled-surrogate" title="'+r.title+'">'+r.name+"</span>";this.addItem(s,n,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