Current Path : /var/www/www-root/data/www/monolith-realty.ru/bitrix/js/landing/node/link/dist/ |
Current File : /var/www/www-root/data/www/monolith-realty.ru/bitrix/js/landing/node/link/dist/link.bundle.min.js |
this.BX=this.BX||{};this.BX.Landing=this.BX.Landing||{};(function(t,e,n){"use strict";const i=BX.Landing.Utils.trim;const s=BX.Landing.Utils.isPlainObject;const a=BX.Landing.Utils.isString;const d=BX.Landing.Utils.textToPlaceholders;const l=BX.Landing.Utils.create;const o=BX.Landing.Utils.escapeText;const r=BX.Landing.Utils.decodeDataValue;class h extends e.Base{constructor(t){super(t);this.type="link";if(!this.isGrouped()){n.Event.bind(this.node,"click",this.onClick.bind(this))}if(this.isAllowInlineEdit()){n.Dom.attr(this.node,"title",BX.Landing.Loc.getMessage("LANDING_TITLE_OF_LINK_NODE"))}this.onChange=BX.Runtime.debounce(this.onChange,500);this.onContentUpdate=BX.Runtime.debounce(this.onContentUpdate,500)}onContentUpdate(){BX.Landing.History.getInstance().push();this.getField().setValue(this.getValue())}isMenuMode(){return this.manifest.menuMode===true}onClick(t){t.preventDefault();if(!this.isMenuMode()){t.stopPropagation()}if(this.isAllowInlineEdit()){BX.Landing.UI.Button.ColorAction.hideAll();if(!BX.Landing.UI.Panel.StylePanel.getInstance().isShown()){BX.Landing.UI.Panel.Link.getInstance().show(this)}}}setValue(t,e,n){this.startValue=this.startValue||this.getValue();this.preventSave(e);if(!this.containsImage()&&this.isAllowInlineEdit()){const e=this.getField(true).hrefInput;if(a(t.text)&&t.text.includes("{{name}}")){e.getPlaceholderData(t.href).then((e=>{this.node.innerHTML=t.text.replace(/{{name}}/,`<span data-placeholder="name">${e.name}</span>`)})).catch((()=>{}))}else if(!this.getField().containsHtml()&&!this.manifest.skipContent){this.node.innerHTML=o(t.text)}}this.setAttrValue(t);this.onChange(n);if(!n){this.onContentUpdate()}}setAttrValue(t){n.Dom.attr(this.node,"href",r(t.href));n.Dom.attr(this.node,"target",o(t.target));if("attrs"in t){Object.keys(t.attrs).forEach((e=>{if(Object.prototype.hasOwnProperty.call(t.attrs,e)){n.Dom.attr(this.node,e,t.attrs[e])}}))}else{n.Dom.attr(this.node,"data-url",null);n.Dom.attr(this.node,"data-embed",null)}}containsImage(){return Boolean(this.node.firstElementChild)&&this.node.firstElementChild.tagName==="IMG"}getValue(){const t={text:d(i(this.node.innerHTML)),href:i(this.node.getAttribute("href")),target:i(this.node.getAttribute("target")||"_self")};if(this.node.getAttribute("data-url")){t.attrs={"data-url":i(this.node.getAttribute("data-url"))}}if(this.node.getAttribute("data-dynamic")){if(!s(t.attrs)){t.attrs={}}t.attrs["data-dynamic"]=this.node.getAttribute("data-dynamic")}if(this.manifest.skipContent){t.skipContent=true;delete t.text}if(t.href&&t.href.startsWith("selectActions:")){t.href="#"}return t}getField(t){const e=this.getValue();e.text=d(l("div",{html:e.text}).innerHTML);if(!this.field){const t=[BX.Landing.UI.Field.LinkUrl.TYPE_BLOCK,BX.Landing.UI.Field.LinkUrl.TYPE_PAGE,BX.Landing.UI.Field.LinkUrl.TYPE_CRM_FORM,BX.Landing.UI.Field.LinkUrl.TYPE_CRM_PHONE];if(BX.Landing.Main.getInstance().options.params.type===BX.Landing.Main.TYPE_STORE){t.push(BX.Landing.UI.Field.LinkUrl.TYPE_CATALOG)}if(BX.Landing.Main.getInstance().options.features.includes("diskFile")){t.push(BX.Landing.UI.Field.LinkUrl.TYPE_DISK_FILE)}this.field=new BX.Landing.UI.Field.Link({title:this.manifest.name,selector:this.selector,skipContent:this.manifest.skipContent,content:e,options:{siteId:BX.Landing.Main.getInstance().options.site_id,landingId:BX.Landing.Main.getInstance().id},allowedTypes:t})}else if(!t){this.field.setValue(e);this.field.content=e;this.field.hrefInput.content=e.href;this.field.hrefInput.makeDisplayedHrefValue();this.field.hrefInput.setHrefTypeSwitcherValue(this.field.hrefInput.getHrefStringType());this.field.hrefInput.removeHrefTypeFromHrefString()}return this.field}}BX.Landing.Node.Link=h;t.Link=h})(this.BX.Landing.Node=this.BX.Landing.Node||{},BX.Landing.Node,BX); //# sourceMappingURL=link.bundle.map.js