Files
galaxy/static/scripts/libs/jquery/jquery.wymeditor.js
T

4 lines
74 KiB
JavaScript

if(!WYMeditor)var WYMeditor={};!function(){if(window.console&&console.firebug)WYMeditor.console=window.console;else{var a=["log","debug","info","warn","error","assert","dir","dirxml","group","groupEnd","time","timeEnd","count","trace","profile","profileEnd"];WYMeditor.console={};for(var b=0;b<a.length;++b)WYMeditor.console[a[b]]=function(){}}}(),jQuery.extend(WYMeditor,{VERSION:"0.5-rc1",INSTANCES:[],STRINGS:[],SKINS:[],NAME:"name",INDEX:"{Wym_Index}",WYM_INDEX:"wym_index",BASE_PATH:"{Wym_Base_Path}",CSS_PATH:"{Wym_Css_Path}",WYM_PATH:"{Wym_Wym_Path}",SKINS_DEFAULT_PATH:"skins/",SKINS_DEFAULT_CSS:"skin.css",SKINS_DEFAULT_JS:"skin.js",LANG_DEFAULT_PATH:"lang/",IFRAME_BASE_PATH:"{Wym_Iframe_Base_Path}",IFRAME_DEFAULT:"iframe/default/",JQUERY_PATH:"{Wym_Jquery_Path}",DIRECTION:"{Wym_Direction}",LOGO:"{Wym_Logo}",TOOLS:"{Wym_Tools}",TOOLS_ITEMS:"{Wym_Tools_Items}",TOOL_NAME:"{Wym_Tool_Name}",TOOL_TITLE:"{Wym_Tool_Title}",TOOL_CLASS:"{Wym_Tool_Class}",CLASSES:"{Wym_Classes}",CLASSES_ITEMS:"{Wym_Classes_Items}",CLASS_NAME:"{Wym_Class_Name}",CLASS_TITLE:"{Wym_Class_Title}",CONTAINERS:"{Wym_Containers}",CONTAINERS_ITEMS:"{Wym_Containers_Items}",CONTAINER_NAME:"{Wym_Container_Name}",CONTAINER_TITLE:"{Wym_Containers_Title}",CONTAINER_CLASS:"{Wym_Container_Class}",HTML:"{Wym_Html}",IFRAME:"{Wym_Iframe}",STATUS:"{Wym_Status}",DIALOG_TITLE:"{Wym_Dialog_Title}",DIALOG_BODY:"{Wym_Dialog_Body}",STRING:"string",BODY:"body",DIV:"div",P:"p",H1:"h1",H2:"h2",H3:"h3",H4:"h4",H5:"h5",H6:"h6",PRE:"pre",BLOCKQUOTE:"blockquote",A:"a",BR:"br",IMG:"img",TABLE:"table",TD:"td",TH:"th",UL:"ul",OL:"ol",LI:"li",CLASS:"class",HREF:"href",SRC:"src",TITLE:"title",ALT:"alt",DIALOG_LINK:"Link",DIALOG_IMAGE:"Image",DIALOG_TABLE:"Table",DIALOG_PASTE:"Paste_From_Word",BOLD:"Bold",ITALIC:"Italic",CREATE_LINK:"CreateLink",INSERT_IMAGE:"InsertImage",INSERT_TABLE:"InsertTable",INSERT_HTML:"InsertHTML",PASTE:"Paste",INDENT:"Indent",OUTDENT:"Outdent",TOGGLE_HTML:"ToggleHtml",FORMAT_BLOCK:"FormatBlock",PREVIEW:"Preview",UNLINK:"Unlink",INSERT_UNORDEREDLIST:"InsertUnorderedList",INSERT_ORDEREDLIST:"InsertOrderedList",MAIN_CONTAINERS:new Array("p","h1","h2","h3","h4","h5","h6","pre","blockquote"),BLOCKS:new Array("address","blockquote","div","dl","fieldset","form","h1","h2","h3","h4","h5","h6","hr","noscript","ol","p","pre","table","ul","dd","dt","li","tbody","td","tfoot","th","thead","tr"),KEY:{BACKSPACE:8,ENTER:13,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,CURSOR:new Array(37,38,39,40),DELETE:46},NODE:{ELEMENT:1,ATTRIBUTE:2,TEXT:3},editor:function(a,b){this._index=WYMeditor.INSTANCES.push(this)-1,this._element=a,this._options=b,this._html=jQuery(a).val(),this._options.html&&(this._html=this._options.html),this._options.basePath=this._options.basePath||this.computeBasePath(),this._options.skinPath=this._options.skinPath||this._options.basePath+WYMeditor.SKINS_DEFAULT_PATH+this._options.skin+"/",this._options.wymPath=this._options.wymPath||this.computeWymPath(),this._options.langPath=this._options.langPath||this._options.basePath+WYMeditor.LANG_DEFAULT_PATH,this._options.iframeBasePath=this._options.iframeBasePath||this._options.basePath+WYMeditor.IFRAME_DEFAULT,this._options.jQueryPath=this._options.jQueryPath||this.computeJqueryPath(),this.init()}}),jQuery.fn.wymeditor=function(a){return a=jQuery.extend({html:"",basePath:!1,skinPath:!1,wymPath:!1,iframeBasePath:!1,jQueryPath:!1,styles:!1,stylesheet:!1,skin:"default",initSkin:!0,loadSkin:!0,lang:"en",direction:"ltr",boxHtml:"<div class='wym_box'><div class='wym_area_top'>"+WYMeditor.TOOLS+"</div><div class='wym_area_left'></div><div class='wym_area_right'>"+WYMeditor.CONTAINERS+WYMeditor.CLASSES+"</div><div class='wym_area_main'>"+WYMeditor.HTML+WYMeditor.IFRAME+WYMeditor.STATUS+"</div><div class='wym_area_bottom'>"+WYMeditor.LOGO+"</div></div>",logoHtml:"<a class='wym_wymeditor_link' href='http://www.wymeditor.org/'>WYMeditor</a>",iframeHtml:"<div class='wym_iframe wym_section'><iframe src='/page/get_editor_iframe' onload='this.contentWindow.parent.WYMeditor.INSTANCES["+WYMeditor.INDEX+"].initIframe(this)'></iframe></div>",editorStyles:[],toolsHtml:"<div class='wym_tools wym_section'><h2>{Tools}</h2><ul>"+WYMeditor.TOOLS_ITEMS+"</ul></div>",toolsItemHtml:"<li class='"+WYMeditor.TOOL_CLASS+"'><a href='#' name='"+WYMeditor.TOOL_NAME+"' title='"+WYMeditor.TOOL_TITLE+"'>"+WYMeditor.TOOL_TITLE+"</a></li>",toolsItems:[{name:"Bold",title:"Strong",css:"wym_tools_strong"},{name:"Italic",title:"Emphasis",css:"wym_tools_emphasis"},{name:"Superscript",title:"Superscript",css:"wym_tools_superscript"},{name:"Subscript",title:"Subscript",css:"wym_tools_subscript"},{name:"InsertOrderedList",title:"Ordered_List",css:"wym_tools_ordered_list"},{name:"InsertUnorderedList",title:"Unordered_List",css:"wym_tools_unordered_list"},{name:"Indent",title:"Indent",css:"wym_tools_indent"},{name:"Outdent",title:"Outdent",css:"wym_tools_outdent"},{name:"Undo",title:"Undo",css:"wym_tools_undo"},{name:"Redo",title:"Redo",css:"wym_tools_redo"},{name:"CreateLink",title:"Link",css:"wym_tools_link"},{name:"Unlink",title:"Unlink",css:"wym_tools_unlink"},{name:"InsertImage",title:"Image",css:"wym_tools_image"},{name:"InsertTable",title:"Table",css:"wym_tools_table"},{name:"Paste",title:"Paste_From_Word",css:"wym_tools_paste"},{name:"ToggleHtml",title:"HTML",css:"wym_tools_html"},{name:"Preview",title:"Preview",css:"wym_tools_preview"}],containersHtml:"<div class='wym_containers wym_section'><h2>{Containers}</h2><ul>"+WYMeditor.CONTAINERS_ITEMS+"</ul></div>",containersItemHtml:"<li class='"+WYMeditor.CONTAINER_CLASS+"'><a href='#' name='"+WYMeditor.CONTAINER_NAME+"'>"+WYMeditor.CONTAINER_TITLE+"</a></li>",containersItems:[{name:"P",title:"Paragraph",css:"wym_containers_p"},{name:"H1",title:"Heading_1",css:"wym_containers_h1"},{name:"H2",title:"Heading_2",css:"wym_containers_h2"},{name:"H3",title:"Heading_3",css:"wym_containers_h3"},{name:"H4",title:"Heading_4",css:"wym_containers_h4"},{name:"H5",title:"Heading_5",css:"wym_containers_h5"},{name:"H6",title:"Heading_6",css:"wym_containers_h6"},{name:"PRE",title:"Preformatted",css:"wym_containers_pre"},{name:"BLOCKQUOTE",title:"Blockquote",css:"wym_containers_blockquote"},{name:"TH",title:"Table_Header",css:"wym_containers_th"}],classesHtml:"<div class='wym_classes wym_section'><h2>{Classes}</h2><ul>"+WYMeditor.CLASSES_ITEMS+"</ul></div>",classesItemHtml:"<li><a href='#' name='"+WYMeditor.CLASS_NAME+"'>"+WYMeditor.CLASS_TITLE+"</a></li>",classesItems:[],statusHtml:"<div class='wym_status wym_section'><h2>{Status}</h2></div>",htmlHtml:"<div class='wym_html wym_section'><h2>{Source_Code}</h2><textarea class='wym_html_val'></textarea></div>",boxSelector:".wym_box",toolsSelector:".wym_tools",toolsListSelector:" ul",containersSelector:".wym_containers",classesSelector:".wym_classes",htmlSelector:".wym_html",iframeSelector:".wym_iframe iframe",iframeBodySelector:".wym_iframe",statusSelector:".wym_status",toolSelector:".wym_tools a",containerSelector:".wym_containers a",classSelector:".wym_classes a",htmlValSelector:".wym_html_val",hrefSelector:".wym_href",srcSelector:".wym_src",titleSelector:".wym_title",altSelector:".wym_alt",textSelector:".wym_text",rowsSelector:".wym_rows",colsSelector:".wym_cols",captionSelector:".wym_caption",summarySelector:".wym_summary",submitSelector:".wym_submit",cancelSelector:".wym_cancel",previewSelector:"",dialogTypeSelector:".wym_dialog_type",dialogLinkSelector:".wym_dialog_link",dialogImageSelector:".wym_dialog_image",dialogTableSelector:".wym_dialog_table",dialogPasteSelector:".wym_dialog_paste",dialogPreviewSelector:".wym_dialog_preview",updateSelector:".wymupdate",updateEvent:"click",dialogFeatures:"menubar=no,titlebar=no,toolbar=no,resizable=no,width=560,height=300,top=0,left=0",dialogFeaturesPreview:"menubar=no,titlebar=no,toolbar=no,resizable=no,scrollbars=yes,width=560,height=300,top=0,left=0",dialogHtml:"<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'><html dir='"+WYMeditor.DIRECTION+"'><head><link rel='stylesheet' type='text/css' media='screen' href='"+WYMeditor.CSS_PATH+"' /><title>"+WYMeditor.DIALOG_TITLE+"</title><script type='text/javascript' src='"+WYMeditor.JQUERY_PATH+"'></script><script type='text/javascript' src='"+WYMeditor.WYM_PATH+"'></script></head>"+WYMeditor.DIALOG_BODY+"</html>",dialogLinkHtml:"<body class='wym_dialog wym_dialog_link' onload='WYMeditor.INIT_DIALOG("+WYMeditor.INDEX+")'><form><fieldset><input type='hidden' class='wym_dialog_type' value='"+WYMeditor.DIALOG_LINK+"' /><legend>{Link}</legend><div class='row'><label>{URL}</label><input type='text' class='wym_href' value='' size='40' /></div><div class='row'><label>{Title}</label><input type='text' class='wym_title' value='' size='40' /></div><div class='row row-indent'><input class='wym_submit' type='button' value='{Submit}' /><input class='wym_cancel' type='button'value='{Cancel}' /></div></fieldset></form></body>",dialogImageHtml:"<body class='wym_dialog wym_dialog_image' onload='WYMeditor.INIT_DIALOG("+WYMeditor.INDEX+")'><form><fieldset><input type='hidden' class='wym_dialog_type' value='"+WYMeditor.DIALOG_IMAGE+"' /><legend>{Image}</legend><div class='row'><label>{URL}</label><input type='text' class='wym_src' value='' size='40' /></div><div class='row'><label>{Alternative_Text}</label><input type='text' class='wym_alt' value='' size='40' /></div><div class='row'><label>{Title}</label><input type='text' class='wym_title' value='' size='40' /></div><div class='row row-indent'><input class='wym_submit' type='button' value='{Submit}' /><input class='wym_cancel' type='button'value='{Cancel}' /></div></fieldset></form></body>",dialogTableHtml:"<body class='wym_dialog wym_dialog_table' onload='WYMeditor.INIT_DIALOG("+WYMeditor.INDEX+")'><form><fieldset><input type='hidden' class='wym_dialog_type' value='"+WYMeditor.DIALOG_TABLE+"' /><legend>{Table}</legend><div class='row'><label>{Caption}</label><input type='text' class='wym_caption' value='' size='40' /></div><div class='row'><label>{Summary}</label><input type='text' class='wym_summary' value='' size='40' /></div><div class='row'><label>{Number_Of_Rows}</label><input type='text' class='wym_rows' value='3' size='3' /></div><div class='row'><label>{Number_Of_Cols}</label><input type='text' class='wym_cols' value='2' size='3' /></div><div class='row row-indent'><input class='wym_submit' type='button' value='{Submit}' /><input class='wym_cancel' type='button'value='{Cancel}' /></div></fieldset></form></body>",dialogPasteHtml:"<body class='wym_dialog wym_dialog_paste' onload='WYMeditor.INIT_DIALOG("+WYMeditor.INDEX+")'><form><input type='hidden' class='wym_dialog_type' value='"+WYMeditor.DIALOG_PASTE+"' /><fieldset><legend>{Paste_From_Word}</legend><div class='row'><textarea class='wym_text' rows='10' cols='50'></textarea></div><div class='row'><input class='wym_submit' type='button' value='{Submit}' /><input class='wym_cancel' type='button'value='{Cancel}' /></div></fieldset></form></body>",dialogPreviewHtml:"<body class='wym_dialog wym_dialog_preview' onload='WYMeditor.INIT_DIALOG("+WYMeditor.INDEX+")'></body>",dialogStyles:[],stringDelimiterLeft:"{",stringDelimiterRight:"}",preInit:null,preBind:null,postInit:null,preInitDialog:null,postInitDialog:null},a),this.each(function(){new WYMeditor.editor(jQuery(this),a)})},jQuery.extend({wymeditors:function(a){return WYMeditor.INSTANCES[a]}}),WYMeditor.editor.prototype.init=function(){if(jQuery.browser.msie)var WymClass=new WYMeditor.WymClassExplorer(this);else if(jQuery.browser.mozilla)var WymClass=new WYMeditor.WymClassMozilla(this);else if(jQuery.browser.opera)var WymClass=new WYMeditor.WymClassOpera(this);else if(jQuery.browser.safari||jQuery.browser.chrome)var WymClass=new WYMeditor.WymClassSafari(this);if(WymClass){jQuery.isFunction(this._options.preInit)&&this._options.preInit(this);var SaxListener=new WYMeditor.XhtmlSaxListener;jQuery.extend(SaxListener,WymClass),this.parser=new WYMeditor.XhtmlParser(SaxListener),(this._options.styles||this._options.stylesheet)&&this.configureEditorUsingRawCss(),this.helper=new WYMeditor.XmlHelper;for(var prop in WymClass)this[prop]=WymClass[prop];this._box=jQuery(this._element).hide().after(this._options.boxHtml).next().addClass("wym_box_"+this._index),jQuery.isFunction(jQuery.fn.data)&&(jQuery.data(this._box.get(0),WYMeditor.WYM_INDEX,this._index),jQuery.data(this._element.get(0),WYMeditor.WYM_INDEX,this._index));var h=WYMeditor.Helper,iframeHtml=this._options.iframeHtml;iframeHtml=h.replaceAll(iframeHtml,WYMeditor.INDEX,this._index),iframeHtml=h.replaceAll(iframeHtml,WYMeditor.IFRAME_BASE_PATH,this._options.iframeBasePath);var boxHtml=jQuery(this._box).html();boxHtml=h.replaceAll(boxHtml,WYMeditor.LOGO,this._options.logoHtml),boxHtml=h.replaceAll(boxHtml,WYMeditor.TOOLS,this._options.toolsHtml),boxHtml=h.replaceAll(boxHtml,WYMeditor.CONTAINERS,this._options.containersHtml),boxHtml=h.replaceAll(boxHtml,WYMeditor.CLASSES,this._options.classesHtml),boxHtml=h.replaceAll(boxHtml,WYMeditor.HTML,this._options.htmlHtml),boxHtml=h.replaceAll(boxHtml,WYMeditor.IFRAME,iframeHtml),boxHtml=h.replaceAll(boxHtml,WYMeditor.STATUS,this._options.statusHtml);for(var aTools=eval(this._options.toolsItems),sTools="",i=0;i<aTools.length;i++){var oTool=aTools[i];if(oTool.name&&oTool.title)var sTool=this._options.toolsItemHtml;var sTool=h.replaceAll(sTool,WYMeditor.TOOL_NAME,oTool.name);sTool=h.replaceAll(sTool,WYMeditor.TOOL_TITLE,this._options.stringDelimiterLeft+oTool.title+this._options.stringDelimiterRight),sTool=h.replaceAll(sTool,WYMeditor.TOOL_CLASS,oTool.css),sTools+=sTool}boxHtml=h.replaceAll(boxHtml,WYMeditor.TOOLS_ITEMS,sTools);for(var aClasses=eval(this._options.classesItems),sClasses="",i=0;i<aClasses.length;i++){var oClass=aClasses[i];if(oClass.name&&oClass.title)var sClass=this._options.classesItemHtml;sClass=h.replaceAll(sClass,WYMeditor.CLASS_NAME,oClass.name),sClass=h.replaceAll(sClass,WYMeditor.CLASS_TITLE,oClass.title),sClasses+=sClass}boxHtml=h.replaceAll(boxHtml,WYMeditor.CLASSES_ITEMS,sClasses);for(var aContainers=eval(this._options.containersItems),sContainers="",i=0;i<aContainers.length;i++){var oContainer=aContainers[i];if(oContainer.name&&oContainer.title)var sContainer=this._options.containersItemHtml;sContainer=h.replaceAll(sContainer,WYMeditor.CONTAINER_NAME,oContainer.name),sContainer=h.replaceAll(sContainer,WYMeditor.CONTAINER_TITLE,this._options.stringDelimiterLeft+oContainer.title+this._options.stringDelimiterRight),sContainer=h.replaceAll(sContainer,WYMeditor.CONTAINER_CLASS,oContainer.css),sContainers+=sContainer}boxHtml=h.replaceAll(boxHtml,WYMeditor.CONTAINERS_ITEMS,sContainers),boxHtml=this.replaceStrings(boxHtml),jQuery(this._box).html(boxHtml),jQuery(this._box).find(this._options.htmlSelector).hide(),this.loadSkin()}},WYMeditor.editor.prototype.bindEvents=function(){var wym=this;jQuery(this._box).find(this._options.toolSelector).click(function(){return wym._iframe.contentWindow.focus(),wym.exec(jQuery(this).attr(WYMeditor.NAME)),!1}),jQuery(this._box).find(this._options.containerSelector).click(function(){return wym.container(jQuery(this).attr(WYMeditor.NAME)),!1}),jQuery(this._box).find(this._options.htmlValSelector).keyup(function(){jQuery(wym._doc.body).html(jQuery(this).val())}).focus(function(){jQuery(this).toggleClass("hasfocus")}).blur(function(){jQuery(this).toggleClass("hasfocus")}),jQuery(this._box).find(this._options.classSelector).click(function(){var aClasses=eval(wym._options.classesItems),sName=jQuery(this).attr(WYMeditor.NAME),oClass=WYMeditor.Helper.findByName(aClasses,sName);if(oClass){var jqexpr=oClass.expr;wym.toggleClass(sName,jqexpr)}return wym._iframe.contentWindow.focus(),!1}),jQuery(this._options.updateSelector).bind(this._options.updateEvent,function(){wym.update()})},WYMeditor.editor.prototype.ready=function(){return null!=this._doc},WYMeditor.editor.prototype.box=function(){return this._box},WYMeditor.editor.prototype.html=function(a){return"string"!=typeof a?jQuery(this._doc.body).html():void jQuery(this._doc.body).html(a)},WYMeditor.editor.prototype.xhtml=function(){return this.parser.parse(this.html())},WYMeditor.editor.prototype.exec=function(a){switch(a){case WYMeditor.CREATE_LINK:var b=this.container();(b||this._selected_image)&&this.dialog(WYMeditor.DIALOG_LINK);break;case WYMeditor.INSERT_IMAGE:this.dialog(WYMeditor.DIALOG_IMAGE);break;case WYMeditor.INSERT_TABLE:this.dialog(WYMeditor.DIALOG_TABLE);break;case WYMeditor.PASTE:this.dialog(WYMeditor.DIALOG_PASTE);break;case WYMeditor.TOGGLE_HTML:this.update(),this.toggleHtml(),jQuery(this._box).find(this._options.htmlSelector).is(":visible")||this.listen();break;case WYMeditor.PREVIEW:this.dialog(WYMeditor.PREVIEW,this._options.dialogFeaturesPreview);break;default:this._exec(a)}},WYMeditor.editor.prototype.container=function(a){if(!a)return this.selected();var b=null;if(a.toLowerCase()==WYMeditor.TH){switch(b=this.container(),b.tagName.toLowerCase()){case WYMeditor.TD:case WYMeditor.TH:break;default:var c=new Array(WYMeditor.TD,WYMeditor.TH);b=this.findUp(this.container(),c)}null!=b&&(a=b.tagName.toLowerCase()==WYMeditor.TD?WYMeditor.TH:WYMeditor.TD,this.switchTo(b,a),this.update())}else{var c=new Array(WYMeditor.P,WYMeditor.H1,WYMeditor.H2,WYMeditor.H3,WYMeditor.H4,WYMeditor.H5,WYMeditor.H6,WYMeditor.PRE,WYMeditor.BLOCKQUOTE);if(b=this.findUp(this.container(),c)){var d=null;if(a.toLowerCase()==WYMeditor.BLOCKQUOTE){var e=this.findUp(this.container(),WYMeditor.BLOCKQUOTE);if(null==e)d=this._doc.createElement(a),b.parentNode.insertBefore(d,b),d.appendChild(b),this.setFocusToNode(d.firstChild);else{var f=e.childNodes,g=f.length,h=null;g>0&&(h=f.item(0));for(var i=0;g>i;i++)e.parentNode.insertBefore(f.item(0),e);e.parentNode.removeChild(e),h&&this.setFocusToNode(h)}}else this.switchTo(b,a);this.update()}}},WYMeditor.editor.prototype.toggleClass=function(a,b){var c=this._selected_image?this._selected_image:jQuery(this.selected());c=jQuery(c).parentsOrSelf(b),jQuery(c).toggleClass(a),jQuery(c).attr(WYMeditor.CLASS)||jQuery(c).removeAttr(this._class)},WYMeditor.editor.prototype.findUp=function(a,b){if(a){var c=a.tagName.toLowerCase();if(typeof b==WYMeditor.STRING)for(;c!=b&&c!=WYMeditor.BODY;)a=a.parentNode,c=a.tagName.toLowerCase();else for(var d=!1;!d&&c!=WYMeditor.BODY;){for(var e=0;e<b.length;e++)if(c==b[e]){d=!0;break}d||(a=a.parentNode,c=a.tagName.toLowerCase())}return c!=WYMeditor.BODY?a:null}return null},WYMeditor.editor.prototype.switchTo=function(a,b){var c=this._doc.createElement(b),d=jQuery(a).html();a.parentNode.replaceChild(c,a),jQuery(c).html(d),this.setFocusToNode(c)},WYMeditor.editor.prototype.replaceStrings=function(sVal){if(!WYMeditor.STRINGS[this._options.lang])try{eval(jQuery.ajax({url:this._options.langPath+this._options.lang+".js",async:!1}).responseText)}catch(e){return WYMeditor.console.error("WYMeditor: error while parsing language file."),sVal}for(var key in WYMeditor.STRINGS[this._options.lang])sVal=WYMeditor.Helper.replaceAll(sVal,this._options.stringDelimiterLeft+key+this._options.stringDelimiterRight,WYMeditor.STRINGS[this._options.lang][key]);return sVal},WYMeditor.editor.prototype.encloseString=function(a){return this._options.stringDelimiterLeft+a+this._options.stringDelimiterRight},WYMeditor.editor.prototype.status=function(a){jQuery(this._box).find(this._options.statusSelector).html(a)},WYMeditor.editor.prototype.update=function(){var a=this.xhtml();jQuery(this._element).val(a),jQuery(this._box).find(this._options.htmlValSelector).not(".hasfocus").val(a)},WYMeditor.editor.prototype.dialog=function(a,b,c){var d=b||this._wym._options.dialogFeatures,e=window.open("","dialog",d);if(e){var f="";switch(a){case WYMeditor.DIALOG_LINK:f=this._options.dialogLinkHtml;break;case WYMeditor.DIALOG_IMAGE:f=this._options.dialogImageHtml;break;case WYMeditor.DIALOG_TABLE:f=this._options.dialogTableHtml;break;case WYMeditor.DIALOG_PASTE:f=this._options.dialogPasteHtml;break;case WYMeditor.PREVIEW:f=this._options.dialogPreviewHtml;break;default:f=c}var g=WYMeditor.Helper,h=this._options.dialogHtml;h=g.replaceAll(h,WYMeditor.BASE_PATH,this._options.basePath),h=g.replaceAll(h,WYMeditor.DIRECTION,this._options.direction),h=g.replaceAll(h,WYMeditor.CSS_PATH,this._options.skinPath+WYMeditor.SKINS_DEFAULT_CSS),h=g.replaceAll(h,WYMeditor.WYM_PATH,this._options.wymPath),h=g.replaceAll(h,WYMeditor.JQUERY_PATH,this._options.jQueryPath),h=g.replaceAll(h,WYMeditor.DIALOG_TITLE,this.encloseString(a)),h=g.replaceAll(h,WYMeditor.DIALOG_BODY,f),h=g.replaceAll(h,WYMeditor.INDEX,this._index),h=this.replaceStrings(h);var i=e.document;i.write(h),i.close()}},WYMeditor.editor.prototype.toggleHtml=function(){jQuery(this._box).find(this._options.htmlSelector).toggle()},WYMeditor.editor.prototype.uniqueStamp=function(){var a=new Date;return"wym-"+a.getTime()},WYMeditor.editor.prototype.paste=function(a){var b,c=this.selected(),d=a.split(this._newLine+this._newLine),e=new RegExp(this._newLine,"g");if(c&&c.tagName.toLowerCase()!=WYMeditor.BODY)for(x=d.length-1;x>=0;x--)b=d[x],b=b.replace(e,"<br />"),jQuery(c).after("<p>"+b+"</p>");else for(x=0;x<d.length;x++)b=d[x],b=b.replace(e,"<br />"),jQuery(this._doc.body).append("<p>"+b+"</p>")},WYMeditor.editor.prototype.insert=function(a){null!=this._iframe.contentWindow.getSelection().focusNode?this._exec(WYMeditor.INSERT_HTML,a):this.paste(a)},WYMeditor.editor.prototype.wrap=function(a,b){null!=this._iframe.contentWindow.getSelection().focusNode&&this._exec(WYMeditor.INSERT_HTML,a+this._iframe.contentWindow.getSelection().toString()+b)},WYMeditor.editor.prototype.unwrap=function(){null!=this._iframe.contentWindow.getSelection().focusNode&&this._exec(WYMeditor.INSERT_HTML,this._iframe.contentWindow.getSelection().toString())},WYMeditor.editor.prototype.addCssRules=function(a,b){var c=a.styleSheets[0];if(c)for(var d=0;d<b.length;d++){var e=b[d];e.name&&e.css&&this.addCssRule(c,e)}},WYMeditor.editor.prototype.computeBasePath=function(){return jQuery(jQuery.grep(jQuery("script"),function(a){return a.src&&a.src.match(/jquery\.wymeditor(\.pack|\.min|\.packed)?\.js(\?.*)?$/)})).attr("src").replace(/jquery\.wymeditor(\.pack|\.min|\.packed)?\.js(\?.*)?$/,"")},WYMeditor.editor.prototype.computeWymPath=function(){return jQuery(jQuery.grep(jQuery("script"),function(a){return a.src&&a.src.match(/jquery\.wymeditor(\.pack|\.min|\.packed)?\.js(\?.*)?$/)})).attr("src")},WYMeditor.editor.prototype.computeJqueryPath=function(){return jQuery(jQuery.grep(jQuery("script"),function(a){return a.src&&a.src.match(/jquery(-(.*)){0,1}(\.pack|\.min|\.packed)?\.js(\?.*)?$/)})).attr("src")},WYMeditor.editor.prototype.computeCssPath=function(){return jQuery(jQuery.grep(jQuery("link"),function(a){return a.href&&a.href.match(/wymeditor\/skins\/(.*)screen\.css(\?.*)?$/)})).attr("href")},WYMeditor.editor.prototype.configureEditorUsingRawCss=function(){var a=new WYMeditor.WymCssParser;this._options.stylesheet?a.parse(jQuery.ajax({url:this._options.stylesheet,async:!1}).responseText):a.parse(this._options.styles,!1),0==this._options.classesItems.length&&(this._options.classesItems=a.css_settings.classesItems),0==this._options.editorStyles.length&&(this._options.editorStyles=a.css_settings.editorStyles),0==this._options.dialogStyles.length&&(this._options.dialogStyles=a.css_settings.dialogStyles)},WYMeditor.editor.prototype.listen=function(){jQuery(this._doc.body).bind("mousedown",this.mousedown);for(var a=this._doc.body.getElementsByTagName("img"),b=0;b<a.length;b++)jQuery(a[b]).bind("mousedown",this.mousedown)},WYMeditor.editor.prototype.mousedown=function(a){var b=WYMeditor.INSTANCES[this.ownerDocument.title];b._selected_image=this.tagName.toLowerCase()==WYMeditor.IMG?this:null,a.stopPropagation()},WYMeditor.loadCss=function(a){var b=document.createElement("link");b.rel="stylesheet",b.href=a;var c=jQuery("head").get(0);c.appendChild(b)},WYMeditor.editor.prototype.loadSkin=function(){if(this._options.loadSkin&&!WYMeditor.SKINS[this._options.skin]){var found=!1,rExp=new RegExp(this._options.skin+"/"+WYMeditor.SKINS_DEFAULT_CSS+"$");jQuery("link").each(function(){this.href.match(rExp)&&(found=!0)}),found||WYMeditor.loadCss(this._options.skinPath+WYMeditor.SKINS_DEFAULT_CSS)}jQuery(this._box).addClass("wym_skin_"+this._options.skin),this._options.initSkin&&!WYMeditor.SKINS[this._options.skin]&&eval(jQuery.ajax({url:this._options.skinPath+WYMeditor.SKINS_DEFAULT_JS,async:!1}).responseText),WYMeditor.SKINS[this._options.skin]&&WYMeditor.SKINS[this._options.skin].init&&WYMeditor.SKINS[this._options.skin].init(this)},WYMeditor.INIT_DIALOG=function(index){var wym=window.opener.WYMeditor.INSTANCES[index],doc=window.document,selected=wym.selected(),dialogType=jQuery(wym._options.dialogTypeSelector).val(),sStamp=wym.uniqueStamp();switch(dialogType){case WYMeditor.DIALOG_LINK:selected&&selected.tagName&&selected.tagName.toLowerCase!=WYMeditor.A&&(selected=jQuery(selected).parentsOrSelf(WYMeditor.A)),!selected&&wym._selected_image&&(selected=jQuery(wym._selected_image).parentsOrSelf(WYMeditor.A))}jQuery.isFunction(wym._options.preInitDialog)&&wym._options.preInitDialog(wym,window);var styles=doc.styleSheets[0],aCss=eval(wym._options.dialogStyles);wym.addCssRules(doc,aCss),selected&&(jQuery(wym._options.hrefSelector).val(jQuery(selected).attr(WYMeditor.HREF)),jQuery(wym._options.srcSelector).val(jQuery(selected).attr(WYMeditor.SRC)),jQuery(wym._options.titleSelector).val(jQuery(selected).attr(WYMeditor.TITLE)),jQuery(wym._options.altSelector).val(jQuery(selected).attr(WYMeditor.ALT))),wym._selected_image&&(jQuery(wym._options.dialogImageSelector+" "+wym._options.srcSelector).val(jQuery(wym._selected_image).attr(WYMeditor.SRC)),jQuery(wym._options.dialogImageSelector+" "+wym._options.titleSelector).val(jQuery(wym._selected_image).attr(WYMeditor.TITLE)),jQuery(wym._options.dialogImageSelector+" "+wym._options.altSelector).val(jQuery(wym._selected_image).attr(WYMeditor.ALT))),jQuery(wym._options.dialogLinkSelector+" "+wym._options.submitSelector).click(function(){var a=jQuery(wym._options.hrefSelector).val();a.length>0&&(wym._exec(WYMeditor.CREATE_LINK,sStamp),jQuery("a[href="+sStamp+"]",wym._doc.body).attr(WYMeditor.HREF,a).attr(WYMeditor.TITLE,jQuery(wym._options.titleSelector).val())),window.close()}),jQuery(wym._options.dialogImageSelector+" "+wym._options.submitSelector).click(function(){var a=jQuery(wym._options.srcSelector).val();a.length>0&&(wym._exec(WYMeditor.INSERT_IMAGE,sStamp),jQuery("img[src$="+sStamp+"]",wym._doc.body).attr(WYMeditor.SRC,a).attr(WYMeditor.TITLE,jQuery(wym._options.titleSelector).val()).attr(WYMeditor.ALT,jQuery(wym._options.altSelector).val())),window.close()}),jQuery(wym._options.dialogTableSelector+" "+wym._options.submitSelector).click(function(){var a=jQuery(wym._options.rowsSelector).val(),b=jQuery(wym._options.colsSelector).val();if(a>0&&b>0){var c=wym._doc.createElement(WYMeditor.TABLE),d=null,e=jQuery(wym._options.captionSelector).val(),f=c.createCaption();for(f.innerHTML=e,x=0;x<a;x++)for(d=c.insertRow(x),y=0;y<b;y++)d.insertCell(y);jQuery(c).attr("summary",jQuery(wym._options.summarySelector).val());var g=jQuery(wym.findUp(wym.container(),WYMeditor.MAIN_CONTAINERS)).get(0);g&&g.parentNode?jQuery(g).after(c):jQuery(wym._doc.body).append(c)}window.close()}),jQuery(wym._options.dialogPasteSelector+" "+wym._options.submitSelector).click(function(){var a=jQuery(wym._options.textSelector).val();wym.paste(a),window.close()}),jQuery(wym._options.dialogPreviewSelector+" "+wym._options.previewSelector).html(wym.xhtml()),jQuery(wym._options.cancelSelector).mousedown(function(){window.close()}),jQuery.isFunction(wym._options.postInitDialog)&&wym._options.postInitDialog(wym,window)},WYMeditor.XmlHelper=function(){return this._entitiesDiv=document.createElement("div"),this},WYMeditor.XmlHelper.prototype.tag=function(a,b,c){return b=b||!1,c=c||!1,"<"+a+(b?this.tagOptions(b):"")+(c?">":" />")},WYMeditor.XmlHelper.prototype.contentTag=function(a,b,c){return c=c||!1,"<"+a+(c?this.tagOptions(c):"")+">"+b+"</"+a+">"},WYMeditor.XmlHelper.prototype.cdataSection=function(a){return"<![CDATA["+a+"]]>"},WYMeditor.XmlHelper.prototype.escapeOnce=function(a){return this._fixDoubleEscape(this.escapeEntities(a))},WYMeditor.XmlHelper.prototype._fixDoubleEscape=function(a){return a.replace(/&amp;([a-z]+|(#\d+));/gi,"&$1;")},WYMeditor.XmlHelper.prototype.tagOptions=function(a){var b=this;b._formated_options="";for(var c in a){var d=a[c];"function"!=typeof d&&d.length>0&&(parseInt(c)==c&&"object"==typeof d&&(c=d.shift(),d=d.pop()),""!=c&&""!=d&&(b._formated_options+=" "+c+'="'+b.escapeOnce(d)+'"'))}return b._formated_options},WYMeditor.XmlHelper.prototype.escapeEntities=function(a,b){this._entitiesDiv.innerHTML=a,this._entitiesDiv.textContent=a;var c=this._entitiesDiv.innerHTML;return"undefined"==typeof b&&(0!=b&&(c=c.replace('"',"&quot;")),1==b&&(c=c.replace('"',"&#039;"))),c},WYMeditor.XmlHelper.prototype.parseAttributes=function(a){var b=[],c=a.split(/((=\s*")(")("))|((=\s*\')(\')(\'))|((=\s*[^>\s]*))/g);if(c.toString()!=a)for(var d in c){var e=c[d];if("function"!=typeof e&&0!=e.length){var f=new RegExp("(\\w+)\\s*"+e);if(match=a.match(f)){var g=e.replace(/^[\s=]+/,""),h=g.charAt(0);h='"'==h?'"':"'"==h?"'":"",""!=h&&(g='"'==h?g.replace(/^"|"+$/g,""):g.replace(/^'|'+$/g,"")),a=a.replace(match[0],""),b.push([match[1],g])}}}return b},WYMeditor.XhtmlValidator={_attributes:{core:{except:["base","head","html","meta","param","script","style","title"],attributes:["class","id","style","title","accesskey","tabindex"]},language:{except:["base","br","hr","iframe","param","script"],attributes:{dir:["ltr","rtl"],0:"lang",1:"xml:lang"}},keyboard:{attributes:{accesskey:/^(\w){1}$/,tabindex:/^(\d)+$/}}},_events:{window:{only:["body"],attributes:["onload","onunload"]},form:{only:["form","input","textarea","select","a","label","button"],attributes:["onchange","onsubmit","onreset","onselect","onblur","onfocus"]},keyboard:{except:["base","bdo","br","frame","frameset","head","html","iframe","meta","param","script","style","title"],attributes:["onkeydown","onkeypress","onkeyup"]},mouse:{except:["base","bdo","br","head","html","meta","param","script","style","title"],attributes:["onclick","ondblclick","onmousedown","onmousemove","onmouseover","onmouseout","onmouseup"]}},_tags:{a:{attributes:{0:"charset",1:"coords",2:"href",3:"hreflang",4:"name",rel:/^(alternate|designates|stylesheet|start|next|prev|contents|index|glossary|copyright|chapter|section|subsection|appendix|help|bookmark| |shortcut|icon)+$/,rev:/^(alternate|designates|stylesheet|start|next|prev|contents|index|glossary|copyright|chapter|section|subsection|appendix|help|bookmark| |shortcut|icon)+$/,shape:/^(rect|rectangle|circ|circle|poly|polygon)$/,5:"type"}},0:"abbr",1:"acronym",2:"address",area:{attributes:{0:"alt",1:"coords",2:"href",nohref:/^(true|false)$/,shape:/^(rect|rectangle|circ|circle|poly|polygon)$/},required:["alt"]},3:"b",base:{attributes:["href"],required:["href"]},bdo:{attributes:{dir:/^(ltr|rtl)$/},required:["dir"]},4:"big",blockquote:{attributes:["cite"]},5:"body",6:"br",button:{attributes:{disabled:/^(disabled)$/,type:/^(button|reset|submit)$/,0:"value"},inside:"form"},7:"caption",8:"cite",9:"code",col:{attributes:{align:/^(right|left|center|justify)$/,0:"char",1:"charoff",span:/^(\d)+$/,valign:/^(top|middle|bottom|baseline)$/,2:"width"},inside:"colgroup"},colgroup:{attributes:{align:/^(right|left|center|justify)$/,0:"char",1:"charoff",span:/^(\d)+$/,valign:/^(top|middle|bottom|baseline)$/,2:"width"}},10:"dd",del:{attributes:{0:"cite",datetime:/^([0-9]){8}/}},11:"div",12:"dfn",13:"dl",14:"dt",15:"em",fieldset:{inside:"form"},form:{attributes:{0:"action",1:"accept",2:"accept-charset",3:"enctype",method:/^(get|post)$/},required:["action"]},head:{attributes:["profile"]},16:"h1",17:"h2",18:"h3",19:"h4",20:"h5",21:"h6",22:"hr",html:{attributes:["xmlns"]},23:"i",img:{attributes:["alt","src","height","ismap","longdesc","usemap","width"],
required:["alt","src"]},input:{attributes:{0:"accept",1:"alt",checked:/^(checked)$/,disabled:/^(disabled)$/,maxlength:/^(\d)+$/,2:"name",readonly:/^(readonly)$/,size:/^(\d)+$/,3:"src",type:/^(button|checkbox|file|hidden|image|password|radio|reset|submit|text)$/,4:"value"},inside:"form"},ins:{attributes:{0:"cite",datetime:/^([0-9]){8}/}},24:"kbd",label:{attributes:["for"],inside:"form"},25:"legend",26:"li",link:{attributes:{0:"charset",1:"href",2:"hreflang",media:/^(all|braille|print|projection|screen|speech|,|;| )+$/i,rel:/^(alternate|appendix|bookmark|chapter|contents|copyright|glossary|help|home|index|next|prev|section|start|stylesheet|subsection| |shortcut|icon)+$/i,rev:/^(alternate|appendix|bookmark|chapter|contents|copyright|glossary|help|home|index|next|prev|section|start|stylesheet|subsection| |shortcut|icon)+$/i,3:"type"},inside:"head"},map:{attributes:["id","name"],required:["id"]},meta:{attributes:{0:"content","http-equiv":/^(content\-type|expires|refresh|set\-cookie)$/i,1:"name",2:"scheme"},required:["content"]},27:"noscript",object:{attributes:["archive","classid","codebase","codetype","data","declare","height","name","standby","type","usemap","width"]},28:"ol",optgroup:{attributes:{0:"label",disabled:/^(disabled)$/},required:["label"]},option:{attributes:{0:"label",disabled:/^(disabled)$/,selected:/^(selected)$/,1:"value"},inside:"select"},29:"p",param:{attributes:{0:"type",valuetype:/^(data|ref|object)$/,1:"valuetype",2:"value"},required:["name"]},30:"pre",q:{attributes:["cite"]},31:"samp",script:{attributes:{type:/^(text\/ecmascript|text\/javascript|text\/jscript|text\/vbscript|text\/vbs|text\/xml)$/,0:"charset",defer:/^(defer)$/,1:"src"},required:["type"]},select:{attributes:{disabled:/^(disabled)$/,multiple:/^(multiple)$/,0:"name",1:"size"},inside:"form"},32:"small",33:"span",34:"strong",style:{attributes:{0:"type",media:/^(screen|tty|tv|projection|handheld|print|braille|aural|all)$/},required:["type"]},35:"sub",36:"sup",table:{attributes:{0:"border",1:"cellpadding",2:"cellspacing",frame:/^(void|above|below|hsides|lhs|rhs|vsides|box|border)$/,rules:/^(none|groups|rows|cols|all)$/,3:"summary",4:"width"}},tbody:{attributes:{align:/^(right|left|center|justify)$/,0:"char",1:"charoff",valign:/^(top|middle|bottom|baseline)$/}},td:{attributes:{0:"abbr",align:/^(left|right|center|justify|char)$/,1:"axis",2:"char",3:"charoff",colspan:/^(\d)+$/,4:"headers",rowspan:/^(\d)+$/,scope:/^(col|colgroup|row|rowgroup)$/,valign:/^(top|middle|bottom|baseline)$/}},textarea:{attributes:["cols","rows","disabled","name","readonly"],required:["cols","rows"],inside:"form"},tfoot:{attributes:{align:/^(right|left|center|justify)$/,0:"char",1:"charoff",valign:/^(top|middle|bottom)$/,2:"baseline"}},th:{attributes:{0:"abbr",align:/^(left|right|center|justify|char)$/,1:"axis",2:"char",3:"charoff",colspan:/^(\d)+$/,4:"headers",rowspan:/^(\d)+$/,scope:/^(col|colgroup|row|rowgroup)$/,valign:/^(top|middle|bottom|baseline)$/}},thead:{attributes:{align:/^(right|left|center|justify)$/,0:"char",1:"charoff",valign:/^(top|middle|bottom|baseline)$/}},37:"title",tr:{attributes:{align:/^(right|left|center|justify|char)$/,0:"char",1:"charoff",valign:/^(top|middle|bottom|baseline)$/}},38:"tt",39:"ul",40:"var"},skiped_attributes:[],skiped_attribute_values:[],getValidTagAttributes:function(a,b){var c={},d=this.getPossibleTagAttributes(a);for(var e in b){var f=b[e],g=WYMeditor.Helper;g.contains(this.skiped_attributes,e)||g.contains(this.skiped_attribute_values,f)||"function"!=typeof f&&g.contains(d,e)&&(this.doesAttributeNeedsValidation(a,e)?this.validateAttribute(a,e,f)&&(c[e]=f):c[e]=f)}return c},getUniqueAttributesAndEventsForTag:function(a){var b=[];if(this._tags[a]&&this._tags[a].attributes)for(k in this._tags[a].attributes)b.push(parseInt(k)==k?this._tags[a].attributes[k]:k);return b},getDefaultAttributesAndEventsForTags:function(){var a=[];for(var b in this._events)a.push(this._events[b]);for(var b in this._attributes)a.push(this._attributes[b]);return a},isValidTag:function(a){if(this._tags[a])return!0;for(var b in this._tags)if(this._tags[b]==a)return!0;return!1},getDefaultAttributesAndEventsForTag:function(a){var b=[];if(this.isValidTag(a)){var c=this.getDefaultAttributesAndEventsForTags();for(var d in c){var e=c[d];if("object"==typeof e){var f=WYMeditor.Helper;if(e.except&&f.contains(e.except,a)||e.only&&!f.contains(e.only,a))continue;var g=e.attributes?e.attributes:e.events;for(var h in g)b.push("string"!=typeof g[h]?h:g[h])}}}return b},doesAttributeNeedsValidation:function(a,b){return this._tags[a]&&(this._tags[a].attributes&&this._tags[a].attributes[b]||this._tags[a].required&&WYMeditor.Helper.contains(this._tags[a].required,b))},validateAttribute:function(a,b,c){return this._tags[a]&&this._tags[a].attributes&&this._tags[a].attributes[b]&&c.length>0&&!c.match(this._tags[a].attributes[b])||this._tags[a]&&this._tags[a].required&&WYMeditor.Helper.contains(this._tags[a].required,b)&&0==c.length?!1:"undefined"!=typeof this._tags[a]},getPossibleTagAttributes:function(a){return this._possible_tag_attributes||(this._possible_tag_attributes={}),this._possible_tag_attributes[a]||(this._possible_tag_attributes[a]=this.getUniqueAttributesAndEventsForTag(a).concat(this.getDefaultAttributesAndEventsForTag(a))),this._possible_tag_attributes[a]}},WYMeditor.ParallelRegex=function(a){return this._case=a,this._patterns=[],this._labels=[],this._regex=null,this},WYMeditor.ParallelRegex.prototype.addPattern=function(a,b){b=b||!0;var c=this._patterns.length;this._patterns[c]=a,this._labels[c]=b,this._regex=null},WYMeditor.ParallelRegex.prototype.match=function(a){if(0==this._patterns.length)return[!1,""];var b=a.match(this._getCompoundedRegex());if(!b)return[!1,""];for(var c=b[0],d=1;d<b.length;d++)if(b[d])return[this._labels[d-1],c];return[!0,b[0]]},WYMeditor.ParallelRegex.prototype._getCompoundedRegex=function(){if(null==this._regex){for(var a=0,b=this._patterns.length;b>a;a++)this._patterns[a]="("+this._untokenizeRegex(this._tokenizeRegex(this._patterns[a]).replace(/([\/\(\)])/g,"\\$1"))+")";this._regex=new RegExp(this._patterns.join("|"),this._getPerlMatchingFlags())}return this._regex},WYMeditor.ParallelRegex.prototype._tokenizeRegex=function(a){return a.replace(/\(\?(i|m|s|x|U)\)/,"~~~~~~Tk1$1~~~~~~").replace(/\(\?(\-[i|m|s|x|U])\)/,"~~~~~~Tk2$1~~~~~~").replace(/\(\?\=(.*)\)/,"~~~~~~Tk3$1~~~~~~").replace(/\(\?\!(.*)\)/,"~~~~~~Tk4$1~~~~~~").replace(/\(\?\<\=(.*)\)/,"~~~~~~Tk5$1~~~~~~").replace(/\(\?\<\!(.*)\)/,"~~~~~~Tk6$1~~~~~~").replace(/\(\?\:(.*)\)/,"~~~~~~Tk7$1~~~~~~")},WYMeditor.ParallelRegex.prototype._untokenizeRegex=function(a){return a.replace(/~~~~~~Tk1(.{1})~~~~~~/,"(?$1)").replace(/~~~~~~Tk2(.{2})~~~~~~/,"(?$1)").replace(/~~~~~~Tk3(.*)~~~~~~/,"(?=$1)").replace(/~~~~~~Tk4(.*)~~~~~~/,"(?!$1)").replace(/~~~~~~Tk5(.*)~~~~~~/,"(?<=$1)").replace(/~~~~~~Tk6(.*)~~~~~~/,"(?<!$1)").replace(/~~~~~~Tk7(.*)~~~~~~/,"(?:$1)")},WYMeditor.ParallelRegex.prototype._getPerlMatchingFlags=function(){return this._case?"m":"mi"},WYMeditor.StateStack=function(a){return this._stack=[a],this},WYMeditor.StateStack.prototype.getCurrent=function(){return this._stack[this._stack.length-1]},WYMeditor.StateStack.prototype.enter=function(a){this._stack.push(a)},WYMeditor.StateStack.prototype.leave=function(){return 1==this._stack.length?!1:(this._stack.pop(),!0)},WYMeditor.LEXER_ENTER=1,WYMeditor.LEXER_MATCHED=2,WYMeditor.LEXER_UNMATCHED=3,WYMeditor.LEXER_EXIT=4,WYMeditor.LEXER_SPECIAL=5,WYMeditor.Lexer=function(a,b,c){return b=b||"accept",this._case=c||!1,this._regexes={},this._parser=a,this._mode=new WYMeditor.StateStack(b),this._mode_handlers={},this._mode_handlers[b]=b,this},WYMeditor.Lexer.prototype.addPattern=function(a,b){var b=b||"accept";"undefined"==typeof this._regexes[b]&&(this._regexes[b]=new WYMeditor.ParallelRegex(this._case)),this._regexes[b].addPattern(a),"undefined"==typeof this._mode_handlers[b]&&(this._mode_handlers[b]=b)},WYMeditor.Lexer.prototype.addEntryPattern=function(a,b,c){"undefined"==typeof this._regexes[b]&&(this._regexes[b]=new WYMeditor.ParallelRegex(this._case)),this._regexes[b].addPattern(a,c),"undefined"==typeof this._mode_handlers[c]&&(this._mode_handlers[c]=c)},WYMeditor.Lexer.prototype.addExitPattern=function(a,b){"undefined"==typeof this._regexes[b]&&(this._regexes[b]=new WYMeditor.ParallelRegex(this._case)),this._regexes[b].addPattern(a,"__exit"),"undefined"==typeof this._mode_handlers[b]&&(this._mode_handlers[b]=b)},WYMeditor.Lexer.prototype.addSpecialPattern=function(a,b,c){"undefined"==typeof this._regexes[b]&&(this._regexes[b]=new WYMeditor.ParallelRegex(this._case)),this._regexes[b].addPattern(a,"_"+c),"undefined"==typeof this._mode_handlers[c]&&(this._mode_handlers[c]=c)},WYMeditor.Lexer.prototype.mapHandler=function(a,b){this._mode_handlers[a]=b},WYMeditor.Lexer.prototype.parse=function(a){if("undefined"==typeof this._parser)return!1;for(var b,c=a.length;"object"==typeof(b=this._reduce(a));){var a=b[0],d=b[1],e=b[2],f=b[3];if(!this._dispatchTokens(d,e,f))return!1;if(""==a)return!0;if(a.length==c)return!1;c=a.length}return b?this._invokeParser(a,WYMeditor.LEXER_UNMATCHED):!1},WYMeditor.Lexer.prototype._dispatchTokens=function(a,b,c){return c=c||!1,this._invokeParser(a,WYMeditor.LEXER_UNMATCHED)?"boolean"==typeof c?this._invokeParser(b,WYMeditor.LEXER_MATCHED):this._isModeEnd(c)?this._invokeParser(b,WYMeditor.LEXER_EXIT)?this._mode.leave():!1:this._isSpecialMode(c)?(this._mode.enter(this._decodeSpecial(c)),this._invokeParser(b,WYMeditor.LEXER_SPECIAL)?this._mode.leave():!1):(this._mode.enter(c),this._invokeParser(b,WYMeditor.LEXER_ENTER)):!1},WYMeditor.Lexer.prototype._isModeEnd=function(a){return"__exit"===a},WYMeditor.Lexer.prototype._isSpecialMode=function(a){return"_"==a.substring(0,1)},WYMeditor.Lexer.prototype._decodeSpecial=function(a){return a.substring(1)},WYMeditor.Lexer.prototype._invokeParser=function(content,is_match){if(!/ +/.test(content)&&(""===content||0==content))return!0;var current=this._mode.getCurrent(),handler=this._mode_handlers[current],result;return eval("result = this._parser."+handler+"(content, is_match);"),result},WYMeditor.Lexer.prototype._reduce=function(a){var b=this._regexes[this._mode.getCurrent()].match(a),c=b[1],d=b[0];if(d){var e=a.indexOf(c),f=a.substr(0,e);return a=a.substring(e+c.length),[a,f,c,d]}return!0},WYMeditor.XhtmlLexer=function(a){return jQuery.extend(this,new WYMeditor.Lexer(a,"Text")),this.mapHandler("Text","Text"),this.addTokens(),this.init(),this},WYMeditor.XhtmlLexer.prototype.init=function(){},WYMeditor.XhtmlLexer.prototype.addTokens=function(){this.addCommentTokens("Text"),this.addScriptTokens("Text"),this.addCssTokens("Text"),this.addTagTokens("Text")},WYMeditor.XhtmlLexer.prototype.addCommentTokens=function(a){this.addEntryPattern("<!--",a,"Comment"),this.addExitPattern("-->","Comment")},WYMeditor.XhtmlLexer.prototype.addScriptTokens=function(a){this.addEntryPattern("<script",a,"Script"),this.addExitPattern("</script>","Script")},WYMeditor.XhtmlLexer.prototype.addCssTokens=function(a){this.addEntryPattern("<style",a,"Css"),this.addExitPattern("</style>","Css")},WYMeditor.XhtmlLexer.prototype.addTagTokens=function(a){this.addSpecialPattern("<\\s*[a-z0-9:-]+\\s*>",a,"OpeningTag"),this.addEntryPattern("<[a-z0-9:-]+[\\/ \\>]+",a,"OpeningTag"),this.addInTagDeclarationTokens("OpeningTag"),this.addSpecialPattern("</\\s*[a-z0-9:-]+\\s*>",a,"ClosingTag")},WYMeditor.XhtmlLexer.prototype.addInTagDeclarationTokens=function(a){this.addSpecialPattern("\\s+",a,"Ignore"),this.addAttributeTokens(a),this.addExitPattern("/>",a),this.addExitPattern(">",a)},WYMeditor.XhtmlLexer.prototype.addAttributeTokens=function(a){this.addSpecialPattern("\\s*[a-z-_0-9]*:?[a-z-_0-9]+\\s*(?==)\\s*",a,"TagAttributes"),this.addEntryPattern('=\\s*"',a,"DoubleQuotedAttribute"),this.addPattern('\\\\"',"DoubleQuotedAttribute"),this.addExitPattern('"',"DoubleQuotedAttribute"),this.addEntryPattern("=\\s*'",a,"SingleQuotedAttribute"),this.addPattern("\\\\'","SingleQuotedAttribute"),this.addExitPattern("'","SingleQuotedAttribute"),this.addSpecialPattern("=\\s*[^>\\s]*",a,"UnquotedAttribute")},WYMeditor.XhtmlParser=function(a,b){var b=b||"Text";return this._Lexer=new WYMeditor.XhtmlLexer(this),this._Listener=a,this._mode=b,this._matches=[],this._last_match="",this._current_match="",this},WYMeditor.XhtmlParser.prototype.parse=function(a){return this._Lexer.parse(this.beforeParsing(a)),this.afterParsing(this._Listener.getResult())},WYMeditor.XhtmlParser.prototype.beforeParsing=function(a){return(a.match(/class="MsoNormal"/)||a.match(/ns = "urn:schemas-microsoft-com/))&&this._Listener.avoidStylingTagsAndAttributes(),this._Listener.beforeParsing(a)},WYMeditor.XhtmlParser.prototype.afterParsing=function(a){return this._Listener._avoiding_tags_implicitly&&this._Listener.allowStylingTagsAndAttributes(),this._Listener.afterParsing(a)},WYMeditor.XhtmlParser.prototype.Ignore=function(){return!0},WYMeditor.XhtmlParser.prototype.Text=function(a){return this._Listener.addContent(a),!0},WYMeditor.XhtmlParser.prototype.Comment=function(a,b){return this._addNonTagBlock(a,b,"addComment")},WYMeditor.XhtmlParser.prototype.Script=function(a,b){return this._addNonTagBlock(a,b,"addScript")},WYMeditor.XhtmlParser.prototype.Css=function(a,b){return this._addNonTagBlock(a,b,"addCss")},WYMeditor.XhtmlParser.prototype._addNonTagBlock=function(a,b,c){switch(b){case WYMeditor.LEXER_ENTER:this._non_tag=a;break;case WYMeditor.LEXER_UNMATCHED:this._non_tag+=a;break;case WYMeditor.LEXER_EXIT:switch(c){case"addComment":this._Listener.addComment(this._non_tag+a);break;case"addScript":this._Listener.addScript(this._non_tag+a);break;case"addCss":this._Listener.addCss(this._non_tag+a)}}return!0},WYMeditor.XhtmlParser.prototype.OpeningTag=function(a,b){switch(b){case WYMeditor.LEXER_ENTER:this._tag=this.normalizeTag(a),this._tag_attributes={};break;case WYMeditor.LEXER_SPECIAL:this._callOpenTagListener(this.normalizeTag(a));break;case WYMeditor.LEXER_EXIT:this._callOpenTagListener(this._tag,this._tag_attributes)}return!0},WYMeditor.XhtmlParser.prototype.ClosingTag=function(a){return this._callCloseTagListener(this.normalizeTag(a)),!0},WYMeditor.XhtmlParser.prototype._callOpenTagListener=function(a,b){var b=b||{};this.autoCloseUnclosedBeforeNewOpening(a),this._Listener.isBlockTag(a)?(this._Listener._tag_stack.push(a),this._Listener.fixNestingBeforeOpeningBlockTag(a,b),this._Listener.openBlockTag(a,b),this._increaseOpenTagCounter(a)):this._Listener.isInlineTag(a)?this._Listener.inlineTag(a,b):(this._Listener.openUnknownTag(a,b),this._increaseOpenTagCounter(a)),this._Listener.last_tag=a,this._Listener.last_tag_opened=!0,this._Listener.last_tag_attributes=b},WYMeditor.XhtmlParser.prototype._callCloseTagListener=function(a){if(this._decreaseOpenTagCounter(a))if(this.autoCloseUnclosedBeforeTagClosing(a),this._Listener.isBlockTag(a)){var b=this._Listener._tag_stack.pop();if(0==b)return;b!=a&&(a=b),this._Listener.closeBlockTag(a)}else this._Listener.closeUnknownTag(a);else this._Listener.closeUnopenedTag(a);this._Listener.last_tag=a,this._Listener.last_tag_opened=!1},WYMeditor.XhtmlParser.prototype._increaseOpenTagCounter=function(a){this._Listener._open_tags[a]=this._Listener._open_tags[a]||0,this._Listener._open_tags[a]++},WYMeditor.XhtmlParser.prototype._decreaseOpenTagCounter=function(a){return this._Listener._open_tags[a]?(this._Listener._open_tags[a]--,0==this._Listener._open_tags[a]&&(this._Listener._open_tags[a]=void 0),!0):!1},WYMeditor.XhtmlParser.prototype.autoCloseUnclosedBeforeNewOpening=function(a){this._autoCloseUnclosed(a,!1)},WYMeditor.XhtmlParser.prototype.autoCloseUnclosedBeforeTagClosing=function(a){this._autoCloseUnclosed(a,!0)},WYMeditor.XhtmlParser.prototype._autoCloseUnclosed=function(a,b){var b=b||!1;if(this._Listener._open_tags)for(var c in this._Listener._open_tags){var d=this._Listener._open_tags[c];d>0&&this._Listener.shouldCloseTagAutomatically(c,a,b)&&this._callCloseTagListener(c,!0)}},WYMeditor.XhtmlParser.prototype.getTagReplacements=function(){return this._Listener.getTagReplacements()},WYMeditor.XhtmlParser.prototype.normalizeTag=function(a){a=a.replace(/^([\s<\/>]*)|([\s<\/>]*)$/gm,"").toLowerCase();var b=this._Listener.getTagReplacements();return b[a]?b[a]:a},WYMeditor.XhtmlParser.prototype.TagAttributes=function(a,b){return WYMeditor.LEXER_SPECIAL==b&&(this._current_attribute=a),!0},WYMeditor.XhtmlParser.prototype.DoubleQuotedAttribute=function(a,b){return WYMeditor.LEXER_UNMATCHED==b&&(this._tag_attributes[this._current_attribute]=a),!0},WYMeditor.XhtmlParser.prototype.SingleQuotedAttribute=function(a,b){return WYMeditor.LEXER_UNMATCHED==b&&(this._tag_attributes[this._current_attribute]=a),!0},WYMeditor.XhtmlParser.prototype.UnquotedAttribute=function(a){return this._tag_attributes[this._current_attribute]=a.replace(/^=/,""),!0},WYMeditor.XhtmlSaxListener=function(){return this.output="",this.helper=new WYMeditor.XmlHelper,this._open_tags={},this.validator=WYMeditor.XhtmlValidator,this._tag_stack=[],this.avoided_tags=[],this.entities={"&nbsp;":"&#160;","&iexcl;":"&#161;","&cent;":"&#162;","&pound;":"&#163;","&curren;":"&#164;","&yen;":"&#165;","&brvbar;":"&#166;","&sect;":"&#167;","&uml;":"&#168;","&copy;":"&#169;","&ordf;":"&#170;","&laquo;":"&#171;","&not;":"&#172;","&shy;":"&#173;","&reg;":"&#174;","&macr;":"&#175;","&deg;":"&#176;","&plusmn;":"&#177;","&sup2;":"&#178;","&sup3;":"&#179;","&acute;":"&#180;","&micro;":"&#181;","&para;":"&#182;","&middot;":"&#183;","&cedil;":"&#184;","&sup1;":"&#185;","&ordm;":"&#186;","&raquo;":"&#187;","&frac14;":"&#188;","&frac12;":"&#189;","&frac34;":"&#190;","&iquest;":"&#191;","&Agrave;":"&#192;","&Aacute;":"&#193;","&Acirc;":"&#194;","&Atilde;":"&#195;","&Auml;":"&#196;","&Aring;":"&#197;","&AElig;":"&#198;","&Ccedil;":"&#199;","&Egrave;":"&#200;","&Eacute;":"&#201;","&Ecirc;":"&#202;","&Euml;":"&#203;","&Igrave;":"&#204;","&Iacute;":"&#205;","&Icirc;":"&#206;","&Iuml;":"&#207;","&ETH;":"&#208;","&Ntilde;":"&#209;","&Ograve;":"&#210;","&Oacute;":"&#211;","&Ocirc;":"&#212;","&Otilde;":"&#213;","&Ouml;":"&#214;","&times;":"&#215;","&Oslash;":"&#216;","&Ugrave;":"&#217;","&Uacute;":"&#218;","&Ucirc;":"&#219;","&Uuml;":"&#220;","&Yacute;":"&#221;","&THORN;":"&#222;","&szlig;":"&#223;","&agrave;":"&#224;","&aacute;":"&#225;","&acirc;":"&#226;","&atilde;":"&#227;","&auml;":"&#228;","&aring;":"&#229;","&aelig;":"&#230;","&ccedil;":"&#231;","&egrave;":"&#232;","&eacute;":"&#233;","&ecirc;":"&#234;","&euml;":"&#235;","&igrave;":"&#236;","&iacute;":"&#237;","&icirc;":"&#238;","&iuml;":"&#239;","&eth;":"&#240;","&ntilde;":"&#241;","&ograve;":"&#242;","&oacute;":"&#243;","&ocirc;":"&#244;","&otilde;":"&#245;","&ouml;":"&#246;","&divide;":"&#247;","&oslash;":"&#248;","&ugrave;":"&#249;","&uacute;":"&#250;","&ucirc;":"&#251;","&uuml;":"&#252;","&yacute;":"&#253;","&thorn;":"&#254;","&yuml;":"&#255;","&OElig;":"&#338;","&oelig;":"&#339;","&Scaron;":"&#352;","&scaron;":"&#353;","&Yuml;":"&#376;","&fnof;":"&#402;","&circ;":"&#710;","&tilde;":"&#732;","&Alpha;":"&#913;","&Beta;":"&#914;","&Gamma;":"&#915;","&Delta;":"&#916;","&Epsilon;":"&#917;","&Zeta;":"&#918;","&Eta;":"&#919;","&Theta;":"&#920;","&Iota;":"&#921;","&Kappa;":"&#922;","&Lambda;":"&#923;","&Mu;":"&#924;","&Nu;":"&#925;","&Xi;":"&#926;","&Omicron;":"&#927;","&Pi;":"&#928;","&Rho;":"&#929;","&Sigma;":"&#931;","&Tau;":"&#932;","&Upsilon;":"&#933;","&Phi;":"&#934;","&Chi;":"&#935;","&Psi;":"&#936;","&Omega;":"&#937;","&alpha;":"&#945;","&beta;":"&#946;","&gamma;":"&#947;","&delta;":"&#948;","&epsilon;":"&#949;","&zeta;":"&#950;","&eta;":"&#951;","&theta;":"&#952;","&iota;":"&#953;","&kappa;":"&#954;","&lambda;":"&#955;","&mu;":"&#956;","&nu;":"&#957;","&xi;":"&#958;","&omicron;":"&#959;","&pi;":"&#960;","&rho;":"&#961;","&sigmaf;":"&#962;","&sigma;":"&#963;","&tau;":"&#964;","&upsilon;":"&#965;","&phi;":"&#966;","&chi;":"&#967;","&psi;":"&#968;","&omega;":"&#969;","&thetasym;":"&#977;","&upsih;":"&#978;","&piv;":"&#982;","&ensp;":"&#8194;","&emsp;":"&#8195;","&thinsp;":"&#8201;","&zwnj;":"&#8204;","&zwj;":"&#8205;","&lrm;":"&#8206;","&rlm;":"&#8207;","&ndash;":"&#8211;","&mdash;":"&#8212;","&lsquo;":"&#8216;","&rsquo;":"&#8217;","&sbquo;":"&#8218;","&ldquo;":"&#8220;","&rdquo;":"&#8221;","&bdquo;":"&#8222;","&dagger;":"&#8224;","&Dagger;":"&#8225;","&bull;":"&#8226;","&hellip;":"&#8230;","&permil;":"&#8240;","&prime;":"&#8242;","&Prime;":"&#8243;","&lsaquo;":"&#8249;","&rsaquo;":"&#8250;","&oline;":"&#8254;","&frasl;":"&#8260;","&euro;":"&#8364;","&image;":"&#8465;","&weierp;":"&#8472;","&real;":"&#8476;","&trade;":"&#8482;","&alefsym;":"&#8501;","&larr;":"&#8592;","&uarr;":"&#8593;","&rarr;":"&#8594;","&darr;":"&#8595;","&harr;":"&#8596;","&crarr;":"&#8629;","&lArr;":"&#8656;","&uArr;":"&#8657;","&rArr;":"&#8658;","&dArr;":"&#8659;","&hArr;":"&#8660;","&forall;":"&#8704;","&part;":"&#8706;","&exist;":"&#8707;","&empty;":"&#8709;","&nabla;":"&#8711;","&isin;":"&#8712;","&notin;":"&#8713;","&ni;":"&#8715;","&prod;":"&#8719;","&sum;":"&#8721;","&minus;":"&#8722;","&lowast;":"&#8727;","&radic;":"&#8730;","&prop;":"&#8733;","&infin;":"&#8734;","&ang;":"&#8736;","&and;":"&#8743;","&or;":"&#8744;","&cap;":"&#8745;","&cup;":"&#8746;","&int;":"&#8747;","&there4;":"&#8756;","&sim;":"&#8764;","&cong;":"&#8773;","&asymp;":"&#8776;","&ne;":"&#8800;","&equiv;":"&#8801;","&le;":"&#8804;","&ge;":"&#8805;","&sub;":"&#8834;","&sup;":"&#8835;","&nsub;":"&#8836;","&sube;":"&#8838;","&supe;":"&#8839;","&oplus;":"&#8853;","&otimes;":"&#8855;","&perp;":"&#8869;","&sdot;":"&#8901;","&lceil;":"&#8968;","&rceil;":"&#8969;","&lfloor;":"&#8970;","&rfloor;":"&#8971;","&lang;":"&#9001;","&rang;":"&#9002;","&loz;":"&#9674;","&spades;":"&#9824;","&clubs;":"&#9827;","&hearts;":"&#9829;","&diams;":"&#9830;"},this.block_tags=["a","abbr","acronym","address","area","b","base","bdo","big","blockquote","body","button","caption","cite","code","col","colgroup","dd","del","div","dfn","dl","dt","em","fieldset","form","head","h1","h2","h3","h4","h5","h6","html","i","ins","kbd","label","legend","li","map","noscript","object","ol","optgroup","option","p","param","pre","q","samp","script","select","small","span","strong","style","sub","sup","table","tbody","td","textarea","tfoot","th","thead","title","tr","tt","ul","var","extends"],this.inline_tags=["br","hr","img","input"],this},WYMeditor.XhtmlSaxListener.prototype.shouldCloseTagAutomatically=function(a,b,c){var c=c||!1;return"td"==a&&(c&&"tr"==b||!c&&"td"==b)?!0:"option"==a&&(c&&"select"==b||!c&&"option"==b)?!0:!1},WYMeditor.XhtmlSaxListener.prototype.beforeParsing=function(a){return this.output="",a},WYMeditor.XhtmlSaxListener.prototype.afterParsing=function(a){return a=this.replaceNamedEntities(a),a=this.joinRepeatedEntities(a),a=this.removeEmptyTags(a),a=this.removeBrInPre(a)},WYMeditor.XhtmlSaxListener.prototype.replaceNamedEntities=function(a){for(var b in this.entities)a=a.replace(new RegExp(b,"g"),this.entities[b]);return a},WYMeditor.XhtmlSaxListener.prototype.joinRepeatedEntities=function(a){var b="em|strong|sub|sup|acronym|pre|del|address";return a.replace(new RegExp("</("+b+")><\\1>",""),"").replace(new RegExp("(s*<("+b+")>s*){2}(.*)(s*</\\2>s*){2}",""),"<$2>$3<$2>")},WYMeditor.XhtmlSaxListener.prototype.removeEmptyTags=function(a){return a.replace(new RegExp("<("+this.block_tags.join("|").replace(/\|td/,"").replace(/\|p/,"").replace(/\|th/,"")+")>(<br />|&#160;|&nbsp;|\\s)*</\\1>","g"),"")},WYMeditor.XhtmlSaxListener.prototype.removeBrInPre=function(a){var b=a.match(new RegExp("<pre[^>]*>(.*?)</pre>","gmi"));if(b)for(var c=0;c<b.length;c++)a=a.replace(b[c],b[c].replace(new RegExp("<br />","g"),String.fromCharCode(13,10)));return a},WYMeditor.XhtmlSaxListener.prototype.getResult=function(){return this.output},WYMeditor.XhtmlSaxListener.prototype.getTagReplacements=function(){return{b:"strong",i:"em"}},WYMeditor.XhtmlSaxListener.prototype.addContent=function(a){this.output+=a},WYMeditor.XhtmlSaxListener.prototype.addComment=function(a){this.remove_comments&&(this.output+=a)},WYMeditor.XhtmlSaxListener.prototype.addScript=function(a){this.remove_scripts||(this.output+=a)},WYMeditor.XhtmlSaxListener.prototype.addCss=function(a){this.remove_embeded_styles||(this.output+=a)},WYMeditor.XhtmlSaxListener.prototype.openBlockTag=function(a,b){this.output+=this.helper.tag(a,this.validator.getValidTagAttributes(a,b),!0)},WYMeditor.XhtmlSaxListener.prototype.inlineTag=function(a,b){this.output+=this.helper.tag(a,this.validator.getValidTagAttributes(a,b))},WYMeditor.XhtmlSaxListener.prototype.openUnknownTag=function(){},WYMeditor.XhtmlSaxListener.prototype.closeBlockTag=function(a){this.output=this.output.replace(/<br \/>$/,"")+this._getClosingTagContent("before",a)+"</"+a+">"+this._getClosingTagContent("after",a)},WYMeditor.XhtmlSaxListener.prototype.closeUnknownTag=function(){},WYMeditor.XhtmlSaxListener.prototype.closeUnopenedTag=function(a){this.output+="</"+a+">"},WYMeditor.XhtmlSaxListener.prototype.avoidStylingTagsAndAttributes=function(){this.avoided_tags=["div","span"],this.validator.skiped_attributes=["style"],this.validator.skiped_attribute_values=["MsoNormal","main1"],this._avoiding_tags_implicitly=!0},WYMeditor.XhtmlSaxListener.prototype.allowStylingTagsAndAttributes=function(){this.avoided_tags=[],this.validator.skiped_attributes=[],this.validator.skiped_attribute_values=[],this._avoiding_tags_implicitly=!1},WYMeditor.XhtmlSaxListener.prototype.isBlockTag=function(a){return!WYMeditor.Helper.contains(this.avoided_tags,a)&&WYMeditor.Helper.contains(this.block_tags,a)},WYMeditor.XhtmlSaxListener.prototype.isInlineTag=function(a){return!WYMeditor.Helper.contains(this.avoided_tags,a)&&WYMeditor.Helper.contains(this.inline_tags,a)},WYMeditor.XhtmlSaxListener.prototype.insertContentAfterClosingTag=function(a,b){this._insertContentWhenClosingTag("after",a,b)},WYMeditor.XhtmlSaxListener.prototype.insertContentBeforeClosingTag=function(a,b){this._insertContentWhenClosingTag("before",a,b)},WYMeditor.XhtmlSaxListener.prototype.fixNestingBeforeOpeningBlockTag=function(a){"li"==a||"ul"!=a&&"ol"!=a||!this.last_tag||this.last_tag_opened||"li"!=this.last_tag||(this.output=this.output.replace(/<\/li>$/,""),this.insertContentAfterClosingTag(a,"</li>"))},WYMeditor.XhtmlSaxListener.prototype._insertContentWhenClosingTag=function(a,b,c){this["_insert_"+a+"_closing"]||(this["_insert_"+a+"_closing"]=[]),this["_insert_"+a+"_closing"][b]||(this["_insert_"+a+"_closing"][b]=[]),this["_insert_"+a+"_closing"][b].push(c)},WYMeditor.XhtmlSaxListener.prototype._getClosingTagContent=function(a,b){return this["_insert_"+a+"_closing"]&&this["_insert_"+a+"_closing"][b]&&this["_insert_"+a+"_closing"][b].length>0?this["_insert_"+a+"_closing"][b].pop():""},WYMeditor.WymCssLexer=function(a,b){var b="undefined"==typeof b?!0:b;return jQuery.extend(this,new WYMeditor.Lexer(a,b?"Ignore":"WymCss")),this.mapHandler("WymCss","Ignore"),1==b&&(this.addEntryPattern("/\\*[<\\s]*WYMeditor[>\\s]*\\*/","Ignore","WymCss"),this.addExitPattern("/\\*[</\\s]*WYMeditor[>\\s]*\\*/","WymCss")),this.addSpecialPattern("[\\sa-z1-6]*\\.[a-z-_0-9]+","WymCss","WymCssStyleDeclaration"),this.addEntryPattern("/\\*","WymCss","WymCssComment"),this.addExitPattern("\\*/","WymCssComment"),this.addEntryPattern("{","WymCss","WymCssStyle"),this.addExitPattern("}","WymCssStyle"),this.addEntryPattern("/\\*","WymCssStyle","WymCssFeedbackStyle"),this.addExitPattern("\\*/","WymCssFeedbackStyle"),this},WYMeditor.WymCssParser=function(){return this._in_style=!1,this._has_title=!1,this.only_wym_blocks=!0,this.css_settings={classesItems:[],editorStyles:[],dialogStyles:[]},this},WYMeditor.WymCssParser.prototype.parse=function(a,b){var b="undefined"==typeof b?this.only_wym_blocks:b;this._Lexer=new WYMeditor.WymCssLexer(this,b),this._Lexer.parse(a)},WYMeditor.WymCssParser.prototype.Ignore=function(){return!0},WYMeditor.WymCssParser.prototype.WymCssComment=function(a,b){return a.match(/end[a-z0-9\s]*wym[a-z0-9\s]*/im)?!1:(b==WYMeditor.LEXER_UNMATCHED&&(this._in_style?this._current_item[this._current_element]&&(this._current_item[this._current_element].expressions?this._current_item[this._current_element].expressions.push(a):this._current_item[this._current_element].expressions=[a]):(this._has_title=!0,this._current_item={title:WYMeditor.Helper.trim(a)}),this._in_style=!0),!0)},WYMeditor.WymCssParser.prototype.WymCssStyle=function(a,b){return b==WYMeditor.LEXER_UNMATCHED?(a=WYMeditor.Helper.trim(a),""!=a&&(this._current_item[this._current_element].style=a)):b==WYMeditor.LEXER_EXIT&&(this._in_style=!1,this._has_title=!1,this.addStyleSetting(this._current_item)),!0},WYMeditor.WymCssParser.prototype.WymCssFeedbackStyle=function(a,b){return b==WYMeditor.LEXER_UNMATCHED&&(this._current_item[this._current_element].feedback_style=a.replace(/^([\s\/\*]*)|([\s\/\*]*)$/gm,"")),!0},WYMeditor.WymCssParser.prototype.WymCssStyleDeclaration=function(a){a=a.replace(/^([\s\.]*)|([\s\.*]*)$/gm,"");var b="";if(a.indexOf(".")>0){var c=a.split(".");this._current_element=c[1];var b=c[0]}else this._current_element=a;return this._has_title||(this._current_item={title:(b?b.toUpperCase()+": ":"")+this._current_element},this._has_title=!0),this._current_item[this._current_element]||(this._current_item[this._current_element]={name:this._current_element}),b&&(this._current_item[this._current_element].tags?this._current_item[this._current_element].tags.push(b):this._current_item[this._current_element].tags=[b]),!0},WYMeditor.WymCssParser.prototype.addStyleSetting=function(a){for(var b in a){var c=a[b];"object"==typeof c&&"title"!=b&&(this.css_settings.classesItems.push({name:WYMeditor.Helper.trim(c.name),title:a.title,expr:WYMeditor.Helper.trim((c.expressions||c.tags).join(", "))}),c.feedback_style&&this.css_settings.editorStyles.push({name:"."+WYMeditor.Helper.trim(c.name),css:c.feedback_style}),c.style&&this.css_settings.dialogStyles.push({name:"."+WYMeditor.Helper.trim(c.name),css:c.style}))}},jQuery.fn.isPhantomNode=function(){return 3==this[0].nodeType?!/[^\t\n\r ]/.test(this[0].data):!1},WYMeditor.isPhantomNode=function(a){return 3==a.nodeType?!/[^\t\n\r ]/.test(a.data):!1},WYMeditor.isPhantomString=function(a){return!/[^\t\n\r ]/.test(a)},jQuery.fn.parentsOrSelf=function(a){var b=this;return 3==b[0].nodeType&&(b=b.parents().slice(0,1)),1==b.filter(a).size()?b:b.parents(a).slice(0,1)},WYMeditor.Helper={replaceAll:function(a,b,c){var d=new RegExp(b,"g");return a.replace(d,c)},insertAt:function(a,b,c){return a.substr(0,c)+b+a.substring(c)},trim:function(a){return a.replace(/^(\s*)|(\s*)$/gm,"")},contains:function(a,b){for(var c=0;c<a.length;c++)if(a[c]===b)return!0;return!1},indexOf:function(a,b){for(var c=-1,d=0;d<a.length;d++)if(a[d]==b){c=d;break}return c},findByName:function(a,b){for(var c=0;c<a.length;c++){var d=a[c];if(d.name==b)return d}return null}},WYMeditor.WymClassExplorer=function(a){this._wym=a,this._class="className",this._newLine="\r\n"},WYMeditor.WymClassExplorer.prototype.initIframe=function(iframe){this._iframe=iframe,this._doc=iframe.contentWindow.document;var styles=this._doc.styleSheets[0],aCss=eval(this._options.editorStyles);this.addCssRules(this._doc,aCss),this._doc.title=this._wym._index,jQuery("html",this._doc).attr("dir",this._options.direction),jQuery(this._doc.body).html(this._wym._html);var wym=this;this._doc.body.onfocus=function(){wym._doc.designMode="on",wym._doc=iframe.contentWindow.document},this._doc.onbeforedeactivate=function(){wym.saveCaret()},this._doc.onkeyup=function(){wym.saveCaret(),wym.keyup()},this._doc.onclick=function(){wym.saveCaret()},this._doc.body.onbeforepaste=function(){wym._iframe.contentWindow.event.returnValue=!1},this._doc.body.onpaste=function(){wym._iframe.contentWindow.event.returnValue=!1,wym.paste(window.clipboardData.getData("Text"))},this._initialized&&(jQuery.isFunction(this._options.preBind)&&this._options.preBind(this),this._wym.bindEvents(),jQuery.isFunction(this._options.postInit)&&this._options.postInit(this),this.listen()),this._initialized=!0,
this._doc.designMode="on";try{this._doc=iframe.contentWindow.document}catch(e){}},WYMeditor.WymClassExplorer.prototype._exec=function(a,b){switch(a){case WYMeditor.INDENT:case WYMeditor.OUTDENT:var c=this.findUp(this.container(),WYMeditor.LI);if(c){var d=c.parentNode.parentNode;(c.parentNode.childNodes.length>1||d.tagName.toLowerCase()==WYMeditor.OL||d.tagName.toLowerCase()==WYMeditor.UL)&&this._doc.execCommand(a)}break;default:b?this._doc.execCommand(a,!1,b):this._doc.execCommand(a)}this.listen()},WYMeditor.WymClassExplorer.prototype.selected=function(){var a=this._iframe.contentWindow.document.caretPos;return null!=a&&void 0!=a.parentElement?a.parentElement():void 0},WYMeditor.WymClassExplorer.prototype.saveCaret=function(){this._doc.caretPos=this._doc.selection.createRange()},WYMeditor.WymClassExplorer.prototype.addCssRule=function(a,b){a.addRule(b.name,b.css)},WYMeditor.WymClassExplorer.prototype.insert=function(a){var b=this._doc.selection.createRange();if(jQuery(b.parentElement()).parents(this._options.iframeBodySelector).is("*"))try{b.pasteHTML(a)}catch(c){}else this.paste(a)},WYMeditor.WymClassExplorer.prototype.wrap=function(a,b){var c=this._doc.selection.createRange();if(jQuery(c.parentElement()).parents(this._options.iframeBodySelector).is("*"))try{c.pasteHTML(a+c.text+b)}catch(d){}},WYMeditor.WymClassExplorer.prototype.unwrap=function(){var a=this._doc.selection.createRange();if(jQuery(a.parentElement()).parents(this._options.iframeBodySelector).is("*"))try{var b=a.text;this._exec("Cut"),a.pasteHTML(b)}catch(c){}},WYMeditor.WymClassExplorer.prototype.keyup=function(){this._selected_image=null},WYMeditor.WymClassExplorer.prototype.setFocusToNode=function(a){var b=this._doc.selection.createRange();b.moveToElementText(a),b.collapse(!1),b.move("character",-1),b.select(),a.focus()},WYMeditor.WymClassMozilla=function(a){this._wym=a,this._class="class",this._newLine="\n"},WYMeditor.WymClassMozilla.prototype.initIframe=function(iframe){this._iframe=iframe,this._doc=iframe.contentDocument;var styles=this._doc.styleSheets[0],aCss=eval(this._options.editorStyles);this.addCssRules(this._doc,aCss),this._doc.title=this._wym._index,jQuery("html",this._doc).attr("dir",this._options.direction),this.html(this._wym._html),this.enableDesignMode(),jQuery.isFunction(this._options.preBind)&&this._options.preBind(this),this._wym.bindEvents(),jQuery(this._doc).bind("keydown",this.keydown),jQuery(this._doc).bind("keyup",this.keyup),jQuery(this._doc).bind("focus",this.enableDesignMode),jQuery.isFunction(this._options.postInit)&&this._options.postInit(this),this.listen()},WYMeditor.WymClassMozilla.prototype.html=function(a){if("string"!=typeof a)return jQuery(this._doc.body).html();try{this._doc.designMode="off"}catch(b){}a=a.replace(/<em(\b[^>]*)>/gi,"<i$1>").replace(/<\/em>/gi,"</i>").replace(/<strong(\b[^>]*)>/gi,"<b$1>").replace(/<\/strong>/gi,"</b>"),jQuery(this._doc.body).html(a),this.enableDesignMode()},WYMeditor.WymClassMozilla.prototype._exec=function(a,b){if(!this.selected())return!1;switch(a){case WYMeditor.INDENT:case WYMeditor.OUTDENT:var c=this.selected(),d=this._iframe.contentWindow.getSelection(),e=d.anchorNode;if("#text"==e.nodeName&&(e=e.parentNode),c=this.findUp(c,WYMeditor.BLOCKS),e=this.findUp(e,WYMeditor.BLOCKS),c&&c==e&&c.tagName.toLowerCase()==WYMeditor.LI){var f=c.parentNode.parentNode;(c.parentNode.childNodes.length>1||f.tagName.toLowerCase()==WYMeditor.OL||f.tagName.toLowerCase()==WYMeditor.UL)&&this._doc.execCommand(a,"",null)}break;default:b?this._doc.execCommand(a,"",b):this._doc.execCommand(a,"",null)}var g=this.selected();g.tagName.toLowerCase()==WYMeditor.BODY&&this._exec(WYMeditor.FORMAT_BLOCK,WYMeditor.P),this.listen()},WYMeditor.WymClassMozilla.prototype.selected=function(){var a=this._iframe.contentWindow.getSelection(),b=a.focusNode;return b?"#text"==b.nodeName?b.parentNode:b:null},WYMeditor.WymClassMozilla.prototype.addCssRule=function(a,b){a.insertRule(b.name+" {"+b.css+"}",a.cssRules.length)},WYMeditor.WymClassMozilla.prototype.keydown=function(a){var b=WYMeditor.INSTANCES[this.title],c=null;if(a.keyCode===WYMeditor.KEY.ENTER&&(c=b.selected())){var d=$(c),e=(d.parent(),d.parents(".embedded-item"));if(e.size()){var f=$("<p/>");return d.hasClass("title")?e.before(f):d.hasClass("content")&&e.after(f),b.setFocusToNode(f.get(0)),!1}}if(a.ctrlKey){if(66==a.keyCode)return b._exec(WYMeditor.BOLD),!1;if(73==a.keyCode)return b._exec(WYMeditor.ITALIC),!1}else 13==a.keyCode&&(a.shiftKey||(c=b.selected(),c&&c.tagName.toLowerCase()==WYMeditor.PRE&&(a.preventDefault(),b.insert("<p></p>"))))},WYMeditor.WymClassMozilla.prototype.keyup=function(a){var b=WYMeditor.INSTANCES[this.title];b._selected_image=null;var c=null;if(13!=a.keyCode||a.shiftKey){if(8!=a.keyCode&&17!=a.keyCode&&46!=a.keyCode&&224!=a.keyCode&&!a.metaKey&&!a.ctrlKey){c=b.selected();var d=c.tagName.toLowerCase();("strong"==d||"b"==d||"em"==d||"i"==d||"sub"==d||"sup"==d||"a"==d)&&(d=c.parentNode.tagName.toLowerCase()),d==WYMeditor.BODY&&b._exec(WYMeditor.FORMAT_BLOCK,WYMeditor.P)}}else jQuery(b._doc.body).children(WYMeditor.BR).remove()},WYMeditor.WymClassMozilla.prototype.enableDesignMode=function(){if("off"==this.designMode)try{this.designMode="on",this.execCommand("styleWithCSS","",!1)}catch(a){}},WYMeditor.WymClassMozilla.prototype.setFocusToNode=function(a){var b=document.createRange();b.selectNode(a);var c=this._iframe.contentWindow.getSelection();c.addRange(b),c.collapse(a,a.childNodes.length),this._iframe.contentWindow.focus()},WYMeditor.WymClassMozilla.prototype.openBlockTag=function(a,b){var b=this.validator.getValidTagAttributes(a,b);if("span"==a&&b.style){var c=this.getTagForStyle(b.style);if(!c)return;this._tag_stack.pop();var a=c;this._tag_stack.push(c),b.style=""}this.output+=this.helper.tag(a,b,!0)},WYMeditor.WymClassMozilla.prototype.getTagForStyle=function(a){return/bold/.test(a)?"strong":/italic/.test(a)?"em":/sub/.test(a)?"sub":/sub/.test(a)?"super":!1},WYMeditor.WymClassOpera=function(a){this._wym=a,this._class="class",this._newLine="\r\n"},WYMeditor.WymClassOpera.prototype.initIframe=function(iframe){this._iframe=iframe,this._doc=iframe.contentWindow.document;var styles=this._doc.styleSheets[0],aCss=eval(this._options.editorStyles);this.addCssRules(this._doc,aCss),this._doc.title=this._wym._index,jQuery("html",this._doc).attr("dir",this._options.direction),this._doc.designMode="on",this.html(this._wym._html),jQuery.isFunction(this._options.preBind)&&this._options.preBind(this),this._wym.bindEvents(),jQuery(this._doc).bind("keydown",this.keydown),jQuery(this._doc).bind("keyup",this.keyup),jQuery.isFunction(this._options.postInit)&&this._options.postInit(this),this.listen()},WYMeditor.WymClassOpera.prototype._exec=function(a,b){b?this._doc.execCommand(a,!1,b):this._doc.execCommand(a),this.listen()},WYMeditor.WymClassOpera.prototype.selected=function(){var a=this._iframe.contentWindow.getSelection(),b=a.focusNode;return b?"#text"==b.nodeName?b.parentNode:b:null},WYMeditor.WymClassOpera.prototype.addCssRule=function(a,b){a.insertRule(b.name+" {"+b.css+"}",a.cssRules.length)},WYMeditor.WymClassOpera.prototype.keydown=function(a){var b=WYMeditor.INSTANCES[this.title],c=b._iframe.contentWindow.getSelection();startNode=c.getRangeAt(0).startContainer,jQuery(startNode).parentsOrSelf(WYMeditor.MAIN_CONTAINERS.join(","))[0]||jQuery(startNode).parentsOrSelf("li")||a.keyCode==WYMeditor.KEY.ENTER||a.keyCode==WYMeditor.KEY.LEFT||a.keyCode==WYMeditor.KEY.UP||a.keyCode==WYMeditor.KEY.RIGHT||a.keyCode==WYMeditor.KEY.DOWN||a.keyCode==WYMeditor.KEY.BACKSPACE||a.keyCode==WYMeditor.KEY.DELETE||b._exec(WYMeditor.FORMAT_BLOCK,WYMeditor.P)},WYMeditor.WymClassOpera.prototype.keyup=function(){var a=WYMeditor.INSTANCES[this.title];a._selected_image=null},WYMeditor.WymClassOpera.prototype.setFocusToNode=function(){},WYMeditor.WymClassSafari=function(a){this._wym=a,this._class="class",this._newLine="\n"},WYMeditor.WymClassSafari.prototype.initIframe=function(iframe){this._iframe=iframe,this._doc=iframe.contentDocument;var styles=this._doc.styleSheets[0],aCss=eval(this._options.editorStyles);this.addCssRules(this._doc,aCss),this._doc.title=this._wym._index,jQuery("html",this._doc).attr("dir",this._options.direction),this._doc.designMode="on",this.html(this._wym._html),jQuery.isFunction(this._options.preBind)&&this._options.preBind(this),this._wym.bindEvents(),jQuery(this._doc).bind("keydown",this.keydown),jQuery(this._doc).bind("keyup",this.keyup),jQuery.isFunction(this._options.postInit)&&this._options.postInit(this),this.listen()},WYMeditor.WymClassSafari.prototype._exec=function(a,b){if(!this.selected())return!1;switch(a){case WYMeditor.INDENT:case WYMeditor.OUTDENT:var c=this.selected(),d=this._iframe.contentWindow.getSelection(),e=d.anchorNode;if("#text"==e.nodeName&&(e=e.parentNode),c=this.findUp(c,WYMeditor.BLOCKS),e=this.findUp(e,WYMeditor.BLOCKS),c&&c==e&&c.tagName.toLowerCase()==WYMeditor.LI){var f=c.parentNode.parentNode;(c.parentNode.childNodes.length>1||f.tagName.toLowerCase()==WYMeditor.OL||f.tagName.toLowerCase()==WYMeditor.UL)&&this._doc.execCommand(a,"",null)}break;case WYMeditor.INSERT_ORDEREDLIST:case WYMeditor.INSERT_UNORDEREDLIST:this._doc.execCommand(a,"",null);var c=this.selected(),g=this.findUp(c,WYMeditor.MAIN_CONTAINERS);g&&jQuery(g).replaceWith(jQuery(g).html());break;default:b?this._doc.execCommand(a,"",b):this._doc.execCommand(a,"",null)}var g=this.selected();g&&g.tagName.toLowerCase()==WYMeditor.BODY&&this._exec(WYMeditor.FORMAT_BLOCK,WYMeditor.P),this.listen()},WYMeditor.WymClassSafari.prototype.selected=function(){var a=this._iframe.contentWindow.getSelection(),b=a.focusNode;return b?"#text"==b.nodeName?b.parentNode:b:null},WYMeditor.WymClassSafari.prototype.addCssRule=function(a,b){a.insertRule(b.name+" {"+b.css+"}",a.cssRules.length)},WYMeditor.WymClassSafari.prototype.keydown=function(a){var b=WYMeditor.INSTANCES[this.title];if(a.keyCode===WYMeditor.KEY.ENTER){var c=b.selected();if(c){var d=$(c),e=(d.parent(),d.parents(".embedded-item"));if(e.size()){var f=$("<p/>");return d.hasClass("title")?e.before(f):d.hasClass("content")&&e.after(f),b.setFocusToNode(f.get(0)),!1}}}if(a.ctrlKey){if(66==a.keyCode)return b._exec(WYMeditor.BOLD),!1;if(73==a.keyCode)return b._exec(WYMeditor.ITALIC),!1}},WYMeditor.WymClassSafari.prototype.keyup=function(a){var b=WYMeditor.INSTANCES[this.title];b._selected_image=null;var c=null;if(13!=a.keyCode||a.shiftKey||(jQuery(b._doc.body).children(WYMeditor.BR).remove(),c=b.selected(),c&&c.tagName.toLowerCase()==WYMeditor.PRE&&b._exec(WYMeditor.FORMAT_BLOCK,WYMeditor.P)),13==a.keyCode&&a.shiftKey&&b._exec("InsertLineBreak"),8!=a.keyCode&&17!=a.keyCode&&46!=a.keyCode&&224!=a.keyCode&&!a.metaKey&&!a.ctrlKey){c=b.selected();var d=c.tagName.toLowerCase();("strong"==d||"b"==d||"em"==d||"i"==d||"sub"==d||"sup"==d||"a"==d||"span"==d)&&(d=c.parentNode.tagName.toLowerCase()),(d==WYMeditor.BODY||d==WYMeditor.DIV)&&b._exec(WYMeditor.FORMAT_BLOCK,WYMeditor.P)}},WYMeditor.WymClassSafari.prototype.setFocusToNode=function(a){var b=this._iframe.contentDocument.createRange();b.selectNode(a);var c=this._iframe.contentWindow.getSelection();c.addRange(b),c.collapse(a,a.childNodes.length),this._iframe.contentWindow.focus()},WYMeditor.WymClassSafari.prototype.openBlockTag=function(a,b){var b=this.validator.getValidTagAttributes(a,b);if("span"==a&&b.style){var c=this.getTagForStyle(b.style);if(!c)return;this._tag_stack.pop();var a=c;this._tag_stack.push(c),b.style="","string"==typeof b.class&&(b.class=b.class.replace(/apple-style-span/gi,""))}this.output+=this.helper.tag(a,b,!0)},WYMeditor.WymClassSafari.prototype.getTagForStyle=function(a){return/bold/.test(a)?"strong":/italic/.test(a)?"em":/sub/.test(a)?"sub":/super/.test(a)?"sup":!1};
//# sourceMappingURL=../../../maps/libs/jquery/jquery.wymeditor.js.map