AdfRichUIPeer.createPeerClass(AdfDhtmlRichTextEditorBasePeer,"AdfDhtmlRichTextEditorPeer",!1);AdfDhtmlRichTextEditorPeer.InitSubclass=function(){AdfDhtmlRichTextEditorBasePeer.InitSubclass.call(this);AdfRichUIPeer.addComponentEventHandlers(this,AdfActionEvent.ACTION_EVENT_TYPE,AdfUIInputEvent.CLICK_EVENT_TYPE,AdfUIInputEvent.MOUSE_DOWN_EVENT_TYPE,AdfUIInputEvent.MOUSE_UP_EVENT_TYPE,AdfUIInputEvent.KEY_UP_EVENT_TYPE);this.InitConstants()};
AdfDhtmlRichTextEditorPeer.InitConstants=function(){AdfDhtmlRichTextEditorBasePeer.InitConstants.call(this);this._TOOLBAR_POPUP_CONTAINER_ID="_tbPopCont";this._TOOLBAR_POPUP_INPUT_CONTAINER_ID="_tbPopInpCont";this._TOOLBAR_POPUP_LINK_INPUT_ID="_tbPopLnkInput";this._TOOLBAR_POPUP_LINK_SELECTED_INPUT_ID="_tbPopLnkSelectedInput";this._CONTENT_INPUT_CONTAINER_SUBID="_cic";this._COLOR_REGEX=/rgba?\((\d+),\s*(\d+),\s*(\d+)(,\s*((\d+)))?\)/};
AdfDhtmlRichTextEditorPeer.HandleTimerUpdate=function(a){if(a=AdfPage.PAGE.findComponent(a))a=a.getPeer(),a.UpdateValue(),a._handleContextChangedForCommands()};AdfDhtmlRichTextEditorPeer.prototype.Init=function(a){AdfDhtmlRichTextEditorPeer.superclass.Init.call(this,a)};
AdfDhtmlRichTextEditorPeer.prototype.InitDomElement=function(a,b){var d=a.getReadOnly(),e=a.getClientId(),f=AdfAgent.AGENT;if(!d){var g=AdfRichUIPeer.CreateSubId(e,AdfDhtmlRichTextEditorPeer._CONTENT_FIELD_SUB_ID);f.setExpandoProperty(b,AdfDhtmlRichTextEditorPeer._FIELD_ID_ATTR_NAME,g);g=AdfRichUIPeer.CreateSubId(e,AdfDhtmlRichTextEditorPeer._SOURCE_FIELD_SUB_ID);f.setExpandoProperty(b,AdfDhtmlRichTextEditorPeer._SOURCE_FIELD_ID_ATTR_NAME,g);AdfPage.PAGE.registerLoadingComponent(a)}AdfDhtmlRichTextEditorPeer.superclass.InitDomElement.call(this,
a,b);this._isTouch=f.isTouchFirstDevice();d?(d=this._getReadOnlyContentField(a),d.innerHTML=d.textContent):(this._modeButtonRichTextClientId=e+"_afrModeRichText",this._modeButtonCodeClientId=e+"_afrModeCode","popup"===a.getToolbarDisplay()&&(this._toolbarPopupListenerInitialized=!1),this._createIframe(a))};
AdfDhtmlRichTextEditorPeer.prototype.GetReadyState=function(){var a=this.getComponent();if((a=this._getContentField(a))&&"1"===a.getAttribute("data-afr-rte-loaded")){AdfLogger.LOGGER.fine("AdfDhtmlRichTextEditorPeer.GetReadyState: RTE loaded");try{if("complete"===a.contentWindow.document.readyState)return AdfLogger.LOGGER.fine("AdfDhtmlRichTextEditorPeer.GetReadyState: RTE ready"),AdfUIComponent.STATE_COMPLETE;AdfLogger.LOGGER.fine("AdfDhtmlRichTextEditorPeer.GetReadyState: RTE inner document not yet ready");
return AdfUIComponent.STATE_LOADING}catch(b){return AdfLogger.LOGGER.fine("AdfDhtmlRichTextEditor.GetReadyState: exception.","Nothing more to do"),AdfUIComponent.STATE_COMPLETE}}AdfLogger.LOGGER.fine("AdfDhtmlRichTextEditorPeer.GetReadyState: richTextEditor's onload has not fired");return AdfUIComponent.STATE_LOADING};
AdfDhtmlRichTextEditorPeer.prototype.ResizeNotify=function(a,b,d,e){if(this._isContainerStretched()&&(b=AdfAgent.AGENT,d=this.getComponent().getClientId(),a=b.getElementById(AdfRichUIPeer.CreateSubId(d,AdfDhtmlRichTextEditorPeer._CONTENT_INPUT_CONTAINER_SUBID)),b=b.getElementById(AdfRichUIPeer.CreateSubId(d,"content")).childNodes,a)){for(var f=d=0,g=b.length;f<g;f++)b[f]!==a&&(d+=b[f].offsetHeight);a.style.height=e-d+"px"}};
AdfDhtmlRichTextEditorPeer.prototype.isEmpty=function(a){a||(a=this.GetSubmittedValue(this.getComponent(),this.getDomElement()));a=AdfStrings.trim(a);return 0==a.length||a.toUpperCase()==AdfEditingAgent.getInstance().getDefaultContent().toUpperCase()};
AdfDhtmlRichTextEditorPeer.prototype.Focus=function(){var a=this.getComponent();if(this.isCodeEditingMode())this._getSourceCodeField(a).focus();else{a=this._getContentField(a);if("IFRAME"==a.nodeName&&a!=document.activeElement)try{var b=a.parentElement,d=b.hasAttribute("tabindex");d||b.setAttribute("tabindex","0");AdfFocusUtils.focusElement(b);d||b.removeAttribute("tabindex")}catch(h){}var e=AdfAgent.AGENT,b=e.getPlatform()==AdfAgent.IE_PLATFORM&&11==e.getVersion(),d=e.getPlatform()==AdfAgent.EDGE_PLATFORM,
e=e.getPlatform()==AdfAgent.WEBKIT_PLATFORM,f=AdfEditingAgent.getInstance(),g=a;if(e||d)g=f.getFocusBlurElement(a);b||d?this._hadFirstFocus&&!this._isComponentHavingFocus()&&AdfFocusUtils.focusElement(g):AdfFocusUtils.focusElement(g);this.StopDialogsFromBeingInactivatedDueToIframes()}};AdfDhtmlRichTextEditorPeer.prototype.getSelectionRange=function(a){var b=AdfEditingAgent.getInstance();a=this._getContentField(a);return b.getSelectionRange(a)};
AdfDhtmlRichTextEditorPeer.prototype.HandleCodeEditingModeChange=function(a){var b=this._getToolboxComponent(a);this.visitChildren(b,AdfDhtmlRichTextEditorPeer._toolboxVisitChildrenCallback,this,!0);var d=AdfEditingAgent.getInstance(),b=this._getContentField(a),e=this._getSourceCodeField(a);this.isCodeEditingMode()?(a=this.getCurrentContent(a),e.value=""+a,b.blur(),this._removeSelection(),b.style.display="none",e.style.display="block",e.focus()):(e.blur(),e.style.display="none",b.style.display="block",
b.focus(),d.setInlineFrameContent(b,e.value),this.focus(a),AdfEditingAgent.getInstance().setInlineFrameContentEditable(b),this._ignoreNextContextChanged=!0)};AdfDhtmlRichTextEditorPeer.prototype.HandleComponentClick=function(a){AdfDhtmlRichTextEditorPeer.superclass.HandleComponentClick.call(this,a);(a=a.getNativeEventTarget())&&"LABEL"==a.nodeName&&this.focus(this.getComponent())};AdfDhtmlRichTextEditorPeer.prototype.HandleComponentMouseDown=function(a){this._handleClonedEvent(a)};
AdfDhtmlRichTextEditorPeer.prototype.HandleComponentMouseUp=function(a){this._handleClonedEvent(a)};AdfDhtmlRichTextEditorPeer.prototype.HandleComponentKeyDown=function(a){this._handleClonedEvent(a)};AdfDhtmlRichTextEditorPeer.prototype.HandleComponentKeyUp=function(a){this._handleClonedEvent(a)};AdfDhtmlRichTextEditorPeer.prototype.HandleComponentAction=function(a){this._styleBindingActionListener(a);this._commandBindingActionListener(a)};
AdfDhtmlRichTextEditorPeer.prototype.HandleContextChanged=function(){this._ignoreNextContextChanged?delete this._ignoreNextContextChanged:1!=this.isCodeEditingMode()&&(this._saveSelection(),this._handleContextChangedForCommands(),this._handleContextChangedForStyles())};AdfDhtmlRichTextEditorPeer.prototype.StopDialogsFromBeingInactivatedDueToIframes=function(){var a=!0,b,d=AdfAgent.AGENT.getDomDocument().activeElement;d&&(b=d.tagName);"IFRAME"==b&&(a=!1);a&&AdfPage.PAGE.getAutoDismissalManager().cancelBlurTimeout()};
AdfDhtmlRichTextEditorPeer.prototype.GetSubmittedValue=function(a,b){if(this._isTouch&&this.WasSubmitted(a)){var d=this._getContentField(a),e=this.getCurrentContent(a),d=AdfDhtmlInputBasePeer.getLastValue(d);d!=e&&void 0!==d&&this.UpdateValue()}if(a.getReadOnly())return e=AdfDhtmlEditableValuePeer.getContentNode(a,b),e.innerHTML;e=this._getSourceCodeField(a);return e.value};
AdfDhtmlRichTextEditorPeer.prototype.UpdateValue=function(){var a=this.getComponent(),b=this._getContentField(a);this._keyTimer&&(clearTimeout(this._keyTimer),delete this._keyTimer);if("none"!=b.style.display){var d=this._getSourceCodeField(a),e=AdfEditingAgent.getInstance(),f=this.getCurrentContent(a),g=f.indexOf(AdfDhtmlRichTextEditorPeer._getDummyInputField(e,b).outerHTML);d.value=-1==g?f:f.slice(0,g);e.updateValueHistory(a,b,f)}};
AdfDhtmlRichTextEditorPeer.prototype.AddStyleBinding=function(a,b,d,e){AdfAssert.assertString(a);AdfAssert.assertString(b);AdfAssert.assertString(d);AdfAssert.assertStringOrNull(e);void 0==e&&(e=AdfActionEvent.ACTION_EVENT_TYPE);var f=AdfPage.PAGE.findComponent(a);a={componentId:a,propertyName:b,styleKey:d,eventType:e};this._styleObservers||(this._styleObservers=[]);this._styleObservers.push(a);e==AdfActionEvent.ACTION_EVENT_TYPE&&f.isDescendant(this.getComponent())||f.addEventListener(e,this._styleBindingActionListener,
this)};AdfDhtmlRichTextEditorPeer.prototype.RemoveStyleBindings=function(a){var b=this._styleObservers;if(void 0!=b)for(var d=b.length,e=this._styleBindingActionListener,f=0;f<d;f++){var g=b[f],h=AdfPage.PAGE.findComponent(g.componentId);void 0!=h&&(g.eventType==AdfActionEvent.ACTION_EVENT_TYPE&&h.isDescendant(a)||h.removeEventListener(g.eventType,e,this))}};
AdfDhtmlRichTextEditorPeer._toolboxVisitChildrenCallback=function(a){var b=0,d=this.isCodeEditingMode();if(a instanceof AdfRichCommandToolbarButton){var e=a.getClientId();e!=this._modeButtonRichTextClientId&&e!=this._modeButtonCodeClientId&&(a.setProperty("selected",!1,!1,AdfUIComponent.PROPAGATE_IF_KNOWN_PROPERTY),a.setProperty("disabled",d,!1,AdfUIComponent.PROPAGATE_IF_KNOWN_PROPERTY),b=1)}else a instanceof AdfRichSelectOneChoice||a instanceof AdfRichInputNumberSpinbox||a instanceof AdfRichInputColor?
(a.setProperty("disabled",d,!1,AdfUIComponent.PROPAGATE_IF_KNOWN_PROPERTY),b=1):a instanceof AdfRichPanelGroupLayout&&(a=AdfRichUIPeer.getDomElementForComponent(a),d?AdfDomUtils.addCSSClassName(a,AdfRichUIPeer.DISABLED_STYLECLASS):AdfDomUtils.removeCSSClassName(a,AdfRichUIPeer.DISABLED_STYLECLASS),b=1);return b};
AdfDhtmlRichTextEditorPeer.prototype._handleMouseUp=function(a){this.HandleContextChanged();var b=navigator.userAgent.toLowerCase();a=a.target;-1!=b.indexOf("chrome")&&"html"==a.nodeName.toLowerCase()?a.getElementsByTagName("body")[0].focus():-1!=b.indexOf("edge")&&"body"==a.nodeName.toLowerCase()&&a.focus()};
AdfDhtmlRichTextEditorPeer.prototype._handleKeyDown=function(a){var b=AdfAgent.AGENT.getPlatform()==AdfAgent.IE_PLATFORM,d=AdfAgent.AGENT.getPlatform()==AdfAgent.GECKO_PLATFORM,e=187,f=e,g=189;if(b){var h=this._keyTimer;h&&clearTimeout(h);h="AdfDhtmlRichTextEditorPeer.HandleTimerUpdate('"+this.getComponent().getClientId()+"')";this._keyTimer=setTimeout(h,3E3)}d&&(e=61,f=107,g=109);d=a.keyCode;if(9==d)a.shiftKey&&(this._mouseDownOrTabBack=!0),e=this.getComponent(),f=e.getEditMode(),g=this._getToolbarPopupNode(e),
d="popup"===e.getToolbarDisplay()&&AdfDomUtils.isVisible(g),"wysiwyg"==f?d?(AdfAgent.AGENT.preventDefault(a),a.shiftKey?AdfFocusUtils.focusElement(AdfFocusUtils.getLastTabStop(g)):AdfFocusUtils.focusNextTabStop(this._getContentField(e))):(AdfEditingAgent.getInstance().handleTab(this._getContentField(e),a),b&&(a.shiftKey?this._tabBack=!0:this._tabForward=!0)):d&&(AdfAgent.AGENT.preventDefault(a),a.shiftKey?AdfFocusUtils.focusElement(AdfFocusUtils.getLastFocusableDescendant(g)):AdfFocusUtils.focusNextTabStop(this._getSourceCodeField(e)));
else if(a.ctrlKey){b=!0;if(a.altKey)switch(d){case e:case f:this._execCommand(AdfDhtmlRichTextEditorPeer.STYLE_SUPERSCRIPT);break;case g:this._execCommand(AdfDhtmlRichTextEditorPeer.STYLE_SUBSCRIPT);break;case 121:(e=AdfPage.PAGE.findComponent(this.getComponent().getClientId()+"_afrToolbox"))&&e.focus();break;default:b=!1}else if(a.shiftKey)switch(d){case 72:this._execCommand(AdfDhtmlRichTextEditorPeer.COMMAND_UNLINK);break;case 77:this._execCommand(AdfDhtmlRichTextEditorPeer.STYLE_OUTDENT);break;
case 83:this._execCommand(AdfDhtmlRichTextEditorPeer.COMMAND_CLEAR_STYLING);break;case 87:this._execCommand(AdfDhtmlRichTextEditorPeer.STYLE_COLOR_FOREGROUND);break;default:b=!1}else switch(d){case 53:this._execCommand(AdfDhtmlRichTextEditorPeer.STYLE_STRIKETHROUGH);break;case 66:this._execCommand(AdfDhtmlRichTextEditorPeer.STYLE_BOLD);break;case 69:this._execCommand(AdfDhtmlRichTextEditorPeer.STYLE_JUSTIFY_CENTER);break;case 72:window.setTimeout(this.createCallback(this._cmdCreateLink),0);break;
case 73:this._execCommand(AdfDhtmlRichTextEditorPeer.STYLE_ITALIC);break;case 74:this._execCommand(AdfDhtmlRichTextEditorPeer.STYLE_JUSTIFY_FULL);break;case 76:this._execCommand(AdfDhtmlRichTextEditorPeer.STYLE_JUSTIFY_LEFT);break;case 77:this._execCommand(AdfDhtmlRichTextEditorPeer.STYLE_INDENT);break;case 82:this._execCommand(AdfDhtmlRichTextEditorPeer.STYLE_JUSTIFY_RIGHT);break;case 85:this._execCommand(AdfDhtmlRichTextEditorPeer.STYLE_UNDERLINE);break;case 87:this._execCommand(AdfDhtmlRichTextEditorPeer.STYLE_COLOR_BACKGROUND);
break;case 219:e=this._getOneThroughSevenFontSize(this._queryCommandValue(AdfDhtmlRichTextEditorPeer.STYLE_FONT_SIZE));1<e&&this._execCommand(AdfDhtmlRichTextEditorPeer.STYLE_FONT_SIZE,+e-1);break;case 221:e=this._getOneThroughSevenFontSize(this._queryCommandValue(AdfDhtmlRichTextEditorPeer.STYLE_FONT_SIZE));7>e&&this._execCommand(AdfDhtmlRichTextEditorPeer.STYLE_FONT_SIZE,+e+1);break;default:b=!1}b&&AdfAgent.AGENT.eatEvent(a)}};AdfDhtmlRichTextEditorPeer.prototype._cmdCreateLink=function(){return this._execCommand(AdfDhtmlRichTextEditorPeer.COMMAND_LINK)};
AdfDhtmlRichTextEditorPeer.prototype._saveSelection=function(){var a=AdfEditingAgent.getInstance(),b=a.getSelectionRange(this._getContentField(this.getComponent()));this._isTouch?null!=b&&(this._lastSelectionRange=b):this._lastSelectionRange=b;var d=this.getComponent();if("popup"===d.getToolbarDisplay()){var e=this._getToolbarPopupInputContainer(d);AdfDomUtils.isVisible(e)&&this._getToolbarPopupDisplayedTextComp(d).setValue(a.getSelectionRangeString(b))}};
AdfDhtmlRichTextEditorPeer.prototype._handleClonedEvent=function(a){var b=a.getNativeEvent();if(null!=this._clonedEventMap&&null!=this._clonedEventMap[b]){var d=this,e=this._clonedEventMap[b];a.cancel=function(){AdfDomUIInputEvent.superclass.cancel.call(a);AdfAgent.AGENT.preventDefault(b);AdfAgent.AGENT.preventDefault(e);delete d._clonedEventMap[b]}}};AdfDhtmlRichTextEditorPeer.prototype._removeSelection=function(){delete this._lastSelectionRange};
AdfDhtmlRichTextEditorPeer.prototype._restoreSelection=function(){null!=this._lastSelectionRange&&AdfEditingAgent.getInstance().setSelectionRange(this._getContentField(this.getComponent()),this._lastSelectionRange)};
AdfDhtmlRichTextEditorPeer.prototype._handleContextChangedForCommands=function(){if(void 0==this._commandObservers)return!1;var a=this.getComponent(),b=this._getContentField(a),d=AdfEditingAgent.getInstance(),e=this._commandObservers,f=e.length,g=this._oldCommandValues;void 0==g&&(g={});for(var h={},k=0;k<f;k++){var l=e[k],m=l.command,l=AdfPage.PAGE.findComponent(l.componentId);AdfAssert.assert(l);if(void 0===h[m]){var n=AdfDhtmlRichTextEditorPeer._execCommandMap[m];h[m]=null==n?null:d.queryCommandEnabled(a,
b,n)}m===AdfDhtmlRichTextEditorPeer.COMMAND_LINK&&"popup"===a.getToolbarDisplay()&&this._updateToolbarPopupURLVal();if(g[m]!==h[m])switch(m){case AdfDhtmlRichTextEditorPeer.COMMAND_INSERT:case AdfDhtmlRichTextEditorPeer.COMMAND_MODE_RICH_TEXT:case AdfDhtmlRichTextEditorPeer.COMMAND_MODE_CODE:break;default:l.setProperty("disabled",!h[m],!1,!1)}}this._oldCommandValues=h};
AdfDhtmlRichTextEditorPeer.prototype._handleContextChangedForStyles=function(){var a=AdfAgent.AGENT;if(void 0==this._styleObservers)return!1;var b=this._styleObservers.length,d=this._oldStyleValues;void 0==d&&(d={});for(var e={},f=0;f<b;f++){var g=this._styleObservers[f],h=g.styleKey,k=AdfPage.PAGE.findComponent(g.componentId);AdfAssert.assert(k);var l=null;void 0==e[h]?(l=this._getSelectionStyling(h),null!=l&&(e[h]=l)):l=e[h];if(d[h]!==l&&null!=l){var m=!1;if(h==AdfDhtmlRichTextEditorPeer.STYLE_COLOR_BACKGROUND||
h==AdfDhtmlRichTextEditorPeer.STYLE_COLOR_FOREGROUND)l=AdfEditingAgent.getInstance().getColor(l);else if(h==AdfDhtmlRichTextEditorPeer.STYLE_FONT_SIZE)l=this._getOneThroughSevenFontSize(l),0<l&&8>l?l+="":(l="2",m=!0);else if(h==AdfDhtmlRichTextEditorPeer.STYLE_FONT_NAME&&k instanceof AdfRichSelectOneChoice){var n=k.getSelectItems(),q=n.length,r=!1;null!=l&&a.getPlatform()==AdfAgent.WEBKIT_PLATFORM&&(l=(""+l).replace(/['"]+/g,""),l=(""+l).replace(/, /gi,","));for(var t=0;t<q;t++)if(n[t].getLabel()==
l){l=n[t].getValue();r=!0;break}if(!r){for(var t=Number.MAX_VALUE,u,v,w=0;w<q;w++)-1<(u=n[w].getValue().search(l))&&(u<t&&(t=u,v=n[w].getValue()),r=!0);if(!r)for(w=1;w<q;w++)-1<(u=l.search(n[w].getLabel()))&&(u<t&&(t=u,v=n[w].getValue()),r=!0);l=r?v:n[0].getValue()}}m||this._getIndeterminateStyling(h);m=k.getProperty(g.propertyName);AdfUIUtils.compareValues(m,l)||("value"==g.propertyName&&this._ignoreNextEvent(h),k.setProperty(g.propertyName,l,!1,!1),h==AdfDhtmlRichTextEditorPeer.STYLE_FONT_SIZE&&
AdfPage.PAGE.clearMessages(k.getClientId()))}}this._oldStyleValues=e};AdfDhtmlRichTextEditorPeer.prototype._getOneThroughSevenFontSize=function(a){var b=""+a,d=b.indexOf("px");-1!=d?(a=parseInt(b.substring(0,d)),a=10>=a?1:13>=a?2:16>=a?3:18>=a?4:24>=a?5:32>=a?6:7):a=parseInt(a)||2;return a};
AdfDhtmlRichTextEditorPeer.prototype._createIframe=function(a){var b=AdfAgent.AGENT,d=this._getContentField(a),e=AdfPage.PAGE,f=this.getDomDocument().createElement("IFRAME");f.frameBorder="0";var g=d.style.cssText;0<g.length&&(f.style.cssText=g);f.className=d.className;f.id=d.id;f.title=e.getLookAndFeel().getTranslatedString("af_richTextEditor.IFRAME_TITLE");"lazy"==a.getContentDelivery()?f.src=e.getLazyFetchURI(a.getClientId()):(a=d.getAttribute("src"))&&""!=a&&(f.src=a);this._loadCallback=this.createCallback(this._handleLoad);
b.addBubbleEventListener(f,"load",this._loadCallback);d.parentNode.replaceChild(f,d);b.elementsRemoved(d);b.elementsAdded(f)};AdfDhtmlRichTextEditorPeer.prototype._makeEditable=function(a){a=this._getContentField(a);AdfAssert.assertDomElement(a);AdfEditingAgent.getInstance().setInlineFrameContentEditable(a);this._addContextChangeListeners(a)};
AdfDhtmlRichTextEditorPeer.prototype._setInlineFrameContent=function(a,b){AdfAssert.assertDomElement(a,"IFRAME");AdfAssert.assertString(b);var d=AdfEditingAgent.getInstance(),e=d.getInlineFrameDocument(a);d.setRTL(e);this._setInlineFrameStyle(e);e=e.body;""==b&&(b=d.getDefaultContent());e.innerHTML=b};
AdfDhtmlRichTextEditorPeer.prototype._setInlineFrameStyle=function(a){a=a.body.style;var b=this._inlineFrameBodyInlineStyle;if(null==b){var d=AdfAgent.AGENT.getPlatform()==AdfAgent.IE_PLATFORM,e=AdfPage.PAGE,b=AdfPage.PAGE.getLookAndFeel().getSkinProperty("af|richTextEditor-tr-field-inline-style");d&&void 0==b?e.scheduleTimer(this,this._updateInlineFrameStyle,b,0,{isSynchronized:!0}):this._updateInlineFrameStyle(b);a.cssText=this._inlineFrameBodyInlineStyle}else a.cssText=b};
AdfDhtmlRichTextEditorPeer.prototype._updateInlineFrameStyle=function(a){void 0==a&&(a=AdfPage.PAGE.getLookAndFeel().getSkinProperty("af|richTextEditor-tr-field-inline-style"));this._inlineFrameBodyInlineStyle=a=a.replace(/ /g,";").replace(/\+/g," ").replace(/_/g,":")};AdfDhtmlRichTextEditorPeer.prototype._getToolboxComponent=function(a){var b=this._toolboxClientId;null==b&&(this._toolboxClientId=b=a.getClientId()+"_afrToolbox");return AdfPage.PAGE.findComponent(b)};
AdfDhtmlRichTextEditorPeer.prototype._execCommand=function(a,b){var d=AdfAgent.AGENT;if(1!=this.isCodeEditingMode()||a==AdfDhtmlRichTextEditorPeer.COMMAND_MODE_RICH_TEXT||a==AdfDhtmlRichTextEditorPeer.COMMAND_INSERT){AdfAssert.assertString(a);var e=AdfDhtmlRichTextEditorPeer._execCommandMap[a];AdfAssert.assertString(e);var f=this.getComponent(),g;a==AdfDhtmlRichTextEditorPeer.COMMAND_INSERT&&1==this.isCodeEditingMode()?g=this._getSourceCodeField(f):(g=this._getContentField(f),AdfAssert.assertDomElement(g,
"IFRAME"),this._isTouch&&d.getPlatform()==AdfAgent.WEBKIT_PLATFORM&&g.focus(),this._restoreSelection());d=AdfEditingAgent.getInstance();d.isEmptySelection(g)?this._invokeAdditionalCommands(f,g,e,b)&&d.execCommand(f,g,e,b):d.execCommand(f,g,e,b)}};
AdfDhtmlRichTextEditorPeer.prototype._invokeAdditionalCommands=function(a,b,d,e){var f=[],g,h=[AdfDhtmlRichTextEditorPeer.STYLE_BOLD,AdfDhtmlRichTextEditorPeer.STYLE_ITALIC,AdfDhtmlRichTextEditorPeer.STYLE_UNDERLINE,AdfDhtmlRichTextEditorPeer.STYLE_STRIKETHROUGH,AdfDhtmlRichTextEditorPeer.STYLE_SUPERSCRIPT,AdfDhtmlRichTextEditorPeer.STYLE_SUBSCRIPT],k=this._oldStyleValues;if(void 0==k)return!0;switch(d){case "bold":case "italic":case "underline":case "strikethrough":case "superscript":case "subscript":break;
default:return!0}var l=!0,m;for(m=0;m<h.length;++m)if(g=AdfDhtmlRichTextEditorPeer._execCommandMap[h[m]],void 0!=g)if(g==d)k[h[m]]&&!this._getSelectionStyling(h[m])&&(l=!1);else{var n=k[h[m]],q=this._getSelectionStyling(h[m]);void 0!==n&&n!=q&&(f[f.length]=g)}d=AdfEditingAgent.getInstance();for(m=0;m<f.length;++m)d.execCommand(a,b,f[m],e);return l};
AdfDhtmlRichTextEditorPeer.prototype._queryCommandValue=function(a){AdfAssert.assertString(a);a=AdfDhtmlRichTextEditorPeer._execCommandMap[a];AdfAssert.assertString(a);var b=this.getComponent(),b=this._getContentField(b);AdfAssert.assertDomElement(b,"IFRAME");return AdfEditingAgent.getInstance().queryCommandValue(b,a)};
AdfDhtmlRichTextEditorPeer.prototype._styleBindingActionListener=function(a){if(void 0!=this._styleObservers&&!this._commandBeingProcessed){this._commandBeingProcessed=!0;for(var b=a.getSource().getClientId(),d=this._styleObservers,e=d.length,f=0;f<e;f++){var g=d[f];if(g.componentId==b){a.setPartial(!0);if(!this._isIgnoreNextEvent(g.styleKey)){if(g.eventType==AdfActionEvent.ACTION_EVENT_TYPE)this._toggleSelectionStyling(g.styleKey);else if(g.eventType==AdfValueChangeEvent.VALUE_CHANGE_TYPE){var h=
a.getNewValue();h&&h._class&&"TrColor"==h._class&&(h=(new TrColorConverter(["#RRGGBB"],!1)).getAsString(h),g.styleKey==AdfDhtmlRichTextEditorPeer.STYLE_COLOR_BACKGROUND&&(this._oldStyleValues[g.styleKey]=h));this._execCommand(g.styleKey,h)}else AdfLogger.LOGGER.severe("This eventType (",eventType,") is not supported by richTextEditor.");this.HandleContextChanged()}g=AdfAgent.AGENT.getPlatform()==AdfAgent.IE_PLATFORM&&11==AdfAgent.AGENT.getVersion();!this._hadFirstFocus||g&&this._isComponentHavingFocus()||
this.focus(this.getComponent());a.cancel()}}this.UpdateValue();delete this._commandBeingProcessed}};AdfDhtmlRichTextEditorPeer.prototype._isComponentHavingFocus=function(){var a=this.getComponent(),a=this.isCodeEditingMode()?this._getSourceCodeField(a):this._getContentField(a),b=AdfAgent.AGENT.getDomDocument().activeElement;return b&&b.id==a.id};AdfDhtmlRichTextEditorPeer.prototype._toggleSelectionStyling=function(a){AdfAssert.assertString(a);return this._execCommand(a,null)};
AdfDhtmlRichTextEditorPeer.prototype._addContextChangeListeners=function(a){var b=this.getComponent(),d=AdfAgent.AGENT,e=AdfEditingAgent.getInstance(),f=e.getFocusBlurElement(a);this._focusCallback=this.createCallback(this._handleFocus);this._blurCallback=this.createCallback(this._handleBlur);if(this._isTouch&&d.getPlatform()==AdfAgent.WEBKIT_PLATFORM){d.addBubbleEventListener(a,"blur",this._blurCallback);AdfAgent.guessOS()!=AdfAgent.ANDROID_OS&&d.addBubbleEventListener(a,"mouseleave",this._blurCallback);
var g=this;this._clickCallback=this.createCallback(this._handleClick);d.addBubbleEventListener(f,"click",this._clickCallback)}d.addBubbleEventListener(f,"blur",this._blurCallback);d.addBubbleEventListener(f,"focus",this._focusCallback);b=this._getSourceCodeField(b);this._sourceBlurCallback=this.createCallback(this._handleBlur);this._sourceFocusCallback=this.createCallback(this._handleFocus);d.addBubbleEventListener(b,"blur",this._sourceBlurCallback);d.addBubbleEventListener(b,"focus",this._sourceFocusCallback);
a=e.getInlineFrameDocument(a);this._keyDownCallback=this.createCallback(this._handleKeyDown);d.addBubbleEventListener(a,"keydown",this._keyDownCallback);d.addBubbleEventListener(b,"keydown",this._keyDownCallback);this._contextChangeCallback=this.createCallback(this.HandleContextChanged);this._mouseUpCallBack=this.createCallback(this._handleMouseUp);d.addBubbleEventListener(a,"mouseup",this._mouseUpCallBack);d.addBubbleEventListener(a,"keyup",this._contextChangeCallback);this._dragEndCallback=this.createCallback(this._handleDragEnd);
d.addBubbleEventListener(a,"dragend",this._dragEndCallback);this._mouseDownCallback=this.createCallback(this._handleMouseDown);d.addBubbleEventListener(this.getDomElement(),"mousedown",this._mouseDownCallback);AdfAgent.AGENT.getPlatform()!=AdfAgent.IE_PLATFORM&&d.addBubbleEventListener(a,"blur",this._contextChangeCallback);this._isTouch&&AdfAgent.guessOS()!=AdfAgent.WINDOWS_OS&&(g=this,this._saveSelectionInterval=setInterval(function(){g._saveSelection()},500),d.getPlatform()==AdfAgent.WEBKIT_PLATFORM&&
536>d.getVersion()&&(this._handleCopyCallback=this.createCallback(this._handleCopy),this.getDomDocument().addEventListener("copy",this._handleCopyCallback,!0),this._handlePasteCallback=this.createCallback(this._handlePaste),this.getDomDocument().addEventListener("paste",this._handlePasteCallback,!0)));this._redistributeEventsToNewTargetCallback=this.createCallback(this._redistributeEventsToNewTarget);d.addEventBubbles(a,this._redistributeEventsToNewTargetCallback)};
AdfDhtmlRichTextEditorPeer.prototype.RemoveContextChangeListeners=function(a){var b=AdfAgent.AGENT,d=this._getContentField(a),e=AdfEditingAgent.getInstance(),f=e.getFocusBlurElement(d);this._isTouch&&b.getPlatform()==AdfAgent.WEBKIT_PLATFORM?(b.removeBubbleEventListener(d,"blur",this._blurCallback),b.removeBubbleEventListener(f,"click",this._clickCallback),delete this._clickCallback):b.removeBubbleEventListener(f,"blur",this._blurCallback);delete this._blurCallback;b.removeBubbleEventListener(f,"focus",
this._focusCallback);delete this._focusCallback;a=this._getSourceCodeField(a);b.removeBubbleEventListener(a,"blur",this._sourceBlurCallback);delete this._sourceBlurCallback;b.removeBubbleEventListener(a,"focus",this._sourceFocusCallback);delete this._sourceFocusCallback;d=e.getInlineFrameDocument(d);b.removeBubbleEventListener(d,"mouseup",this._mouseUpCallBack);delete this._mouseUpCallBack;b.removeBubbleEventListener(d,"keyup",this._contextChangeCallback);AdfAgent.AGENT.getPlatform()!=AdfAgent.IE_PLATFORM&&
b.removeBubbleEventListener(d,"blur",this._contextChangeCallback);delete this._contextChangeCallback;b.removeBubbleEventListener(d,"keydown",this._keyDownCallback);delete this._keyDownCallback;b.removeEventBubbles(d,this._redistributeEventsToNewTargetCallback);delete this._redistributeEventsToNewTargetCallback;this._isTouch&&this._saveSelectionInterval&&clearInterval(this._saveSelectionInterval)};
AdfDhtmlRichTextEditorPeer.prototype._redistributeEventsToNewTarget=function(a){var b=this.getComponent();a||(a=this._getContentField(b).contentWindow.event);var d=AdfAgent.AGENT;if(d.isKeyboardEvent(a)||d.isMouseEvent(a))b=AdfAgent.AGENT.cloneEvent(a,this._getSourceCodeField(b)),this._clonedEventMap||(this._clonedEventMap=[]),this._clonedEventMap[b]=a,AdfPage.PAGE._redistribute(b)};
AdfDhtmlRichTextEditorPeer.prototype._handleFocus=function(a){var b=AdfAgent.AGENT;if(!this._commandBeingProcessed){var d=this.getComponent(),e=this._hadFirstFocus;this._hadFirstFocus||(this._hadFirstFocus=!0);var f=AdfAgent.AGENT.getComponentEvent(d,a),g=this._getContentField(d);AdfPage.PAGE.__setActiveDomNodeInfo(g,d.getClientId());this.isCodeEditingMode()?g=this._getSourceCodeField(d):(g=AdfEditingAgent.getInstance().getContentWindow(g),g=g.document);g==a.originalTarget&&f.getEventPhase()==AdfBaseEvent.CAPTURING_PHASE&&
f.nextEventPhase();this.HandleComponentFocus(f);e||this.isCodeEditingMode()||"inline"!==d.getToolbarDisplay()||(a=this._getToolboxComponent(d),this.visitChildren(a,AdfDhtmlRichTextEditorPeer._toolboxVisitChildrenCallback,this,!0))}if(this._isTouch&&b.getPlatform()==AdfAgent.WEBKIT_PLATFORM&&AdfAgent.guessOS()!=AdfAgent.ANDROID_OS&&b._getTouchEventListeners&&(b=b._getTouchEventListeners()))for(a=0;a<b.length;a++)this.getDomDocument().removeEventListener(b[a].eventType,b[a].listener,b[a].capture)};
AdfDhtmlRichTextEditorPeer.prototype._handleLoad=function(a){var b=AdfEditingAgent.getInstance();a=this.getComponent();AdfAssert.assertObject(a,"Unexpected unbound peer for load event on iframe.");var d=this._getContentField(a);AdfAssert.assertDomElement(d);var e=!a.getDisabled()&&!b.isDesignMode(d);if(b.isDesignModeReloadingFrame()&&e)this._makeEditable(a);else{var f=this._getSourceCodeField(a);AdfAssert.assertDomElement(f);if("lazy"!=a.getContentDelivery())this._setInlineFrameContent(d,f.value);
else{var g=this.getCurrentContent(a,!0);f.value=g;b=b.getInlineFrameDocument(d);this._setInlineFrameStyle(b)}e&&this._makeEditable(a);a.getReadOnly()||AdfRichTextEditorBehaviorManager.getInstance().registerComponent(a);d.setAttribute("data-afr-rte-loaded","1")}};
AdfDhtmlRichTextEditorPeer.prototype._handleBlur=function(a){a=AdfAgent.AGENT;if(!this._commandBeingProcessed){var b=this.getComponent(),d=this._getContentField(b),e=AdfDhtmlInputBasePeer.getLastValue(d);this._tabForward?(delete this._tabForward,AdfFocusUtils.focusNextTabStop(AdfPage.PAGE.getActiveDomElement())):this._tabBack&&(delete this._tabBack,AdfFocusUtils.focusPreviousTabStop(AdfPage.PAGE.getActiveDomElement()));this.UpdateValue();this._mouseDownOrTabBack&&delete this._mouseDownOrTabBack;var f=
!1,g=this._getSourceCodeField(b).value;e!=g&&void 0!==e&&(f=!0);!f||this._mouseDownOrTabBack&&b.getValid(b.getClientId())||(this.Validate(b,this.GetSubmittedValue(b,this.getDomElement())),AdfDhtmlInputBasePeer.setLastValue(d,g))}b=AdfAgent.guessOS();if(this._isTouch&&a.getPlatform()==AdfAgent.WEBKIT_PLATFORM&&b!=AdfAgent.ANDROID_OS&&b!=AdfAgent.WINDOWS_OS&&(this._keyboardClose(),a._getTouchEventListeners&&(a=a._getTouchEventListeners())))for(b=0;b<a.length;b++)this.getDomDocument().addEventListener(a[b].eventType,
a[b].listener,a[b].capture)};AdfDhtmlRichTextEditorPeer.prototype._handleClick=function(a){this.Focus()};AdfDhtmlRichTextEditorPeer.prototype._handleMouseDown=function(a){this._mouseDownOrTabBack=!0};AdfDhtmlRichTextEditorPeer.prototype._handleDragEnd=function(a){AdfAgent.AGENT.getPlatform()==AdfAgent.IE_PLATFORM?((a=this._keyTimer)&&clearTimeout(a),AdfPage.PAGE.scheduleTimer(this,AdfDhtmlRichTextEditorPeer.HandleTimerUpdate,this.getComponent().getClientId(),0)):this._handleContextChanged()};
AdfDhtmlRichTextEditorPeer.prototype._handleCopy=function(a){if(a.clipboardData&&null!=this._lastSelectionRange&&(this._isInPopup()||!AdfPage.PAGE.getModalityManager().isGlassPaneVisible())){var b=this.getDomDocument(),d=b.createElement("div");d.style.position="absolute";d.style.left="-1000px";d.style.top="-1000px";d.contentEditable="true";d.textContent=this._lastSelectionRange.toString();b.body.appendChild(d);a=b.createRange();a.selectNodeContents(d);var e=window.getSelection();e.removeAllRanges();
e.addRange(a);b.execCommand("copy",!1,null);setTimeout(function(){b.body.removeChild(d)},500)}};
AdfDhtmlRichTextEditorPeer.prototype._handlePaste=function(a){var b=AdfAgent.AGENT;if(a.clipboardData&&(this._isInPopup()||!AdfPage.PAGE.getModalityManager().isGlassPaneVisible())){if(this._isInPopup()&&b.getPlatform()==AdfAgent.WEBKIT_PLATFORM&&536>b.getVersion()){if(this._hasPasteEvent)return;this._hasPasteEvent=!0;var d=this;setTimeout(function(){delete d._hasPasteEvent},500)}a=a.clipboardData.getData("Text");this._execCommand("cmd_insert",a)}};
AdfDhtmlRichTextEditorPeer.prototype._getSelectionStyling=function(a){AdfAssert.assertString(a);a=AdfDhtmlRichTextEditorPeer._execCommandMap[a];AdfAssert.assertString(a);return AdfEditingAgent.getInstance().queryCommandState(this._getContentField(this.getComponent()),a)};
AdfDhtmlRichTextEditorPeer.prototype._getIndeterminateStyling=function(a){AdfAssert.assertString(a);a=AdfDhtmlRichTextEditorPeer._execCommandMap[a];AdfAssert.assertString(a);return AdfEditingAgent.getInstance().queryCommandIndeterminate(this._getContentField(this.getComponent()),a)};AdfDhtmlRichTextEditorPeer.prototype._ignoreNextEvent=function(a){AdfAssert.assertString(a);void 0==this._ignoreEvents[a]&&(this._ignoreEvents[a]=0);this._ignoreEvents[a]++};
AdfDhtmlRichTextEditorPeer.prototype._isIgnoreNextEvent=function(a){AdfAssert.assertString(a);if(void 0==this._ignoreEvents[a]||0==this._ignoreEvents[a])return!1;this._ignoreEvents[a]--;return!0};AdfDhtmlRichTextEditorPeer.prototype._keyboardClose=function(){var a=AdfEditingAgent.getInstance(),b=this._getContentField(this.getComponent()),d=a.getFocusBlurElement(b),a=AdfDhtmlRichTextEditorPeer._getDummyInputField(a,b);d.appendChild(a);a.focus();a.blur();d.removeChild(a)};
AdfDhtmlRichTextEditorPeer._getDummyInputField=function(a,b){var d=a.getInlineFrameDocument(b).createElement("input");d.type="text";d.style.position="absolute";d.style.left="0px";d.style.top="0px";d.style.height="0px";d.style.width="0px";d.style.opacity="0";return d};AdfDhtmlRichTextEditorPeer.prototype._emptySelection=function(a){return!a||0==AdfEditingAgent.getInstance().getSelectionRangeString(a).length};
AdfDhtmlRichTextEditorPeer.prototype._toolbarPopupURLBlur=function(a){a.getEventPhase()!=AdfBaseEvent.AT_TARGET_PHASE||this._emptySelection(this._lastSelectionRange)||(a=a.getCurrentTarget().getValue(),"about:blank"!==a&&(/^http:\/\//.test(a)||(a="http://"+a),this._execCommand(AdfDhtmlRichTextEditorPeer.COMMAND_LINK,a),this._saveSelection()))};
AdfDhtmlRichTextEditorPeer.prototype._toolbarPopupDisplayedTextBlur=function(a){if(a.getEventPhase()==AdfBaseEvent.AT_TARGET_PHASE){var b=this._lastSelectionRange,d=AdfEditingAgent.getInstance();this._emptySelection(b)||(a=a.getCurrentTarget().getValue(),b=d.getSelectionRangeString(b),a!==b&&this._execCommand(AdfDhtmlRichTextEditorPeer.COMMAND_INSERT,a))}};
AdfDhtmlRichTextEditorPeer.prototype._getToolbarPopupNode=function(a){return AdfAgent.AGENT.getElementById(AdfRichUIPeer.CreateSubId(a.getClientId(),AdfDhtmlRichTextEditorPeer._TOOLBAR_POPUP_CONTAINER_ID))};AdfDhtmlRichTextEditorPeer.prototype._getToolbarPopupInputContainer=function(a){return AdfAgent.AGENT.getElementById(a.getId()+AdfDhtmlRichTextEditorPeer._TOOLBAR_POPUP_INPUT_CONTAINER_ID)};
AdfDhtmlRichTextEditorPeer.prototype._getToolbarPopupURLComp=function(a){return AdfPage.PAGE.findComponent(a.getId()+AdfDhtmlRichTextEditorPeer._TOOLBAR_POPUP_LINK_INPUT_ID)};AdfDhtmlRichTextEditorPeer.prototype._getToolbarPopupDisplayedTextComp=function(a){return AdfPage.PAGE.findComponent(a.getId()+AdfDhtmlRichTextEditorPeer._TOOLBAR_POPUP_LINK_SELECTED_INPUT_ID)};
AdfDhtmlRichTextEditorPeer.prototype._showToolbarPopup=function(a){var b=AdfAgent.AGENT;a=this.getComponent();var d=a.getClientId(),e=b.getElementById(AdfRichUIPeer.CreateSubId(d,AdfDhtmlRichTextEditorPeer._CONTENT_INPUT_CONTAINER_SUBID)),b=this._getToolbarPopupNode(a),f={};f[AdfDhtmlPopupHints.AUTODISMISS]=AdfDhtmlPopupHints.AUTODISMISS_ALWAYS;f[AdfDhtmlPopupHints.ALIGN_ELEMENT]=e;f[AdfRichPopup.HINT_ALIGN]=AdfRichPopup.ALIGN_BEFORE_START;f[AdfDhtmlPopupHints.FOCUS]=!1;AdfDomUtils.setVisible(b,!0);
if(!this._toolbarPopupListenerInitialized){var e=this._getToolbarPopupDisplayedTextComp(a),g=this._getToolbarPopupURLComp(a),h=function(a){a=a.getCurrentTarget();AdfDhtmlEditableValuePeer.getContentNode(a,a.getPeer().getDomElement()).select()};g.addEventListener(AdfUIInputEvent.BLUR_EVENT_TYPE,this._toolbarPopupURLBlur,this);g.addEventListener(AdfUIInputEvent.FOCUS_EVENT_TYPE,h,this);e.addEventListener(AdfUIInputEvent.BLUR_EVENT_TYPE,this._toolbarPopupDisplayedTextBlur,this);e.addEventListener(AdfUIInputEvent.FOCUS_EVENT_TYPE,
h,this);this._toolbarPopupListenerInitialized=!0}this.showPopup(a,b,f,d)};
AdfDhtmlRichTextEditorPeer.prototype.PopupClosed=function(a,b,d){AdfDhtmlRichTextEditorPeer.superclass.PopupClosed.call(this,a,b);d=this._getToolbarPopupNode(a);if(d==b&&AdfDomUtils.isVisible(d)){d=AdfAgent.AGENT;var e=a.getId(),f=this.getComponent().getClientId();a=d.getElementById(AdfRichUIPeer.CreateSubId(f,"content"));f=d.getElementById(AdfRichUIPeer.CreateSubId(f,AdfDhtmlRichTextEditorPeer._CONTENT_INPUT_CONTAINER_SUBID));d=d.getElementById(e+AdfDhtmlRichTextEditorPeer._TOOLBAR_POPUP_INPUT_CONTAINER_ID);
a.insertBefore(b,f);AdfDomUtils.setVisible(d,!1);AdfDomUtils.setVisible(b,!1)}};AdfDhtmlRichTextEditorPeer.prototype._updateToolbarPopupURLVal=function(){var a=this.getComponent(),b=this._getToolbarPopupInputContainer(a);AdfDomUtils.isVisible(b)&&(b=this._getToolbarPopupURLComp(a),a=AdfEditingAgent.getInstance()._getLinkURLForSelection(a,this._getContentField(a)),b.setValue(a))};
AdfDhtmlRichTextEditorPeer.prototype._processToolbarPopupAddLinkCmd=function(a){var b=this.getComponent(),d=this._lastSelectionRange,e=AdfEditingAgent.getInstance();if(!this._emptySelection(d)){var f=this._getToolbarPopupInputContainer(b);if(AdfDomUtils.isVisible(f))AdfDomUtils.setVisible(f,!1);else{var g=this._getToolbarPopupDisplayedTextComp(b),b=this._getToolbarPopupURLComp(b);g.setValue(e.getSelectionRangeString(d));b.setValue(a);AdfDomUtils.setVisible(f,!0)}}};