Current Path : /home/bitrix/vorobey-clubru/bitrix/js/fileman/html_editor/ |
Current File : /home/bitrix/vorobey-clubru/bitrix/js/fileman/html_editor/html-views.min.js |
(function(){function e(e,t,i){this.editor=e;this.element=t;this.container=i;this.config=e.config||{};this.isShown=null;this.bbCode=e.bbCode;BX.addCustomEvent(this.editor,"OnClickBefore",BX.proxy(this.OnClick,this))}e.prototype={Focus:function(){if(!document.querySelector||this.element.ownerDocument.querySelector(":focus")===this.element)return;try{this.element.focus()}catch(e){}},Hide:function(){this.isShown=false;this.container.style.display="none"},Show:function(){this.isShown=true;this.container.style.display=""},Disable:function(){this.element.setAttribute("disabled","disabled")},Enable:function(){this.element.removeAttribute("disabled")},OnClick:function(e){},IsShown:function(){return!!this.isShown}};function t(e,t,n){i.superclass.constructor.apply(this,arguments);this.name="textarea";this.InitEventHandlers();if(!this.element.value&&this.editor.config.content)this.SetValue(this.editor.config.content,false)}BX.extend(t,e);t.prototype.Clear=function(){this.element.value=""};t.prototype.GetValue=function(e){var t=this.IsEmpty()?"":this.element.value;if(e){t=this.parent.parse(t)}return t};t.prototype.SetValue=function(e,t,i){if(t){e=this.editor.Parse(e,true,i)}this.editor.dom.pValueInput.value=this.element.value=e};t.prototype.SaveValue=function(){if(this.editor.inited){this.editor.dom.pValueInput.value=this.element.value}};t.prototype.HasPlaceholderSet=function(){var e=this.element.getAttribute("placeholder")||null,t=this.element.value;return!t||t===e};t.prototype.IsEmpty=function(){var e=BX.util.trim(this.element.value);return e===""||this.HasPlaceholderSet()};t.prototype.InitEventHandlers=function(){var e=this;BX.bind(this.element,"focus",function(){e.editor.On("OnTextareaFocus");e.isFocused=true});BX.bind(this.element,"blur",function(){e.editor.On("OnTextareaBlur");e.isFocused=false});BX.bind(this.element,"keydown",function(t){e.editor.textareaKeyDownPreventDefault=false;if((t.ctrlKey||t.metaKey)&&!t.altKey&&t.keyCode===e.editor.KEY_CODES["enter"]){e.editor.On("OnCtrlEnter",[t,e.editor.GetViewMode()]);return BX.PreventDefault(t)}e.editor.On("OnTextareaKeydown",[t]);if(e.editor.textareaKeyDownPreventDefault)return BX.PreventDefault(t)});BX.bind(this.element,"keyup",function(t){e.editor.On("OnTextareaKeyup",[t])})};t.prototype.IsFocused=function(){return this.isFocused};t.prototype.ScrollToSelectedText=function(e){};t.prototype.SelectText=function(e){var t=this.element.value,i=t.indexOf(e);if(i!=-1){this.element.focus();this.element.setSelectionRange(i,i+e.length)}};t.prototype.GetTextSelection=function(){var e=false;if(this.element.selectionStart!=undefined){e=this.element.value.substr(this.element.selectionStart,this.element.selectionEnd-this.element.selectionStart)}else if(document.selection&&document.selection.createRange){e=document.selection.createRange().text}else if(window.getSelection){e=window.getSelection();e=e.toString()}return e};t.prototype.WrapWith=function(e,t,i){if(!e)e="";if(!t)t="";if(!i)i="";if(e.length<=0&&t.length<=0&&i.length<=0)return true;var n=!!i,o=this.GetTextSelection(),r=o?"select":n?"after":"in";if(n){i=e+i+t}else if(o){i=e+o+t}else{i=e+t}if(this.element.selectionStart!=undefined){var s=this.element.scrollTop,a=this.element.selectionStart,l=this.element.selectionEnd;this.element.value=this.element.value.substr(0,a)+i+this.element.value.substr(l);if(r=="select"){this.element.selectionStart=a;this.element.selectionEnd=a+i.length}else if(r=="in"){this.element.selectionStart=this.element.selectionEnd=a+e.length}else{this.element.selectionStart=this.element.selectionEnd=a+i.length}this.element.scrollTop=s}else if(document.selection&&document.selection.createRange){var d=document.selection.createRange();var u=d.duplicate();i=i.replace(/\r?\n/g,"\n");d.text=i;d.setEndPoint("StartToStart",u);d.setEndPoint("EndToEnd",u);if(r=="select"){d.collapse(true);i=i.replace(/\r\n/g,"1");d.moveEnd("character",i.length)}else if(r=="in"){d.collapse(false);d.moveEnd("character",e.length);d.collapse(false)}else{d.collapse(false);d.moveEnd("character",i.length);d.collapse(false)}d.select()}else{this.element.value+=i}return true};t.prototype.GetCursorPosition=function(){return this.element.selectionStart};function i(e,t,n){i.superclass.constructor.apply(this,arguments);this.name="wysiwyg";this.caretNode="<br>"}BX.extend(i,e);i.prototype.OnCreateIframe=function(){this.document=this.editor.sandbox.GetDocument();this.element=this.document.body;this.editor.document=this.document;this.textarea=this.editor.dom.textarea;this.isFocused=false;this.InitEventHandlers();window.rangy.init();this.Enable()};i.prototype.Clear=function(){this.element.innerHTML=this.caretNode};i.prototype.GetValue=function(e,t){this.iframeValue=this.IsEmpty()?"":this.editor.GetInnerHtml(this.element);this.editor.On("OnIframeBeforeGetValue",[this.iframeValue]);if(e){this.iframeValue=this.editor.Parse(this.iframeValue,false,t)}return this.iframeValue};i.prototype.SetValue=function(e,t){if(t){e=this.editor.Parse(e)}this.element.innerHTML=e;this.CheckContentLastChild(this.element);this.editor.On("OnIframeSetValue",[e])};i.prototype.Show=function(){this.isShown=true;this.container.style.display="";this.ReInit()};i.prototype.ReInit=function(){this.Disable();this.Enable();this.editor.On("OnIframeReInit")};i.prototype.Hide=function(){this.isShown=false;this.container.style.display="none"};i.prototype.Disable=function(){this.element.removeAttribute("contentEditable")};i.prototype.Enable=function(){this.element.setAttribute("contentEditable","true")};i.prototype.Focus=function(e){if(BX.browser.IsIE()&&this.HasPlaceholderSet()){this.Clear()}if(!document.querySelector||this.element.ownerDocument.querySelector(":focus")!==this.element||!this.IsFocused()){BX.focus(this.element)}if(e&&this.element.lastChild){if(this.element.lastChild.nodeName==="BR"){this.editor.selection.SetBefore(this.element.lastChild)}else{this.editor.selection.SetAfter(this.element.lastChild)}}};i.prototype.SetFocusedFlag=function(e){this.isFocused=e};i.prototype.IsFocused=function(){return this.isFocused};i.prototype.GetTextContent=function(e){var t=this.editor.util.GetTextContent(this.element);return e===true?t.replace(/\uFEFF/gi,""):t};i.prototype.HasPlaceholderSet=function(){return this.textarea&&this.GetTextContent()==this.textarea.getAttribute("placeholder")};i.prototype.IsEmpty=function(e){if(!document.querySelector)return false;var t=this.element.innerHTML,i="blockquote, ul, ol, img, embed, object, table, iframe, svg, video, audio, button, input, select, textarea";return t===""||t===this.caretNode||this.HasPlaceholderSet()||this.GetTextContent(e)===""&&!this.element.querySelector(i)};i.prototype._initObjectResizing=function(){var e=["width","height"],t=e.length,i=this.element;this.commands.exec("enableObjectResizing",this.config.allowObjectResizing);if(this.config.allowObjectResizing){if(browser.supportsEvent("resizeend")){dom.observe(i,"resizeend",function(n){var o=n.target||n.srcElement,r=o.style,s=0,a;for(;s<t;s++){a=e[s];if(r[a]){o.setAttribute(a,parseInt(r[a],10));r[a]=""}}redraw(i)})}}else{if(browser.supportsEvent("resizestart")){dom.observe(i,"resizestart",function(e){e.preventDefault()})}}};var n=function(e){if(e.setActive){try{e.setActive()}catch(t){}}else{var i=e.style,n=doc.documentElement.scrollTop||doc.body.scrollTop,o=doc.documentElement.scrollLeft||doc.body.scrollLeft,r={position:i.position,top:i.top,left:i.left,WebkitUserSelect:i.WebkitUserSelect};dom.setStyles({position:"absolute",top:"-99999px",left:"-99999px",WebkitUserSelect:"none"}).on(e);e.focus();dom.setStyles(r).on(e);if(win.scrollTo){win.scrollTo(o,n)}}};i.prototype.InitEventHandlers=function(){var e=this,t=this.editor,i=this.GetValue(),n=this.element,o=this.editor.sandbox.GetWindow(),r=!BX.browser.IsOpera()?n:this.editor.sandbox.GetWindow();if(this._eventsInitedObject&&this._eventsInitedObject===r)return;this._eventsInitedObject=r;BX.bind(r,"focus",function(){t.On("OnIframeFocus");e.isFocused=true;if(i!==e.GetValue())BX.onCustomEvent(t,"OnIframeChange")});BX.bind(r,"blur",function(){t.On("OnIframeBlur");e.isFocused=false;setTimeout(function(){i=e.GetValue()},0)});BX.bind(r,"contextmenu",function(i){if(i&&!i.ctrlKey&&!i.shiftKey&&BX.getEventButton(i)&BX.MSRIGHT){t.On("OnIframeContextMenu",[i,i.target||i.srcElement,e.contMenuRangeCollapsed])}});BX.bind(r,"mousedown",function(i){var n=t.selection.GetRange(),o=i.target||i.srcElement,r=t.GetBxTag(o);e.contMenuRangeCollapsed=n&&n.collapsed;if(t.synchro.IsSyncOn()){t.synchro.StopSync()}if(BX.browser.IsIE10()||BX.browser.IsIE11()){t.phpParser.RedrawSurrogates()}if(o.nodeName=="BODY"||!t.phpParser.CheckParentSurrogate(o)){setTimeout(function(){n=t.selection.GetRange();if(n&&n.collapsed&&n.startContainer&&n.startContainer==n.endContainer){var e=t.phpParser.CheckParentSurrogate(n.startContainer);if(e){t.selection.SetInvisibleTextAfterNode(e);t.selection.SetInvisibleTextBeforeNode(e)}}},10)}t.action.actions.quote.checkSpaceAfterQuotes(o);t.selection.SaveRange(false);setTimeout(function(){t.selection.SaveRange(false)},10);t.On("OnIframeMouseDown",[i,o,r])});BX.bind(r,"touchend",function(){e.Focus()});BX.bind(r,"touchstart",function(){e.Focus()});BX.bind(r,"click",function(e){var i=e.target||e.srcElement;t.On("OnIframeClick",[e,i])});BX.bind(r,"dblclick",function(e){var i=e.target||e.srcElement;t.On("OnIframeDblClick",[e,i])});BX.bind(r,"mouseup",function(e){var i=e.target||e.srcElement;if(!t.synchro.IsSyncOn()){t.synchro.StartSync()}t.On("OnIframeMouseUp",[e,i])});if(BX.browser.IsIOS()){BX.bind(o,"blur",function(){var e=BX.create("INPUT",{props:{type:"text",value:""}},n.ownerDocument),i=document.documentElement.scrollTop||document.body.scrollTop,o=document.documentElement.scrollLeft||document.body.scrollLeft;try{t.selection.InsertNode(e)}catch(r){n.appendChild(e)}BX.focus(e);BX.remove(e);window.scrollTo(o,i)})}BX.bind(n,"dragover",function(){t.On("OnIframeDragOver",arguments)});BX.bind(n,"dragenter",function(){t.On("OnIframeDragEnter",arguments)});BX.bind(n,"dragleave",function(){t.On("OnIframeDragLeave",arguments)});BX.bind(n,"dragexit",function(){t.On("OnIframeDragExit",arguments)});BX.bind(n,"drop",function(){t.On("OnIframeDrop",arguments)});if(BX.browser.IsFirefox()){BX.bind(n,"dragover",function(e){e.preventDefault()});BX.bind(n,"dragenter",function(e){e.preventDefault()})}BX.bind(n,"drop",BX.delegate(this.OnPasteHandler,this));BX.bind(n,"paste",BX.delegate(this.OnPasteHandler,this));BX.bind(n,"keyup",function(i){var n=i.keyCode,o=t.selection.GetSelectedNode(true);e.SetFocusedFlag(true);if(n===t.KEY_CODES["space"]||n===t.KEY_CODES["enter"]){if(n===t.KEY_CODES["enter"]){e.OnEnterHandlerKeyUp(i,n,o)}t.On("OnIframeNewWord")}else{e.OnKeyUpArrowsHandler(i,n)}t.selection.SaveRange();t.On("OnIframeKeyup",[i,n,o]);if(n===t.KEY_CODES["backspace"]&&BX.browser.IsChrome()&&o&&o.nodeType=="3"&&o.nextSibling&&o.nextSibling.nodeType=="3"){e.editor.selection.ExecuteAndRestoreSimple(function(){e.editor.util.SetTextContent(o,e.editor.util.GetTextContent(o)+e.editor.util.GetTextContent(o.nextSibling));o.nextSibling.parentNode.removeChild(o.nextSibling)})}if(!t.util.FirstLetterSupported()&&e.editor.parser.firstNodeCheck){e.editor.parser.FirstLetterCheckNodes("","",true)}});BX.bind(n,"mousedown",function(i){var n=i.target||i.srcElement;if(!t.util.CheckImageSelectSupport()&&n.nodeName==="IMG"){t.selection.SelectNode(n)}if(!t.util.CheckPreCursorSupport()&&n.nodeName==="PRE"){var o=t.selection.GetSelectedNode(true);if(o&&o!=n){e.FocusPreElement(n,true)}}});BX.bind(n,"keydown",BX.proxy(this.KeyDown,this));var s={IMG:BX.message.SrcTitle+": ",A:BX.message.UrlTitle+": "};BX.bind(n,"mouseover",function(e){var t=e.target||e.srcElement,i=t.getAttribute("href")||t.getAttribute("src"),n=t.nodeName;if(s[n]&&!t.hasAttribute("title")&&i&&i.indexOf("data:image/")===-1){t.setAttribute("title",s[n]+i);t.setAttribute("data-bx-clean-attribute","title")}});this.editor.InitClipboardHandler()};i.prototype.KeyDown=function(e){this.SetFocusedFlag(true);this.editor.iframeKeyDownPreventDefault=false;var t=this,i=e.keyCode,n=this.editor.KEY_CODES,o=this.editor.SHORTCUTS[i],r=this.editor.selection.GetSelectedNode(true),s=this.editor.selection.GetRange(),a=this.document.body,l;if((BX.browser.IsIE()||BX.browser.IsIE10()||BX.browser.IsIE11())&&!BX.util.in_array(i,[16,17,18,20,65,144,37,38,39,40])){if(r&&r.nodeName=="BODY"||s.startContainer&&s.startContainer.nodeName=="BODY"||s.startContainer==a.firstChild&&s.endContainer==a.lastChild&&s.startOffset==0&&s.endOffset==a.lastChild.length){BX.addCustomEvent(this.editor,"OnIframeKeyup",BX.proxy(this._IEBodyClearHandler,this))}}if((BX.browser.IsIE()||BX.browser.IsIE10()||BX.browser.IsIE11())&&i==n["backspace"]){BX.addCustomEvent(this.editor,"OnIframeKeyup",BX.proxy(this._IEBodyClearHandlerEx,this))}this.isUserTyping=true;if(this.typingTimeout){this.typingTimeout=clearTimeout(this.typingTimeout)}this.typingTimeout=setTimeout(function(){t.isUserTyping=false},1e3);this.editor.synchro.StartSync(200);this.editor.On("OnIframeKeydown",[e,i,o,r]);if(this.editor.iframeKeyDownPreventDefault)return BX.PreventDefault(e);if((e.ctrlKey||e.metaKey)&&!e.altKey&&o){this.editor.action.Exec(o);return BX.PreventDefault(e)}if(i===n["backspace"]&&s.startOffset==0&&s.startContainer.nodeType==3&&s.startContainer.parentNode.firstChild==s.startContainer&&s.startContainer.parentNode&&s.startContainer.parentNode.nodeName=="BLOCKQUOTE"&&s.startContainer.parentNode.className){s.startContainer.parentNode.className=""}if(i===n["delete"]&&s.collapsed&&s.endContainer.nodeType==3&&s.endOffset==s.endContainer.length){var d=this.editor.util.GetNextNotEmptySibling(s.endContainer);if(d){if(d.nodeName=="BR"){d=this.editor.util.GetNextNotEmptySibling(d)}if(d&&d.nodeName=="BLOCKQUOTE"&&d.className){d.className=""}}}if(r&&r.nodeName==="IMG"&&(i===n["backspace"]||i===n["delete"])){l=r.parentNode;l.removeChild(r);if(l.nodeName==="A"&&!l.firstChild){l.parentNode.removeChild(l)}setTimeout(function(){t.editor.util.Refresh(t.element)},0);BX.PreventDefault(e)}if(s.collapsed&&this.OnKeyDownArrowsHandler(e,i,s)===false){return false}if((e.ctrlKey||e.metaKey)&&!e.altKey&&i===n["enter"]){if(this.IsFocused())this.editor.On("OnIframeBlur");this.editor.On("OnCtrlEnter",[e,this.editor.GetViewMode()]);return BX.PreventDefault(e)}if(BX.browser.IsFirefox()&&r&&(i===n["delete"]||i===n["backspace"])){var u=r.nodeName=="LI"?r:BX.findParent(r,{tag:"LI"},a);if(u&&u.firstChild&&u.firstChild.nodeName=="I"){var c=BX.findParent(u,{tag:"UL"},a);if(c){var f=this.editor.action.actions.insertUnorderedList.getCustomBullitClass(c);if(f){setTimeout(function(){if(c&&u&&u.innerHTML!==""){t.editor.action.actions.insertUnorderedList.checkCustomBullitList(c,f)}},0)}}}}if(!this.editor.util.FirstLetterSupported()&&t.editor.parser.firstNodeCheck&&i===this.editor.KEY_CODES["backspace"]){t.editor.parser.FirstLetterBackspaceHandler(s)}if(!e.shiftKey&&(i===n["enter"]||i===n["backspace"])){return this.OnEnterHandler(e,i,r,s)}if(i===n["pageUp"]||i===n["pageDown"]){this.savedScroll=BX.GetWindowScrollPos(document);BX.addCustomEvent(this.editor,"OnIframeKeyup",BX.proxy(this._RestoreScrollTop,this));setTimeout(BX.proxy(this._RestoreScrollTop,this),0)}};i.prototype._RestoreScrollTop=function(e){if(this.savedScroll){window.scrollTo(this.savedScroll.scrollLeft,this.savedScroll.scrollTop);this.savedScroll=null}BX.removeCustomEvent(this.editor,"OnIframeKeyup",BX.proxy(this._RestoreScrollTop,this))};i.prototype._IEBodyClearHandler=function(e){var t=this.document.body.firstChild;if(e.keyCode==this.editor.KEY_CODES["enter"]&&t.nodeName=="P"&&t!=this.document.body.lastChild){if(t.innerHTML&&t.innerHTML.toLowerCase()=="<br>"){var i=t.nextSibling;this.editor.util.ReplaceWithOwnChildren(t);t=i}}if(t&&t.nodeName=="P"&&t==this.document.body.lastChild){this.editor.util.ReplaceWithOwnChildren(t)}BX.removeCustomEvent(this.editor,"OnIframeKeyup",BX.proxy(this._IEBodyClearHandler,this))};i.prototype._IEBodyClearHandlerEx=function(e){var t=this.document.body.firstChild;if(e.keyCode==this.editor.KEY_CODES["backspace"]&&t&&t.nodeName=="P"&&t==this.document.body.lastChild&&(this.editor.util.IsEmptyNode(t,true,true)||t.innerHTML&&t.innerHTML.toLowerCase()=="<br>")){this.editor.util.ReplaceWithOwnChildren(t)}BX.removeCustomEvent(this.editor,"OnIframeKeyup",BX.proxy(this._IEBodyClearHandlerEx,this))};i.prototype.OnEnterHandler=function(e,t,i,n){if(BX.browser.IsChrome()){this.document.body.style.minHeight=parseInt(this.document.body.style.minHeight)+1+"px";this.document.body.style.minHeight=parseInt(this.document.body.style.minHeight)-1+"px"}if(!i){return}var o=this;function r(e){if(e){if(e.nodeName!=="P"&&e.nodeName!=="DIV"){e=BX.findParent(e,function(e){return e.nodeName==="P"||e.nodeName==="DIV"},o.document.body)}var t=o.editor.util.GetInvisibleTextNode();if(e){e.parentNode.insertBefore(t,e);o.editor.util.ReplaceWithOwnChildren(e);o.editor.selection.SelectNode(t)}}}var s,a,l,d=["LI","P","H1","H2","H3","H4","H5","H6"],u=["UL","OL","MENU"];if(BX.util.in_array(i.nodeName,d)){l=i}else{l=BX.findParent(i,function(e){return BX.util.in_array(e.nodeName,d)},this.document.body)}if(l){if(l.nodeName==="LI"){if(t===o.editor.KEY_CODES["enter"]&&l&&l.parentNode){var c=o.editor.action.actions.insertUnorderedList.getCustomBullitClass(l.parentNode)}setTimeout(function(){var e=o.editor.selection.GetSelectedNode(true);if(e){s=BX.findParent(e,function(e){return BX.util.in_array(e.nodeName,u)},o.document.body);if(t===o.editor.KEY_CODES["enter"]&&l&&l.parentNode){o.editor.action.actions.insertUnorderedList.checkCustomBullitList(l.parentNode,c,true)}if(s&&BX.browser.IsChrome()&&t===o.editor.KEY_CODES["enter"]){var i,n=s.getElementsByTagName("LI");for(i=0;i<n.length;i++){n[i].innerHTML=n[i].innerHTML.replace(/\uFEFF/gi,"")}}if(!s){r(e)}}},0)}else if(l.nodeName.match(/H[1-6]/)&&t===this.editor.KEY_CODES["enter"]){setTimeout(function(){r(o.editor.selection.GetSelectedNode())},0)}return true}if(t===this.editor.KEY_CODES["enter"]&&!BX.browser.IsFirefox()&&this.editor.action.IsSupported("insertLineBreak")){if(BX.browser.IsIE10()||BX.browser.IsIE11()){this.editor.action.Exec("insertHTML","<br>"+this.editor.INVISIBLE_SPACE)}else if(BX.browser.IsChrome()){this.editor.action.Exec("insertLineBreak");if(BX.browser.IsMac()){var f="bx-editor-temp-"+Math.round(Math.random()*1e6);this.editor.action.Exec("insertHTML",'<span id="'+f+'">'+this.editor.INVISIBLE_SPACE+"</span>");var h=this.editor.GetIframeElement(f);if(h)BX.remove(h)}else{this.editor.action.Exec("insertHTML",this.editor.INVISIBLE_SPACE)}}else{this.editor.action.Exec("insertLineBreak")}return BX.PreventDefault(e)}if((BX.browser.IsChrome()||BX.browser.IsIE10()||BX.browser.IsIE11())&&t==this.editor.KEY_CODES["backspace"]&&n.collapsed){var m=BX.create("SPAN",false,this.document);this.editor.selection.InsertNode(m);var p=m.previousSibling;if(p&&p.nodeType==3&&this.editor.util.IsEmptyNode(p,false,false)){BX.remove(p)}this.editor.selection.SetBefore(m);BX.remove(m)}};i.prototype.OnEnterHandlerKeyUp=function(e,t,i){if(i){var n=this;if(!BX.util.in_array(i.nodeName,this.editor.GetBlockTags())){i=BX.findParent(i,function(e){return BX.util.in_array(e.nodeName,n.editor.GetBlockTags())},this.document.body)}if(i&&BX.util.in_array(i.nodeName,this.editor.GetBlockTags())){var o=BX.util.trim(i.innerHTML).toLowerCase();if(this.editor.util.IsEmptyNode(i,true,true)||o==""||o=="<br>"){i.removeAttribute("class")}}}};i.prototype.OnKeyDownArrowsHandler=function(e,t,i){var n,o,r,s,a=this.editor.KEY_CODES;this.keyDownRange=i;if(t===a["right"]||t===a["down"]){n=i.endContainer;r=n?n.nextSibling:false;o=n?n.parentNode:false;if(n.nodeType==3&&n.length==i.endOffset&&o&&o.nodeName!=="BODY"&&(!r||r&&r.nodeName=="BR"&&!r.nextSibling)&&(this.editor.util.IsBlockElement(o)||this.editor.util.IsBlockNode(o))){this.editor.selection.SetInvisibleTextAfterNode(o,true);return BX.PreventDefault(e)}else if(n.nodeType==3&&this.editor.util.IsEmptyNode(n)&&r&&(this.editor.util.IsBlockElement(r)||this.editor.util.IsBlockNode(r))){BX.remove(n);if(r.firstChild){this.editor.selection.SetBefore(r.firstChild)}else{this.editor.selection.SetAfter(r)}return BX.PreventDefault(e)}else if(n.nodeType==3&&n.length==i.endOffset&&o&&o.nodeName!=="BODY"&&r&&r.nodeName=="BR"&&!r.nextSibling&&(this.editor.util.IsBlockElement(o)||this.editor.util.IsBlockNode(o))){this.editor.selection.SetInvisibleTextAfterNode(o,true);return BX.PreventDefault(e)}}else if(t===a["left"]||t===a["up"]){n=i.startContainer;o=n?n.parentNode:false;s=n?n.previousSibling:false;if(n.nodeType==3&&i.endOffset===0&&o&&o.nodeName!=="BODY"&&!s&&(this.editor.util.IsBlockElement(o)||this.editor.util.IsBlockNode(o))){this.editor.selection.SetInvisibleTextBeforeNode(o);return BX.PreventDefault(e)}else if(n.nodeType==3&&this.editor.util.IsEmptyNode(n)&&s&&(this.editor.util.IsBlockElement(s)||this.editor.util.IsBlockNode(s))){BX.remove(n);if(s.lastChild){this.editor.selection.SetAfter(s.lastChild)}else{this.editor.selection.SetBefore(s)}return BX.PreventDefault(e)}}return true};i.prototype.OnKeyUpArrowsHandler=function(e,t){var i=this,n,o,r,s,a,l=this.editor.selection.GetRange(),d,u,c,f,h,m,p,y,v,B,S,I=this.editor.KEY_CODES;if(t===I["right"]||t===I["down"]){this.editor.selection.GetStructuralTags();if(l.collapsed){d=l.endContainer;h=this.editor.util.IsEmptyNode(d);p=this.editor.selection.CheckLastRange(l);c=d.nextSibling;if(!this.editor.util.CheckPreCursorSupport()){if(d.nodeName==="PRE"){n=d}else if(d.nodeType==3){n=BX.findParent(d,{tag:"PRE"},this.element)}if(n){if(this.keyDownRange){s=this.keyDownRange.endContainer;a=s==n?n:BX.findParent(s,function(e){return e==n},this.element)}i.FocusPreElement(n,false,a?null:"start")}}if(d.nodeType==3&&h&&c){d=c;h=this.editor.util.IsEmptyNode(d)}m=this.editor.util.CheckSurrogateNode(d);if(m){r=d.nextSibling;if(r&&r.nodeType==3&&this.editor.util.IsEmptyNode(r))this.editor.selection._MoveCursorAfterNode(r);else this.editor.selection._MoveCursorAfterNode(d);BX.PreventDefault(e)}else if(d.nodeType==1&&d.nodeName!="BODY"&&!h){if(p){this.editor.selection._MoveCursorAfterNode(d);BX.PreventDefault(e)}}else if(p&&d.nodeType==3&&!h){u=d.parentNode;if(u&&d===u.lastChild&&u.nodeName!="BODY"){this.editor.selection._MoveCursorAfterNode(u)}}else if(d.nodeType==3&&d.parentNode){u=d.parentNode;f=u.previousSibling;if((this.editor.util.IsBlockElement(u)||this.editor.util.IsBlockNode(u))&&f&&f.nodeType==3&&this.editor.util.IsEmptyNode(f)){BX.remove(f)}}}else{y=l.startContainer;v=l.endContainer;B=this.editor.util.CheckSurrogateNode(y);S=this.editor.util.CheckSurrogateNode(v);if(B){o=y.previousSibling;if(o&&o.nodeType==3&&this.editor.util.IsEmptyNode(o))l.setStartBefore(o);else l.setStartBefore(y);this.editor.selection.SetSelection(l)}if(S){r=v.nextSibling;if(r&&r.nodeType==3&&this.editor.util.IsEmptyNode(r))l.setEndAfter(r);else l.setEndAfter(v);this.editor.selection.SetSelection(l)}}}else if(t===I["left"]||t===I["up"]){this.editor.selection.GetStructuralTags();if(l.collapsed){d=l.startContainer;h=this.editor.util.IsEmptyNode(d);p=this.editor.selection.CheckLastRange(l);if(d.nodeType==3&&h&&d.previousSibling){d=d.previousSibling;h=this.editor.util.IsEmptyNode(d)}if(!this.editor.util.CheckPreCursorSupport()){if(d.nodeName==="PRE"){n=d}else if(d.nodeType==3){n=BX.findParent(d,{tag:"PRE"},this.element)}if(n){if(this.keyDownRange){s=this.keyDownRange.startContainer;a=s==n?n:BX.findParent(s,function(e){return e==n},this.element)}i.FocusPreElement(n,false,a?null:"end")}}m=this.editor.util.CheckSurrogateNode(d);if(m){o=d.previousSibling;if(o&&o.nodeType==3&&this.editor.util.IsEmptyNode(o))this.editor.selection._MoveCursorBeforeNode(o);else this.editor.selection._MoveCursorBeforeNode(d);BX.PreventDefault(e)}else if(d.nodeType==1&&d.nodeName!="BODY"&&!h){if(p){this.editor.selection._MoveCursorBeforeNode(d);BX.PreventDefault(e)}}else if(p&&d.nodeType==3&&!h){u=d.parentNode;if(u&&d===u.firstChild&&u.nodeName!="BODY"){this.editor.selection._MoveCursorBeforeNode(u)}}else if(d.nodeType==3&&d.parentNode){u=d.parentNode;f=u.nextSibling;if((this.editor.util.IsBlockElement(u)||this.editor.util.IsBlockNode(u))&&f&&f.nodeType==3&&this.editor.util.IsEmptyNode(f)){BX.remove(f)}}}else{y=l.startContainer;v=l.endContainer;B=this.editor.util.CheckSurrogateNode(y);S=this.editor.util.CheckSurrogateNode(v);if(B){o=y.previousSibling;if(o&&o.nodeType==3&&this.editor.util.IsEmptyNode(o))l.setStartBefore(o);else l.setStartBefore(y);this.editor.selection.SetSelection(l)}if(S){r=v.nextSibling;if(r&&r.nodeType==3&&this.editor.util.IsEmptyNode(r))l.setEndAfter(r);else l.setEndAfter(v);this.SetSelection(l)}}}this.keyDownRange=null};i.prototype.FocusPreElement=function(e,t,i){var n=this;if(this._focusPreElementTimeout)this._focusPreElementTimeout=clearTimeout(this._focusPreElementTimeout);if(t){this._focusPreElementTimeout=setTimeout(function(){n.FocusPreElement(e,false,i)},100);return}BX.focus(e);if(i=="end"&&e.lastChild){this.editor.selection.SetAfter(e.lastChild)}else if(i=="start"&&e.firstChild){this.editor.selection.SetBefore(e.firstChild)}};i.prototype.OnPasteHandler=function(e){if(!this.editor.skipPasteHandler){this.editor.skipPasteHandler=true;this.editor.pasteNodeIndex={};var t=document.documentElement.scrollTop||document.body.scrollTop,i=document.documentElement.scrollLeft||document.body.scrollLeft,n=this,o=[],r,s,a,l;function d(e){if(e&&e.setAttribute){var t=Math.round(Math.random()*1e6);n.editor.pasteNodeIndex[t]=true;e.setAttribute("data-bx-paste-flag",t)}}r=this.document.body;if(r){l=r.querySelectorAll("*");for(s=0;s<l.length;s++){if(l[s].nodeType==1&&l[s].nodeName!="BODY"&&l[s].nodeName!="HEAD"){o.push(l[s])}}for(s=0;s<r.parentNode.childNodes.length;s++){a=r.parentNode.childNodes[s];if(a.nodeType==1&&a.nodeName!="BODY"&&a.nodeName!="HEAD"){o.push(a)}}}for(s=0;s<o.length;s++){d(o[s])}var u=this.editor.synchro.IsSyncOn();if(u){this.editor.synchro.StopSync()}if(this.editor.iframeView.pasteHandlerTimeout)clearTimeout(this.editor.iframeView.pasteHandlerTimeout);this.pasteHandlerTimeout=setTimeout(function(){n.editor.SetCursorNode();n.editor.pasteHandleMode=true;n.editor.bbParseContentMode=true;n.editor.synchro.lastIframeValue=false;if(!n.editor.skipPasteControl){n.editor.pasteControl.SaveIframeContent(n.GetValue());n.editor.pasteControl.CheckAndShow()}n.editor.synchro.FromIframeToTextarea(true,true);n.editor.pasteHandleMode=false;n.editor.bbParseContentMode=false;n.editor.synchro.lastTextareaValue=false;n.editor.synchro.FromTextareaToIframe(true);n.editor.RestoreCursor();n.editor.On("OnIframePaste");n.editor.On("OnIframeNewWord");n.editor.skipPasteHandler=false;if(u){n.editor.synchro.StartSync()}if(window.scrollTo){window.scrollTo(i,t)}},10)}};i.prototype.InitAutoLinking=function(){var e=this,t=this.editor,i=t.action.IsSupportedByBrowser("autoUrlDetect"),n=BX.browser.IsIE()||BX.browser.IsIE9()||BX.browser.IsIE10();if(i)t.action.Exec("autoUrlDetect",false);if(t.config.autoLink===false)return;var o={CODE:1,PRE:1,A:1,SCRIPT:1,HEAD:1,TITLE:1,STYLE:1},r=/(((?:https?|ftp):\/\/|www\.)[^\s'"<]{3,500})/gi,s=/[\.a-z0-9_\-]+@[\.a-z0-9_\-]+\.[\.a-z0-9_\-]+/gi,a=100,l={")":"(","]":"[","}":"{"};this.editor.autolinkUrlRegExp=r;this.editor.autolinkEmailRegExp=s;function d(){try{if(u()){t.selection.ExecuteAndRestore(function(e,t){if(t&&t.parentNode)c(t.parentNode)})}}catch(e){}}function u(){var e,i,n=false,o=t.GetIframeDoc(),a=o.createTreeWalker(o.body,NodeFilter.SHOW_TEXT,null,false);while(e=a.nextNode()){i=e.nodeValue||"";if((i.match(s)||i.match(r))&&e.parentNode&&e.parentNode.nodeName!="A"){n=true;break}}return n}function c(e){if(e&&!o[e.nodeName]){var t=BX.findParent(e,function(e){return!!o[e.nodeName]},e.ownerDocument.body);if(t)return e;if(e===e.ownerDocument.documentElement)e=e.ownerDocument.body;return p(e)}}function f(t){t=BX.util.htmlspecialchars(t);return t.replace(r,function(t,i){var n=(i.match(/([^\w\u0430-\u0456\u0451\/\-#](,?))$/i)||[])[1]||"",o=l[n];i=i.replace(/([^\w\u0430-\u0456\u0451\/\-#](,?))$/i,"");if(i.split(o).length>i.split(n).length){i=i+n;n=""}var r=i,s=BX.util.htmlspecialchars(i);if(i.length>a)s=s.substr(0,a)+"...";if(r.substr(0,4)==="www.")r="http://"+r;BX.onCustomEvent(e.editor,"OnAfterUrlConvert",[r]);return'<a href="'+r+'">'+s+"</a>"+n})}function h(e){e=BX.util.htmlspecialchars(e);return e.replace(s,function(e){var t=(e.match(/([^\w\/\-](,?))$/i)||[])[1]||"",i=l[t];e=e.replace(/([^\w\/\-](,?))$/i,"");if(e.split(i).length>e.split(t).length){e=e+t;t=""}var n="mailto:"+e;return'<a href="'+n+'">'+e+"</a>"+t})}function m(e){var t=e._bx_autolink_temp_div;if(!t)t=e._bx_autolink_temp_div=e.createElement("div");return t}function p(e){var t,i,n;if(e&&!o[e.nodeName]){if(e.nodeType===3&&e.data.match(r)&&e.parentNode){i=e.parentNode;n=m(i.ownerDocument);n.innerHTML="<span></span>"+f(e.data);n.removeChild(n.firstChild);while(n.firstChild)i.insertBefore(n.firstChild,e);i.removeChild(e)}else if(e.nodeType===3&&e.data.match(s)&&e.parentNode){i=e.parentNode;n=m(i.ownerDocument);n.innerHTML="<span></span>"+h(e.data);n.removeChild(n.firstChild);while(n.firstChild)i.insertBefore(n.firstChild,e);i.removeChild(e)}else if(e.nodeType===1){var a=e.childNodes,l;for(l=0;l<a.length;l++)p(a[l]);t=e}}return t}if(!n||n&&i){BX.addCustomEvent(t,"OnIframeNewWord",function(){if(t.autolinkTimeout)t.autolinkTimeout=clearTimeout(t.autolinkTimeout);t.autolinkTimeout=setTimeout(d,500)});BX.addCustomEvent(t,"OnSubmit",function(){try{c(t.GetIframeDoc().body)}catch(e){}})}var y=t.sandbox.GetDocument().getElementsByTagName("a"),v=function(e){var i=BX.util.trim(t.util.GetTextContent(e));if(i.substr(0,4)==="www.")i="http://"+i;return i};BX.addCustomEvent(t,"OnIframeKeydown",function(e,t,i,n){if(y.length>0&&n){var o=BX.findParent(n,{tag:"A"},n.ownerDocument.body);if(o){var s=v(o);setTimeout(function(){var e=v(o);if(e===s)return;if(e.match(r))o.setAttribute("href",e)},0)}}})};i.prototype.IsUserTypingNow=function(e){return this.isFocused&&this.isShown&&this.isUserTyping};i.prototype.CheckContentLastChild=function(e){if(!e){e=this.element}var t=e.lastChild;if(t&&(this.editor.util.IsEmptyNode(t,true)&&this.editor.util.IsBlockNode(t.previousSibling)||this.editor.phpParser.IsSurrogate(t))){e.appendChild(BX.create("BR",{},e.ownerDocument));e.appendChild(this.editor.util.GetInvisibleTextNode())}};function o(e,t,i){this.INTERVAL=500;this.editor=e;this.textareaView=t;this.iframeView=i;this.lastFocused="wysiwyg";this.InitEventHandlers()}o.prototype={FromIframeToTextarea:function(e,t){var i;if(this.editor.bbCode){i=this.iframeView.GetValue(this.editor.bbParseContentMode,false);i=BX.util.trim(i);if(i!==this.lastIframeValue){var n=this.editor.bbParser.Unparse(i);this.textareaView.SetValue(n,false,t||this.editor.bbParseContentMode);if(typeof this.lastSavedIframeValue!=="undefined"&&this.lastSavedIframeValue!=i){this.editor.On("OnContentChanged",[n,i])}this.lastSavedIframeValue=i;this.lastIframeValue=i}}else{i=this.iframeView.GetValue();i=BX.util.trim(i);if(i!==this.lastIframeValue){this.textareaView.SetValue(i,true,t);if(typeof this.lastSavedIframeValue!=="undefined"&&this.lastSavedIframeValue!=i){this.editor.On("OnContentChanged",[this.textareaView.GetValue()||"",i||""])}this.lastSavedIframeValue=i;this.lastIframeValue=i}}},FromTextareaToIframe:function(e){var t=this.textareaView.GetValue();if(t!==this.lastTextareaValue){if(t){if(this.editor.bbCode){var i=this.editor.bbParser.Parse(t);i=i.replace(/\u2060/gi,'<span id="bx-cursor-node"> </span>');this.iframeView.SetValue(i,e)}else{t=t.replace(/\u2060/gi,'<span id="bx-cursor-node"> </span>');this.iframeView.SetValue(t,e)}}else{this.iframeView.Clear()}this.lastTextareaValue=t;this.editor.On("OnContentChanged",[t||"",this.iframeView.GetValue()||""])}},FullSyncFromIframe:function(){this.lastIframeValue=false;this.FromIframeToTextarea(true,true);this.lastTextareaValue=false;this.FromTextareaToIframe(true)},Sync:function(){var e=true;var t=this.editor.currentViewName;if(t==="split"){if(this.GetSplitMode()==="code"){this.FromTextareaToIframe(e)}else{ this.FromIframeToTextarea(e)}}else if(t==="code"){this.FromTextareaToIframe(e)}else{this.FromIframeToTextarea(e)}},GetSplitMode:function(){var e=false;if(this.editor.currentViewName=="split"){if(this.editor.iframeView.IsFocused()){e="wysiwyg"}else if(this.editor.textareaView.IsFocused()){e="code"}else{e=this.lastFocused}}return e},InitEventHandlers:function(){var e=this;BX.addCustomEvent(this.editor,"OnTextareaFocus",function(){e.lastFocused="code";e.StartSync()});BX.addCustomEvent(this.editor,"OnIframeFocus",function(){e.lastFocused="wysiwyg";e.StartSync()});BX.addCustomEvent(this.editor,"OnTextareaBlur",BX.delegate(this.StopSync,this));BX.addCustomEvent(this.editor,"OnIframeBlur",BX.delegate(this.StopSync,this))},StartSync:function(e){var t=this;if(this.interval){this.interval=clearTimeout(this.interval)}this.delay=e||this.INTERVAL;function i(){t.delay=t.INTERVAL;t.Sync();t.interval=setTimeout(i,t.delay)}this.interval=setTimeout(i,t.delay)},StopSync:function(){if(this.interval){this.interval=clearTimeout(this.interval)}},IsSyncOn:function(){return!!this.interval},OnIframeMousedown:function(e,t,i){},IsFocusedOnTextarea:function(){var e=this.editor.currentViewName;return e==="code"||e==="split"&&this.GetSplitMode()==="code"}};window.BXEditorTextareaView=t;window.BXEditorIframeView=i;window.BXEditorViewsSynchro=o})(); //# sourceMappingURL=html-views.map.js