HTMLArea.RemoveFormat=HTMLArea.Plugin.extend({constructor:function(editor,pluginName){this.base(editor,pluginName);},configurePlugin:function(editor){var pluginInformation={version:'2.1',developer:'Stanislas Rolland',developerUrl:'http://www.sjbr.ca/',copyrightOwner:'Stanislas Rolland',sponsor:'SJBR',sponsorUrl:'http://www.sjbr.ca/',license:'GPL',hasHelp:true};this.registerPluginInformation(pluginInformation);var buttonId='RemoveFormat';var buttonConfiguration={id:buttonId,tooltip:this.localize(buttonId+'Tooltip'),iconCls:'htmlarea-action-remove-format',action:'onButtonPress',dialog:true};this.registerButton(buttonConfiguration);return true;},onButtonPress:function(editor,id,target){var buttonId=this.translateHotKey(id);buttonId=buttonId?buttonId:id;this.openDialogue(buttonId,'Remove formatting',this.getWindowDimensions({width:260,height:260},buttonId));return false;},openDialogue:function(buttonId,title,dimensions){this.dialog=new Ext.Window({title:this.getHelpTip('',title),cls:'htmlarea-window',border:false,width:dimensions.width,height:'auto',resizable:!Ext.isIE,iconCls:this.getButton(buttonId).iconCls,listeners:{close:{fn:this.onClose,scope:this}},items:[{xtype:'fieldset',title:this.getHelpTip('area','Cleaning Area'),defaultType:'radio',labelWidth:140,defaults:{labelSeparator:''},items:[{itemId:'selection',fieldLabel:this.getHelpTip('selection','Selection'),name:'htmlarea-removeFormat-area'},{itemId:'allContent',fieldLabel:this.getHelpTip('all','All'),checked:true,name:'htmlarea-removeFormat-area'}]},{xtype:'fieldset',defaultType:'checkbox',title:this.getHelpTip('options','Cleaning options'),labelWidth:170,defaults:{labelSeparator:''},items:[{itemId:'formatting',fieldLabel:this.getHelpTip('htmlFormat','Formatting:')},{itemId:'msWordFormatting',fieldLabel:this.getHelpTip('msWordFormat','MS Word Formatting:'),checked:true},{itemId:'typographical',fieldLabel:this.getHelpTip('typographicalPunctuation','Typographical punctuation:')},{itemId:'spaces',fieldLabel:this.getHelpTip('nonBreakingSpace','Spaces')},{itemId:'images',fieldLabel:this.getHelpTip('images','Images:')},{itemId:'allHtml',fieldLabel:this.getHelpTip('allHtml','All HTML:')}]}],buttons:[this.buildButtonConfig('OK',this.onOK),this.buildButtonConfig('Cancel',this.onCancel)]});this.show();},onOK:function(){var fields=['selection','allContent','formatting','msWordFormatting','typographical','spaces','images','allHtml'];var params={};Ext.each(fields,function(field){params[field]=this.dialog.find('itemId',field)[0].getValue();},this);if(params['allHtml']||params['formatting']||params['spaces']||params['images']||params['msWordFormatting']||params['typographical']){this.applyRequest(params);this.close();}else{TYPO3.Dialog.InformationDialog({title:this.getButton('RemoveFormat').tooltip.title,msg:this.localize('Select the type of formatting you wish to remove.')});}
return false;},applyRequest:function(params){var editor=this.editor;editor.focus();this.restoreSelection();if(params['allContent']){var html=editor.getInnerHTML();}else{var html=editor.getSelectedHTML();}
if(html){if(params['allHtml']){html=html.replace(/<[\!]*?[^<>]*?>/g,"");}
if(params['formatting']){html=html.replace(/<\/?(abbr|acronym|b|big|cite|code|em|font|i|q|s|samp|small|span|strike|strong|sub|sup|tt|u|var)(>|[^>a-zA-Z][^>]*>)/gi,'');html=html.replace(/[ \t\n\r]+(style|class|align|cellpadding|cellspacing|frame|bgcolor)=\"[^>\"]*\"/gi,"");}
if(params['spaces']){html=html.replace(/ /g," ");}
if(params['images']){html=html.replace(/<\/?img[^>]*>/gi,"");}
if(params['msWordFormatting']){html=html.replace(/[ \r\n\t]+/g," ");html=html.replace(/<(b|strong|i|em|p|li|ul) [^>]*>/gi,"<$1>");html=html.replace(/ (style|class|align)=\"[^>\"]*\"/gi,"");html=html.replace(/<\/?span[^>]*>/gi,"").replace(/<\/?div[^>]*>/gi,"").replace(/<\?xml:[^>]*>/gi,"").replace(/<\/?st1:[^>]*>/gi,"").replace(/<\/?[a-z]:[^>]*>/g,"").replace(/<\/?meta[^>]*>/g,"").replace(/<\/?link[^>]*>/g,"");html=html.replace(/