(function(A,_aoUndefined){A.extend(QMEditor.CONST.LANGUAGE.zh_CN,{FUN_SEPERATE:"间隔线",FUN_BOLD:"加粗",FUN_ITALIC:"斜体",FUN_UNDERLINE:"下划线",FUN_FONTNAME:"选择字体",FUN_FONTSIZE:"选择字体大小",FUN_FORECOLOR:"选择字体颜色",FUN_BACKCOLOR:"选择背景颜色",FUN_ALIGNMODE:"选择对齐方式",FUN_SERIAL:"设置编号",FUN_INDENT:"设置缩进",FUN_QUOT:"引用内容",FUN_CREATELINK:"插入链接",FUN_SOURCEEDIT:"编辑HTML源码",FS_XXSMALL:"10",FS_XSMALL:"12",FS_SMALL:"14",FS_MEDIUM:"16",FS_LARGE:"18",FS_XLARGE:"24",FS_XXLARGE:"36",AM_LEFT:"左对齐",AM_CENTER:"居中对齐",AM_RIGHT:"右对齐",SL_NUMBER:"数字编号",SL_PROJECT:"项目编号",IT_INDENT:"向右缩进",IT_OUTDENT:"向左缩进",CL_NAME:"文字:",CL_LINK:"链接:",CL_MODIFY:"修改",CL_DELETE:"移除",CL_CONFIRM:"添加",CL_CANCEL:"取消",CL_NAME_DEF:"默认使用链接名字",SE_PREVIEW:"返回可视化编辑"});A.extend(QMEditor.CONST.getTemplate(),{_MENU_STATUS_ITEM:A.T(['
']),_MENU_ICON_STATUS_ITEM:A.T(['"]),_MENU_COLOR_CNTR:A.T(['']),_MENU_COLOR:A.T(['"]),_MENU_BREAKLINE:A.T(['
']),_MENU_SELECT_ITEM:A.T(["» $content$"]),_MENU_CREATELINK:A.T(['"]),BOTTON_ICON_SOURCEEDIT:A.TE(['<HTML>
']),SOURCEEDIT_TOOLBAR:A.TE(['','',"$langFormatting$","","$langFormat$","
",'',"$langPreview$»","
"]),BOTTON_ICON_PREVIEW:A.TE(['$ui.langPreview$
']),BOTTON_ICON_UPLOADEML:A.TE(['$ui.langUploadEml$
'])});QMEditor.prototype._isCollapsed=function(){var _oEditWin=this.getEditWin();if(_oEditWin.getSelection){var _oSelection=_oEditWin.getSelection();return _oSelection.isCollapsed||_oSelection.getRangeAt(0).collapsed}else{return this.getEditDoc().selection.type=="None"}};QMEditor.prototype._hasAncestorNode=function(_asNodeTagName){var _oSelf=this,_oEditWin=_oSelf.getEditWin(),_oNode=_oSelf.getSelectionElement(),_oTestNode=_oNode,_bIsIEorChrome=A.gbIsIE||A.gbIsOpera;while(_oTestNode&&_oTestNode.nodeName!=_asNodeTagName){_oTestNode=_oTestNode.parentNode}if(_oTestNode){return true}if(this._isCollapsed()){return false}if(!_bIsIEorChrome){var _oPreviousNode=_oNode.previousSibling,_oNextNode=_oNode.nextSibling;if(_oPreviousNode&&_oPreviousNode.nodeName==_asNodeTagName){var _bResult=_oEditWin.getSelection().containsNode(_oPreviousNode,true);if(_bResult){return true}}if(_oNextNode&&_oNextNode.nodeName==_asNodeTagName){var _bResult=_oEditWin.getSelection().containsNode(_oNextNode,true);if(_bResult){return true}}}(function(_aoNode){if(!_aoNode){return}if(_aoNode.nodeName==_asNodeTagName){_oTestNode=_aoNode;return}for(var _curNode=_aoNode.firstChild,_nextNode;_curNode;_curNode=_nextNode){_nextNode=_curNode.nextSibling;arguments.callee(_curNode)}})(_bIsIEorChrome?_oNode.parentNode:_oNode);return!!_oTestNode};QMEditor.prototype.changeEditMode=function(_asEditMode){var _smEditMode=this.getEditMode();if(_smEditMode=="text"){return false}if(_smEditMode==_asEditMode){return true}var _bIsCode=_asEditMode=="source",_sEditMode=_bIsCode?"source":"html",_oSrceBody=this.getSrceBody(),_oEditObj=this.getEditObj();if(A.gbIsWebKit){(_bIsCode?this.getEditBody():_oSrceBody).blur()}_oEditObj.style.display=_bIsCode?"none":"block";_oSrceBody.style.display=_bIsCode?"block":"none";A.show(this.getRichToolBarObj(),!_bIsCode);A.show(this.getSrceToolBarObj(),_bIsCode);this.setEditContent(_sEditMode,this.getEditContent(_bIsCode?"html":"source"));this.setEditMode(_sEditMode);this.focus(0)};QMEditor.FUNCLIB._MENUSTATUS=QMEditor.FUNCLIB.inheritFrom(function(){this.setId("MENUSTATUS");this._msMenuItemTmpl=QMEditor.CONST.getTemplate()._MENU_STATUS_ITEM},QMEditor.FUNCLIB.MENU);QMEditor.FUNCLIB._MENUSTATUS.prototype.getMenuItems=function(){if(!this._moItemDatas){var _oMenuDatas=this._moMenuData,_oTmpl=this._msMenuItemTmpl,_sProp=this.getCmd()?"param":"cmd",_oItemDatas=[];for(var i=0,_nLen=_oMenuDatas.length,_oData;i<_nLen;i++){_oData=_oMenuDatas[i];_oItemDatas[i]={sId:i,sParam:_oData[_sProp],label:_oData["label"],nHeight:_oData.height||"auto",sItemValue:_oTmpl.replace(_oData)}}this._moItemDatas=_oItemDatas}return this._moItemDatas};QMEditor.FUNCLIB._MENUSTATUS.prototype.initMenu=function(_aoMenu){var _oSelf=this,_oBindEditor=_oSelf.getBindEditor(),_sCmd=_oSelf.getCmd();if(_sCmd){var _sValue=_oBindEditor.queryCmdValue(_sCmd),_sId=_oSelf.transValueToid(_sValue);_sValue&&_aoMenu.selectItem(_sId)}else{A.E(_oSelf._moMenuData,function(_aoData){_aoMenu.itemOption(_aoData.cmd,"bDisSelect",!_oBindEditor.queryCmdEnabled(_aoData.cmd))})}var _oMenuAll=_aoMenu.S("_menuall_");_oMenuAll.setAttribute('role',"listbox");_oMenuAll.setAttribute('tabindex',"-1");var _childNodes=_oMenuAll.childNodes;for(var i=0,len=_childNodes.length;i-1){_childNodes[i].setAttribute('role',"option");_childNodes[i].setAttribute('aria-label',_oSelf._moItemDatas[i]["label"]);_childNodes[i].setAttribute('tabindex',"-1")}}};QMEditor.FUNCLIB._MENUSTATUS.prototype.doItemClick=function(_asId){var _oSelf=this,_oBindEditor=_oSelf.getBindEditor(),_sCmd=_oSelf.getCmd();_sCmd?_oBindEditor.execCmd(_sCmd,_asId):_oBindEditor.execCmd(_asId)};QMEditor.FUNCLIB._MENUSTATUS.prototype.transValueToid=function(_sValue){return _sValue};QMEditor.FUNCLIB._MENUICONSTATUS=QMEditor.FUNCLIB.inheritFrom(function(){this.setId("MENUICONSTATUS");this._msMenuItemTmpl=QMEditor.CONST.getTemplate()._MENU_ICON_STATUS_ITEM},QMEditor.FUNCLIB._MENUSTATUS);QMEditor.FUNCLIB._MENUCOLOR=QMEditor.FUNCLIB.inheritFrom(function(){this.setId("MENUCOLOR");this._moCurSelItem=null;this._moMenuData=["#000000 #993300 #333300 #003300 #003366 #000080 #333399 #333333","#800000 #FF6600 #808000 #008000 #008080 #0000FF #666699 #808080","#FF0000 #FF9900 #99CC00 #339966 #33CCCC #3366FF #800080 #999999","#FF00FF #FFCC00 #FFFF00 #00FF00 #00FFFF #00CCFF #993366 #C0C0C0","#FF99CC #FFCC99 #FFFF99 #CCFFCC #CCFFFF #99CCFF #CC99FF #FFFFFF"];this._moBidiMapValue={};for(var i=0,len=this._moMenuData.length;i-1){_childNodes[i].setAttribute('role',"option");_childNodes[i].setAttribute('aria-label',_oSelf._moItemDatas[i]["label"]);_childNodes[i].setAttribute('tabindex',"-1")}}function _findItem(_oItem,_nDirection){if(!_oItem)return null;var _param=_oItem.getAttribute("param"),_sValue=_param.replace('#','C'),_nItemValue=_oSelf._moBidiMapValue[_sValue];switch(_nDirection){case 0:_nItemValue-=8;break;case 1:_nItemValue-=1;break;case 2:_nItemValue+=8;break;case 3:_nItemValue+=1;break}if(_nItemValue>=0&&_nItemValue<40){var _sItemValue=_oSelf._moBidiMapValue[_nItemValue];return _aoMenu.S(_sItemValue)}return null}function _selectItem(_oItem){if(_oItem){var _oCurSelItem=_oSelf._moCurSelItem,_sClassName=_oCurSelItem.getAttribute('curclass')||'qmEditorMenuItem';if(_oCurSelItem.className!=_sClassName){_oCurSelItem.className=_sClassName}if(_oItem.className!='QMEditorMenuItemDisabled'&&_oItem.className!='qmEditorMenuItemOver'){_oItem.className='qmEditorMenuItemOver'}_oSelf._moCurSelItem=_oItem}}A.addEvent(_aoMenu.S("qmEditorMenuColorCntr"),"click",function(_aoEvent){var _sValue=A.getEventTarget(_aoEvent).getAttribute("param");if(_sValue){_oSelf.hideMenu();_oEditor.execCmd(_sCmd,_sValue)}});_aoMenu.setKeyDownProxy(function(_aoEvent){var _oItem,_oCurSelItem=_oSelf._moCurSelItem;switch(_aoEvent.keyCode){case 37:{_oItem=_findItem(_oCurSelItem,1);_selectItem(_oItem)}break;case 38:{_oItem=_findItem(_oCurSelItem,0);_selectItem(_oItem)}break;case 39:{_oItem=_findItem(_oCurSelItem,3);_selectItem(_oItem)}break;case 40:{_oItem=_findItem(_oCurSelItem,2);_selectItem(_oItem)}break;case 13:{var _sValue=_oCurSelItem.getAttribute("param");if(_sValue){_oSelf.hideMenu();_oEditor.execCmd(_sCmd,_sValue)}}break;case 9:case 27:{_oSelf.hideMenu()}break}});if(typeof _sValue=="string"){var _oValueParts=_sValue.substring(4,_sValue.length-1).split(",");for(var i=0,_nLen=_oValueParts.length;i<_nLen;i++){_oValueParts[i]=parseInt(A.trim(_oValueParts[i])).toString(16);if(_oValueParts[i].length==1){_oValueParts[i]="0"+_oValueParts[i]}}_sValue=_oValueParts.join("")}else if(typeof _sValue=="number"){_oValueParts=[_sValue.toString(16)];for(var i=0,_nLen=6-_oValueParts[0].length;i<_nLen;i++){_oValueParts.unshift("0")}_oValueParts=_oValueParts.join("").split("");var _sTmp=_oValueParts[0];_oValueParts[0]=_oValueParts[4];_oValueParts[4]=_sTmp;_sTmp=_oValueParts[1];_oValueParts[1]=_oValueParts[5];_oValueParts[5]=_sTmp;_sValue=_oValueParts.join("")}else{return}_sValue="#"+_sValue;var _oTmpl=_oEditor.getTemplate()._MENU_SELECT_ITEM;_sValue=_sValue.toString().toUpperCase();(this._moCurSelItem=_aoMenu.S(_sValue.replace("#","C"))||{}).className="qmEditorMenuItemCheck"};QMEditor.FUNCLIB.Bold=QMEditor.FUNCLIB.inheritFrom(function(_aoParamSet){this.setId("Bold");this.setCmd("Bold");this.setType("btn");this.setBindEditor(_aoParamSet.editor);this.setUiConfig(A.extend(this.getUiConfig(),{title:this.getBindEditor().getLanguage().FUN_BOLD,label:this.getBindEditor().getLanguage().FUN_BOLD}));this.setfOnKeyDown(function(_aoEvent){if(_aoEvent.ctrlKey&&_aoEvent.keyCode==66){this.getfDoDefaultClick()();A.preventDefault(_aoEvent)}})},QMEditor.FUNCLIB.BASE);QMEditor.FUNCLIB.Italic=QMEditor.FUNCLIB.inheritFrom(function(_aoParamSet){this.setId("Italic");this.setCmd("Italic");this.setType("btn");this.setBindEditor(_aoParamSet.editor);this.setUiConfig({title:this.getBindEditor().getLanguage().FUN_ITALIC,label:this.getBindEditor().getLanguage().FUN_ITALIC});this.setfOnKeyDown(function(_aoEvent){if(_aoEvent.ctrlKey&&_aoEvent.keyCode==73){this.getfDoDefaultClick()();A.preventDefault(_aoEvent)}})},QMEditor.FUNCLIB.BASE);QMEditor.FUNCLIB.Underline=QMEditor.FUNCLIB.inheritFrom(function(_aoParamSet){this.setId("Underline");this.setCmd("Underline");this.setType("btn");this.setBindEditor(_aoParamSet.editor);this.setUiConfig({title:this.getBindEditor().getLanguage().FUN_UNDERLINE,label:this.getBindEditor().getLanguage().FUN_UNDERLINE});this.setfOnKeyDown(function(_aoEvent){if(_aoEvent.ctrlKey&&_aoEvent.keyCode==85){this.getfDoDefaultClick()();A.preventDefault(_aoEvent)}})},QMEditor.FUNCLIB.BASE);QMEditor.FUNCLIB.Separate=QMEditor.FUNCLIB.inheritFrom(function(_aoParamSet){this.setId("Separate");this.setType("label");this.setBindEditor(_aoParamSet.editor);this.setUiConfig({title:this.getBindEditor().getLanguage().FUN_SEPERATE})},QMEditor.FUNCLIB.BASE);QMEditor.FUNCLIB.FontName=QMEditor.FUNCLIB.inheritFrom(function(_aoParamSet){this.setId("FontName");this.setCmd("FontName");this.setBindEditor(_aoParamSet.editor);this.setUiConfig({id:A.unikey("qmEditorFontName_"),title:this.getBindEditor().getLanguage().FUN_FONTNAME,label:this.getBindEditor().getLanguage().FUN_FONTNAME,defaultValue:"微软雅黑",sClassName:"qmEditorComboBoxContainer"});var _oCNMenu=[{param:"宋体",label:"宋体",style:"font-family:宋体",content:"宋体"},{param:"黑体",label:"黑体",style:"font-family:黑体",content:"黑体"},{param:"楷体,楷体_GB2312",label:"楷体,楷体_GB2312",style:"font-family:楷体,楷体_GB2312",content:"楷书"},{param:"微软雅黑",label:"微软雅黑",style:"font-family:Microsoft YaHei",content:"微软雅黑"},{param:"幼圆",label:"幼圆",style:"font-family:幼圆",content:"幼圆"}],_oPublicMenu=[{param:"Arial",label:"Arial",style:"font-family:Arial",content:"Arial"},{param:"Arial Black",label:"Arial Black",style:"font-family:Arial Black;",content:"Arial Black"},{param:"Arial Unicode MS",label:"Arial Unicode MS",style:"font-family:Arial Unicode MS;",content:"Arial Unicode MS"},{param:"Times New Roman",label:"Times New Roman",style:"font-family:Times New Roman",content:"Times New Roman"},{param:"Verdana",label:"Verdana",style:"font-family:Verdana",content:"Verdana"}];if(A.getLocale()=="zh_CN"){this._moMenuData=_oCNMenu.concat(_oPublicMenu)}else{this._moMenuData=_oPublicMenu}this.makeStyleMapping();this.addListener(function(_sId,_asId){if(_sId=="FontName"){var _sFontName=_asId.split(",")[0],_oUiCfg=this.getUiConfig();var _oFontComboBtn=$(_oUiCfg.id);_oFontComboBtn.innerText=_sFontName;_oFontComboBtn.style.fontFamily=this._moStyleMap[_asId]}})},QMEditor.FUNCLIB._MENUSTATUS);QMEditor.FUNCLIB.FontName.prototype.init_=function(){var _oSelf=this,_sFontName="微软雅黑",_oBindEditor=_oSelf.getBindEditor(),_sCmd=_oSelf.getCmd();_sCmd?_oBindEditor.execCmd(_sCmd,_sFontName):_oBindEditor.execCmd(_sFontName)};QMEditor.FUNCLIB.FontName.prototype.makeStyleMapping=function(){if(!this._moStyleMap){this._moStyleMap={};for(var i in this._moMenuData){this._moStyleMap[this._moMenuData[i].param]=this._moMenuData[i].param}}};QMEditor.FUNCLIB.FontName.prototype.transValueToid=function(_sValue){var _sId;_sValue=_sValue.replace(/[\s]*/gi,"");for(var i=0,len=this._moItemDatas.length;i$name$').replace({url:_oSelf._getLinkText(),name:_oSelf._getNameText()}))}else{var _oRange=_oEditWin.getSelection().getRangeAt(0),_oLink=_oEditDoc.createElement("a");_oLink.href=_oSelf._getLinkText();_oLink.innerHTML=_oSelf._getNameText();_oRange.insertNode(_oLink);_oRange.setStartAfter(_oLink);if(external){_oEditor.startEditContent();if(external.NotifyCommitHtmlContent)external.NotifyCommitHtmlContent()}}}else{_oEditor.execCmd(_oSelf.getCmd(),_oSelf._getLinkText())}_oSelf.hideMenu(true);_oSelf.getBindEditor().checkEditContentChange()};_aoMenu.S("cancel").onclick=function(){_oSelf.hideMenu(true)};A.addEvent(_aoMenu.S("name"),"keydown",function(_aoEvent){var _sKeyCode=_aoEvent.keyCode;if({13:1,27:1}[_sKeyCode]){A.stopPropagation(_aoEvent);A.preventDefault(_aoEvent)}_sKeyCode==13&&(_oSelf.getMenu().S("link").value?_oSelf.getMenu().S(!_bIsEnabledUnlink?"confirm":"modify").click():_oSelf.getMenu().S("link").focus());_sKeyCode==27&&_oSelf.hideMenu(true)});A.addEvent(_aoMenu.S("link"),"keydown",function(_aoEvent){var _sKeyCode=_aoEvent.keyCode;if({13:1,27:1}[_sKeyCode]){A.stopPropagation(_aoEvent);A.preventDefault(_aoEvent)}_sKeyCode==13&&_oSelf.getMenu().S(!_bIsEnabledUnlink?"confirm":"modify").click();_sKeyCode==27&&_oSelf.hideMenu(true)});_aoMenu=_oEditor=_aoUndefined};QMEditor.FUNCLIB.CreateLink.prototype.doMenuShow=function(_aoMenu){if(A.isShow(_aoMenu.S("link_cntr"))){_aoMenu.S("link").focus();_aoMenu.S("link").select()}};QMEditor.FUNCLIB.CreateLink.prototype._getLinkText=function(){var _sLinkValue=A.htmlEncode(this.getMenu().S("link").value);if(/[a-zA-Z_0-9.-]+@[a-zA-Z_0-9.-]+\.\w+/.test(_sLinkValue)){return A.trim(_sLinkValue).toLowerCase().indexOf("mailto")==0?_sLinkValue:"mailto:"+_sLinkValue}return A.trim(_sLinkValue).indexOf("://")==-1?"http://"+_sLinkValue:_sLinkValue};QMEditor.FUNCLIB.CreateLink.prototype._getNameText=function(){var _oNameText=this.getMenu().S("name");return _oNameText.className!="qmEditorCLNameDef"&&A.htmlEncode(_oNameText.value)||this._getLinkText()};QMEditor.FUNCLIB.SourceEdit=QMEditor.FUNCLIB.inheritFrom(function(_aoParamSet){this.setId("SourceEdit");this.setType("custom");this.setBindEditor(_aoParamSet.editor);var _oLanguage=this.getBindEditor().getLanguage();this.setUiConfig({title:_oLanguage.FUN_SOURCEEDIT,sourceToolBar:{formatTitle:_oLanguage.SE_FORMAT_TITLE,langFormat:_oLanguage.SE_FORMAT,previewTitle:_oLanguage.SE_PREVIEW_TITLE,langPreview:_oLanguage.SE_PREVIEW,langFormatting:_oLanguage.SE_FORMATTING}});this.setfOnClick(this._fDoDefaultClick);this.setfDoDefaultClick(this._fDoDefaultClick)},QMEditor.FUNCLIB.BASE);QMEditor.FUNCLIB.SourceEdit.prototype.setMouseOverEvent=function(_asUiType){};QMEditor.FUNCLIB.SourceEdit.prototype._fDoDefaultClick=function(_aoEvent){var _oEditor=this.getBindEditor(),_oSpellCheck=_oEditor.getToolBarInfo().SpellCheck;if(_oSpellCheck){_oSpellCheck._show(0,0,1)}this._setupSourceToolBar();_oEditor.hideMenu();_oEditor.changeEditMode("source")};QMEditor.FUNCLIB.SourceEdit.prototype._setupSourceToolBar=function(){var _oEditor=this.getBindEditor(),_srceToolBarObj=_oEditor.getSrceToolBarObj();if(_srceToolBarObj.getAttribute("setuped")=="true"){return false}_srceToolBarObj.innerHTML=_oEditor.getTemplate().SOURCEEDIT_TOOLBAR.replace(this.getUiConfig().sourceToolBar);_srceToolBarObj.setAttribute("setuped","true");this._setSourceToolBarEvent()};QMEditor.FUNCLIB.SourceEdit.prototype._setSourceToolBarEvent=function(){var _oSelf=this,_oEditor=this.getBindEditor(),_oFormatObj=_oEditor.getSrceToolBarObj().firstChild,_oPreviewObj=_oFormatObj.nextSibling;_oPreviewObj.onclick=function(){if(_oSelf._mnWaitLoadTimer){clearInterval(_oSelf._mnWaitLoadTimer)}_oEditor.changeEditMode("html");var _oSpellCheck=_oEditor.getToolBarInfo().SpellCheck;if(_oSpellCheck){_oSpellCheck._show(1,0,1)}};_oFormatObj.onclick=function(){_oSelf._formatCode()}};QMEditor.FUNCLIB.SourceEdit.prototype._formatCode=function(){var _oSelf=this;_oEditor=_oSelf.getBindEditor();if(!window.QMFormatter){_oEditor.loadFile({"../release/plus/formatter.js":true});if(_oSelf._mnWaitLoadTimer){return}this._mnWaitLoadTimer=setInterval(function(){_oSelf._formatCode()},500);return}if(this._mnWaitLoadTimer){clearInterval(this._mnWaitLoadTimer)}var _oFormatObj=_oEditor.getSrceToolBarObj().firstChild,_oRunObj=_oFormatObj.firstChild,_oSizeObj=_oRunObj.lastChild,_oBtnObj=_oFormatObj.lastChild;A.show(_oRunObj,true);A.show(_oBtnObj,false);_oFormatObj.className="qmEditorFormatting";_oSizeObj.innerHTML="0%";function _finish(_asResult){_oEditor.setEditContent("source",_asResult);A.show(_oRunObj,false);A.show(_oBtnObj,true);_oFormatObj.className="qmEditorBtnA"}function _process(_asProcessInfo){_oSizeObj.innerHTML=_asProcessInfo}QMFormatter.format(_oEditor.getEditContent("source"),_finish,_process)};(function(){QMEditor.setupFunc()})()})(QMEditorAdapter);