Your IP : 3.148.104.65
(function(){"use strict";BX.namespace("BX.Landing");var e=BX.Landing.Utils.onAnimationEnd;var n=BX.Landing.Utils.htmlToElement;var t=BX.Landing.Utils.deepFreeze;var i=BX.Landing.Utils.fireCustomEvent;var o=BX.Landing.Utils.isPlainObject;var a=BX.Landing.Utils.isEmpty;var r=BX.Landing.Utils.isBoolean;var s=BX.Landing.Utils.addClass;var l=BX.Landing.Utils.removeClass;var c=BX.Landing.Utils.hasClass;var d=BX.Landing.Utils.append;var u=BX.Landing.Utils.prepend;var h=BX.Landing.Utils.insertAfter;var B=BX.Landing.Utils.remove;var g=BX.Landing.Utils.slice;var f=BX.Landing.Utils.data;var k=BX.Landing.Utils.arrayUnique;var m=BX.Landing.Utils.create;var b=BX.Landing.Utils.delay;var L=BX.Landing.UI.Button.Plus;var p=BX.Landing.UI.Panel.Content;var v="ru";var y="by";var A="kz";var T="la";var X="de";var w="br";var E="ua";function C(e){return!!e&&!!e.querySelector(".block-wrapper")}function S(e){return!!e&&!!e.querySelector('button[data-id="insert_first_block"]')}BX.Landing.Main=function(e,n){this.id=e;this.options=t(n||{});this.blocksPanel=null;this.currentBlock=null;this.loadedDeps={};this.onSliderFormLoaded=this.onSliderFormLoaded.bind(this);this.onBlockDelete=this.onBlockDelete.bind(this);BX.addCustomEvent("Landing.Block:onAfterDelete",this.onBlockDelete);this.adjustEmptyAreas();if(this.options.blocks){if(!this.blocksPanel){this.blocksPanel=this.createBlocksPanel();this.onBlocksListCategoryChange("last");this.blocksPanel.layout.hidden=true;d(this.blocksPanel.layout,document.body)}this.blocksPanel.content.hidden=false}BX.Landing.UI.Panel.StatusPanel.setLastModified(n.lastModified);BX.Landing.UI.Panel.StatusPanel.getInstance().show()};BX.Landing.Main.TYPE_PAGE="PAGE";BX.Landing.Main.TYPE_STORE="STORE";BX.Landing.getMode=function(){return"edit"};BX.Landing.Main.instance=null;BX.Landing.Main.createInstance=function(e,n){top.BX.Landing.Main.instance=new BX.Landing.Main(e,n)};BX.Landing.Main.getInstance=function(){if(top.BX.Landing.Main.instance){return top.BX.Landing.Main.instance}top.BX.Landing.Main.instance=new BX.Landing.Main(-1,{});return top.BX.Landing.Main.instance};BX.Landing.Main.prototype={hideBlocksPanel:function(){if(this.blocksPanel){return this.blocksPanel.hide()}return Promise.resolve()},getLayoutAreas:function(){if(!this.layoutAreas){this.layoutAreas=[].concat(g(document.body.querySelectorAll(".landing-header")),g(document.body.querySelectorAll(".landing-sidebar")),g(document.body.querySelectorAll(".landing-main")),g(document.body.querySelectorAll(".landing-footer")))}return this.layoutAreas},createInsertBlockButton:function(e){var n=new L("insert_first_block",{text:BX.message("ACTION_BUTTON_CREATE")});n.on("click",this.showBlocksPanel.bind(this,null,e,n));n.on("mouseover",this.onCreateButtonMouseover.bind(this,e,n));n.on("mouseout",this.onCreateButtonMouseout.bind(this,e,n));return n},onCreateButtonMouseover:function(e,n){if(c(e,"landing-header")||c(e,"landing-footer")){var t=this.getLayoutAreas();if(t.length>1){switch(true){case c(e,"landing-main"):n.setText([BX.message("ACTION_BUTTON_CREATE"),BX.message("LANDING_ADD_BLOCK_TO_MAIN")].join(" "));break;case c(e,"landing-header"):n.setText([BX.message("ACTION_BUTTON_CREATE"),BX.message("LANDING_ADD_BLOCK_TO_HEADER")].join(" "));break;case c(e,"landing-sidebar"):n.setText([BX.message("ACTION_BUTTON_CREATE"),BX.message("LANDING_ADD_BLOCK_TO_SIDEBAR")].join(" "));break;case c(e,"landing-footer"):n.setText([BX.message("ACTION_BUTTON_CREATE"),BX.message("LANDING_ADD_BLOCK_TO_FOOTER")].join(" "));break}clearTimeout(this.fadeTimeout);this.fadeTimeout=setTimeout(function(){s(e,"landing-area-highlight");t.forEach(function(n){if(n!==e){s(n,"landing-area-fade")}},this)}.bind(this),400)}}},onCreateButtonMouseout:function(e,n){clearTimeout(this.fadeTimeout);if(c(e,"landing-header")||c(e,"landing-footer")){var t=this.getLayoutAreas();if(t.length>1){n.setText(BX.message("ACTION_BUTTON_CREATE"));t.forEach(function(e){l(e,"landing-area-highlight");l(e,"landing-area-fade")},this)}}},initEmptyArea:function(e){if(e){e.innerHTML="";d(this.createInsertBlockButton(e).layout,e);s(e,"landing-empty")}},destroyEmptyArea:function(e){if(e){var n=e.querySelector('button[data-id="insert_first_block"]');if(n){B(n)}l(e,"landing-empty")}},adjustEmptyAreas:function(){this.getLayoutAreas().filter(function(e){return C(e)&&S(e)}).forEach(this.destroyEmptyArea,this);this.getLayoutAreas().filter(function(e){return!C(e)&&!S(e)}).forEach(this.initEmptyArea,this);var e=document.body.querySelector("main.landing-edit-mode");var n=!this.getLayoutAreas().some(C);if(e){if(n){s(e,"landing-empty");return}l(e,"landing-empty")}},enableControls:function(){l(document.body,"landing-ui-hide-controls")},disableControls:function(){s(document.body,"landing-ui-hide-controls")},isControlsEnabled:function(){return!c(document.body,"landing-ui-hide-controls")},appendBlock:function(t,i){var o=n(t.content);o.id="block"+t.id;if(!i){s(o,"landing-ui-show");e(o,"showBlock").then(function(){l(o,"landing-ui-show")})}this.insertToBlocksFlow(o);return o},showBlocksPanel:function(e,n,t){this.currentBlock=e;this.currentArea=n;this.blocksPanel.show();if(!!n&&!!t){this.onCreateButtonMouseout(n,t)}},createBlocksPanel:function(){var e=this.options.blocks;var n=Object.keys(e);var t=new p("blocks_panel",{title:BX.message("LANDING_CONTENT_BLOCKS_TITLE"),className:"landing-ui-panel-block-list",scrollAnimation:true});n.forEach(function(n){var i=!a(e[n].items);var o=n==="popular";var r=e[n].separator;if(i&&!o||r){t.appendSidebarButton(this.createBlockPanelSidebarButton(n,e[n]))}},this);t.appendSidebarButton(new BX.Landing.UI.Button.SidebarButton("feedback_button",{className:"landing-ui-button-sidebar-feedback",text:BX.message("LANDING_BLOCKS_LIST_FEEDBACK_BUTTON"),onClick:this.showFeedbackForm.bind(this)}));return t},showSliderFeedbackForm:function(e){if(!this.sliderFeedbackInited){this.sliderFeedbackInited=true;this.sliderFeedback=new p("slider_feedback",{title:BX.message("LANDING_PANEL_FEEDBACK_TITLE"),className:"landing-ui-panel-feedback"});d(this.sliderFeedback.layout,document.body);this.sliderFormLoader=new BX.Loader({target:this.sliderFeedback.content});this.sliderFormLoader.show();this.initFeedbackForm()}e=o(e)?e:{};e.bitrix24=this.options.server_name;e.siteId=this.options.site_id;e.siteUrl=this.options.url;e.siteTemplate=this.options.xml_id;e.productType=this.options.productType||"Undefined";var n=this.getFeedbackFormOptions();b24formFeedBack({id:n.id,lang:n.lang,sec:n.sec,type:"slider_inline",node:this.sliderFeedback.content,handlers:{load:this.onSliderFormLoaded.bind(this)},presets:o(e)?e:{}});this.sliderFeedback.show()},getFeedbackFormOptions:function(){var e=BX.message("LANGUAGE_ID");var n={id:"16",sec:"3h483y",lang:"en"};switch(e){case v:case y:case A:n={id:"8",sec:"x80yjw",lang:"ru"};break;case T:n={id:"14",sec:"wu561i",lang:"la"};break;case X:n={id:"10",sec:"eraz2q",lang:"de"};break;case w:n={id:"12",sec:"r6wvge",lang:"br"};break;case E:n={id:"18",sec:"d9e09o",lang:"ua"};break}return n},onSliderFormLoaded:function(){this.sliderFormLoader.hide()},showFeedbackForm:function(){this.showSliderFeedbackForm({target:"blocksList"})},initFeedbackForm:function(){(function(e,n,t,i){e["Bitrix24FormObject"]=i;e[i]=e[i]||function(){arguments[0].ref=t;(e[i].forms=e[i].forms||[]).push(arguments[0])};if(e[i]["forms"])return;var o=n.createElement("script");var a=1*new Date;o.async=1;o.src=t+"?"+a;var r=n.getElementsByTagName("script")[0];r.parentNode.insertBefore(o,r)})(window,document,"https://landing.bitrix24.ru/bitrix/js/crm/form_loader.js","b24formFeedBack")},createBlockPanelSidebarButton:function(e,n){return new BX.Landing.UI.Button.SidebarButton(e,{text:n.name,child:!n.separator,className:n.new?"landing-ui-new-section":"",onClick:this.onBlocksListCategoryChange.bind(this,e)})},onBlocksListCategoryChange:function(e){this.blocksPanel.content.hidden=false;this.blocksPanel.sidebarButtons.forEach(function(n){n.layout.classList[n.id===e?"add":"remove"]("landing-ui-active")});this.blocksPanel.content.innerHTML="";if(e==="last"){if(!this.lastBlocks){this.lastBlocks=Object.keys(this.options.blocks["last"].items)}this.lastBlocks=k(this.lastBlocks);this.lastBlocks.forEach(function(e){var n=this.getBlockFromRepository(e);this.blocksPanel.appendCard(this.createBlockCard(e,n))},this);return}Object.keys(this.options.blocks[e].items).forEach(function(n){var t=this.options.blocks[e].items[n];this.blocksPanel.appendCard(this.createBlockCard(n,t))},this);if(this.blocksPanel.content.scrollTop){requestAnimationFrame(function(){this.blocksPanel.content.scrollTop=0}.bind(this))}},getBlockFromRepository:function(e){var n=this.options.blocks;var t=Object.keys(n);var i=t.find(function(t){return e in n[t].items});if(i){return n[i].items[e]}},onCopyBlock:function(e){window.localStorage.landingBlockId=e.id;window.localStorage.landingBlockName=e.manifest.block.name;window.localStorage.landingBlockAction="copy";try{window.localStorage.requiredUserAction=JSON.stringify(e.requiredUserActionOptions)}catch(e){window.localStorage.requiredUserAction=""}},onCutBlock:function(e){window.localStorage.landingBlockId=e.id;window.localStorage.landingBlockName=e.manifest.block.name;window.localStorage.landingBlockAction="cut";try{window.localStorage.requiredUserAction=JSON.stringify(e.requiredUserActionOptions)}catch(e){window.localStorage.requiredUserAction=""}top.BX.Landing.Block.storage.remove(e);B(e.node);i("Landing.Block:onAfterDelete",[e])},onPasteBlock:function(e){if(window.localStorage.landingBlockId){var n="Landing::copyBlock";if(window.localStorage.landingBlockAction==="cut"){n="Landing::moveBlock"}var t={};t[n]={action:n,data:{lid:e.lid||BX.Landing.Main.getInstance().id,block:window.localStorage.landingBlockId,params:{AFTER_ID:e.id,RETURN_CONTENT:"Y"}}};BX.Landing.Backend.getInstance().batch(n,t,{action:n}).then(function(t){this.currentBlock=e;return this.addBlock(t[n].result.content)}.bind(this))}},addBlock:function(e,n,t){if(this.lastBlocks){this.lastBlocks.unshift(e.manifest.code)}var i=this;var o=this.appendBlock(e,t);return this.loadBlockDeps(e).then(function(e){if(!r(n)||n===false){var t=null;var a=null;if(i.currentBlock){t=i.currentBlock.lid;a=i.currentBlock.id}if(i.currentArea){t=f(i.currentArea,"landing");a=f(i.currentArea,"site")}BX.Landing.History.getInstance().push(new BX.Landing.History.Entry({block:e.id,selector:"#block"+e.id,command:"addBlock",undo:"",redo:{currentBlock:a,lid:t,code:e.manifest.code}}))}i.currentBlock=null;i.currentArea=null;var s=parseInt(e.id);var l=top.BX.Landing.Block.storage.get(s);if(l){B(l.node);top.BX.Landing.Block.storage.remove(l)}new BX.Landing.Block(o,{id:s,active:true,requiredUserAction:e.requiredUserAction,manifest:e.manifest});return i.runBlockScripts(e).then(function(){return o})}).catch(function(e){console.warn(e)})},onAddBlock:function(e,n,t){n=parseInt(n);this.hideBlocksPanel();return this.showBlockLoader().then(this.loadBlock(e,n)).then(function(e){return b(500,e)}).then(function(e){var n=this.addBlock(e,t);this.adjustEmptyAreas();this.hideBlockLoader();return n}.bind(this))},insertToBlocksFlow:function(e){var n=this.currentBlock&&this.currentBlock.node&&this.currentBlock.node.parentNode;if(n){h(e,this.currentBlock.node);return}u(e,this.currentArea)},getBlockLoader:function(){if(!this.blockLoader){this.blockLoader=new BX.Loader({size:60});this.blockLoaderContainer=m("div",{props:{className:"landing-block-loader-container"},children:[this.blockLoader.layout]})}return this.blockLoaderContainer},showBlockLoader:function(){this.insertToBlocksFlow(this.getBlockLoader());return Promise.resolve()},hideBlockLoader:function(){B(this.getBlockLoader());return Promise.resolve()},loadBlockDeps:function(e){var n=BX.processHTML(e.content_ext);if(BX.type.isArray(n.SCRIPT)){n.SCRIPT=n.SCRIPT.filter(function(e){return!e.isInternal})}var t=0;var i=e.js.length+n.SCRIPT.length+n.STYLE.length+e.css.length;var o=null;if(!this.loadedDeps[e.manifest.code]&&i>0){o=new Promise(function(o){function a(){t+=1;t===i&&o(e)}if(i>t){n.SCRIPT.forEach(function(e){if(!e.isInternal){BX.loadScript(e.JS,a)}});n.STYLE.forEach(function(e){BX.loadScript(e,a)});e.css.forEach(function(e){BX.loadScript(e,a)});e.js.forEach(function(e){BX.loadScript(e,a)})}else{a()}this.loadedDeps[e.manifest.code]=true}.bind(this))}else{o=Promise.resolve(e)}return o},runBlockScripts:function(e){return new Promise(function(n){var t=BX.processHTML(e.content).SCRIPT;if(t.length){BX.ajax.processScripts(t,undefined,function(){n(e)})}else{n(e)}})},loadBlock:function(e,n){return function(){var t=this.id;var i=this.options.site_id;if(this.currentBlock){t=this.currentBlock.lid;i=this.currentBlock.siteId}if(this.currentArea){t=f(this.currentArea,"landing");i=f(this.currentArea,"site")}var o={lid:t,siteId:i};var a={ACTIVE:"Y",CODE:e,AFTER_ID:!!this.currentBlock?this.currentBlock.id:0,RETURN_CONTENT:"Y"};if(!n){o.fields=a;return BX.Landing.Backend.getInstance().action("Landing::addBlock",o,{code:e})}else{o={undeleete:{action:"Landing::markUndeletedBlock",data:{lid:t,block:n}},getContent:{action:"Block::getContent",data:{block:n,lid:t,fields:a,editMode:1}}};return BX.Landing.Backend.getInstance().batch("Landing::addBlock",o,{code:e}).then(function(e){e.getContent.result.id=n;return e.getContent.result})}}.bind(this)},createBlockCard:function(e,n,t){return new BX.Landing.UI.Card.BlockPreviewCard({title:n.name,image:n.preview,code:e,mode:t,isNew:n.new===true,onClick:this.onAddBlock.bind(this,e)})},onBlockDelete:function(e){if(!e.parent.querySelector(".block-wrapper")){this.adjustEmptyAreas()}},showOverlay:function(){var e=document.querySelector("main.landing-edit-mode");if(e){s(e,"landing-ui-overlay")}},hideOverlay:function(){var e=document.querySelector("main.landing-edit-mode");if(e){l(e,"landing-ui-overlay")}}}})();