Current Path : /var/www/www-root/data/www/info.monolith-realty.ru/bitrix/js/landing/ui/panel/ |
Current File : /var/www/www-root/data/www/info.monolith-realty.ru/bitrix/js/landing/ui/panel/link_panel.min.js |
(function(){"use strict";BX.namespace("BX.Landing.UI.Panel");var n=BX.Landing.Utils.attr;var e=BX.Landing.Utils.join;var t=BX.Landing.Utils.random;var i=BX.Landing.Utils.setTextContent;var a=BX.Landing.Utils.isPlainObject;var s=BX.Landing.Utils.isString;var d=BX.Landing.Utils.textToPlaceholders;var l=BX.Landing.Utils.findParent;var o=BX.Landing.Utils.escapeText;BX.Landing.UI.Panel.Link=function(n,e){BX.Landing.UI.Panel.Content.apply(this,arguments);this.layout.classList.add("landing-ui-panel-link");this.overlay.classList.add("landing-ui-panel-link");this.appendFooterButton(new BX.Landing.UI.Button.BaseButton("save_block_content",{text:BX.Landing.Loc.getMessage("BLOCK_SAVE"),onClick:this.save.bind(this),className:"landing-ui-button-content-save"}));this.appendFooterButton(new BX.Landing.UI.Button.BaseButton("cancel_block_content",{text:BX.Landing.Loc.getMessage("BLOCK_CANCEL"),onClick:this.hide.bind(this),className:"landing-ui-button-content-cancel"}));window.parent.document.body.appendChild(this.layout)};BX.Landing.UI.Panel.Link.instance=null;BX.Landing.UI.Panel.Link.getInstance=function(){if(!BX.Landing.UI.Panel.Link.instance){BX.Landing.UI.Panel.Link.instance=new BX.Landing.UI.Panel.Link("link_panel",{title:BX.Landing.Loc.getMessage("LANDING_EDIT_LINK")})}return BX.Landing.UI.Panel.Link.instance};BX.Landing.UI.Panel.Link.prototype={constructor:BX.Landing.UI.Panel.Link,__proto__:BX.Landing.UI.Panel.Content.prototype,show:function(n){var e;this.title.innerHTML=BX.Landing.Loc.getMessage("LANDING_EDIT_LINK");if(!!n&&n instanceof BX.Landing.Node.Link){this.node=n;e=new BX.Landing.UI.Form.BaseForm({title:this.node.manifest.name});this.field=this.node.getField();e.addField(this.field);this.clear();this.appendForm(e);this.checkReadyToSave();BX.Landing.UI.Panel.Content.prototype.show.call(this);BX.Landing.UI.Panel.EditorPanel.getInstance().hide()}if(!!n&&(n instanceof BX.Landing.Node.Text||n instanceof BX.Landing.UI.Field.Text)){this.range=this.contextDocument.getSelection().getRangeAt(0);this.node=n;this.textField=BX.Landing.UI.Field.BaseField.currentField;if(!!this.textField&&this.textField.isEditable()){this.node=this.textField}var t=this.range.cloneContents().querySelector("a");if(!t){t=l(this.range.startContainer,{tagName:"A"})}var i="";var a="";if(t){i=t.getAttribute("href");a=t.getAttribute("target")||"_self"}else{this.title.innerHTML=BX.Landing.Loc.getMessage("LANDING_CREATE_LINK")}e=new BX.Landing.UI.Form.BaseForm({title:""});BX.remove(e.header);var s=[BX.Landing.UI.Field.LinkUrl.TYPE_BLOCK,BX.Landing.UI.Field.LinkUrl.TYPE_PAGE];if(BX.Landing.Main.getInstance().options.params.type==="STORE"){s.push(BX.Landing.UI.Field.LinkUrl.TYPE_CATALOG)}this.field=new BX.Landing.UI.Field.Link({title:BX.Landing.Loc.getMessage("FIELD_LINK_TEXT_LABEL"),content:{text:d(o(t?t.innerText:this.range.toString())),href:o(i),target:o(a)},options:{siteId:BX.Landing.Main.getInstance().options.site_id,landingId:BX.Landing.Main.getInstance().id,filter:{"=TYPE":BX.Landing.Main.getInstance().options.params.type}},allowedTypes:s});e.addField(this.field);this.clear();this.appendForm(e);this.checkReadyToSave();BX.Landing.UI.Panel.Content.prototype.show.call(this)}},save:function(){if(this.field.isChanged()){if(!!this.node&&this.node instanceof BX.Landing.Node.Link){this.node.setValue(this.field.getValue())}else{var d=this.field.getValue();this.contextDocument.getSelection().removeAllRanges();this.contextDocument.getSelection().addRange(this.range);this.node.enableEdit();var l=o(e(d.href,t()));var g=this.contextDocument.getSelection();this.contextDocument.execCommand("createLink",false,l);var r=g.anchorNode.parentElement.parentElement.parentElement.querySelector(e('[href="',l,'"]'));if(r){n(r,"href",d.href);n(r,"target",d.target);if(s(d.text)){if(d.text.includes("{{name}}")){this.field.hrefInput.getPlaceholderData(d.href).then(function(n){r.innerHTML=d.text.replace(new RegExp("{{name}}"),'<span data-placeholder="name">'+n.name+"</span>")}.bind(this))}else{i(r,d.text)}}if(a(d.attrs)){n(r,d.attrs)}}}}this.hide()}}})(); //# sourceMappingURL=link_panel.map.js