if(typeof(HTMLArea)=='undefined'){Ext.namespace('HTMLArea.CSS','HTMLArea.util.TYPO3','HTMLArea.util.Tips','HTMLArea.util.Color','Ext.ux.form','Ext.ux.menu','Ext.ux.Toolbar');Ext.apply(HTMLArea,{is_gecko:Ext.isGecko||Ext.isOpera||Ext.isWebKit,is_ff2:Ext.isGecko2,is_ie:Ext.isIE,is_safari:Ext.isWebKit,is_chrome:Ext.isChrome,is_opera:Ext.isOpera,RE_htmlTag:/<.[^<>]*?>/g,RE_tagName:/(<\/|<)\s*([^ \t\n>]+)/ig,RE_head:/
((.|\n)*?)<\/head>/i,RE_body:/((.|\n)*?)<\/body>/i,Reg_body:new RegExp('<\/?(body)[^>]*>','gi'),reservedClassNames:/htmlarea/,RE_email:/([0-9a-z]+([a-z0-9_-]*[0-9a-z])*){1}(\.[0-9a-z]+([a-z0-9_-]*[0-9a-z])*)*@([0-9a-z]+([a-z0-9_-]*[0-9a-z])*\.)+[a-z]{2,9}/i,RE_url:/(([^:/?#]+):\/\/)?(([a-z0-9_]+:[a-z0-9_]+@)?[a-z0-9_-]{2,}(\.[a-z0-9_-]{2,})+\.[a-z]{2,5}(:[0-9]+)?(\/\S+)*\/?)/i,RE_blockTags:/^(body|p|h1|h2|h3|h4|h5|h6|ul|ol|pre|dl|dt|dd|div|noscript|blockquote|form|hr|table|caption|fieldset|address|td|tr|th|li|tbody|thead|tfoot|iframe)$/i,RE_closingTags:/^(p|blockquote|a|li|ol|ul|dl|dt|td|th|tr|tbody|thead|tfoot|caption|colgroup|table|div|b|bdo|big|cite|code|del|dfn|em|i|ins|kbd|label|q|samp|small|span|strike|strong|sub|sup|tt|u|var|abbr|acronym|font|center|object|embed|style|script|title|head)$/i,RE_noClosingTag:/^(img|br|hr|col|input|area|base|link|meta|param)$/i,RE_numberOrPunctuation:/[0-9.(),;:!¡?¿%#$'"_+=\\\/-]*/g,isIEBeforeIE9:Ext.isIE6||Ext.isIE7||Ext.isIE8||(Ext.isIE&&typeof(document.documentMode)!=='undefined'&&document.documentMode<9),_appendToLog:function(str){if(HTMLArea.enableDebugMode){var log=document.getElementById('HTMLAreaLog');if(log){log.appendChild(document.createTextNode(str));log.appendChild(document.createElement('br'));}}},appendToLog:function(editorId,objectName,functionName,text){HTMLArea._appendToLog(editorId+'['+objectName+'::'+functionName+']: '+text);},localize:function(label){return HTMLArea.I18N.dialogs[label]||HTMLArea.I18N.tooltips[label]||HTMLArea.I18N.msg[label]||'';},init:function(){Ext.apply(HTMLArea,RTEarea[0]);Ext.applyIf(HTMLArea,{editorSkin:HTMLArea.editorUrl+'skins/default/',editorCSS:HTMLArea.editorUrl+'skins/default/htmlarea.css'});if(!Ext.isString(HTMLArea.editedContentCSS)){HTMLArea.editedContentCSS=HTMLArea.editorSkin+'htmlarea-edited-content.css';}
HTMLArea.isReady=true;HTMLArea._appendToLog("[HTMLArea::init]: Editor url set to: "+HTMLArea.editorUrl);HTMLArea._appendToLog("[HTMLArea::init]: Editor skin CSS set to: "+HTMLArea.editorCSS);HTMLArea._appendToLog("[HTMLArea::init]: Editor content skin CSS set to: "+HTMLArea.editedContentCSS);}});HTMLArea.Config=function(editorId){this.editorId=editorId;this.useHTTPS=false;this.useCSS=false;this.enableMozillaExtension=true;this.disableEnterParagraphs=false;this.disableObjectResizing=false;this.removeTrailingBR=true;this.editedContentStyle=HTMLArea.editedContentCSS;this.pageStyle="";this.htmlRemoveTags=/none/i;this.htmlRemoveTagsAndContents=/none/i;this.htmlRemoveComments=false;this.customTags=[];this.baseURL=document.baseURI;if(!this.baseURL){var baseTags=document.getElementsByTagName('base');if(baseTags.length>0){this.baseURL=baseTags[0].href;}else{this.baseURL=document.URL;}}
if(this.baseURL&&this.baseURL.match(/(.*\:\/\/.*\/)[^\/]*/)){this.baseURL=RegExp.$1;}
this.popupURL="popups/";this.documentType='\r';this.blankDocument='';this.buttonsConfig={};this.hotKeyList={};this.configDefaults={all:{xtype:'htmlareabutton',disabledClass:'buttonDisabled',textMode:false,selection:false,dialog:false,hidden:false,hideMode:'display'},htmlareabutton:{cls:'button',overCls:'buttonHover',clickEvent:(Ext.isWebKit||Ext.isIE)?'mousedown':'click'},htmlareacombo:{cls:'select',typeAhead:true,lastQuery:'',triggerAction:'all',editable:!Ext.isIE,selectOnFocus:!Ext.isIE,validationEvent:false,validateOnBlur:false,submitValue:false,forceSelection:true,mode:'local',storeRoot:'options',storeFields:[{name:'text'},{name:'value'}],valueField:'value',displayField:'text',labelSeparator:'',hideLabel:true,tpl:'{text}
'}};};HTMLArea.Config=Ext.extend(HTMLArea.Config,{registerButton:function(config){config.itemId=config.id;if(Ext.type(this.buttonsConfig[config.id])){HTMLArea._appendToLog('[HTMLArea.Config::registerButton]: A toolbar item with the same Id: '+config.id+' already exists and will be overidden.');}
config=Ext.applyIf(config,this.configDefaults['all']);config=Ext.applyIf(config,this.configDefaults[config.xtype]);switch(config.xtype){case'htmlareacombo':if(config.options){config.store=new Ext.data.ArrayStore({autoDestroy:true,fields:config.storeFields,data:config.options});}else if(config.storeUrl){config.store=new Ext.data.JsonStore({autoDestroy:true,autoLoad:true,root:config.storeRoot,fields:config.storeFields,url:config.storeUrl});}
config.hideLabel=Ext.isEmpty(config.fieldLabel)||Ext.isIE6;config.helpTitle=config.tooltip;break;default:if(!config.iconCls){config.iconCls=config.id;}
break;}
config.cmd=config.id;config.tooltip={title:config.tooltip};this.buttonsConfig[config.id]=config;return true;},registerHotKey:function(hotKeyConfiguration){if(Ext.isDefined(this.hotKeyList[hotKeyConfiguration.id])){HTMLArea._appendToLog('[HTMLArea.Config::registerHotKey]: A hotkey with the same key '+hotKeyConfiguration.id+' already exists and will be overidden.');}
if(Ext.isDefined(hotKeyConfiguration.cmd)&&!Ext.isEmpty(hotKeyConfiguration.cmd)&&Ext.isDefined(this.buttonsConfig[hotKeyConfiguration.cmd])){this.hotKeyList[hotKeyConfiguration.id]=hotKeyConfiguration;HTMLArea._appendToLog('[HTMLArea.Config::registerHotKey]: A hotkey with key '+hotKeyConfiguration.id+' was registered for toolbar item '+hotKeyConfiguration.cmd+'.');return true;}else{HTMLArea._appendToLog('[HTMLArea.Config::registerHotKey]: A hotkey with key '+hotKeyConfiguration.id+' could not be registered because toolbar item with id '+hotKeyConfiguration.cmd+' was not registered.');return false;}},getDocumentType:function(){return this.documentType;}});Ext.ux.HTMLAreaButton=Ext.extend(Ext.Button,{initComponent:function(){Ext.ux.HTMLAreaButton.superclass.initComponent.call(this);this.addEvents('HTMLAreaEventHotkey','HTMLAreaEventContextMenu');this.addListener({afterrender:{fn:this.initEventListeners,single:true}});},initEventListeners:function(){this.addListener({HTMLAreaEventHotkey:{fn:this.onHotKey},HTMLAreaEventContextMenu:{fn:this.onButtonClick}});this.setHandler(this.onButtonClick,this);this.mon(this.getToolbar(),'HTMLAreaEventToolbarUpdate',this.onUpdateToolbar,this);},getEditor:function(){return RTEarea[this.ownerCt.editorId].editor;},getToolbar:function(){return this.ownerCt;},inactive:true,activeClass:'buttonActive',setInactive:function(inactive){this.inactive=inactive;return inactive?this.removeClass(this.activeClass):this.addClass(this.activeClass);},isInContext:function(mode,selectionEmpty,ancestors){var editor=this.getEditor();var inContext=true;if(mode==='wysiwyg'&&this.context){var attributes=[],contexts=[];if(/(.*)\[(.*?)\]/.test(this.context)){contexts=RegExp.$1.split(',');attributes=RegExp.$2.split(',');}else{contexts=this.context.split(',');}
contexts=new RegExp('^('+contexts.join('|')+')$','i');var matchAny=contexts.test('*');Ext.each(ancestors,function(ancestor){inContext=matchAny||contexts.test(ancestor.nodeName);if(inContext){Ext.each(attributes,function(attribute){inContext=eval("ancestor."+attribute);return inContext;});}
return!inContext;});}
return inContext&&(!this.selection||!selectionEmpty);},onButtonClick:function(button,event,key){if(!this.disabled){if(!this.plugins[this.action](this.getEditor(),key||this.itemId)&&event){event.stopEvent();}
if(Ext.isOpera){this.getEditor().focus();}
if(this.dialog){this.setDisabled(true);}else{this.getToolbar().update();}}
return false;},onHotKey:function(key,event){return this.onButtonClick(this,event,key);},onUpdateToolbar:function(mode,selectionEmpty,ancestors,endPointsInSameBlock){this.setDisabled(mode==='textmode'&&!this.textMode);if(!this.disabled){if(!this.noAutoUpdate){this.setDisabled(!this.isInContext(mode,selectionEmpty,ancestors));}
this.plugins['onUpdateToolbar'](this,mode,selectionEmpty,ancestors,endPointsInSameBlock);}}});Ext.reg('htmlareabutton',Ext.ux.HTMLAreaButton);Ext.ux.Toolbar.HTMLAreaToolbarText=Ext.extend(Ext.Toolbar.TextItem,{initComponent:function(){Ext.ux.Toolbar.HTMLAreaToolbarText.superclass.initComponent.call(this);this.addListener({afterrender:{fn:this.initEventListeners,single:true}});},initEventListeners:function(){this.mon(this.getToolbar(),'HTMLAreaEventToolbarUpdate',this.onUpdateToolbar,this);},getEditor:function(){return RTEarea[this.ownerCt.editorId].editor;},getToolbar:function(){return this.ownerCt;},onUpdateToolbar:function(mode,selectionEmpty,ancestors,endPointsInSameBlock){this.setDisabled(mode==='textmode'&&!this.textMode);if(!this.disabled){this.plugins['onUpdateToolbar'](this,mode,selectionEmpty,ancestors,endPointsInSameBlock);}}});Ext.reg('htmlareatoolbartext',Ext.ux.Toolbar.HTMLAreaToolbarText);Ext.ux.form.HTMLAreaCombo=Ext.extend(Ext.form.ComboBox,{initComponent:function(){Ext.ux.form.HTMLAreaCombo.superclass.initComponent.call(this);this.addEvents('HTMLAreaEventHotkey');this.addListener({afterrender:{fn:this.initEventListeners,single:true}});},initEventListeners:function(){this.addListener({select:{fn:this.onComboSelect},specialkey:{fn:this.onSpecialKey},HTMLAreaEventHotkey:{fn:this.onHotKey},beforedestroy:{fn:this.onBeforeDestroy,single:true}});this.mon(this.getToolbar(),'HTMLAreaEventToolbarUpdate',this.onUpdateToolbar,this);this.mon(this.getToolbar().ownerCt,'HTMLAreaEventFrameworkReady',this.onFrameworkReady,this);},getEditor:function(){return RTEarea[this.ownerCt.editorId].editor;},getToolbar:function(){return this.ownerCt;},onComboSelect:function(combo,record,index){if(!combo.disabled){var editor=this.getEditor();if(Ext.isIE){editor.focus();if(!Ext.isEmpty(this.savedRange)){editor.selectRange(this.savedRange);this.savedRange=null;}}
this.plugins[this.action](editor,combo,record,index);if(Ext.isIE){editor.focus();this.savedRange=editor._createRange(editor._getSelection());this.triggered=true;}
if(Ext.isOpera){editor.focus();}
this.getToolbar().update();}
return false;},onTriggerClick:function(){Ext.ux.form.HTMLAreaCombo.superclass.onTriggerClick.call(this);if(Ext.isIE){this.triggered=true;this.getEditor().focus();}},onViewClick:function(doFocus){Ext.ux.form.HTMLAreaCombo.superclass.onViewClick.call(this,false);},saveSelection:function(event){var editor=this.getEditor();if(editor.document.hasFocus()){this.savedRange=editor._createRange(editor._getSelection());}},restoreSelection:function(event){if(!Ext.isEmpty(this.savedRange)&&this.triggered){this.getEditor().selectRange(this.savedRange);this.triggered=false;}},onSpecialKey:function(combo,event){if(event.getKey()==event.ENTER){event.stopEvent();}
return false;},onHotKey:function(key){if(!this.disabled){this.plugins.onHotKey(this.getEditor(),key);if(Ext.isOpera){this.getEditor().focus();}
this.getToolbar().update();}
return false;},onUpdateToolbar:function(mode,selectionEmpty,ancestors,endPointsInSameBlock){this.setDisabled(mode==='textmode'&&!this.textMode);if(!this.disabled){this.plugins['onUpdateToolbar'](this,mode,selectionEmpty,ancestors,endPointsInSameBlock);}},onFrameworkReady:function(){var iframe=this.getEditor().iframe;this.mon(Ext.get(iframe.document.documentElement),'click',this.collapse,this);if(Ext.isIE){this.mon(iframe.getEl(),'mouseleave',this.saveSelection,this);this.mon(iframe.getEl(),'focus',this.restoreSelection,this);}},onBeforeDestroy:function(){this.savedRange=null;this.getStore().removeAll();this.getStore().destroy();}});Ext.reg('htmlareacombo',Ext.ux.form.HTMLAreaCombo);HTMLArea.Toolbar=Ext.extend(Ext.Container,{initComponent:function(){HTMLArea.Toolbar.superclass.initComponent.call(this);this.addEvents('HTMLAreaEventToolbarUpdate');this.updateLater=new Ext.util.DelayedTask(this.update,this);this.addItems();this.addListener({afterrender:{fn:this.initEventListeners,single:true}});},initEventListeners:function(){this.addListener({beforedestroy:{fn:this.onBeforeDestroy,single:true}});this.mon(this.getEditor(),'HTMLAreaEventEditorReady',this.update,this,{single:true});},editorId:null,getEditor:function(){return RTEarea[this.editorId].editor;},addItems:function(){var editor=this.getEditor();var firstOnRow=true;var firstInGroup=true;Ext.each(editor.config.toolbar,function(row){if(!firstOnRow){this.add({xtype:'tbspacer',cls:'x-form-clear-left'});}
firstOnRow=true;Ext.each(row,function(group){if(!firstOnRow&&!firstInGroup){this.add({xtype:'tbseparator',cls:'separator'});}
firstInGroup=true;Ext.each(group,function(item){if(item=='space'){this.add({xtype:'tbspacer',cls:'space'});}else{var itemConfig=editor.config.buttonsConfig[item];if(!Ext.isEmpty(itemConfig)){itemConfig.id=this.editorId+'-'+itemConfig.id;this.add(itemConfig);firstInGroup=firstInGroup&&itemConfig.hidden;firstOnRow=firstOnRow&&firstInGroup;}}
return true;},this);return true;},this);return true;},this);this.add({xtype:'tbspacer',cls:'x-form-clear-left'});},getButton:function(buttonId){return this.find('itemId',buttonId)[0];},update:function(){var editor=this.getEditor(),mode=editor.getMode(),selectionEmpty=true,ancestors=null,endPointsInSameBlock=true;if(editor.getMode()==='wysiwyg'){selectionEmpty=editor._selectionEmpty(editor._getSelection());ancestors=editor.getAllAncestors();endPointsInSameBlock=editor.endPointsInSameBlock();}
this.fireEvent('HTMLAreaEventToolbarUpdate',mode,selectionEmpty,ancestors,endPointsInSameBlock);},onBeforeDestroy:function(){this.removeAll(true);return true;}});Ext.reg('htmlareatoolbar',HTMLArea.Toolbar);HTMLArea.Iframe=Ext.extend(Ext.BoxComponent,{initComponent:function(){HTMLArea.Iframe.superclass.initComponent.call(this);this.addEvents('HTMLAreaEventIframeReady','HTMLAreaEventWordCountChange');this.addListener({afterrender:{fn:this.initEventListeners,single:true},beforedestroy:{fn:this.onBeforeDestroy,single:true}});this.config=this.getEditor().config;this.htmlRenderer=new HTMLArea.DOM.Walker({keepComments:!this.config.htmlRemoveComments,removeTags:this.config.htmlRemoveTags,removeTagsAndContents:this.config.htmlRemoveTagsAndContents,baseUrl:this.config.baseURL});if(!this.config.showStatusBar){this.addClass('noStatusBar');}},initEventListeners:function(){this.initStyleChangeEventListener();if(Ext.isOpera){this.mon(this.getEl(),'load',this.initializeIframe,this,{single:true});}else{this.initializeIframe();}},initStyleChangeEventListener:function(){if(this.isNested&&Ext.isGecko){var options={stopEvent:true,delay:50};Ext.each(this.nestedParentElements.sorted,function(nested){this.mon(Ext.get(nested),Ext.isIE?'propertychange':'DOMAttrModified',this.onNestedShow,this,options);},this);}},editorId:null,getEditor:function(){return RTEarea[this.editorId].editor;},getToolbar:function(){return this.ownerCt.getTopToolbar();},getStatusBar:function(){return this.ownerCt.getBottomToolbar();},getButton:function(buttonId){return this.getToolbar().getButton(buttonId);},ready:false,onRender:function(ct,position){if(!this.el&&this.autoEl){if(Ext.isString(this.autoEl)){this.el=document.createElement(this.autoEl);}else{this.el=Ext.DomHelper.append(ct,this.autoEl,true);}
if(!this.el.id){this.el.id=this.getId();}}
if(this.resizeEl){this.resizeEl=Ext.get(this.resizeEl);}
if(this.positionEl){this.positionEl=Ext.get(this.positionEl);}},initializeIframe:function(){var iframe=this.getEl().dom;if(!iframe||(!iframe.contentWindow&&!iframe.contentDocument)){this.initializeIframe.defer(50,this);}else if(iframe.contentWindow&&!Ext.isWebKit&&(!iframe.contentWindow.document||!iframe.contentWindow.document.documentElement)){this.initializeIframe.defer(50,this);}else if(Ext.isWebKit&&(!iframe.contentDocument.documentElement||!iframe.contentDocument.body)){this.initializeIframe.defer(50,this);}else{this.document=iframe.contentWindow?iframe.contentWindow.document:iframe.contentDocument;this.getEditor().document=this.document;this.getEditor()._doc=this.document;this.getEditor()._iframe=iframe;this.initializeCustomTags();this.createHead();this.getStyleSheets();}},initializeCustomTags:function(){if(HTMLArea.isIEBeforeIE9){Ext.each(this.config.customTags,function(tag){this.document.createElement(tag);},this);}},createHead:function(){var head=this.document.getElementsByTagName('head')[0];if(!head){head=this.document.createElement('head');this.document.documentElement.appendChild(head);}
if(this.config.baseURL){var base=this.document.getElementsByTagName('base')[0];if(!base){base=this.document.createElement('base');base.href=this.config.baseURL;head.appendChild(base);}
HTMLArea._appendToLog('[HTMLArea.Iframe::createHead]: Iframe baseURL set to: '+base.href);}
var link0=this.document.getElementsByTagName('link')[0];if(!link0){link0=this.document.createElement('link');link0.rel='stylesheet';link0.type='text/css';link0.href=((Ext.isGecko&&navigator.productSub<2010072200&&!/^http(s?):\/{2}/.test(this.config.editedContentStyle))?this.config.baseURL:'')+this.config.editedContentStyle;head.appendChild(link0);HTMLArea._appendToLog('[HTMLArea.Iframe::createHead]: Skin CSS set to: '+link0.href);}
if(this.config.defaultPageStyle){var link=this.document.getElementsByTagName('link')[1];if(!link){link=this.document.createElement('link');link.rel='stylesheet';link.type='text/css';link.href=((Ext.isGecko&&navigator.productSub<2010072200&&!/^https?:\/{2}/.test(this.config.defaultPageStyle))?this.config.baseURL:'')+this.config.defaultPageStyle;head.appendChild(link);}
HTMLArea._appendToLog('[HTMLArea.Iframe::createHead]: Override CSS set to: '+link.href);}
if(this.config.pageStyle){var link=this.document.getElementsByTagName('link')[2];if(!link){link=this.document.createElement('link');link.rel='stylesheet';link.type='text/css';link.href=((Ext.isGecko&&navigator.productSub<2010072200&&!/^https?:\/{2}/.test(this.config.pageStyle))?this.config.baseURL:'')+this.config.pageStyle;head.appendChild(link);}
HTMLArea._appendToLog('[HTMLArea.Iframe::createHead]: Content CSS set to: '+link.href);}
HTMLArea._appendToLog('[HTMLArea.Iframe::createHead]: Editor iframe document head successfully built.');},getStyleSheets:function(){var stylesAreLoaded=true;var errorText='';var rules;if(Ext.isOpera){if(this.document.readyState!='complete'){stylesAreLoaded=false;errorText='Document.readyState not complete';}}else{if(HTMLArea.isIEBeforeIE9){try{var rules=this.document.styleSheets[0].rules;var imports=this.document.styleSheets[0].imports;if(!rules.length&&!imports.length){stylesAreLoaded=false;errorText='Empty rules and imports arrays';}}catch(e){stylesAreLoaded=false;errorText=e;}}else{try{this.document.styleSheets&&this.document.styleSheets[0]&&this.document.styleSheets[0].rules;}catch(e){stylesAreLoaded=false;errorText=e;}}
if(stylesAreLoaded){if(this.document.styleSheets.length>2){Ext.each(this.document.styleSheets,function(styleSheet,index){if(HTMLArea.isIEBeforeIE9){try{var rules=styleSheet.rules;var imports=styleSheet.imports;if(!rules.length&&!imports.length&&styleSheet.href.indexOf('defaultPageStyle')===-1){stylesAreLoaded=false;errorText='Empty rules and imports arrays of styleSheets['+index+']';return false;}}catch(e){stylesAreLoaded=false;errorText=e;return false;}}else{try{var rules=styleSheet.cssRules;}catch(e){stylesAreLoaded=false;errorText=e;return false;}}});}else{stylesAreLoaded=false;errorText='Empty stylesheets array or missing linked stylesheets';}}}
if(!stylesAreLoaded){this.getStyleSheets.defer(100,this);HTMLArea._appendToLog('[HTMLArea.Iframe::getStyleSheets]: Stylesheets not yet loaded ('+errorText+'). Retrying...');if(/Security/i.test(errorText)){HTMLArea._appendToLog('ERROR [HTMLArea.Iframe::getStyleSheets]: A security error occurred. Make sure all stylesheets are accessed from the same domain/subdomain and using the same protocol as the current script.');}}else{HTMLArea._appendToLog('[HTMLArea.Iframe::getStyleSheets]: Stylesheets successfully accessed.');Ext.get(this.document.body).addClass('htmlarea-content-body');if(!Ext.isOpera){this.startListening();}
this.hide();this.ready=true;this.fireEvent('HTMLAreaEventIframeReady');}},focus:function(){try{if(Ext.isWebKit){this.getEl().dom.focus();}else{this.getEl().dom.contentWindow.focus();}}catch(e){}},isNested:false,nestedParentElements:{},setDesignMode:function(on){if(on){if(!Ext.isIE){if(Ext.isGecko){if(!this.isNested||HTMLArea.util.TYPO3.allElementsAreDisplayed(this.nestedParentElements.sorted)){this.document.designMode='on';this.setOptions();}}else{this.document.designMode='on';this.setOptions();}}
if(Ext.isIE||Ext.isWebKit){this.document.body.contentEditable=true;}}else{if(!Ext.isIE){this.document.designMode='off';}
if(Ext.isIE||Ext.isWebKit){this.document.body.contentEditable=false;}}},setOptions:function(){if(!Ext.isIE){try{if(this.document.queryCommandEnabled('insertBrOnReturn')){this.document.execCommand('insertBrOnReturn',false,this.config.disableEnterParagraphs);}
if(this.document.queryCommandEnabled('styleWithCSS')){this.document.execCommand('styleWithCSS',false,this.config.useCSS);}else if(Ext.isGecko&&this.document.queryCommandEnabled('useCSS')){this.document.execCommand('useCSS',false,!this.config.useCSS);}
if(Ext.isGecko){if(this.document.queryCommandEnabled('enableObjectResizing')){this.document.execCommand('enableObjectResizing',false,!this.config.disableObjectResizing);}
if(this.document.queryCommandEnabled('enableInlineTableEditing')){this.document.execCommand('enableInlineTableEditing',false,(this.config.buttons.table&&this.config.buttons.table.enableHandles)?true:false);}}}catch(e){}}},onNestedShow:function(event,target){var styleEvent=true;if((Ext.isGecko&&navigator.productSub>2007112700)||Ext.isOpera){styleEvent=(event.browserEvent.attrName=='style');}else if(Ext.isIE){styleEvent=(event.browserEvent.propertyName=='style.display');}
if(styleEvent&&this.nestedParentElements.sorted.indexOf(target.id)!=-1&&(target.style.display==''||target.style.display=='block')){if(HTMLArea.util.TYPO3.allElementsAreDisplayed(this.nestedParentElements.sorted)){if(this.getEditor().getMode()==='wysiwyg'){if(Ext.isGecko){this.setDesignMode(true);}
this.fireEvent('show');}else{this.ownerCt.textAreaContainer.fireEvent('show');}
this.getToolbar().update();return false;}}},htmlRenderer:{},getHTML:function(){return this.htmlRenderer.render(this.document.body,false);},startListening:function(){this.keyMap=new Ext.KeyMap(Ext.get(this.document.documentElement),[],(Ext.isIE||Ext.isWebKit)?'keydown':'keypress');this.keyMap.addBinding([{key:[Ext.EventObject.DOWN,Ext.EventObject.UP,Ext.EventObject.LEFT,Ext.EventObject.RIGHT],alt:false,handler:this.onArrow,scope:this},{key:Ext.EventObject.TAB,ctrl:false,alt:false,handler:this.onTab,scope:this},{key:Ext.EventObject.SPACE,ctrl:true,shift:false,alt:false,handler:this.onCtrlSpace,scope:this}]);if(Ext.isGecko||Ext.isIE){this.keyMap.addBinding({key:[Ext.EventObject.BACKSPACE,Ext.EventObject.DELETE],alt:false,handler:this.onBackSpace,scope:this});}
if(!Ext.isIE&&!this.config.disableEnterParagraphs){this.keyMap.addBinding({key:Ext.EventObject.ENTER,shift:false,handler:this.onEnter,scope:this});}
if(Ext.isWebKit){this.keyMap.addBinding({key:Ext.EventObject.ENTER,alt:false,handler:this.onWebKitEnter,scope:this});}
var hotKeys='';Ext.iterate(this.config.hotKeyList,function(key){if(key.length==1){hotKeys+=key.toUpperCase();}});this.hotKeyMap=new Ext.KeyMap(Ext.get(this.document.documentElement));if(!Ext.isEmpty(hotKeys)){this.hotKeyMap.addBinding({key:hotKeys,ctrl:true,shift:false,alt:false,handler:this.onHotKey,scope:this});}
this.mon(Ext.get(this.document.documentElement),(Ext.isIE||Ext.isWebKit)?'keydown':'keypress',this.onAnyKey,this);this.mon(Ext.get(this.document.documentElement),'mouseup',this.onMouse,this);this.mon(Ext.get(this.document.documentElement),'click',this.onMouse,this);if(Ext.isGecko){this.mon(Ext.get(this.document.documentElement),'paste',this.onPaste,this);}
this.mon(Ext.get(this.document.documentElement),'drop',this.onDrop,this);if(Ext.isWebKit){this.mon(Ext.get(this.document.body),'dragend',this.onDrop,this);}},onAnyKey:function(event){if(this.inhibitKeyboardInput(event)){return false;}
if(this.getEditor().hasPluginWithOnKeyPressHandler){var letBubble=true;Ext.iterate(this.getEditor().plugins,function(pluginId){var plugin=this.getEditor().getPlugin(pluginId);if(Ext.isFunction(plugin.onKeyPress)){if(!plugin.onKeyPress(event.browserEvent)){event.stopEvent();letBubble=false;}}
return letBubble;},this);if(!letBubble){return letBubble;}}
this.fireEvent('HTMLAreaEventWordCountChange',100);if(!event.altKey&&!event.ctrlKey){if(!Ext.isIE&&(event.getKey()!=Ext.EventObject.ENTER||(event.shiftKey&&!Ext.isWebKit))){this.getEditor()._detectURL(event);}
if(Ext.isMac&&event.browserEvent.charCode==160){return this.onOptionSpace(event.browserEvent.charCode,event);}}
return true;},inhibitKeyboardInput:function(event){if(this.getEditor().inhibitKeyboardInput){event.stopEvent();return true;}else{return false;}},onMouse:function(event,target){if(Ext.isWebKit&&/^(img)$/i.test(target.nodeName)&&event.browserEvent.type=='click'){this.getEditor().selectNode(target);}
this.getToolbar().updateLater.delay(100);return true;},onPaste:function(event){if(Ext.isGecko){HTMLArea.DOM.makeUrlsAbsolute.defer(50,this,[this.getEditor().document.body,this.config.baseURL,this.htmlRenderer]);}},onDrop:function(event,target){if(Ext.isWebKit){this.getEditor().cleanAppleStyleSpans.defer(50,this.getEditor(),[this.getEditor().document.body]);}
if(Ext.isGecko){HTMLArea.DOM.makeUrlsAbsolute.defer(50,this,[target,this.config.baseURL,this.htmlRenderer]);}
this.getToolbar().updateLater.delay(100);},onArrow:function(){this.getToolbar().updateLater.delay(100);return true;},onTab:function(key,event){if(this.inhibitKeyboardInput(event)){return false;}
var keyName=(event.shiftKey?'SHIFT-':'')+'TAB';if(this.config.hotKeyList[keyName]&&this.config.hotKeyList[keyName].cmd){var button=this.getButton(this.config.hotKeyList[keyName].cmd);if(button){event.stopEvent();button.fireEvent('HTMLAreaEventHotkey',keyName,event);return false;}}
return true;},onBackSpace:function(key,event){if(this.inhibitKeyboardInput(event)){return false;}
if((!Ext.isIE&&!event.shiftKey)||Ext.isIE){if(this.getEditor()._checkBackspace()){event.stopEvent();}}
this.getToolbar().updateLater.delay(200);return false;},onEnter:function(key,event){if(this.inhibitKeyboardInput(event)){return false;}
this.getEditor()._detectURL(event);if(this.getEditor()._checkInsertP()){event.stopEvent();}
this.getToolbar().updateLater.delay(200);return false;},onWebKitEnter:function(key,event){if(this.inhibitKeyboardInput(event)){return false;}
if(event.shiftKey||this.config.disableEnterParagraphs){var editor=this.getEditor();editor._detectURL(event);if(Ext.isSafari){var brNode=editor.document.createElement('br');editor.insertNodeAtSelection(brNode);brNode.parentNode.normalize();if(editor._unlinkOnUndo){brNode=brNode.parentNode.parentNode.insertBefore(brNode,brNode.parentNode.nextSibling);}
if(!brNode.nextSibling||!/\S+/i.test(brNode.nextSibling.textContent)){var secondBrNode=editor.document.createElement('br');secondBrNode=brNode.parentNode.appendChild(secondBrNode);}
editor.selectNode(brNode,false);event.stopEvent();}}
this.getToolbar().updateLater.delay(200);return false;},onCtrlSpace:function(key,event){if(this.inhibitKeyboardInput(event)){return false;}
this.getEditor().insertHTML(' ');event.stopEvent();return false;},onOptionSpace:function(key,event){if(this.inhibitKeyboardInput(event)){return false;}
this.getEditor().insertHTML(' ');event.stopEvent();return false;},onHotKey:function(key,event){if(this.inhibitKeyboardInput(event)){return false;}
var hotKey=String.fromCharCode(key).toLowerCase();this.getButton(this.config.hotKeyList[hotKey].cmd).fireEvent('HTMLAreaEventHotkey',hotKey,event);return false;},onBeforeDestroy:function(){Ext.each(this.keyMap.bindings,function(binding,index){this.keyMap.bindings[index]=null;},this);this.keyMap.handleKeyDown=null;Ext.each(this.hotKeyMap.bindings,function(binding,index){this.hotKeyMap.bindings[index]=null;},this);this.hotKeyMap.handleKeyDown=null;this.keyMap.disable();this.hotKeyMap.disable();Ext.get(this.document.body).purgeAllListeners();Ext.get(this.document.body).dom=null;Ext.get(this.document.documentElement).purgeAllListeners();Ext.get(this.document.documentElement).dom=null;this.document=null;this.getEditor().document=null;this.getEditor()._doc=null;this.getEditor()._iframe=null;Ext.each(this.nestedParentElements.sorted,function(nested){Ext.get(nested).purgeAllListeners();Ext.get(nested).dom=null;});Ext.destroy(this.autoEl,this.el,this.resizeEl,this.positionEl);return true;}});Ext.reg('htmlareaiframe',HTMLArea.Iframe);HTMLArea.StatusBar=Ext.extend(Ext.Container,{initComponent:function(){HTMLArea.StatusBar.superclass.initComponent.call(this);this.updateWordCountLater=new Ext.util.DelayedTask(this.updateWordCount,this);this.addListener({render:{fn:this.addComponents,single:true},afterrender:{fn:this.initEventListeners,single:true}});},initEventListeners:function(){this.addListener({beforedestroy:{fn:this.onBeforeDestroy,single:true}});this.mon(this.ownerCt.toolbar,'HTMLAreaEventToolbarUpdate',this.onUpdateToolbar,this);this.mon(this.getEditor(),'HTMLAreaEventModeChange',this.onModeChange,this);this.mon(this.ownerCt.iframe,'HTMLAreaEventWordCountChange',this.onWordCountChange,this);},editorId:null,getEditor:function(){return RTEarea[this.editorId].editor;},addComponents:function(){this.statusBarWordCount=Ext.DomHelper.append(this.getEl(),{id:this.editorId+'-statusBarWordCount',tag:'span',cls:'statusBarWordCount',html:' '},true);this.statusBarTree=Ext.DomHelper.append(this.getEl(),{id:this.editorId+'-statusBarTree',tag:'span',cls:'statusBarTree',html:HTMLArea.I18N.msg['Path']+': '},true).setVisibilityMode(Ext.Element.DISPLAY).setVisible(true);this.statusBarTextMode=Ext.DomHelper.append(this.getEl(),{id:this.editorId+'-statusBarTextMode',tag:'span',cls:'statusBarTextMode',html:HTMLArea.I18N.msg['TEXT_MODE']},true).setVisibilityMode(Ext.Element.DISPLAY).setVisible(false);},clear:function(){this.statusBarTree.removeAllListeners();Ext.each(this.statusBarTree.query('a'),function(node){Ext.QuickTips.unregister(node);Ext.get(node).dom.ancestor=null;Ext.destroy(node);});this.statusBarTree.update('');this.setSelection(null);},noUpdate:false,onUpdateToolbar:function(mode,selectionEmpty,ancestors,endPointsInSameBlock){if(mode==='wysiwyg'&&!this.noUpdate){var text,language,languageObject=this.getEditor().getPlugin('Language'),classes=new Array(),classText;this.clear();var path=Ext.DomHelper.append(this.statusBarTree,{tag:'span',html:HTMLArea.I18N.msg['Path']+': '},true);Ext.each(ancestors,function(ancestor,index){if(!ancestor){return true;}
text=ancestor.nodeName.toLowerCase();if(ancestor.id&&text!=='body'&&ancestor.id.substr(0,7)!=='ext-gen'){text+='#'+ancestor.id;}
if(languageObject&&languageObject.getLanguageAttribute){language=languageObject.getLanguageAttribute(ancestor);if(language!='none'){text+='['+language+']';}}
if(ancestor.className){classText='';classes=ancestor.className.trim().split(' ');for(var j=0,n=classes.length;j'),html:text},true);element.dom.ancestor=ancestor;element.on('click',this.onClick,this);element.on('mousedown',this.onClick,this);if(!Ext.isOpera){element.on('contextmenu',this.onContextMenu,this);}
if(index){Ext.DomHelper.insertAfter(element,{tag:'span',html:String.fromCharCode(0xbb)});}},this);}
this.updateWordCount();this.noUpdate=false;},onWordCountChange:function(delay){this.updateWordCountLater.delay(delay?delay:0);},updateWordCount:function(){var wordCount=0;if(this.getEditor().getMode()=='wysiwyg'){var text=this.getEditor().getHTML();if(!Ext.isEmpty(text)){text=text.replace(HTMLArea.RE_htmlTag,' ');text=text.replace(/ | /gi,' ');text=text.replace(HTMLArea.RE_numberOrPunctuation,'');wordCount=text.split(/\S\s+/g).length-1;}}
this.statusBarWordCount.dom.innerHTML=wordCount?(wordCount+' '+HTMLArea.I18N.dialogs[(wordCount==1)?'word':'words']):' ';},onModeChange:function(mode){switch(mode){case'wysiwyg':this.statusBarTextMode.setVisible(false);this.statusBarTree.setVisible(true);break;case'textmode':default:this.statusBarTree.setVisible(false);this.statusBarTextMode.setVisible(true);break;}},selected:null,getSelection:function(){return this.selected;},setSelection:function(element){this.selected=element?element:null;},selectElement:function(element){var editor=this.getEditor();element.blur();if(!Ext.isIE){if(/^(img|table)$/i.test(element.ancestor.nodeName)){editor.selectNode(element.ancestor);}else{editor.selectNodeContents(element.ancestor);}}else{if(/^(img|table)$/i.test(element.ancestor.nodeName)){var range=editor.document.body.createControlRange();range.addElement(element.ancestor);range.select();}else{editor.selectNode(element.ancestor);}}
this.setSelection(element.ancestor);this.noUpdate=true;editor.toolbar.update();},onClick:function(event,element){this.selectElement(element);event.stopEvent();return false;},onContextMenu:function(event,target){this.selectElement(target);return this.getEditor().getPlugin('ContextMenu')?this.getEditor().getPlugin('ContextMenu').show(event,target.ancestor):false;},onBeforeDestroy:function(){this.clear();this.removeAll(true);Ext.destroy(this.statusBarTree,this.statusBarTextMode);return true;}});Ext.reg('htmlareastatusbar',HTMLArea.StatusBar);HTMLArea.Framework=Ext.extend(Ext.Panel,{initComponent:function(){HTMLArea.Framework.superclass.initComponent.call(this);this.toolbar=this.getTopToolbar();this.statusBar=this.getBottomToolbar();this.iframe=this.getComponent('iframe');this.textAreaContainer=this.getComponent('textAreaContainer');this.addEvents('HTMLAreaEventFrameworkReady');this.addListener({beforedestroy:{fn:this.onBeforeDestroy,single:true}});this.mon(this.iframe,'HTMLAreaEventIframeReady',this.onIframeReady,this,{single:true});if(!this.isNested||HTMLArea.util.TYPO3.allElementsAreDisplayed(this.nestedParentElements.sorted)){this.render(this.textArea.parent(),this.textArea.id);}else{var parentElements=[].concat(this.nestedParentElements.sorted);HTMLArea.util.TYPO3.accessParentElements(parentElements,'args[0].render(args[0].textArea.parent(), args[0].textArea.id)',[this]);}},initEventListeners:function(){this.makeResizable();this.mon(this.textAreaContainer,'show',this.resizable?this.onTextAreaShow:this.onWindowResize,this);this.mon(this.iframe,'show',this.resizable?this.onIframeShow:this.onWindowResize,this);Ext.EventManager.onWindowResize(this.onWindowResize,this);var form=this.textArea.dom.form;if(form){if(Ext.isFunction(form.onreset)){if(typeof(form.htmlAreaPreviousOnReset)=='undefined'){form.htmlAreaPreviousOnReset=[];}
form.htmlAreaPreviousOnReset.push(form.onreset);}
this.mon(Ext.get(form),'reset',this.onReset,this);}
this.addListener({resize:{fn:this.onFrameworkResize}});},editorId:null,getEditor:function(){return RTEarea[this.editorId].editor;},isNested:false,nestedParentElements:{},ready:false,nestedParentElements:{},resizable:false,maxHeight:2000,textAreaInitialSize:{width:0,contextWidth:0,height:0},doLayout:function(){if(!this.isNested||HTMLArea.util.TYPO3.allElementsAreDisplayed(this.nestedParentElements.sorted)){HTMLArea.Framework.superclass.doLayout.call(this);}else{var parentElements=[].concat(this.nestedParentElements.sorted);HTMLArea.util.TYPO3.accessParentElements(parentElements,'HTMLArea.Framework.superclass.doLayout.call(args[0])',[this]);}},onLayout:function(){if(!this.isNested||HTMLArea.util.TYPO3.allElementsAreDisplayed(this.nestedParentElements.sorted)){HTMLArea.Framework.superclass.onLayout.call(this);}else{var parentElements=[].concat(this.nestedParentElements.sorted);HTMLArea.util.TYPO3.accessParentElements(parentElements,'HTMLArea.Framework.superclass.onLayout.call(args[0])',[this]);}},makeResizable:function(){if(this.resizable){this.addClass('resizable');this.resizer=new Ext.Resizable(this.getEl(),{minWidth:300,maxHeight:this.maxHeight,dynamic:false});this.resizer.on('resize',this.onHtmlAreaResize,this);}},onHtmlAreaResize:function(resizer,width,height,event){this.setWidth(width);this.iframe.setHeight(this.getInnerHeight());this.textArea.setSize(this.getInnerWidth(),this.getInnerHeight());},onWindowResize:function(width,height){if(!this.isNested||HTMLArea.util.TYPO3.allElementsAreDisplayed(this.nestedParentElements.sorted)){this.resizeFramework(width,height);}else{var parentElements=[].concat(this.nestedParentElements.sorted);HTMLArea.util.TYPO3.accessParentElements(parentElements,'args[0].resizeFramework(args[1], args[2])',[this,width,height]);}},resizeFramework:function(width,height){var frameworkHeight=parseInt(this.textAreaInitialSize.height);if(this.textAreaInitialSize.width.indexOf('%')===-1){var frameworkWidth=parseInt(this.textAreaInitialSize.width)-this.getFrameWidth();}else{if(Ext.isNumber(width)){var frameworkWidth=parseInt(((width-this.textAreaInitialSize.wizardsWidth-(this.fullScreen?10:Ext.getScrollBarWidth())-this.getBox().x-15)*parseInt(this.textAreaInitialSize.width))/100);}else{var frameworkWidth=parseInt(((HTMLArea.util.TYPO3.getWindowSize().width-this.textAreaInitialSize.wizardsWidth-(this.fullScreen?10:Ext.getScrollBarWidth())-this.getBox().x-15)*parseInt(this.textAreaInitialSize.width))/100);}}
if(this.resizable){this.resizer.resizeTo(frameworkWidth,frameworkHeight);}else{this.setSize(frameworkWidth,frameworkHeight);this.doLayout();}},onFrameworkResize:function(){this.iframe.setSize(this.getInnerWidth(),this.getInnerHeight());this.textArea.setSize(this.getInnerWidth(),this.getInnerHeight());},onTextAreaShow:function(){this.iframe.setHeight(this.getInnerHeight());this.textArea.setHeight(this.getInnerHeight());},onIframeShow:function(){if(this.getInnerHeight()<=0){this.onWindowResize();}else{this.iframe.setHeight(this.getInnerHeight());this.textArea.setHeight(this.getInnerHeight());}},getInnerHeight:function(){return this.getSize().height-this.toolbar.getHeight()-this.statusBar.getHeight()-5;},onIframeReady:function(){this.ready=this.rendered&&this.toolbar.rendered&&this.statusBar.rendered&&this.textAreaContainer.rendered;if(this.ready){this.initEventListeners();this.textAreaContainer.show();if(!this.getEditor().config.showStatusBar){this.statusBar.hide();}
this.onWindowResize();this.fireEvent('HTMLAreaEventFrameworkReady');}else{this.onIframeReady.defer(50,this);}},onReset:function(event){this.getEditor().setHTML(this.textArea.getValue());this.toolbar.update();var htmlAreaPreviousOnReset=event.getTarget().dom.htmlAreaPreviousOnReset;if(typeof(htmlAreaPreviousOnReset)!='undefined'){Ext.each(htmlAreaPreviousOnReset,function(onReset){onReset();return true;});}},onBeforeDestroy:function(){Ext.EventManager.removeResizeListener(this.onWindowResize,this);var form=this.textArea.dom.form;if(form){form.htmlAreaPreviousOnReset=null;Ext.get(form).dom=null;}
Ext.getBody().dom=null;this.toolbar.destroy();this.statusBar.destroy();this.removeAll(true);if(this.resizer){this.resizer.destroy();}
return true;}});Ext.reg('htmlareaframework',HTMLArea.Framework);HTMLArea.Editor=Ext.extend(Ext.util.Observable,{constructor:function(config){HTMLArea.Editor.superclass.constructor.call(this,{});this.config=config;this.editorId=this.config.editorId;RTEarea[this.editorId].editor=this;this.textArea=Ext.get(this.config.id);this.textAreaInitialSize={width:this.config.RTEWidthOverride?this.config.RTEWidthOverride:this.textArea.getStyle('width'),height:this.config.fullScreen?HTMLArea.util.TYPO3.getWindowSize().height-20:this.textArea.getStyle('height'),wizardsWidth:0};this.nestedParentElements={all:this.config.tceformsNested,sorted:HTMLArea.util.TYPO3.simplifyNested(this.config.tceformsNested)};this.isNested=!Ext.isEmpty(this.nestedParentElements.sorted);if(Ext.get('typo3-docheader')){this.wizards=this.textArea.parent().parent().next();if(this.wizards){if(!this.isNested||HTMLArea.util.TYPO3.allElementsAreDisplayed(this.nestedParentElements.sorted)){this.textAreaInitialSize.wizardsWidth=this.wizards.getWidth();}else{var parentElements=[].concat(this.nestedParentElements.sorted);this.textAreaInitialSize.wizardsWidth=HTMLArea.util.TYPO3.accessParentElements(parentElements,'args[0].getWidth()',[this.wizards]);}
this.wizards.hide();}}
this.plugins={};Ext.iterate(this.config.plugin,function(plugin){if(this.config.plugin[plugin]){this.registerPlugin(plugin);}},this);this.ajax=new HTMLArea.Ajax({editor:this});this.inhibitKeyboardInput=false;this.addEvents('HTMLAreaEventEditorReady','HTMLAreaEventModeChange');},ready:false,mode:'textmode',generate:function(){this.htmlArea=new HTMLArea.Framework({id:this.editorId+'-htmlArea',layout:'anchor',baseCls:'htmlarea',editorId:this.editorId,textArea:this.textArea,textAreaInitialSize:this.textAreaInitialSize,fullScreen:this.config.fullScreen,resizable:this.config.resizable,maxHeight:this.config.maxHeight,isNested:this.isNested,nestedParentElements:this.nestedParentElements,tbar:{xtype:'htmlareatoolbar',id:this.editorId+'-toolbar',anchor:'100%',layout:'form',cls:'toolbar',editorId:this.editorId},items:[{xtype:'htmlareaiframe',itemId:'iframe',anchor:'100%',width:(this.textAreaInitialSize.width.indexOf('%')===-1)?parseInt(this.textAreaInitialSize.width):300,height:parseInt(this.textAreaInitialSize.height),autoEl:{id:this.editorId+'-iframe',tag:'iframe',cls:'editorIframe',src:Ext.isGecko?'javascript:void(0);':(Ext.isWebKit?'javascript: \''+HTMLArea.htmlEncode(this.config.documentType+this.config.blankDocument)+'\'':HTMLArea.editorUrl+'popups/blank.html')},isNested:this.isNested,nestedParentElements:this.nestedParentElements,editorId:this.editorId},{xtype:'box',itemId:'textAreaContainer',anchor:'100%',width:(this.textAreaInitialSize.width.indexOf('%')===-1)?parseInt(this.textAreaInitialSize.width):300,listeners:{afterrender:{fn:function(textAreaContainer){this.originalParent=this.textArea.parent().dom;textAreaContainer.getEl().appendChild(this.textArea);},single:true,scope:this},beforedestroy:{fn:function(textAreaContainer){this.originalParent.appendChild(this.textArea.dom);return true;},single:true,scope:this}}}],bbar:{xtype:'htmlareastatusbar',anchor:'100%',cls:'statusBar',editorId:this.editorId}});this.toolbar=this.htmlArea.getTopToolbar();this.statusBar=this.htmlArea.getBottomToolbar();this.iframe=this.htmlArea.getComponent('iframe');this.textAreaContainer=this.htmlArea.getComponent('textAreaContainer');this.relayEvents(this.htmlArea,['HTMLAreaEventFrameworkReady']);this.on('HTMLAreaEventFrameworkReady',this.onFrameworkReady,this,{single:true});},onFrameworkReady:function(){this.setMode('wysiwyg');this.initEventsListening();this.generatePlugins();this.show();if(this.wizards){this.wizards.show();}
Ext.iterate(RTEarea,function(editorId,RTE){if(!Ext.isDefined(RTE.editor)||(RTE.editor.isNested&&!HTMLArea.util.TYPO3.allElementsAreDisplayed(RTE.editor.nestedParentElements.sorted))){return true;}else{RTE.editor.focus();return false;}},this);this.ready=true;this.fireEvent('HTMLAreaEventEditorReady');HTMLArea._appendToLog('[HTMLArea.Editor::onFrameworkReady]: Editor ready.');},setMode:function(mode){switch(mode){case'textmode':this.textArea.set({value:this.getHTML()},false);this.iframe.setDesignMode(false);this.iframe.hide();this.textAreaContainer.show();this.mode=mode;break;case'wysiwyg':try{this.document.body.innerHTML=this.getHTML();}catch(e){HTMLArea._appendToLog('[HTMLArea.Editor::setMode]: The HTML document is not well-formed.');TYPO3.Dialog.ErrorDialog({title:'htmlArea RTE',msg:HTMLArea.I18N.msg['HTML-document-not-well-formed']});break;}
this.textAreaContainer.hide();this.iframe.show();this.iframe.setDesignMode(true);this.mode=mode;break;}
this.fireEvent('HTMLAreaEventModeChange',this.mode);this.focus();Ext.iterate(this.plugins,function(pluginId){this.getPlugin(pluginId).onMode(this.mode);},this);},getMode:function(){return this.mode;},getHTML:function(){switch(this.mode){case'wysiwyg':return this.iframe.getHTML();case'textmode':return this.textArea.getValue().replace(/[\x20]+/g,'\x20').replace(/^\x20/g,' ').replace(/\x20$/g,' ');default:return'';}},getInnerHTML:function(){switch(this.mode){case'wysiwyg':return this.document.body.innerHTML;case'textmode':return this.textArea.getValue();default:return'';}},setHTML:function(html){switch(this.mode){case'wysiwyg':this.document.body.innerHTML=html;break;case'textmode':this.textArea.set({value:html},false);;break;}},registerPlugin:function(pluginName){var plugin=null;if(Ext.isString(pluginName)){try{plugin=eval(pluginName);}catch(e){try{plugin=eval('HTMLArea.'+pluginName);}catch(error){HTMLArea._appendToLog('ERROR [HTMLArea.Editor::registerPlugin]: Cannot register invalid plugin: '+error);return false;}}}
if(!Ext.isFunction(plugin)){HTMLArea._appendToLog('ERROR [HTMLArea.Editor::registerPlugin]: Cannot register undefined plugin.');return false;}
var pluginInstance=new plugin(this,pluginName);if(pluginInstance){var pluginInformation=pluginInstance.getPluginInformation();pluginInformation.instance=pluginInstance;this.plugins[pluginName]=pluginInformation;HTMLArea._appendToLog('[HTMLArea.Editor::registerPlugin]: Plugin '+pluginName+' was successfully registered.');return true;}else{HTMLArea._appendToLog("ERROR [HTMLArea.Editor::registerPlugin]: Can't register plugin "+pluginName+'.');return false;}},generatePlugins:function(){this.hasPluginWithOnKeyPressHandler=false;Ext.iterate(this.plugins,function(pluginId){var plugin=this.getPlugin(pluginId);plugin.onGenerate();if(Ext.isFunction(plugin.onKeyPress)){this.hasPluginWithOnKeyPressHandler=true;HTMLArea._appendToLog('[HTMLArea.Editor::generatePlugins]: Deprecated use of onKeyPress function by plugin '+pluginId+'. Use keyMap instead.');}},this);HTMLArea._appendToLog('[HTMLArea.Editor::generatePlugins]: All plugins successfully generated.');},getPlugin:function(pluginName){return(this.plugins[pluginName]?this.plugins[pluginName].instance:null);},unRegisterPlugin:function(pluginName){delete this.plugins[pluginName].instance;delete this.plugins[pluginName];},focus:function(){switch(this.getMode()){case'wysiwyg':this.iframe.focus();break;case'textmode':this.textArea.focus();break;}},initEventsListening:function(){if(Ext.isOpera){this.iframe.startListening();}
var iframe=this.iframe.getEl().dom;Ext.EventManager.on(iframe.contentWindow?iframe.contentWindow:iframe.contentDocument,'unload',this.onUnload,this,{single:true});},show:function(){document.getElementById('pleasewait'+this.editorId).style.display='none';document.getElementById('editorWrap'+this.editorId).style.visibility='visible';},appendToLog:function(objectName,functionName,text){HTMLArea.appendToLog(this.editorId,objectName,functionName,text);},onUnload:function(event){if(this.ready){this.textArea.set({value:this.getHTML()},false);}
Ext.TaskMgr.stopAll();this.htmlArea.destroy();Ext.iterate(this.plugins,function(pluginId){this.unRegisterPlugin(pluginId);},this);this.purgeListeners();if(this.wizards){this.wizards.dom=null;this.textArea.parent().parent().dom=null;this.textArea.parent().dom=null;}
this.textArea.dom=null;RTEarea[this.editorId].editor=null;}});HTMLArea.Ajax=function(config){Ext.apply(this,config);};HTMLArea.Ajax=Ext.extend(HTMLArea.Ajax,{getJavascriptFile:function(url,callback,scope){var success=false;var self=this;this.editor.appendToLog('HTMLArea.Ajax','getJavascriptFile','Requesting script '+url);Ext.Ajax.request({method:'GET',url:url,callback:callback,success:function(response){success=true;},failure:function(response){self.editor.inhibitKeyboardInput=false;self.editor.appendToLog('HTMLArea.Ajax','getJavascriptFile','Unable to get '+url+' . Server reported '+response.status);},scope:scope});return success;},postData:function(url,data,callback,scope){var success=false;var self=this;data.charset=this.editor.config.typo3ContentCharset?this.editor.config.typo3ContentCharset:'utf-8';var params='';Ext.iterate(data,function(parameter,value){params+=(params.length?'&':'')+parameter+'='+encodeURIComponent(value);});params+=this.editor.config.RTEtsConfigParams;this.editor.appendToLog('HTMLArea.Ajax','postData','Posting to '+url+'. Data: '+params);Ext.Ajax.request({method:'POST',headers:{'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8'},url:url,params:params,callback:Ext.isFunction(callback)?callback:function(options,success,response){if(success){self.editor.appendToLog('HTMLArea.Ajax','postData','Post request to '+url+' successful. Server response: '+response.responseText);}else{self.editor.appendToLog('HTMLArea.Ajax','postData','Post request to '+url+' failed. Server reported '+response.status);}},success:function(response){success=true;},failure:function(response){self.editor.appendToLog('HTMLArea.Ajax','postData','Unable to post '+url+' . Server reported '+response.status);},scope:scope});return success;}});HTMLArea.util.TYPO3=function(){return{simplifyNested:function(nested){var i,type,level,elementId,max,simplifiedNested=[],elementIdSuffix={tab:'-DIV',inline:'_fields',flex:'-content'};if(nested&&nested.length){if(nested[0][0]=='inline'){nested=inline.findContinuedNestedLevel(nested,nested[0][1]);}
for(i=0,max=nested.length;i=0;){value=element.getAttribute(allowedAttributes[i]);if(value){if(allowedAttributes[i]=="style"&&element.style.cssText){return true;}else{return true;}}}
return false;};HTMLArea.Editor.prototype.hasSelectedText=function(){return this.getSelectedHTML()!="";};HTMLArea.Editor.prototype.getAllAncestors=function(){var p=this.getParentElement();var a=[];while(p&&(p.nodeType===1)&&(p.nodeName.toLowerCase()!=="body")){a.push(p);p=p.parentNode;}
a.push(this.document.body);return a;};HTMLArea.Editor.prototype.getBlockAncestors=function(element,withinBlock){var ancestors=new Array();var ancestor=element;while(ancestor&&(ancestor.nodeType===1)&&!/^(body)$/i.test(ancestor.nodeName)&&ancestor!=withinBlock){if(HTMLArea.isBlockElement(ancestor)){ancestors.unshift(ancestor);}
ancestor=ancestor.parentNode;}
ancestors.unshift(ancestor);return ancestors;};HTMLArea.Editor.prototype.getEndBlocks=function(selection){var range=this._createRange(selection);if(!Ext.isIE){var parentStart=range.startContainer;if(/^(body)$/i.test(parentStart.nodeName)){parentStart=parentStart.firstChild;}
var parentEnd=range.endContainer;if(/^(body)$/i.test(parentEnd.nodeName)){parentEnd=parentEnd.lastChild;}}else{if(selection.type!=="Control"){var rangeEnd=range.duplicate();range.collapse(true);var parentStart=range.parentElement();rangeEnd.collapse(false);var parentEnd=rangeEnd.parentElement();}else{var parentStart=range.item(0);var parentEnd=parentStart;}}
while(parentStart&&!HTMLArea.isBlockElement(parentStart)){parentStart=parentStart.parentNode;}
while(parentEnd&&!HTMLArea.isBlockElement(parentEnd)){parentEnd=parentEnd.parentNode;}
return{start:parentStart,end:parentEnd};};HTMLArea.Editor.prototype.endPointsInSameBlock=function(){var selection=this._getSelection();if(this._selectionEmpty(selection)){return true;}else{var parent=this.getParentElement(selection);var endBlocks=this.getEndBlocks(selection);return(endBlocks.start===endBlocks.end&&!/^(table|thead|tbody|tfoot|tr)$/i.test(parent.nodeName));}};HTMLArea.Editor.prototype._getFirstAncestor=function(sel,types){var prnt=this._activeElement(sel);if(prnt==null){try{prnt=(Ext.isIE?this._createRange(sel).parentElement():this._createRange(sel).commonAncestorContainer);}catch(e){return null;}}
if(typeof(types)=='string')types=[types];while(prnt){if(prnt.nodeType==1){if(types==null)return prnt;for(var i=0;ih+t||e.offsetTop");str=str.replace(/ /g,"\xA0");str=str.replace(/"/g,"\x22");str=str.replace(/'/g,"'");str=str.replace(/&/g,"&");return str;};HTMLArea.htmlEncode=function(str){if(typeof(str)!='string')str=str.toString();str=str.replace(/&/g,"&");str=str.replace(//g,">");str=str.replace(/\xA0/g," ");str=str.replace(/\x22/g,""");return str;};HTMLArea.getHTML=function(root,outputRoot,editor){try{return editor.iframe.htmlRenderer.render(root,outputRoot);}catch(e){HTMLArea._appendToLog('[HTMLArea::getHTML]: The HTML document is not well-formed.');if(!HTMLArea.enableDebugMode){TYPO3.Dialog.ErrorDialog({title:'htmlArea RTE',msg:HTMLArea.I18N.msg['HTML-document-not-well-formed']});return editor.document.body.innerHTML;}else{return editor.iframe.htmlRenderer.render(root,outputRoot);}}};HTMLArea.getPrevNode=function(node){if(!node)return null;if(node.previousSibling)return node.previousSibling;if(node.parentNode)return node.parentNode;return null;};HTMLArea.getNextNode=function(node){if(!node)return null;if(node.nextSibling)return node.nextSibling;if(node.parentNode)return node.parentNode;return null;};HTMLArea.removeFromParent=function(el){if(!el.parentNode)return;var pN=el.parentNode;pN.removeChild(el);return el;};HTMLArea.DOM=function(){return{ELEMENT_NODE:1,ATTRIBUTE_NODE:2,TEXT_NODE:3,CDATA_SECTION_NODE:4,ENTITY_REFERENCE_NODE:5,ENTITY_NODE:6,PROCESSING_INSTRUCTION_NODE:7,COMMENT_NODE:8,DOCUMENT_NODE:9,DOCUMENT_TYPE_NODE:10,DOCUMENT_FRAGMENT_NODE:11,NOTATION_NODE:12,getClassNames:function(node){var classNames=[];if(node){if(node.className&&/\S/.test(node.className)){classNames=node.className.trim().split(' ');}
if(HTMLArea.reservedClassNames.test(node.className)){var cleanClassNames=[];var j=-1;for(var i=0;i=0;){found=((classes[i]==className)||(substring&&classes[i].indexOf(className)==0));if(found){break;}}}
return found;},addClass:function(node,className){if(node){HTMLArea.DOM.removeClass(node,className);if(node.className&&HTMLArea.classesXOR&&HTMLArea.classesXOR[className]&&Ext.isFunction(HTMLArea.classesXOR[className].test)){var classNames=node.className.trim().split(' ');for(var i=classNames.length;--i>=0;){if(HTMLArea.classesXOR[className].test(classNames[i])){HTMLArea.DOM.removeClass(node,classNames[i]);}}}
if(node.className){node.className+=' '+className;}else{node.className=className;}}},removeClass:function(node,className,substring){if(node&&node.className){var classes=node.className.trim().split(' ');var newClasses=[];for(var i=classes.length;--i>=0;){if((!substring&&classes[i]!=className)||(substring&&classes[i].indexOf(className)!=0)){newClasses[newClasses.length]=classes[i];}}
if(newClasses.length){node.className=newClasses.join(' ');}else{if(!Ext.isOpera){node.removeAttribute('class');if(Ext.isIE){node.removeAttribute('className');}}else{node.className='';}}}},makeUrlsAbsolute:function(node,baseUrl,walker){walker.walk(node,true,'HTMLArea.DOM.makeImageSourceAbsolute(node, args[0]) || HTMLArea.DOM.makeLinkHrefAbsolute(node, args[0])','Ext.emptyFn',[baseUrl]);},makeImageSourceAbsolute:function(node,baseUrl){if(/^img$/i.test(node.nodeName)){var src=node.getAttribute('src');if(src){node.setAttribute('src',HTMLArea.DOM.addBaseUrl(src,baseUrl));}
return true;}
return false;},makeLinkHrefAbsolute:function(node,baseUrl){if(/^a$/i.test(node.nodeName)){var href=node.getAttribute('href');if(href){node.setAttribute('href',HTMLArea.DOM.addBaseUrl(href,baseUrl));}
return true;}
return false;},addBaseUrl:function(url,baseUrl){var absoluteUrl=url;if(!/^[a-z0-9_]{2,}\:/i.test(absoluteUrl)){var base=baseUrl;while(absoluteUrl.match(/^\.\.\/(.*)/)){absoluteUrl=RegExp.$1;base.match(/(.*\:\/\/.*\/)[^\/]+\/$/);base=RegExp.$1;absoluteUrl=base+absoluteUrl;}
if(!/^.*\:\/\//.test(absoluteUrl)){absoluteUrl=baseUrl+absoluteUrl;}}
return absoluteUrl;}};}();HTMLArea.DOM.Walker=function(config){var configDefaults={keepComments:false,keepCDATASections:false,removeTags:/none/i,removeTagsAndContents:/none/i,keepTags:/.*/i,removeAttributes:/none/i,removeTrailingBR:true,baseUrl:''};Ext.apply(this,config,configDefaults);};HTMLArea.DOM.Walker=Ext.extend(HTMLArea.DOM.Walker,{walk:function(node,includeNode,startCallback,endCallback,args){if(!this.removeTagsAndContents.test(node.nodeName)){if(includeNode){eval(startCallback);}
var child=node.firstChild;while(child){this.walk(child,true,startCallback,endCallback,args);child=child.nextSibling;}
if(includeNode){eval(endCallback);}}},render:function(node,includeNode){this.html='';this.walk(node,includeNode,'args[0].renderNodeStart(node)','args[0].renderNodeEnd(node)',[this]);return this.html;},renderNodeStart:function(node){var html='';switch(node.nodeType){case HTMLArea.DOM.ELEMENT_NODE:if(this.keepTags.test(node.nodeName)&&!this.removeTags.test(node.nodeName)){html+=this.setOpeningTag(node);}
break;case HTMLArea.DOM.TEXT_NODE:html+=/^(script|style)$/i.test(node.parentNode.nodeName)?node.data:HTMLArea.htmlEncode(node.data);break;case HTMLArea.DOM.ENTITY_NODE:html+=node.nodeValue;break;case HTMLArea.DOM.ENTITY_REFERENCE_NODE:html+='&'+node.nodeValue+';';break;case HTMLArea.DOM.COMMENT_NODE:if(this.keepComments){html+='';}
break;case HTMLArea.DOM.CDATA_SECTION_NODE:if(this.keepCDATASections){html+='';}
break;default:break;}
this.html+=html;},renderNodeEnd:function(node){var html='';if(node.nodeType==HTMLArea.DOM.ELEMENT_NODE){if(this.keepTags.test(node.nodeName)&&!this.removeTags.test(node.nodeName)){html+=this.setClosingTag(node);}}
this.html+=html;},getAttributes:function(node){var attributes=node.attributes;var filterededAttributes=[];var attribute,attributeName,attributeValue;for(var i=attributes.length;--i>=0;){attribute=attributes.item(i);attributeName=attribute.nodeName.toLowerCase();attributeValue=attribute.nodeValue;if(/_moz|contenteditable|complete/.test(attributeName)||this.removeAttributes.test(attributeName)){continue;}
if(!attribute.specified&&attributeName!=='value'){continue;}
if(Ext.isIE){if(attributeName==='style'){attributeValue=node.style.cssText;}else if(attributeName==='href'||attributeName==='src'){attributeValue=this.stripBaseURL(attributeValue);}else if(attributeName==='value'&&/^li$/i.test(node.nodeName)&&attributeValue==0){continue;}}else if(Ext.isGecko){if(/(_moz|^$)/.test(attributeValue)){continue;}else if(attributeName==='href'||attributeName==='src'){attributeValue=HTMLArea.DOM.addBaseUrl(attributeValue,this.baseUrl);}}
if(attributeName==='id'&&/^ext-gen/.test(attributeValue)){continue;}
filterededAttributes.push({attributeName:attributeName,attributeValue:attributeValue});}
return(Ext.isWebKit||Ext.isOpera)?filterededAttributes.reverse():filterededAttributes;},setOpeningTag:function(node){var html='';if(/^br$/i.test(node.nodeName)){if(Ext.isGecko&&node.hasAttribute('_moz_editor_bogus_node')){return html;}else if(this.removeTrailingBR&&!node.nextSibling&&HTMLArea.isBlockElement(node.parentNode)&&(!node.previousSibling||!/^br$/i.test(node.previousSibling.nodeName))){if(!node.previousSibling&&node.parentNode&&/^p$/i.test(node.parentNode.nodeName)&&node.parentNode.className){html+=" ";}
return html;}}
var attributes=this.getAttributes(node);for(var i=0,n=attributes.length;i':'>');if(/^li$/i.test(node.nodeName)&&!/^[ou]l$/i.test(node.parentNode.nodeName)){html=''+html;}
return html;},setClosingTag:function(node){var html=HTMLArea.RE_noClosingTag.test(node.nodeName)?'':''+node.nodeName.toLowerCase()+'>';if(/^li$/i.test(node.nodeName)&&!/^[ou]l$/i.test(node.parentNode.nodeName)){html+='
';}
return html;},stripBaseURL:function(value){return value;}});HTMLArea.CSS.Parser=Ext.extend(Ext.util.Observable,{constructor:function(config){HTMLArea.CSS.Parser.superclass.constructor.call(this,{});var configDefaults={parseAttemptsMaximumNumber:17,prefixLabelWithClassName:false,postfixLabelWithClassName:false,showTagFreeClasses:false,tags:null,editor:null};Ext.apply(this,config,configDefaults);this.addEvents('HTMLAreaEventCssParsingComplete');},parsedClasses:{},isReady:false,cssLoaded:false,parseAttemptsCounter:0,attemptTimeout:null,error:null,getClasses:function(){return this.parsedClasses;},initiateParsing:function(){if(this.editor.config.classesUrl&&(typeof(HTMLArea.classesLabels)==='undefined')){this.editor.ajax.getJavascriptFile(this.editor.config.classesUrl,function(options,success,response){if(success){try{if(typeof(HTMLArea.classesLabels)==='undefined'){eval(response.responseText);this.editor.appendToLog('HTMLArea.CSS.Parser','initiateParsing','Javascript file successfully evaluated: '+this.editor.config.classesUrl);}}catch(e){this.editor.appendToLog('HTMLArea.CSS.Parser','initiateParsing','Error evaluating contents of Javascript file: '+this.editor.config.classesUrl);}}
this.parse();},this);}else{this.parse();}},parse:function(){if(this.editor.document){this.parseStyleSheets();if(!this.cssLoaded){if(this.parseAttemptsCounter-1){var match=pattern.exec(s.substring(index));s=s.substring(index+match[0].length);nodeName=(match[1]&&(match[1]!='*'))?match[1].toLowerCase().trim():'all';className=match[2];if(className&&!HTMLArea.reservedClassNames.test(className)){if(((nodeName!='all')&&(!this.tags||!this.tags[nodeName]))||((nodeName=='all')&&(!this.tags||!this.tags[nodeName])&&this.showTagFreeClasses)||(this.tags&&this.tags[nodeName]&&this.tags[nodeName].allowedClasses&&this.tags[nodeName].allowedClasses.test(className))){if(!this.parsedClasses[nodeName]){this.parsedClasses[nodeName]={};}
cssName=className;if(HTMLArea.classesLabels&&HTMLArea.classesLabels[className]){cssName=this.prefixLabelWithClassName?(className+' - '+HTMLArea.classesLabels[className]):HTMLArea.classesLabels[className];cssName=this.postfixLabelWithClassName?(cssName+' - '+className):cssName;}
this.parsedClasses[nodeName][className]=cssName;}}}}}},filterAllowedClasses:function(){Ext.iterate(this.tags,function(nodeName){var allowedClasses={};if(nodeName!=='all'&&Ext.isDefined(this.parsedClasses['all'])){if(this.tags&&this.tags[nodeName]&&this.tags[nodeName].allowedClasses){var allowed=this.tags[nodeName].allowedClasses;Ext.iterate(this.parsedClasses['all'],function(cssClass,value){if(allowed.test(cssClass)){allowedClasses[cssClass]=value;}});}else{allowedClasses=this.parsedClasses['all'];}}
if(Ext.isDefined(this.parsedClasses[nodeName])){if(this.tags&&this.tags[nodeName]&&this.tags[nodeName].allowedClasses){var allowed=this.tags[nodeName].allowedClasses;Ext.iterate(this.parsedClasses[nodeName],function(cssClass,value){if(allowed.test(cssClass)){allowedClasses[cssClass]=value;}});}else{Ext.iterate(this.parsedClasses[nodeName],function(cssClass,value){allowedClasses[cssClass]=value;});}}
this.parsedClasses[nodeName]=allowedClasses;},this);if(this.showTagFreeClasses&&Ext.isDefined(this.parsedClasses['all'])){Ext.iterate(this.parsedClasses,function(nodeName){if(nodeName!=='all'&&!this.tags[nodeName]){Ext.iterate(this.parsedClasses['all'],function(cssClass,value){this.parsedClasses[nodeName][cssClass]=value;},this);}},this);}},sort:function(){Ext.iterate(this.parsedClasses,function(nodeName,value){var classes=[];var sortedClasses={};Ext.iterate(value,function(cssClass){classes.push(cssClass);});function compare(a,b){x=value[a];y=value[b];return((xy)?1:0));}
classes=classes.sort(compare);for(var i=0;i>8)&0xFF;var b=(v>>16)&0xFF;return'rgb('+r+','+g+','+b+')';},colorToHex:function(v){if(typeof(v)==='undefined'||v==null){return'';}
function hex(d){return(d<16)?('0'+d.toString(16)):d.toString(16);};if(typeof(v)=='number'){var b=v&0xFF;var g=(v>>8)&0xFF;var r=(v>>16)&0xFF;return'#'+hex(r)+hex(g)+hex(b);}
if(v.substr(0,3)==='rgb'){var re=/rgb\s*\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*\)/;if(v.match(re)){var r=parseInt(RegExp.$1);var g=parseInt(RegExp.$2);var b=parseInt(RegExp.$3);return('#'+hex(r)+hex(g)+hex(b)).toUpperCase();}
return null;}
if(v.substr(0,1)==='#'){return v;}
return'';},checkIfColorInPalette:function(color){if(this.el&&!this.el.child('a.color-'+color)){this.deSelect();return false;}}}}();HTMLArea._makeColor=HTMLArea.util.Color.colorToRgb;HTMLArea._colorToRgb=HTMLArea.util.Color.colorToHex;Ext.ColorPalette.prototype.select=Ext.ColorPalette.prototype.select.createInterceptor(HTMLArea.util.Color.checkIfColorInPalette);Ext.override(Ext.ColorPalette,{deSelect:function(){if(this.el&&this.value){this.el.child('a.color-'+this.value).removeClass('x-color-palette-sel');this.value=null;}}});Ext.ux.menu.HTMLAreaColorMenu=Ext.extend(Ext.menu.Menu,{enableScrolling:false,hideOnClick:true,cls:'x-color-menu',colorPaletteValue:'',customColorsValue:'',plain:true,showSeparator:false,initComponent:function(){var paletteItems=[];var width='auto';if(this.colorsConfiguration){paletteItems.push({xtype:'container',layout:'anchor',width:160,style:{float:'right'},items:{xtype:'colorpalette',itemId:'custom-colors',cls:'htmlarea-custom-colors',colors:this.colorsConfiguration,value:this.value,allowReselect:true,tpl:new Ext.XTemplate(' {0}')}});}
if(this.colors.length){paletteItems.push({xtype:'container',layout:'anchor',items:{xtype:'colorpalette',itemId:'color-palette',cls:'color-palette',colors:this.colors,value:this.value,allowReselect:true}});}
if(this.colorsConfiguration&&this.colors.length){width=350;}
Ext.apply(this,{layout:'menu',width:width,items:paletteItems});Ext.ux.menu.HTMLAreaColorMenu.superclass.initComponent.call(this);this.standardPalette=this.find('itemId','color-palette')[0];this.customPalette=this.find('itemId','custom-colors')[0];if(this.standardPalette){this.standardPalette.purgeListeners();this.relayEvents(this.standardPalette,['select']);}
if(this.customPalette){this.customPalette.purgeListeners();this.relayEvents(this.customPalette,['select']);}
this.on('select',this.menuHide,this);if(this.handler){this.on('select',this.handler,this.scope||this);}},menuHide:function(){if(this.hideOnClick){this.hide(true);}}});Ext.reg('htmlareacolormenu',Ext.ux.menu.HTMLAreaColorMenu);Ext.ux.form.ColorPaletteField=Ext.extend(Ext.form.TriggerField,{triggerClass:'x-form-color-trigger',defaultColors:['000000','222222','444444','666666','999999','BBBBBB','DDDDDD','FFFFFF','660000','663300','996633','003300','003399','000066','330066','660066','990000','993300','CC9900','006600','0033FF','000099','660099','990066','CC0000','CC3300','FFCC00','009900','0066FF','0000CC','663399','CC0099','FF0000','FF3300','FFFF00','00CC00','0099FF','0000FF','9900CC','FF0099','CC3333','FF6600','FFFF33','00FF00','00CCFF','3366FF','9933FF','FF00FF','FF6666','FF6633','FFFF66','66FF66','00FFFF','3399FF','9966FF','FF66FF','FF9999','FF9966','FFFF99','99FF99','99FFFF','66CCFF','9999FF','FF99FF','FFCCCC','FFCC99','FFFFCC','CCFFCC','CCFFFF','99CCFF','CCCCFF','FFCCFF'],colorizeFieldBackgroud:true,colorizeFieldText:true,colorizeTrigger:false,editable:true,initComponent:function(){Ext.ux.form.ColorPaletteField.superclass.initComponent.call(this);if(!this.colors){this.colors=this.defaultColors;}
this.addEvents('select');},validateBlur:function(){return!this.menu||!this.menu.isVisible();},setValue:function(color){if(color){if(this.colorizeFieldBackgroud){this.el.applyStyles('background: #'+color+';');}
if(this.colorizeFieldText){this.el.applyStyles('color: #'+this.rgbToHex(this.invert(this.hexToRgb(color)))+';');}
if(this.colorizeTrigger){this.trigger.applyStyles('background-color: #'+color+';');}}
return Ext.ux.form.ColorPaletteField.superclass.setValue.call(this,color);},onDestroy:function(){Ext.destroy(this.menu);Ext.ux.form.ColorPaletteField.superclass.onDestroy.call(this);},onTriggerClick:function(){if(this.disabled){return;}
if(this.menu==null){this.menu=new Ext.ux.menu.HTMLAreaColorMenu({cls:'htmlarea-color-menu',hideOnClick:false,colors:this.colors,colorsConfiguration:this.colorsConfiguration,value:this.getValue()});}
this.onFocus();this.menu.show(this.el,"tl-bl?");this.menuEvents('on');},menuEvents:function(method){this.menu[method]('select',this.onSelect,this);this.menu[method]('hide',this.onMenuHide,this);this.menu[method]('show',this.onFocus,this);},onSelect:function(m,d){this.setValue(d);this.fireEvent('select',this,d);this.menu.hide();},onMenuHide:function(){this.focus(false,60);this.menuEvents('un');},invert:function(r,g,b){if(r instanceof Array){return this.invert.call(this,r[0],r[1],r[2]);}
return[255-r,255-g,255-b];},hexToRgb:function(hex){return[this.hexToDec(hex.substr(0,2)),this.hexToDec(hex.substr(2,2)),this.hexToDec(hex.substr(4,2))];},hexToDec:function(hex){var s=hex.split('');return((this.getHCharPos(s[0])*16)+this.getHCharPos(s[1]));},getHCharPos:function(c){var HCHARS='0123456789ABCDEF';return HCHARS.indexOf(c.toUpperCase());},rgbToHex:function(r,g,b){if(r instanceof Array){return this.rgbToHex.call(this,r[0],r[1],r[2]);}
return this.decToHex(r)+this.decToHex(g)+this.decToHex(b);},decToHex:function(n){var HCHARS='0123456789ABCDEF';n=parseInt(n,10);n=(!isNaN(n))?n:0;n=(n>255||n<0)?0:n;return HCHARS.charAt((n-n%16)/16)+HCHARS.charAt(n%16);}});Ext.reg('colorpalettefield',Ext.ux.form.ColorPaletteField);HTMLArea.getElementById=function(tag,id){var el,i,objs=document.getElementsByTagName(tag);for(i=objs.length;--i>=0&&(el=objs[i]);){if(el.id==id)return el;}
return null;};var lorem_ipsum=function(element,text){if(element.tagName.toLowerCase()=="textarea"&&element.id&&element.id.substr(0,7)=="RTEarea"){var editor=RTEarea[element.id.substr(7,element.id.length)]["editor"];editor.insertHTML(text);editor.toolbar.update();}};HTMLArea.initEditor=function(editorNumber){if(document.getElementById('pleasewait'+editorNumber)){if(HTMLArea.checkSupportedBrowser()){document.getElementById('pleasewait'+editorNumber).style.display='block';document.getElementById('editorWrap'+editorNumber).style.visibility='hidden';if(!HTMLArea.isReady){HTMLArea.initEditor.defer(150,null,[editorNumber]);}else{HTMLArea._appendToLog("[HTMLArea::initEditor]: Initializing editor with editor Id: "+editorNumber+".");var editor=new HTMLArea.Editor(Ext.apply(new HTMLArea.Config(editorNumber),RTEarea[editorNumber]));editor.generate();return false;}}else{document.getElementById('pleasewait'+editorNumber).style.display='none';document.getElementById('editorWrap'+editorNumber).style.visibility='visible';}}};HTMLArea.Base=function(){if(arguments.length){if(this==window){HTMLArea.Base.prototype.extend.call(arguments[0],arguments.callee.prototype);}else{this.extend(arguments[0]);}}};HTMLArea.Base.version="1.0.2";HTMLArea.Base.prototype={extend:function(source,value){var extend=HTMLArea.Base.prototype.extend;if(arguments.length==2){var ancestor=this[source];if((ancestor instanceof Function)&&(value instanceof Function)&&ancestor.valueOf()!=value.valueOf()&&/\bbase\b/.test(value)){var method=value;value=function(){var previous=this.base;this.base=ancestor;var returnValue=method.apply(this,arguments);this.base=previous;return returnValue;};value.valueOf=function(){return method;};value.toString=function(){return String(method);};}
return this[source]=value;}else if(source){var _prototype={toSource:null};var _protected=["toString","valueOf"];if(HTMLArea.Base._prototyping)_protected[2]="constructor";for(var i=0;(name=_protected[i]);i++){if(source[name]!=_prototype[name]){extend.call(this,name,source[name]);}}
for(var name in source){if(!_prototype[name]){extend.call(this,name,source[name]);}}}
return this;},base:function(){}};HTMLArea.Base.extend=function(_instance,_static){var extend=HTMLArea.Base.prototype.extend;if(!_instance)_instance={};HTMLArea.Base._prototyping=true;var _prototype=new this;extend.call(_prototype,_instance);var constructor=_prototype.constructor;_prototype.constructor=this;delete HTMLArea.Base._prototyping;var klass=function(){if(!HTMLArea.Base._prototyping)constructor.apply(this,arguments);this.constructor=klass;};klass.prototype=_prototype;klass.extend=this.extend;klass.implement=this.implement;klass.toString=function(){return String(constructor);};extend.call(klass,_static);var object=constructor?klass:_prototype;return object;};HTMLArea.Base.implement=function(_interface){if(_interface instanceof Function)_interface=_interface.prototype;this.prototype.extend(_interface);};HTMLArea.Plugin=HTMLArea.Base.extend({constructor:function(editor,pluginName){this.editor=editor;this.editorNumber=editor.editorId;this.editorId=editor.editorId;this.editorConfiguration=editor.config;this.name=pluginName;try{this.I18N=HTMLArea.I18N[this.name];}catch(e){this.I18N=new Object();}
return this.configurePlugin(editor);},configurePlugin:function(editor){return false;},registerPluginInformation:function(pluginInformation){if(typeof(pluginInformation)!=="object"){this.appendToLog("registerPluginInformation","Plugin information was not provided");return false;}else{this.pluginInformation=pluginInformation;this.pluginInformation.name=this.name;this.pluginInformation.developer_url=this.pluginInformation.developerUrl;this.pluginInformation.c_owner=this.pluginInformation.copyrightOwner;this.pluginInformation.sponsor_url=this.pluginInformation.sponsorUrl;return true;}},getPluginInformation:function(){return this.pluginInformation;},getPluginInstance:function(pluginName){return this.editor.getPlugin(pluginName);},getEditorMode:function(){return this.editor.getMode();},isButtonInToolbar:function(buttonId){var index=-1;Ext.each(this.editorConfiguration.toolbar,function(row){Ext.each(row,function(group){index=group.indexOf(buttonId);return index===-1;});return index===-1;});return index!==-1;},getButton:function(buttonId){return this.editor.toolbar.getButton(buttonId);},registerButton:function(buttonConfiguration){if(this.isButtonInToolbar(buttonConfiguration.id)){if(Ext.isString(buttonConfiguration.action)&&Ext.isFunction(this[buttonConfiguration.action])){buttonConfiguration.plugins=this;if(buttonConfiguration.dialog){if(!buttonConfiguration.dimensions){buttonConfiguration.dimensions={width:250,height:250};}
buttonConfiguration.dimensions.top=buttonConfiguration.dimensions.top?buttonConfiguration.dimensions.top:this.editorConfiguration.dialogueWindows.defaultPositionFromTop;buttonConfiguration.dimensions.left=buttonConfiguration.dimensions.left?buttonConfiguration.dimensions.left:this.editorConfiguration.dialogueWindows.defaultPositionFromLeft;}
buttonConfiguration.hidden=buttonConfiguration.hide;if(this.editorConfiguration.buttons[this.editorConfiguration.convertButtonId[buttonConfiguration.id]]){Ext.applyIf(buttonConfiguration,this.editorConfiguration.buttons[this.editorConfiguration.convertButtonId[buttonConfiguration.id]]);}
if(this.editorConfiguration.registerButton(buttonConfiguration)){var hotKey=buttonConfiguration.hotKey?buttonConfiguration.hotKey:((this.editorConfiguration.buttons[this.editorConfiguration.convertButtonId[buttonConfiguration.id]]&&this.editorConfiguration.buttons[this.editorConfiguration.convertButtonId[buttonConfiguration.id]].hotKey)?this.editorConfiguration.buttons[this.editorConfiguration.convertButtonId[buttonConfiguration.id]].hotKey:null);if(!hotKey&&buttonConfiguration.hotKey=="0"){hotKey="0";}
if(!hotKey&&this.editorConfiguration.buttons[this.editorConfiguration.convertButtonId[buttonConfiguration.id]]&&this.editorConfiguration.buttons[this.editorConfiguration.convertButtonId[buttonConfiguration.id]].hotKey=="0"){hotKey="0";}
if(hotKey||hotKey=="0"){var hotKeyConfiguration={id:hotKey,cmd:buttonConfiguration.id};return this.registerHotKey(hotKeyConfiguration);}
return true;}}else{this.appendToLog("registerButton","Function "+buttonConfiguration.action+" was not defined when registering button "+buttonConfiguration.id);}}
return false;},registerDropDown:function(dropDownConfiguration){if(this.isButtonInToolbar(dropDownConfiguration.id)){if(Ext.isString(dropDownConfiguration.action)&&Ext.isFunction(this[dropDownConfiguration.action])){dropDownConfiguration.plugins=this;dropDownConfiguration.hidden=dropDownConfiguration.hide;dropDownConfiguration.xtype='htmlareacombo';if(this.editorConfiguration.buttons[this.editorConfiguration.convertButtonId[dropDownConfiguration.id]]){Ext.applyIf(dropDownConfiguration,this.editorConfiguration.buttons[this.editorConfiguration.convertButtonId[dropDownConfiguration.id]]);}
return this.editorConfiguration.registerButton(dropDownConfiguration);}else{this.appendToLog('registerDropDown','Function '+dropDownConfiguration.action+' was not defined when registering drop-down '+dropDownConfiguration.id);}}
return false;},registerText:function(textConfiguration){if(this.isButtonInToolbar(textConfiguration.id)){textConfiguration.plugins=this;textConfiguration.xtype='htmlareatoolbartext';return this.editorConfiguration.registerButton(textConfiguration);}
return false;},getDropDownConfiguration:function(dropDownId){return this.editorConfiguration.buttonsConfig[dropDownId];},registerHotKey:function(hotKeyConfiguration){return this.editorConfiguration.registerHotKey(hotKeyConfiguration);},translateHotKey:function(key){if(typeof(this.editorConfiguration.hotKeyList[key])!=="undefined"){var buttonId=this.editorConfiguration.hotKeyList[key].cmd;if(typeof(buttonId)!=="undefined"){return buttonId;}else{return"";}}
return"";},getHotKeyConfiguration:function(key){if(Ext.isDefined(this.editorConfiguration.hotKeyList[key])){return this.editorConfiguration.hotKeyList[key];}else{return null;}},init:Ext.emptyFn,onUpdateToolbar:Ext.emptyFn,onKeyPress:null,onMode:function(mode){if(mode==="textmode"&&this.dialog&&HTMLArea.Dialog[this.name]==this.dialog&&!(this.dialog.buttonId&&this.editorConfiguration.buttons[this.dialog.buttonId]&&this.editorConfiguration.buttons[this.dialog.buttonId].textMode)){this.dialog.close();}},onGenerate:Ext.emptyFn,makeFunctionReference:function(functionName){var self=this;return(function(arg1,arg2,arg3){return(self[functionName](arg1,arg2,arg3));});},localize:function(label){return this.I18N[label]||HTMLArea.localize(label);},getHelpTip:function(fieldName,label,pluginName){if(Ext.isDefined(TYPO3.ContextHelp)){var pluginName=Ext.isDefined(pluginName)?pluginName:this.name;return''+(this.localize(label)||label)+'';}else{return this.localize(label)||label;}},getJavascriptFile:function(url,callback){this.appendToLog('getJavascriptFile','Requesting script '+url);return this.editor.ajax.getJavascriptFile(url,callback,this);},postData:function(url,data,callback){this.appendToLog('postData','Posting to '+url+'.');return this.editor.ajax.postData(url,data,callback,this);},openDialog:function(buttonId,url,action,arguments,dimensions,showScrollbars,dialogOpener){if(this.dialog&&this.dialog.hasOpenedWindow()&&this.dialog.buttonId===buttonId){this.dialog.focus();return this.dialog;}else{var actionFunctionReference=action;if(typeof(action)==="string"){if(typeof(this[action])==="function"){var actionFunctionReference=this.makeFunctionReference(action);}else{this.appendToLog("openDialog","Function "+action+" was not defined when opening dialog for "+buttonId);}}
return new HTMLArea.Dialog(this,buttonId,url,actionFunctionReference,arguments,this.getWindowDimensions(dimensions,buttonId),(showScrollbars?showScrollbars:"no"),dialogOpener);}},openContainerWindow:function(buttonId,title,dimensions,url){this.dialog=new Ext.Window({id:this.editor.editorId+buttonId,title:this.localize(title)||title,cls:'htmlarea-window',width:dimensions.width,border:false,resizable:true,iconCls:this.getButton(buttonId).iconCls,listeners:{afterrender:{fn:this.onContainerResize},resize:{fn:this.onContainerResize},close:{fn:this.onClose,scope:this}},items:{xtype:'box',height:dimensions.height-20,itemId:'content-iframe',autoEl:{tag:'iframe',cls:'content-iframe',src:url}}});this.show();},onContainerResize:function(panel){var iframe=panel.getComponent('content-iframe');if(iframe.rendered){iframe.getEl().setSize(panel.getInnerWidth(),panel.getInnerHeight());}},getWindowDimensions:function(dimensions,buttonId){this.dialogueWindowDimensions={width:250,height:250};if(this.editorConfiguration.dialogueWindows){Ext.apply(this.dialogueWindowDimensions,this.editorConfiguration.dialogueWindows);}
if(this.editorConfiguration.buttonsConfig[buttonId]){Ext.apply(this.dialogueWindowDimensions,this.editorConfiguration.buttonsConfig[buttonId].dimensions);}
Ext.apply(this.dialogueWindowDimensions,dimensions);var buttonConfiguration=this.editorConfiguration.buttons[this.editorConfiguration.convertButtonId[buttonId]];if(buttonConfiguration&&buttonConfiguration.dialogueWindow){Ext.apply(this.dialogueWindowDimensions,buttonConfiguration.dialogueWindow);}
return this.dialogueWindowDimensions;},makeUrlFromPopupName:function(popupName){return(popupName?this.editor.popupURL("plugin://"+this.name+"/"+popupName):this.editor.popupURL("blank.html"));},makeUrlFromModulePath:function(modulePath,parameters){return modulePath+'?'+this.editorConfiguration.RTEtsConfigParams+'&editorNo='+this.editor.editorId+'&sys_language_content='+this.editorConfiguration.sys_language_content+'&contentTypo3Language='+this.editorConfiguration.typo3ContentLanguage+'&contentTypo3Charset='+encodeURIComponent(this.editorConfiguration.typo3ContentCharset)+(parameters?parameters:'');},appendToLog:function(functionName,text){this.editor.appendToLog(this.name,functionName,text);},addConfigElement:function(configElement,configArray){if(!Ext.isEmpty(configElement)){configArray.push(configElement);}},syncHeight:function(tabPanel,tab){var position=this.dialog.getPosition();if(position[0]>0){this.dialog.setPosition(position);}},show:function(){this.dialog.mon(this.editor,'HTMLAreaEventModeChange',this.close,this,{single:true});this.saveSelection();if(typeof(this.dialogueWindowDimensions)!=='undefined'){this.dialog.setPosition(this.dialogueWindowDimensions.positionFromLeft,this.dialogueWindowDimensions.positionFromTop);}
this.dialog.show();this.restoreSelection();},close:function(){this.saveSelection();this.dialog.close();},onClose:function(){this.editor.focus();this.restoreSelection();this.editor.updateToolbar();},onCancel:function(){this.dialog.close();this.editor.focus();},saveSelection:function(){if(Ext.isIE){this.savedRange=this.editor._createRange(this.editor._getSelection());}},restoreSelection:function(){if(Ext.isIE&&this.savedRange){try{this.editor.selectRange(this.savedRange);}catch(e){}}},buildButtonConfig:function(button,handler){return{xtype:'button',text:this.localize(button),listeners:{click:{fn:handler,scope:this}}};}});HTMLArea.Dialog=HTMLArea.Base.extend({constructor:function(plugin,buttonId,url,action,arguments,dimensions,showScrollbars,dialogOpener){this.window=window.window?window.window:window.self;this.plugin=plugin;this.buttonId=buttonId;this.action=action;if(typeof(arguments)!=="undefined"){this.arguments=arguments;}
this.plugin.dialog=this;if(HTMLArea.Dialog[this.plugin.name]&&HTMLArea.Dialog[this.plugin.name].hasOpenedWindow()&&HTMLArea.Dialog[this.plugin.name].plugin!=this.plugin){HTMLArea.Dialog[this.plugin.name].close();}
HTMLArea.Dialog[this.plugin.name]=this;this.dialogWindow=window.open(url,this.plugin.name+"Dialog","toolbar=no,location=no,directories=no,menubar=no,resizable=yes,top="+dimensions.top+",left="+dimensions.left+",dependent=yes,dialog=yes,chrome=no,width="+dimensions.width+",height="+dimensions.height+",scrollbars="+showScrollbars);if(!this.dialogWindow){this.plugin.appendToLog("openDialog","Dialog window could not be opened with url "+url);return false;}
if(typeof(dialogOpener)!=="undefined"){this.dialogWindow.opener=dialogOpener;this.dialogWindow.opener.openedDialog=this;}
if(!this.dialogWindow.opener){this.dialogWindow.opener=this.window;}
return true;},addButtons:function(){var self=this;var div=this.document.createElement("div");this.content.appendChild(div);div.className="buttons";for(var i=0;i=0;){var tag=tags[ti];var els=this.content.getElementsByTagName(tag);for(var j=0;j=0;){var element=elements[i];if(element.firstChild&&element.firstChild.data){label=this.plugin.localize(element.firstChild.data);if(label)element.firstChild.data=label;}
if(element.title){label=this.plugin.localize(element.title);if(label)element.title=label;}
if(types[type]=="option"&&element.selected){element.selected=false;element.selected=true;}}}
label=this.plugin.localize(this.dialogWindow.document.title);if(label)this.dialogWindow.document.title=label;},resize:function(noResize){var buttonConfiguration=this.plugin.editorConfiguration.buttons[this.plugin.editorConfiguration.convertButtonId[this.buttonId]];if(!this.plugin.editorConfiguration.dialogueWindows.doNotResize&&(!buttonConfiguration||!buttonConfiguration.dialogueWindow||!buttonConfiguration.dialogueWindow.doNotResize)){var dialogWindow=this.dialogWindow;var doc=dialogWindow.document;var content=doc.getElementById("content");if(Ext.isGecko||((Ext.isIE||Ext.isOpera||(Ext.isWebKit&&!Ext.isChrome))&&content)){var self=this;setTimeout(function(){if(!noResize){if(content){self.resizeToContent(content);}else if(dialogWindow.sizeToContent){dialogWindow.sizeToContent();}}
self.centerOnParent();},75);}else if(!noResize){var body=doc.body;if(Ext.isIE){var innerX=(doc.documentElement&&doc.documentElement.clientWidth)?doc.documentElement.clientWidth:body.clientWidth;var innerY=(doc.documentElement&&doc.documentElement.clientHeight)?doc.documentElement.clientHeight:body.clientHeight;var pageY=Math.max(body.scrollHeight,body.offsetHeight);if(innerY==pageY){dialogWindow.resizeTo(body.scrollWidth,body.scrollHeight+80);}else{dialogWindow.resizeBy((innerX