Your IP : 13.59.241.118
(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(){return false;var e=supportsPlaceholderAttributeOn(this.element),t=this.element.getAttribute("placeholder")||null,i=this.element.value,n=!i;return e&&n||i===t};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,r=this.GetTextSelection(),o=r?"select":n?"after":"in";if(n){i=e+i+t}else if(r){i=e+r+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(o=="select"){this.element.selectionStart=a;this.element.selectionEnd=a+i.length}else if(o=="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(o=="select"){d.collapse(true);i=i.replace(/\r\n/g,"1");d.moveEnd("character",i.length)}else if(o=="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){var i=this.IsEmpty()?"":this.editor.GetInnerHtml(this.element);if(e){i=this.editor.Parse(i,false,t)}return i};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(){return this.editor.util.GetTextContent(this.element)};i.prototype.HasPlaceholderSet=function(){return this.GetTextContent()==this.textarea.getAttribute("placeholder")};i.prototype.IsEmpty=function(){if(!document.querySelector)return false;var e=this.element.innerHTML,t="blockquote, ul, ol, img, embed, object, table, iframe, svg, video, audio, button, input, select, textarea";return e===""||e===this.caretNode||this.HasPlaceholderSet()||this.GetTextContent()===""&&!this.element.querySelector(t)};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 r=n.target||n.srcElement,o=r.style,s=0,a;for(;s<t;s++){a=e[s];if(o[a]){r.setAttribute(a,parseInt(o[a],10));o[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,r=doc.documentElement.scrollLeft||doc.body.scrollLeft,o={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(o).on(e);if(win.scrollTo){win.scrollTo(r,n)}}};i.prototype.InitEventHandlers=function(){var e=this,t=this.editor,i=this.GetValue(),n=this.element,r=this.editor.sandbox.GetWindow(),o=!BX.browser.IsOpera()?n:this.editor.sandbox.GetWindow();if(this._eventsInitedObject&&this._eventsInitedObject===o)return;this._eventsInitedObject=o;BX.bind(o,"focus",function(){t.On("OnIframeFocus");e.isFocused=true;if(i!==e.GetValue())BX.onCustomEvent(t,"OnIframeChange")});BX.bind(o,"blur",function(){t.On("OnIframeBlur");e.isFocused=false;setTimeout(function(){i=e.GetValue()},0)});BX.bind(o,"contextmenu",function(e){if(e&&!e.ctrlKey&&!e.shiftKey&&BX.getEventButton(e)&BX.MSRIGHT){t.On("OnIframeContextMenu",[e,e.target||e.srcElement])}});BX.bind(o,"mousedown",function(e){var i=e.target||e.srcElement,n=t.GetBxTag(i);if(t.synchro.IsSyncOn()){t.synchro.StopSync()}if(BX.browser.IsIE10()||BX.browser.IsIE11()){t.phpParser.RedrawSurrogates()}if(i.nodeName=="BODY"||!t.phpParser.CheckParentSurrogate(i)){setTimeout(function(){var e=t.selection.GetRange();if(e&&e.collapsed&&e.startContainer&&e.startContainer==e.endContainer){var i=t.phpParser.CheckParentSurrogate(e.startContainer);if(i){t.selection.SetInvisibleTextAfterNode(i);t.selection.SetInvisibleTextBeforeNode(i)}}},10)}t.selection.SaveRange(false);t.On("OnIframeMouseDown",[e,i,n])});BX.bind(o,"touchend",function(t){e.Focus()});BX.bind(o,"touchstart",function(t){e.Focus()});BX.bind(o,"click",function(e){var i=e.target||e.srcElement;t.On("OnIframeClick",[e,i])});BX.bind(o,"dblclick",function(e){var i=e.target||e.srcElement;t.On("OnIframeDblClick",[e,i])});BX.bind(o,"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(r,"blur",function(){var e=BX.create("INPUT",{props:{type:"text",value:""}},n.ownerDocument),i=document.documentElement.scrollTop||document.body.scrollTop,r=document.documentElement.scrollLeft||document.body.scrollLeft;try{t.selection.InsertNode(e)}catch(o){n.appendChild(e)}BX.focus(e);BX.remove(e);window.scrollTo(r,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,r=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,r)}t.On("OnIframeNewWord")}else{e.OnKeyUpArrowsHandler(i,n)}t.selection.SaveRange();t.On("OnIframeKeyup",[i,n,r]);if(n===t.KEY_CODES["backspace"]&&BX.browser.IsChrome()&&r&&r.nodeType=="3"&&r.nextSibling&&r.nextSibling.nodeType=="3"){e.editor.selection.ExecuteAndRestoreSimple(function(){e.editor.util.SetTextContent(r,e.editor.util.GetTextContent(r)+e.editor.util.GetTextContent(r.nextSibling));r.nextSibling.parentNode.removeChild(r.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 r=t.selection.GetSelectedNode(true);if(r&&r!=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.nodeName;if(!s[i]){return}if(!t.hasAttribute("title")){t.setAttribute("title",s[i]+(t.getAttribute("href")||t.getAttribute("src")));t.setAttribute("data-bx-clean-attribute","title")}});this.InitClipboardHandler()};i.prototype.KeyDown=function(e){this.SetFocusedFlag(true);this.editor.iframeKeyDownPreventDefault=false;var t=this,i=e.keyCode,n=this.editor.KEY_CODES,r=this.editor.SHORTCUTS[i],o=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(o&&o.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,r,o]);if(this.editor.iframeKeyDownPreventDefault)return BX.PreventDefault(e);if((e.ctrlKey||e.metaKey)&&!e.altKey&&r){this.editor.action.Exec(r);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(o&&o.nodeName==="IMG"&&(i===n["backspace"]||i===n["delete"])){l=o.parentNode;l.removeChild(o);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()&&o&&(i===n["delete"]||i===n["backspace"])){var u=o.nodeName=="LI"?o:BX.findParent(o,{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,o,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 r=this;function o(e){if(e){if(e.nodeName!=="P"&&e.nodeName!=="DIV"){e=BX.findParent(e,function(e){return e.nodeName==="P"||e.nodeName==="DIV"},r.document.body)}var t=r.editor.util.GetInvisibleTextNode();if(e){e.parentNode.insertBefore(t,e);r.editor.util.ReplaceWithOwnChildren(e);r.editor.selection.SelectNode(t)}}}var s,a,l,d,u,c=["LI","P","H1","H2","H3","H4","H5","H6"],f=["UL","OL","MENU"];if(t===this.editor.KEY_CODES["enter"]&&BX.browser.IsChrome()&&i.nodeName==="LI"&&i.childNodes.length==1&&i.firstChild.nodeName==="BR"){s=BX.findParent(i,function(e){return BX.util.in_array(e.nodeName,f)},r.document.body);l=s.getElementsByTagName("LI");if(i===l[l.length-1]){d=BX.create("BR",{},r.document);this.editor.util.InsertAfter(d,s);this.editor.selection.SetBefore(d);this.editor.Focus();BX.remove(i)}else{var h=s.ownerDocument.createElement(s.nodeName),m=false,p=r.editor.util.GetInvisibleTextNode();for(a=0;a<l.length;a++){if(l[a]==i){m=true;continue}if(m){h.appendChild(l[a])}}if(s.nextSibling){s.parentNode.insertBefore(s.nextSibling,p);p.parentNode.insertBefore(p.nextSibling,h)}else{s.parentNode.appendChild(p);s.parentNode.appendChild(h)}this.editor.selection.SetAfter(p);this.editor.Focus();BX.remove(i)}return BX.PreventDefault(e)}else{if(BX.util.in_array(i.nodeName,c)){u=i}else{u=BX.findParent(i,function(e){return BX.util.in_array(e.nodeName,c)},this.document.body)}if(u){if(u.nodeName==="LI"){if(t===r.editor.KEY_CODES["enter"]&&u&&u.parentNode){var y=r.editor.action.actions.insertUnorderedList.getCustomBullitClass(u.parentNode)}setTimeout(function(){var e=r.editor.selection.GetSelectedNode(true);if(e){s=BX.findParent(e,function(e){return BX.util.in_array(e.nodeName,f)},r.document.body);if(t===r.editor.KEY_CODES["enter"]&&u&&u.parentNode){r.editor.action.actions.insertUnorderedList.checkCustomBullitList(u.parentNode,y,true)}if(!s){o(e)}}},0)}else if(u.nodeName.match(/H[1-6]/)&&t===this.editor.KEY_CODES["enter"]){setTimeout(function(){o(r.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 v="bx-editor-temp-"+Math.round(Math.random()*1e6);this.editor.action.Exec("insertHTML",'<span id="'+v+'">'+this.editor.INVISIBLE_SPACE+"</span>");var B=this.editor.GetIframeElement(v);if(B)BX.remove(B)}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 b=BX.create("SPAN",false,this.document);this.editor.selection.InsertNode(b);var S=b.previousSibling;if(S&&S.nodeType==3&&this.editor.util.IsEmptyNode(S,false,false)){BX.remove(S)}this.editor.selection.SetBefore(b);BX.remove(b)}};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 r=BX.util.trim(i.innerHTML).toLowerCase();if(this.editor.util.IsEmptyNode(i,true,true)||r==""||r=="<br>"){i.removeAttribute("class")}}}};i.prototype.OnKeyDownArrowsHandler=function(e,t,i){var n,r,o,s,a=this.editor.KEY_CODES;this.keyDownRange=i;if(t===a["right"]||t===a["down"]){n=i.endContainer;o=n?n.nextSibling:false;r=n?n.parentNode:false;if(n.nodeType==3&&n.length==i.endOffset&&r&&r.nodeName!=="BODY"&&(!o||o&&o.nodeName=="BR"&&!o.nextSibling)&&(this.editor.util.IsBlockElement(r)||this.editor.util.IsBlockNode(r))){this.editor.selection.SetInvisibleTextAfterNode(r,true);return BX.PreventDefault(e)}else if(n.nodeType==3&&this.editor.util.IsEmptyNode(n)&&o&&(this.editor.util.IsBlockElement(o)||this.editor.util.IsBlockNode(o))){BX.remove(n);if(o.firstChild){this.editor.selection.SetBefore(o.firstChild)}else{this.editor.selection.SetAfter(o)}return BX.PreventDefault(e)}else if(n.nodeType==3&&n.length==i.endOffset&&r&&r.nodeName!=="BODY"&&o&&o.nodeName=="BR"&&!o.nextSibling&&(this.editor.util.IsBlockElement(r)||this.editor.util.IsBlockNode(r))){this.editor.selection.SetInvisibleTextAfterNode(r,true);return BX.PreventDefault(e)}}else if(t===a["left"]||t===a["up"]){n=i.startContainer;r=n?n.parentNode:false;s=n?n.previousSibling:false;if(n.nodeType==3&&i.endOffset===0&&r&&r.nodeName!=="BODY"&&!s&&(this.editor.util.IsBlockElement(r)||this.editor.util.IsBlockNode(r))){this.editor.selection.SetInvisibleTextBeforeNode(r);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,r,o,s,a,l=this.editor.selection.GetRange(),d,u,c,f,h,m,p,y,v,B,b,S=this.editor.KEY_CODES;if(t===S["right"]||t===S["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){o=d.nextSibling;if(o&&o.nodeType==3&&this.editor.util.IsEmptyNode(o))this.editor.selection._MoveCursorAfterNode(o);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);b=this.editor.util.CheckSurrogateNode(v);if(B){r=y.previousSibling;if(r&&r.nodeType==3&&this.editor.util.IsEmptyNode(r))l.setStartBefore(r);else l.setStartBefore(y);this.editor.selection.SetSelection(l)}if(b){o=v.nextSibling;if(o&&o.nodeType==3&&this.editor.util.IsEmptyNode(o))l.setEndAfter(o);else l.setEndAfter(v);this.editor.selection.SetSelection(l)}}}else if(t===S["left"]||t===S["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){r=d.previousSibling;if(r&&r.nodeType==3&&this.editor.util.IsEmptyNode(r))this.editor.selection._MoveCursorBeforeNode(r);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);b=this.editor.util.CheckSurrogateNode(v);if(B){r=y.previousSibling;if(r&&r.nodeType==3&&this.editor.util.IsEmptyNode(r))l.setStartBefore(r);else l.setStartBefore(y);this.editor.selection.SetSelection(l)}if(b){o=v.nextSibling;if(o&&o.nodeType==3&&this.editor.util.IsEmptyNode(o))l.setEndAfter(o);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;var t=document.documentElement.scrollTop||document.body.scrollTop,i=document.documentElement.scrollLeft||document.body.scrollLeft,n=this,r=[],o,s,a,l;function d(e){if(e&&e.setAttribute){e.setAttribute("data-bx-paste-flag","Y")}}function u(e){return e.nodeType==1?e:BX.findParent(e,function(e){return e.nodeType==1})}o=this.document.body;if(o){l=o.querySelectorAll("*");for(s=0;s<l.length;s++){if(l[s].nodeType==1&&l[s].nodeName!="BODY"&&l[s].nodeName!="HEAD"){r.push(l[s])}}for(s=0;s<o.parentNode.childNodes.length;s++){a=o.parentNode.childNodes[s];if(a.nodeType==1&&a.nodeName!="BODY"&&a.nodeName!="HEAD"){r.push(a)}}}for(s=0;s<r.length;s++){d(r[s])}var c=this.editor.synchro.IsSyncOn();if(c){this.editor.synchro.StopSync()}setTimeout(function(){n.editor.SetCursorNode();n.editor.pasteHandleMode=true;n.editor.bbParseContentMode=true;n.editor.synchro.lastIframeValue=false;n.editor.pasteControl.SaveIframeContent(n.GetValue());n.editor.pasteControl.Show();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(c){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 r={CODE:1,PRE:1,A:1,SCRIPT:1,HEAD:1,TITLE:1,STYLE:1},o=/(((?:https?|ftp):\/\/|www\.)[^\s<]{3,500})/gi,s=/[\.a-z0-9_\-]+@[\.a-z0-9_\-]+\.[\.a-z0-9_\-]+/gi,a=100,l={")":"(","]":"[","}":"{"};this.editor.autolinkUrlRegExp=o;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,r=t.GetIframeDoc(),a=r.createTreeWalker(r.body,NodeFilter.SHOW_TEXT,null,false);while(e=a.nextNode()){i=e.nodeValue||"";if((i.match(s)||i.match(o))&&e.parentNode&&e.parentNode.nodeName!="A"){n=true;break}}return n}function c(e){if(e&&!r[e.nodeName]){var t=BX.findParent(e,function(e){return!!r[e.nodeName]},e.ownerDocument.body);if(t)return e;if(e===e.ownerDocument.documentElement)e=e.ownerDocument.body;return p(e)}}function f(t){return t.replace(o,function(t,i){var n=(i.match(/([^\w\u0430-\u0456\u0451\/\-](,?))$/i)||[])[1]||"",r=l[n];i=i.replace(/([^\w\u0430-\u0456\u0451\/\-](,?))$/i,"");if(i.split(r).length>i.split(n).length){i=i+n;n=""}var o=i,s=i;if(i.length>a)s=s.substr(0,a)+"...";if(o.substr(0,4)==="www.")o="http://"+o;BX.onCustomEvent(e.editor,"OnAfterUrlConvert",[o]);return'<a href="'+o+'">'+s+"</a>"+n})}function h(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&&!r[e.nodeName]){if(e.nodeType===3&&e.data.match(o)&&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 r=BX.findParent(n,{tag:"A"},n.ownerDocument.body);if(r){var s=v(r);setTimeout(function(){var e=v(r);if(e===s)return;if(e.match(o))r.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())}};i.prototype.InitClipboardHandler=function(){var e=this;BX.bind(this.element,"paste",function(t){var i=t.clipboardData;if(i&&i.items){var n=i.items[0];if(n&&n.type.indexOf("image/")>-1){var r=n.getAsFile();if(r){var o=new FileReader;o.readAsDataURL(r);o.onload=function(t){var i=new Image;i.src=t.target.result;e.element.appendChild(i);e.HandleImageDataUri(i)}}}}})};i.prototype.HandleImageDataUri=function(e){this.editor.On("OnImageDataUriHandle",[this,{src:e.src,title:e.title||""},BX.proxy(this.HandleImageDataUriCallback,this)])};i.prototype.HandleImageDataUriCallback=function(e){};function r(e,t,i){this.INTERVAL=500;this.editor=e;this.textareaView=t;this.iframeView=i;this.lastFocused="wysiwyg";this.InitEventHandlers()}r.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=r})();
//# sourceMappingURL=html-views.map.js