%PDF- %PDF-
Direktori : /home/bitrix/www/bitrix/js/landing/ui/panel/ |
Current File : /home/bitrix/www/bitrix/js/landing/ui/panel/editor_panel.min.js |
(function(){"use strict";BX.namespace("BX.Landing.UI.Panel");BX.Landing.UI.Panel.EditorPanel=function(){BX.Landing.UI.Panel.BaseButtonPanel.apply(this,arguments);this.layout.classList.add("landing-ui-panel-editor");this.position="absolute";this.currentElement=null;s(this);d(this);u(this);this.rect=this.layout.getBoundingClientRect()};BX.Landing.UI.Panel.EditorPanel.instance=null;BX.Landing.UI.Panel.EditorPanel.getInstance=function(){if(!BX.Landing.UI.Panel.EditorPanel.instance){BX.Landing.UI.Panel.EditorPanel.instance=new BX.Landing.UI.Panel.EditorPanel}return BX.Landing.UI.Panel.EditorPanel.instance};var t=null;var n=null;function e(e){n=e;t=t||o.bind(null,e);document.addEventListener("keydown",a);window.addEventListener("resize",t);try{document.addEventListener("scroll",t,{passive:true})}catch(n){document.addEventListener("scroll",t)}}function i(){document.removeEventListener("keydown",a);window.removeEventListener("resize",t);try{document.removeEventListener("scroll",t,{passive:true})}catch(n){document.removeEventListener("scroll",t)}}function a(t){if(t.which===13&&t.target.nodeName!=="LI"&&t.target.nodeName!=="UL"){t.preventDefault();var e=window.getSelection().getRangeAt(0);var i=BX.create("br");e.deleteContents();e.insertNode(i);e=document.createRange();e.setStartAfter(i);e.collapse(true);var a=window.getSelection();a.removeAllRanges();a.addRange(e)}setTimeout(function(){BX.Landing.UI.Panel.EditorPanel.getInstance().adjustPosition(n)},10)}function o(){BX.Landing.UI.Panel.EditorPanel.getInstance().adjustPosition(n)}function s(t){var n=new BX.Landing.UI.Button.EditorAction("drag",{html:'<strong class="landing-ui-drag"> </strong>',attrs:{title:BX.message("LANDING_TITLE_OF_EDITOR_ACTION_DRAG")}});n.layout.onbxdrag=o.bind(this);n.layout.onbxdragstop=s.bind(this);jsDD.registerObject(n.layout);t.prependButton(n);var e;var i;var a;function o(n,o){if(!e){var s=BX.pos(jsDD.current_node);i=Math.max(Math.abs(n-s.left),0);a=Math.max(Math.abs(o-s.top),0);e=true}BX.DOM.write(function(){t.layout.classList.remove("landing-ui-transition");t.layout.style.top=o-a+"px";t.layout.style.left=n-i+"px"}.bind(this))}function s(){e=false;t.layout.classList.add("landing-ui-transition")}}function d(t){t.addButton(new BX.Landing.UI.Button.EditorAction("bold",{html:'<span class="fa fa-bold"><em></em></span>',attrs:{title:BX.message("LANDING_TITLE_OF_EDITOR_ACTION_BOLD")}}));t.addButton(new BX.Landing.UI.Button.EditorAction("italic",{html:'<span class="fa fa-italic"><em></em></span>',attrs:{title:BX.message("LANDING_TITLE_OF_EDITOR_ACTION_ITALIC")}}));t.addButton(new BX.Landing.UI.Button.EditorAction("underline",{html:'<span class="fa fa-underline"><em></em></span>',attrs:{title:BX.message("LANDING_TITLE_OF_EDITOR_ACTION_UNDERLINE")}}));t.addButton(new BX.Landing.UI.Button.EditorAction("strikeThrough",{html:'<span class="fa fa-strikethrough"><em></em></span>',attrs:{title:BX.message("LANDING_TITLE_OF_EDITOR_ACTION_STRIKE")}}));t.addButton(new BX.Landing.UI.Button.EditorAction("justifyLeft",{html:'<span class="fa fa-align-left"><em></em></span>',attrs:{title:BX.message("LANDING_TITLE_OF_EDITOR_ACTION_ALIGN_LEFT")}}));t.addButton(new BX.Landing.UI.Button.EditorAction("justifyCenter",{html:'<span class="fa fa-align-center"><em></em></span>',attrs:{title:BX.message("LANDING_TITLE_OF_EDITOR_ACTION_ALIGN_CENTER")}}));t.addButton(new BX.Landing.UI.Button.EditorAction("justifyRight",{html:'<span class="fa fa-align-right"><em></em></span>',attrs:{title:BX.message("LANDING_TITLE_OF_EDITOR_ACTION_ALIGN_RIGHT")}}));t.addButton(new BX.Landing.UI.Button.EditorAction("justifyFull",{html:'<span class="fa fa-align-justify"><em></em></span>',attrs:{title:BX.message("LANDING_TITLE_OF_EDITOR_ACTION_ALIGN_JUSTIFY")}}));t.addButton(new BX.Landing.UI.Button.CreateLink("createLink",{html:'<span class="fa fa-link"><em></em></span>',attrs:{title:BX.message("LANDING_TITLE_OF_EDITOR_ACTION_CREATE_LINK")}}));t.addButton(new BX.Landing.UI.Button.EditorAction("unlink",{html:'<span class="fa fa-unlink"><em></em></span>',attrs:{title:BX.message("LANDING_TITLE_OF_EDITOR_ACTION_UNLINK")}}));t.addButton(new BX.Landing.UI.Button.ColorAction("foreColor",{text:BX.message("EDITOR_ACTION_SET_FORE_COLOR"),attrs:{title:BX.message("LANDING_TITLE_OF_EDITOR_ACTION_COLOR")}}));t.addButton(new BX.Landing.UI.Button.EditorAction("removeFormat",{html:'<span class="fa fa-eraser"><em></em></span>',attrs:{title:BX.message("LANDING_TITLE_OF_EDITOR_ACTION_CLEAR")}}))}var l={top:0,left:0};function r(t,n,e){var i=n.getBoundingClientRect();var a=i.left+i.width/2-t.rect.width/2;var o=i.top-t.rect.height-4;o=(o>0?o:i.bottom+4)+window.pageYOffset;if(a+t.rect.width>window.innerWidth-20){a-=a+t.rect.width-(window.innerWidth-20)}a=Math.max(20,a);if(l.top!==o||l.left!==a||e){BX.DOM.write(function(){t.layout.style.position="absolute";t.layout.style.top=o+"px";t.layout.style.left=a+"px"});l.top=o;l.left=a;g(t)}}function u(t){document.body.appendChild(t.layout)}var c=null;function B(t){c=t.target}var I=false;function f(t){I=c!==t.target}function m(t){if(I){t.preventDefault();t.stopPropagation()}}function L(t){if(t.popup){t.popup.close()}if(t.menu){t.menu.close()}}function g(t){t.buttons.forEach(L);if(t.additionalButtons){t.additionalButtons.forEach(L)}BX.Landing.UI.Tool.ColorPicker.hideAll()}BX.Landing.UI.Panel.EditorPanel.prototype={constructor:BX.Landing.UI.Panel.EditorPanel,__proto__:BX.Landing.UI.Panel.BaseButtonPanel.prototype,show:function(t,n,i){this.currentElement=t;if(this.additionalButtons){this.additionalButtons.forEach(function(t){this.buttons.remove(t);L(t);BX.remove(t.layout)},this);this.additionalButtons=null}if(i){this.additionalButtons=i;this.additionalButtons.forEach(function(t){if(t.insertAfter){var n=this.layout.querySelector('[data-id="'+t.insertAfter+'"]');if(n){BX.insertAfter(t.layout,n);this.buttons.add(t)}}else{this.addButton(t)}},this)}if(!this.isShown()){BX.onCustomEvent("BX.Landing.Editor:enable",[t]);document.addEventListener("mousedown",B,true);document.addEventListener("mouseup",f,true);document.addEventListener("click",m,true);setTimeout(function(){this.layout.classList.add("landing-ui-transition")}.bind(this),100)}BX.Landing.UI.Panel.BaseButtonPanel.prototype.show.call(this,arguments);BX.DOM.write(function(){this.rect=this.layout.getBoundingClientRect();this.adjustPosition(t,n,true)}.bind(this));e(t)},hide:function(){if(this.isShown()){BX.onCustomEvent("BX.Landing.Editor:disable",[null]);document.removeEventListener("mousedown",B,true);document.removeEventListener("mouseup",f,true);document.removeEventListener("click",m,true);setTimeout(function(){this.rect=this.layout.getBoundingClientRect();this.layout.classList.remove("landing-ui-transition")}.bind(this),100)}BX.Landing.UI.Panel.BaseButtonPanel.prototype.hide.call(this,arguments);i()},adjustPosition:function(t,n,e){r(this,t,e)},isFixed:function(){return this.position==="fixed-top"||this.position==="fixed-right"}}})();