HtmlEditor - fire HTML cleanup on loading, and fix compress issues
authorAlan Knowles <alan@akbkhome.com>
Fri, 20 May 2011 06:28:47 +0000 (06:28 +0000)
committerAlan Knowles <alan@akbkhome.com>
Wed, 7 Sep 2011 01:43:18 +0000 (09:43 +0800)
Roo/form/HtmlEditor.js
roojs-all.js
roojs-debug.js
roojs-ui-debug.js
roojs-ui.js

index c178596..f72d2d8 100644 (file)
@@ -345,6 +345,7 @@ Roo.form.HtmlEditor = Roo.extend(Roo.form.Field, {
     syncValue : function(){
         if(this.initialized){
             var bd = (this.doc.body || this.doc.documentElement);
+            this.cleanUpPaste();
             var html = bd.innerHTML;
             if(Roo.isSafari){
                 var bs = bd.getAttribute('style'); // Safari puts text-align styles on the body element!
@@ -371,8 +372,12 @@ Roo.form.HtmlEditor = Roo.extend(Roo.form.Field, {
             if(v.length < 1){
                 v = '&#160;';
             }
+            
             if(this.fireEvent('beforepush', this, v) !== false){
-                (this.doc.body || this.doc.documentElement).innerHTML = v;
+                var d = (this.doc.body || this.doc.documentElement);
+                d.innerHTML = v;
+                this.cleanUpPaste();
+                this.el.dom.value = d.innerHTML;
                 this.fireEvent('push', this, v);
             }
         }
@@ -867,7 +872,7 @@ Roo.form.HtmlEditor = Roo.extend(Roo.form.Field, {
     {
         // cleans up the whole document..
       //  console.log('cleanuppaste');
-        this.cleanUpChildren(this.doc.body)
+        this.cleanUpChildren(this.doc.body);
         
         
     },
index 56270ce..619c1de 100644 (file)
@@ -705,8 +705,8 @@ Roo.form.Radio=function(){Roo.form.Radio.superclass.constructor.apply(this,argum
 Roo.form.HtmlEditor=Roo.extend(Roo.form.Field,{toolbars:false,createLinkText:'Please enter the URL for the link:',defaultLinkValue:'http:/'+'/',frameId:false,validationEvent:false,deferHeight:true,initialized:false,activated:false,sourceEditMode:false,onFocus:Roo.emptyFn,iframePad:3,hideMode:'offsets',defaultAutoCreate:{tag:"textarea",style:"width:500px;height:300px;",autocomplete:"off"},initComponent:function(){this.addEvents({initialize:true,activate:true,beforesync:true,beforepush:true,sync:true,push:true,editmodechange:true,editorevent:true})},createToolbar:function(A){if(!A.toolbars||!A.toolbars.length){A.toolbars=[new Roo.form.HtmlEditor.ToolbarStandard()];}for(var i=0;i<A.toolbars.length;i++){A.toolbars[i]=Roo.factory(A.toolbars[i],Roo.form.HtmlEditor);A.toolbars[i].init(A);}},getDocMarkup:function(){return '<html><head><style type="text/css">body{border:0;margin:0;padding:3px;height:98%;cursor:text;}</style></head><body></body></html>';},onRender:function(ct,A){Roo.form.HtmlEditor.superclass.onRender.call(this,ct,A);this.el.dom.style.border='0 none';this.el.dom.setAttribute('tabIndex',-1);this.el.addClass('x-hidden');if(Roo.isIE){this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;')}
 this.wrap=this.el.wrap({cls:'x-html-editor-wrap',cn:{cls:'x-html-editor-tb'}});this.frameId=Roo.id();this.createToolbar(this);var B=this.wrap.createChild({tag:'iframe',id:this.frameId,name:this.frameId,frameBorder:'no','src':Roo.SSL_SECURE_URL?Roo.SSL_SECURE_URL:"javascript:false"});this.iframe=B.dom;this.assignDocWin();this.doc.designMode='on';this.doc.open();this.doc.write(this.getDocMarkup());this.doc.close();var C={run:function(){this.assignDocWin();if(this.doc.body||this.doc.readyState=='complete'){try{this.doc.designMode="on";}catch(e){return;}
 Roo.TaskMgr.stop(C);this.initEditor.defer(10,this);}},interval:10,duration:10000,scope:this};Roo.TaskMgr.start(C);if(!this.width){this.setSize(this.el.getSize());}},onResize:function(w,h){Roo.form.HtmlEditor.superclass.onResize.apply(this,arguments);if(this.el&&this.iframe){if(typeof w=='number'){var aw=w-this.wrap.getFrameWidth('lr');this.el.setWidth(this.adjustWidth('textarea',aw));this.iframe.style.width=aw+'px';}if(typeof h=='number'){var A=0;for(var i=0;i<this.toolbars.length;i++){A+=this.toolbars[i].tb.el.getHeight();}var ah=h-this.wrap.getFrameWidth('tb')-A;this.el.setHeight(this.adjustWidth('textarea',ah));this.iframe.style.height=ah+'px';if(this.doc){(this.doc.body||this.doc.documentElement).style.height=(ah-(this.iframePad*2))+'px';}}}},toggleSourceEdit:function(A){this.sourceEditMode=A===true;if(this.sourceEditMode){this.syncValue();this.iframe.className='x-hidden';this.el.removeClass('x-hidden');this.el.dom.removeAttribute('tabIndex');this.el.focus();}else {this.pushValue();this.iframe.className='';this.el.addClass('x-hidden');this.el.dom.setAttribute('tabIndex',-1);this.deferFocus();}
-this.setSize(this.wrap.getSize());this.fireEvent('editmodechange',this,this.sourceEditMode);},createLink:function(){var A=prompt(this.createLinkText,this.defaultLinkValue);if(A&&A!='http:/'+'/'){this.relayCmd('createlink',A);}},adjustSize:Roo.BoxComponent.prototype.adjustSize,getResizeEl:function(){return this.wrap;},getPositionEl:function(){return this.wrap;},initEvents:function(){this.originalValue=this.getValue();},markInvalid:Roo.emptyFn,clearInvalid:Roo.emptyFn,setValue:function(v){Roo.form.HtmlEditor.superclass.setValue.call(this,v);this.pushValue();},cleanHtml:function(A){A=String(A);if(A.length>5){if(Roo.isSafari){A=A.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi,'');}}if(A=='&nbsp;'){A='';}return A;},syncValue:function(){if(this.initialized){var bd=(this.doc.body||this.doc.documentElement);var A=bd.innerHTML;if(Roo.isSafari){var bs=bd.getAttribute('style');var m=bs.match(/text-align:(.*?);/i);if(m&&m[1]){A='<div style="'+m[0]+'">'+A+'</div>';}}
-A=this.cleanHtml(A);if(this.fireEvent('beforesync',this,A)!==false){this.el.dom.value=A;this.fireEvent('sync',this,A);}}},pushValue:function(){if(this.initialized){var v=this.el.dom.value;if(v.length<1){v='&#160;';}if(this.fireEvent('beforepush',this,v)!==false){(this.doc.body||this.doc.documentElement).innerHTML=v;this.fireEvent('push',this,v);}}},deferFocus:function(){this.focus.defer(10,this);},focus:function(){if(this.win&&!this.sourceEditMode){this.win.focus();}else {this.el.focus();}},assignDocWin:function(){var A=this.iframe;if(Roo.isIE){this.doc=A.contentWindow.document;this.win=A.contentWindow;}else {if(!Roo.get(this.frameId)){return;}
+this.setSize(this.wrap.getSize());this.fireEvent('editmodechange',this,this.sourceEditMode);},createLink:function(){var A=prompt(this.createLinkText,this.defaultLinkValue);if(A&&A!='http:/'+'/'){this.relayCmd('createlink',A);}},adjustSize:Roo.BoxComponent.prototype.adjustSize,getResizeEl:function(){return this.wrap;},getPositionEl:function(){return this.wrap;},initEvents:function(){this.originalValue=this.getValue();},markInvalid:Roo.emptyFn,clearInvalid:Roo.emptyFn,setValue:function(v){Roo.form.HtmlEditor.superclass.setValue.call(this,v);this.pushValue();},cleanHtml:function(A){A=String(A);if(A.length>5){if(Roo.isSafari){A=A.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi,'');}}if(A=='&nbsp;'){A='';}return A;},syncValue:function(){if(this.initialized){var bd=(this.doc.body||this.doc.documentElement);this.cleanUpPaste();var A=bd.innerHTML;if(Roo.isSafari){var bs=bd.getAttribute('style');var m=bs.match(/text-align:(.*?);/i);if(m&&m[1]){A='<div style="'+m[0]+'">'+A+'</div>';}}
+A=this.cleanHtml(A);if(this.fireEvent('beforesync',this,A)!==false){this.el.dom.value=A;this.fireEvent('sync',this,A);}}},pushValue:function(){if(this.initialized){var v=this.el.dom.value;if(v.length<1){v='&#160;';}if(this.fireEvent('beforepush',this,v)!==false){var d=(this.doc.body||this.doc.documentElement);d.innerHTML=v;this.cleanUpPaste();this.el.dom.value=d.innerHTML;this.fireEvent('push',this,v);}}},deferFocus:function(){this.focus.defer(10,this);},focus:function(){if(this.win&&!this.sourceEditMode){this.win.focus();}else {this.el.focus();}},assignDocWin:function(){var A=this.iframe;if(Roo.isIE){this.doc=A.contentWindow.document;this.win=A.contentWindow;}else {if(!Roo.get(this.frameId)){return;}
 this.doc=(A.contentDocument||Roo.get(this.frameId).dom.document);this.win=Roo.get(this.frameId).dom.contentWindow;}},initEditor:function(){this.assignDocWin();this.doc.designMode="on";this.doc.open();this.doc.write(this.getDocMarkup());this.doc.close();var A=(this.doc.body||this.doc.documentElement);var ss=this.el.getStyles('font-size','background-image','background-repeat');ss['background-attachment']='fixed';A.bgProperties='fixed';Roo.DomHelper.applyStyles(A,ss);Roo.EventManager.on(this.doc,{'mousedown':this.onEditorEvent,'dblclick':this.onEditorEvent,'click':this.onEditorEvent,'keyup':this.onEditorEvent,buffer:100,scope:this});if(Roo.isGecko){Roo.EventManager.on(this.doc,'keypress',this.mozKeyPress,this);}if(Roo.isIE||Roo.isSafari||Roo.isOpera){Roo.EventManager.on(this.doc,'keydown',this.fixKeys,this);}
 this.initialized=true;this.fireEvent('initialize',this);this.pushValue();},onDestroy:function(){if(this.rendered){for(var i=0;i<this.toolbars.length;i++){this.toolbars[i].onDestroy();}
 this.wrap.dom.innerHTML='';this.wrap.remove();}},onFirstFocus:function(){this.assignDocWin();this.activated=true;for(var i=0;i<this.toolbars.length;i++){this.toolbars[i].onFirstFocus();}if(Roo.isGecko){this.win.focus();var s=this.win.getSelection();if(!s.focusNode||s.focusNode.nodeType!=3){var r=s.getRangeAt(0);r.selectNodeContents((this.doc.body||this.doc.documentElement));r.collapse(true);this.deferFocus();}try{this.execCmd('useCSS',true);this.execCmd('styleWithCSS',false);}catch(e){}}
@@ -714,7 +714,7 @@ this.fireEvent('activate',this);},adjustFont:function(A){var B=A.cmd=='increasef
 v=Math.max(1,v+B);this.execCmd('FontSize',v);},onEditorEvent:function(e){this.fireEvent('editorevent',this,e);this.syncValue();},insertTag:function(tg){this.execCmd("formatblock",tg);},insertText:function(A){range=this.createRange();range.deleteContents();range.insertNode(this.doc.createTextNode(A));},relayBtnCmd:function(A){this.relayCmd(A.cmd);},relayCmd:function(A,B){this.win.focus();this.execCmd(A,B);this.fireEvent('editorevent',this);this.deferFocus();},execCmd:function(A,B){this.doc.execCommand(A,false,B===undefined?null:B);this.syncValue();},insertAtCursor:function(A){if(!this.activated){return;}if(Roo.isIE){this.win.focus();var r=this.doc.selection.createRange();if(r){r.collapse(true);r.pasteHTML(A);this.syncValue();this.deferFocus();}}else if(Roo.isGecko||Roo.isOpera||Roo.isSafari){this.win.focus();this.execCmd('InsertHTML',A);this.deferFocus();}},mozKeyPress:function(e){if(e.ctrlKey){var c=e.getCharCode(),A;if(c>0){c=String.fromCharCode(c).toLowerCase();switch(c){case 'b':A='bold';break;case 'i':A='italic';break;case 'u':A='underline';case 'v':this.cleanUpPaste.defer(100,this);return;break;}if(A){this.win.focus();this.execCmd(A);this.deferFocus();e.preventDefault();}}}},fixKeys:function(){if(Roo.isIE){return function(e){var k=e.getKey(),r;if(k==e.TAB){e.stopEvent();r=this.doc.selection.createRange();if(r){r.collapse(true);r.pasteHTML('&#160;&#160;&#160;&#160;');this.deferFocus();}return;}if(k==e.ENTER){r=this.doc.selection.createRange();if(r){var A=r.parentElement();if(!A||A.tagName.toLowerCase()!='li'){e.stopEvent();r.pasteHTML('<br />');r.collapse(false);r.select();}}}if(String.fromCharCode(k).toLowerCase()=='v'){this.cleanUpPaste.defer(100,this);return;}};}else if(Roo.isOpera){return function(e){var k=e.getKey();if(k==e.TAB){e.stopEvent();this.win.focus();this.execCmd('InsertHTML','&#160;&#160;&#160;&#160;');this.deferFocus();}if(String.fromCharCode(k).toLowerCase()=='v'){this.cleanUpPaste.defer(100,this);return;}};}else if(Roo.isSafari){return function(e){var k=e.getKey();if(k==e.TAB){e.stopEvent();this.execCmd('InsertText','\t');this.deferFocus();return;}if(String.fromCharCode(k).toLowerCase()=='v'){this.cleanUpPaste.defer(100,this);return;}};}}(),getAllAncestors:function(){var p=this.getSelectedNode();var a=[];if(!p){a.push(p);p=this.getParentElement();}while(p&&(p.nodeType==1)&&(p.tagName.toLowerCase()!='body')){a.push(p);p=p.parentNode;}
 a.push(this.doc.body);return a;},lastSel:false,lastSelNode:false,getSelection:function(){this.assignDocWin();return Roo.isIE?this.doc.selection:this.win.getSelection();},getSelectedNode:function(){var A=this.createRange(this.getSelection());if(Roo.isIE){var B=A.parentElement();while(true){var C=A.duplicate();C.moveToElementText(B);if(C.inRange(A)){break;}if((B.nodeType!=1)||(B.tagName.toLowerCase()=='body')){break;}
 B=B.parentElement;}return B;}var ar=A.endContainer.childNodes;if(!ar.length){ar=A.commonAncestorContainer.childNodes;}var D=[];var E=[];var F=false;for(var i=0;i<ar.length;i++){if((ar[i].nodeType==3)&&(!ar[i].data.length)){continue;}if(this.rangeIntersectsNode(A,ar[i])&&this.rangeCompareNode(A,ar[i])==3){D.push(ar[i]);continue;}if((ar[i].nodeType==1)&&this.rangeIntersectsNode(A,ar[i])&&(this.rangeCompareNode(A,ar[i])>0)){E.push(ar[i]);continue;}if(!this.rangeIntersectsNode(A,ar[i])||(this.rangeCompareNode(A,ar[i])==0)){continue;}
-F=true;}if(!D.length&&E.length){D=E;}if(F||!D.length||(D.length>1)){return false;}return D[0];},createRange:function(A){if(typeof A!="undefined"){try{return A.getRangeAt?A.getRangeAt(0):A.createRange();}catch(e){return this.doc.createRange();}}else {return this.doc.createRange();}},getParentElement:function(){this.assignDocWin();var A=Roo.isIE?this.doc.selection:this.win.getSelection();var B=this.createRange(A);try{var p=B.commonAncestorContainer;while(p.nodeType==3){p=p.parentNode;}return p;}catch(e){return null;}},rangeIntersectsNode:function(A,B){var C=B.ownerDocument.createRange();try{C.selectNode(B);}catch(e){nodeRange.selectNodeContents(node);}return A.compareBoundaryPoints(Range.END_TO_START,C)==-1&&A.compareBoundaryPoints(Range.START_TO_END,C)==1;},rangeCompareNode:function(A,B){var C=B.ownerDocument.createRange();try{C.selectNode(B);}catch(e){nodeRange.selectNodeContents(node);}var D=A.compareBoundaryPoints(Range.START_TO_START,C)==1;var E=A.compareBoundaryPoints(Range.END_TO_END,C)==-1;if(D&&!E)return 0;if(!D&&E)return 1;if(D&&E)return 2;return 3;},cleanUpPaste:function(){this.cleanUpChildren(this.doc.body)},cleanUpChildren:function(n){if(!n.childNodes.length){return;}for(var i=n.childNodes.length-1;i>-1;i--){this.cleanUpChild(n.childNodes[i]);}},cleanUpChild:function(A){if(A.nodeName=="#text"){return;}if(A.nodeName=="#comment"){A.parentNode.removeChild(A);return;}if(Roo.form.HtmlEditor.black.indexOf(A.tagName.toLowerCase())>-1){A.parentNode.removeChild(A);return;}if(!A.attributes||!A.attributes.length){this.cleanUpChildren(A);return;}function cleanAttr(n,v){if(v.match(/^\./)||v.match(/^\//)){return;}if(v.match(/^(http|https):\/\//)||v.match(/^mailto:/)){return;}
+F=true;}if(!D.length&&E.length){D=E;}if(F||!D.length||(D.length>1)){return false;}return D[0];},createRange:function(A){if(typeof A!="undefined"){try{return A.getRangeAt?A.getRangeAt(0):A.createRange();}catch(e){return this.doc.createRange();}}else {return this.doc.createRange();}},getParentElement:function(){this.assignDocWin();var A=Roo.isIE?this.doc.selection:this.win.getSelection();var B=this.createRange(A);try{var p=B.commonAncestorContainer;while(p.nodeType==3){p=p.parentNode;}return p;}catch(e){return null;}},rangeIntersectsNode:function(A,B){var C=B.ownerDocument.createRange();try{C.selectNode(B);}catch(e){nodeRange.selectNodeContents(node);}return A.compareBoundaryPoints(Range.END_TO_START,C)==-1&&A.compareBoundaryPoints(Range.START_TO_END,C)==1;},rangeCompareNode:function(A,B){var C=B.ownerDocument.createRange();try{C.selectNode(B);}catch(e){nodeRange.selectNodeContents(node);}var D=A.compareBoundaryPoints(Range.START_TO_START,C)==1;var E=A.compareBoundaryPoints(Range.END_TO_END,C)==-1;if(D&&!E)return 0;if(!D&&E)return 1;if(D&&E)return 2;return 3;},cleanUpPaste:function(){this.cleanUpChildren(this.doc.body);},cleanUpChildren:function(n){if(!n.childNodes.length){return;}for(var i=n.childNodes.length-1;i>-1;i--){this.cleanUpChild(n.childNodes[i]);}},cleanUpChild:function(A){if(A.nodeName=="#text"){return;}if(A.nodeName=="#comment"){A.parentNode.removeChild(A);return;}if(Roo.form.HtmlEditor.black.indexOf(A.tagName.toLowerCase())>-1){A.parentNode.removeChild(A);return;}if(!A.attributes||!A.attributes.length){this.cleanUpChildren(A);return;}function cleanAttr(n,v){if(v.match(/^\./)||v.match(/^\//)){return;}if(v.match(/^(http|https):\/\//)||v.match(/^mailto:/)){return;}
 Roo.log("(REMOVE)"+A.tagName+'.'+n+'='+v);A.removeAttribute(n);}function cleanStyle(n,v){if(v.match(/expression/)){A.removeAttribute(n);return;}var B=v.split(/;/);Roo.each(B,function(p){p=p.replace(/\s+/g,'');if(!p.length){return;}var l=p.split(':').shift().replace(/\s+/g,'');if(Roo.form.HtmlEditor.cwhite.indexOf(l)<0){Roo.log('(REMOVE)'+A.tagName+'.'+n+':'+l+'='+v);A.removeAttribute(n);return false;}});}for(var i=A.attributes.length-1;i>-1;i--){var a=A.attributes[i];if(Roo.form.HtmlEditor.ablack.indexOf(a.name.toLowerCase())>-1){A.removeAttribute(a.name);return;}if(Roo.form.HtmlEditor.aclean.indexOf(a.name.toLowerCase())>-1){cleanAttr(a.name,a.value);return;}if(a.name=='style'){cleanStyle(a.name,a.value);}if(a.name=='class'){if(a.value.match(/^Mso/)){A.className='';}}}
 this.cleanUpChildren(A);}});Roo.form.HtmlEditor.white=['area','br','img','input','hr','wbr','address','blockquote','center','dd','dir','div','dl','dt','h1','h2','h3','h4','h5','h6','hr','isindex','listing','marquee','menu','multicol','ol','p','plaintext','pre','table','ul','xmp','caption','col','colgroup','tbody','td','tfoot','th','thead','tr','dir','menu','ol','ul','dl','embed','object'];Roo.form.HtmlEditor.black=['applet','base','basefont','bgsound','blink','body','frame','frameset','head','html','ilayer','iframe','layer','link','meta','object','script','style','title','xml'];Roo.form.HtmlEditor.clean=['script','style','title','xml'];Roo.form.HtmlEditor.ablack=['on'];Roo.form.HtmlEditor.aclean=['action','background','codebase','dynsrc','href','lowsrc'];Roo.form.HtmlEditor.pwhite=['http','https','mailto'];Roo.form.HtmlEditor.cwhite=['text-align','font-size'];
 Roo.form.HtmlEditor.ToolbarStandard=function(A){Roo.apply(this,A);}
index 8ff0a7c..6cd85fc 100644 (file)
@@ -38656,6 +38656,7 @@ Roo.form.HtmlEditor = Roo.extend(Roo.form.Field, {
     syncValue : function(){
         if(this.initialized){
             var bd = (this.doc.body || this.doc.documentElement);
+            this.cleanUpPaste();
             var html = bd.innerHTML;
             if(Roo.isSafari){
                 var bs = bd.getAttribute('style'); // Safari puts text-align styles on the body element!
@@ -38682,8 +38683,12 @@ Roo.form.HtmlEditor = Roo.extend(Roo.form.Field, {
             if(v.length < 1){
                 v = '&#160;';
             }
+            
             if(this.fireEvent('beforepush', this, v) !== false){
-                (this.doc.body || this.doc.documentElement).innerHTML = v;
+                var d = (this.doc.body || this.doc.documentElement);
+                d.innerHTML = v;
+                this.cleanUpPaste();
+                this.el.dom.value = d.innerHTML;
                 this.fireEvent('push', this, v);
             }
         }
@@ -39178,7 +39183,7 @@ Roo.form.HtmlEditor = Roo.extend(Roo.form.Field, {
     {
         // cleans up the whole document..
       //  console.log('cleanuppaste');
-        this.cleanUpChildren(this.doc.body)
+        this.cleanUpChildren(this.doc.body);
         
         
     },
index 3e74bae..0b0e027 100644 (file)
@@ -24211,6 +24211,7 @@ Roo.form.HtmlEditor = Roo.extend(Roo.form.Field, {
     syncValue : function(){
         if(this.initialized){
             var bd = (this.doc.body || this.doc.documentElement);
+            this.cleanUpPaste();
             var html = bd.innerHTML;
             if(Roo.isSafari){
                 var bs = bd.getAttribute('style'); // Safari puts text-align styles on the body element!
@@ -24237,8 +24238,12 @@ Roo.form.HtmlEditor = Roo.extend(Roo.form.Field, {
             if(v.length < 1){
                 v = '&#160;';
             }
+            
             if(this.fireEvent('beforepush', this, v) !== false){
-                (this.doc.body || this.doc.documentElement).innerHTML = v;
+                var d = (this.doc.body || this.doc.documentElement);
+                d.innerHTML = v;
+                this.cleanUpPaste();
+                this.el.dom.value = d.innerHTML;
                 this.fireEvent('push', this, v);
             }
         }
@@ -24733,7 +24738,7 @@ Roo.form.HtmlEditor = Roo.extend(Roo.form.Field, {
     {
         // cleans up the whole document..
       //  console.log('cleanuppaste');
-        this.cleanUpChildren(this.doc.body)
+        this.cleanUpChildren(this.doc.body);
         
         
     },
index ed64b86..b2e5a8c 100644 (file)
@@ -462,8 +462,8 @@ Roo.form.Radio=function(){Roo.form.Radio.superclass.constructor.apply(this,argum
 Roo.form.HtmlEditor=Roo.extend(Roo.form.Field,{toolbars:false,createLinkText:'Please enter the URL for the link:',defaultLinkValue:'http:/'+'/',frameId:false,validationEvent:false,deferHeight:true,initialized:false,activated:false,sourceEditMode:false,onFocus:Roo.emptyFn,iframePad:3,hideMode:'offsets',defaultAutoCreate:{tag:"textarea",style:"width:500px;height:300px;",autocomplete:"off"},initComponent:function(){this.addEvents({initialize:true,activate:true,beforesync:true,beforepush:true,sync:true,push:true,editmodechange:true,editorevent:true})},createToolbar:function(A){if(!A.toolbars||!A.toolbars.length){A.toolbars=[new Roo.form.HtmlEditor.ToolbarStandard()];}for(var i=0;i<A.toolbars.length;i++){A.toolbars[i]=Roo.factory(A.toolbars[i],Roo.form.HtmlEditor);A.toolbars[i].init(A);}},getDocMarkup:function(){return '<html><head><style type="text/css">body{border:0;margin:0;padding:3px;height:98%;cursor:text;}</style></head><body></body></html>';},onRender:function(ct,A){Roo.form.HtmlEditor.superclass.onRender.call(this,ct,A);this.el.dom.style.border='0 none';this.el.dom.setAttribute('tabIndex',-1);this.el.addClass('x-hidden');if(Roo.isIE){this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;')}
 this.wrap=this.el.wrap({cls:'x-html-editor-wrap',cn:{cls:'x-html-editor-tb'}});this.frameId=Roo.id();this.createToolbar(this);var B=this.wrap.createChild({tag:'iframe',id:this.frameId,name:this.frameId,frameBorder:'no','src':Roo.SSL_SECURE_URL?Roo.SSL_SECURE_URL:"javascript:false"});this.iframe=B.dom;this.assignDocWin();this.doc.designMode='on';this.doc.open();this.doc.write(this.getDocMarkup());this.doc.close();var C={run:function(){this.assignDocWin();if(this.doc.body||this.doc.readyState=='complete'){try{this.doc.designMode="on";}catch(e){return;}
 Roo.TaskMgr.stop(C);this.initEditor.defer(10,this);}},interval:10,duration:10000,scope:this};Roo.TaskMgr.start(C);if(!this.width){this.setSize(this.el.getSize());}},onResize:function(w,h){Roo.form.HtmlEditor.superclass.onResize.apply(this,arguments);if(this.el&&this.iframe){if(typeof w=='number'){var aw=w-this.wrap.getFrameWidth('lr');this.el.setWidth(this.adjustWidth('textarea',aw));this.iframe.style.width=aw+'px';}if(typeof h=='number'){var A=0;for(var i=0;i<this.toolbars.length;i++){A+=this.toolbars[i].tb.el.getHeight();}var ah=h-this.wrap.getFrameWidth('tb')-A;this.el.setHeight(this.adjustWidth('textarea',ah));this.iframe.style.height=ah+'px';if(this.doc){(this.doc.body||this.doc.documentElement).style.height=(ah-(this.iframePad*2))+'px';}}}},toggleSourceEdit:function(A){this.sourceEditMode=A===true;if(this.sourceEditMode){this.syncValue();this.iframe.className='x-hidden';this.el.removeClass('x-hidden');this.el.dom.removeAttribute('tabIndex');this.el.focus();}else {this.pushValue();this.iframe.className='';this.el.addClass('x-hidden');this.el.dom.setAttribute('tabIndex',-1);this.deferFocus();}
-this.setSize(this.wrap.getSize());this.fireEvent('editmodechange',this,this.sourceEditMode);},createLink:function(){var A=prompt(this.createLinkText,this.defaultLinkValue);if(A&&A!='http:/'+'/'){this.relayCmd('createlink',A);}},adjustSize:Roo.BoxComponent.prototype.adjustSize,getResizeEl:function(){return this.wrap;},getPositionEl:function(){return this.wrap;},initEvents:function(){this.originalValue=this.getValue();},markInvalid:Roo.emptyFn,clearInvalid:Roo.emptyFn,setValue:function(v){Roo.form.HtmlEditor.superclass.setValue.call(this,v);this.pushValue();},cleanHtml:function(A){A=String(A);if(A.length>5){if(Roo.isSafari){A=A.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi,'');}}if(A=='&nbsp;'){A='';}return A;},syncValue:function(){if(this.initialized){var bd=(this.doc.body||this.doc.documentElement);var A=bd.innerHTML;if(Roo.isSafari){var bs=bd.getAttribute('style');var m=bs.match(/text-align:(.*?);/i);if(m&&m[1]){A='<div style="'+m[0]+'">'+A+'</div>';}}
-A=this.cleanHtml(A);if(this.fireEvent('beforesync',this,A)!==false){this.el.dom.value=A;this.fireEvent('sync',this,A);}}},pushValue:function(){if(this.initialized){var v=this.el.dom.value;if(v.length<1){v='&#160;';}if(this.fireEvent('beforepush',this,v)!==false){(this.doc.body||this.doc.documentElement).innerHTML=v;this.fireEvent('push',this,v);}}},deferFocus:function(){this.focus.defer(10,this);},focus:function(){if(this.win&&!this.sourceEditMode){this.win.focus();}else {this.el.focus();}},assignDocWin:function(){var A=this.iframe;if(Roo.isIE){this.doc=A.contentWindow.document;this.win=A.contentWindow;}else {if(!Roo.get(this.frameId)){return;}
+this.setSize(this.wrap.getSize());this.fireEvent('editmodechange',this,this.sourceEditMode);},createLink:function(){var A=prompt(this.createLinkText,this.defaultLinkValue);if(A&&A!='http:/'+'/'){this.relayCmd('createlink',A);}},adjustSize:Roo.BoxComponent.prototype.adjustSize,getResizeEl:function(){return this.wrap;},getPositionEl:function(){return this.wrap;},initEvents:function(){this.originalValue=this.getValue();},markInvalid:Roo.emptyFn,clearInvalid:Roo.emptyFn,setValue:function(v){Roo.form.HtmlEditor.superclass.setValue.call(this,v);this.pushValue();},cleanHtml:function(A){A=String(A);if(A.length>5){if(Roo.isSafari){A=A.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi,'');}}if(A=='&nbsp;'){A='';}return A;},syncValue:function(){if(this.initialized){var bd=(this.doc.body||this.doc.documentElement);this.cleanUpPaste();var A=bd.innerHTML;if(Roo.isSafari){var bs=bd.getAttribute('style');var m=bs.match(/text-align:(.*?);/i);if(m&&m[1]){A='<div style="'+m[0]+'">'+A+'</div>';}}
+A=this.cleanHtml(A);if(this.fireEvent('beforesync',this,A)!==false){this.el.dom.value=A;this.fireEvent('sync',this,A);}}},pushValue:function(){if(this.initialized){var v=this.el.dom.value;if(v.length<1){v='&#160;';}if(this.fireEvent('beforepush',this,v)!==false){var d=(this.doc.body||this.doc.documentElement);d.innerHTML=v;this.cleanUpPaste();this.el.dom.value=d.innerHTML;this.fireEvent('push',this,v);}}},deferFocus:function(){this.focus.defer(10,this);},focus:function(){if(this.win&&!this.sourceEditMode){this.win.focus();}else {this.el.focus();}},assignDocWin:function(){var A=this.iframe;if(Roo.isIE){this.doc=A.contentWindow.document;this.win=A.contentWindow;}else {if(!Roo.get(this.frameId)){return;}
 this.doc=(A.contentDocument||Roo.get(this.frameId).dom.document);this.win=Roo.get(this.frameId).dom.contentWindow;}},initEditor:function(){this.assignDocWin();this.doc.designMode="on";this.doc.open();this.doc.write(this.getDocMarkup());this.doc.close();var A=(this.doc.body||this.doc.documentElement);var ss=this.el.getStyles('font-size','background-image','background-repeat');ss['background-attachment']='fixed';A.bgProperties='fixed';Roo.DomHelper.applyStyles(A,ss);Roo.EventManager.on(this.doc,{'mousedown':this.onEditorEvent,'dblclick':this.onEditorEvent,'click':this.onEditorEvent,'keyup':this.onEditorEvent,buffer:100,scope:this});if(Roo.isGecko){Roo.EventManager.on(this.doc,'keypress',this.mozKeyPress,this);}if(Roo.isIE||Roo.isSafari||Roo.isOpera){Roo.EventManager.on(this.doc,'keydown',this.fixKeys,this);}
 this.initialized=true;this.fireEvent('initialize',this);this.pushValue();},onDestroy:function(){if(this.rendered){for(var i=0;i<this.toolbars.length;i++){this.toolbars[i].onDestroy();}
 this.wrap.dom.innerHTML='';this.wrap.remove();}},onFirstFocus:function(){this.assignDocWin();this.activated=true;for(var i=0;i<this.toolbars.length;i++){this.toolbars[i].onFirstFocus();}if(Roo.isGecko){this.win.focus();var s=this.win.getSelection();if(!s.focusNode||s.focusNode.nodeType!=3){var r=s.getRangeAt(0);r.selectNodeContents((this.doc.body||this.doc.documentElement));r.collapse(true);this.deferFocus();}try{this.execCmd('useCSS',true);this.execCmd('styleWithCSS',false);}catch(e){}}
@@ -471,7 +471,7 @@ this.fireEvent('activate',this);},adjustFont:function(A){var B=A.cmd=='increasef
 v=Math.max(1,v+B);this.execCmd('FontSize',v);},onEditorEvent:function(e){this.fireEvent('editorevent',this,e);this.syncValue();},insertTag:function(tg){this.execCmd("formatblock",tg);},insertText:function(A){range=this.createRange();range.deleteContents();range.insertNode(this.doc.createTextNode(A));},relayBtnCmd:function(A){this.relayCmd(A.cmd);},relayCmd:function(A,B){this.win.focus();this.execCmd(A,B);this.fireEvent('editorevent',this);this.deferFocus();},execCmd:function(A,B){this.doc.execCommand(A,false,B===undefined?null:B);this.syncValue();},insertAtCursor:function(A){if(!this.activated){return;}if(Roo.isIE){this.win.focus();var r=this.doc.selection.createRange();if(r){r.collapse(true);r.pasteHTML(A);this.syncValue();this.deferFocus();}}else if(Roo.isGecko||Roo.isOpera||Roo.isSafari){this.win.focus();this.execCmd('InsertHTML',A);this.deferFocus();}},mozKeyPress:function(e){if(e.ctrlKey){var c=e.getCharCode(),A;if(c>0){c=String.fromCharCode(c).toLowerCase();switch(c){case 'b':A='bold';break;case 'i':A='italic';break;case 'u':A='underline';case 'v':this.cleanUpPaste.defer(100,this);return;break;}if(A){this.win.focus();this.execCmd(A);this.deferFocus();e.preventDefault();}}}},fixKeys:function(){if(Roo.isIE){return function(e){var k=e.getKey(),r;if(k==e.TAB){e.stopEvent();r=this.doc.selection.createRange();if(r){r.collapse(true);r.pasteHTML('&#160;&#160;&#160;&#160;');this.deferFocus();}return;}if(k==e.ENTER){r=this.doc.selection.createRange();if(r){var A=r.parentElement();if(!A||A.tagName.toLowerCase()!='li'){e.stopEvent();r.pasteHTML('<br />');r.collapse(false);r.select();}}}if(String.fromCharCode(k).toLowerCase()=='v'){this.cleanUpPaste.defer(100,this);return;}};}else if(Roo.isOpera){return function(e){var k=e.getKey();if(k==e.TAB){e.stopEvent();this.win.focus();this.execCmd('InsertHTML','&#160;&#160;&#160;&#160;');this.deferFocus();}if(String.fromCharCode(k).toLowerCase()=='v'){this.cleanUpPaste.defer(100,this);return;}};}else if(Roo.isSafari){return function(e){var k=e.getKey();if(k==e.TAB){e.stopEvent();this.execCmd('InsertText','\t');this.deferFocus();return;}if(String.fromCharCode(k).toLowerCase()=='v'){this.cleanUpPaste.defer(100,this);return;}};}}(),getAllAncestors:function(){var p=this.getSelectedNode();var a=[];if(!p){a.push(p);p=this.getParentElement();}while(p&&(p.nodeType==1)&&(p.tagName.toLowerCase()!='body')){a.push(p);p=p.parentNode;}
 a.push(this.doc.body);return a;},lastSel:false,lastSelNode:false,getSelection:function(){this.assignDocWin();return Roo.isIE?this.doc.selection:this.win.getSelection();},getSelectedNode:function(){var A=this.createRange(this.getSelection());if(Roo.isIE){var B=A.parentElement();while(true){var C=A.duplicate();C.moveToElementText(B);if(C.inRange(A)){break;}if((B.nodeType!=1)||(B.tagName.toLowerCase()=='body')){break;}
 B=B.parentElement;}return B;}var ar=A.endContainer.childNodes;if(!ar.length){ar=A.commonAncestorContainer.childNodes;}var D=[];var E=[];var F=false;for(var i=0;i<ar.length;i++){if((ar[i].nodeType==3)&&(!ar[i].data.length)){continue;}if(this.rangeIntersectsNode(A,ar[i])&&this.rangeCompareNode(A,ar[i])==3){D.push(ar[i]);continue;}if((ar[i].nodeType==1)&&this.rangeIntersectsNode(A,ar[i])&&(this.rangeCompareNode(A,ar[i])>0)){E.push(ar[i]);continue;}if(!this.rangeIntersectsNode(A,ar[i])||(this.rangeCompareNode(A,ar[i])==0)){continue;}
-F=true;}if(!D.length&&E.length){D=E;}if(F||!D.length||(D.length>1)){return false;}return D[0];},createRange:function(A){if(typeof A!="undefined"){try{return A.getRangeAt?A.getRangeAt(0):A.createRange();}catch(e){return this.doc.createRange();}}else {return this.doc.createRange();}},getParentElement:function(){this.assignDocWin();var A=Roo.isIE?this.doc.selection:this.win.getSelection();var B=this.createRange(A);try{var p=B.commonAncestorContainer;while(p.nodeType==3){p=p.parentNode;}return p;}catch(e){return null;}},rangeIntersectsNode:function(A,B){var C=B.ownerDocument.createRange();try{C.selectNode(B);}catch(e){nodeRange.selectNodeContents(node);}return A.compareBoundaryPoints(Range.END_TO_START,C)==-1&&A.compareBoundaryPoints(Range.START_TO_END,C)==1;},rangeCompareNode:function(A,B){var C=B.ownerDocument.createRange();try{C.selectNode(B);}catch(e){nodeRange.selectNodeContents(node);}var D=A.compareBoundaryPoints(Range.START_TO_START,C)==1;var E=A.compareBoundaryPoints(Range.END_TO_END,C)==-1;if(D&&!E)return 0;if(!D&&E)return 1;if(D&&E)return 2;return 3;},cleanUpPaste:function(){this.cleanUpChildren(this.doc.body)},cleanUpChildren:function(n){if(!n.childNodes.length){return;}for(var i=n.childNodes.length-1;i>-1;i--){this.cleanUpChild(n.childNodes[i]);}},cleanUpChild:function(A){if(A.nodeName=="#text"){return;}if(A.nodeName=="#comment"){A.parentNode.removeChild(A);return;}if(Roo.form.HtmlEditor.black.indexOf(A.tagName.toLowerCase())>-1){A.parentNode.removeChild(A);return;}if(!A.attributes||!A.attributes.length){this.cleanUpChildren(A);return;}function cleanAttr(n,v){if(v.match(/^\./)||v.match(/^\//)){return;}if(v.match(/^(http|https):\/\//)||v.match(/^mailto:/)){return;}
+F=true;}if(!D.length&&E.length){D=E;}if(F||!D.length||(D.length>1)){return false;}return D[0];},createRange:function(A){if(typeof A!="undefined"){try{return A.getRangeAt?A.getRangeAt(0):A.createRange();}catch(e){return this.doc.createRange();}}else {return this.doc.createRange();}},getParentElement:function(){this.assignDocWin();var A=Roo.isIE?this.doc.selection:this.win.getSelection();var B=this.createRange(A);try{var p=B.commonAncestorContainer;while(p.nodeType==3){p=p.parentNode;}return p;}catch(e){return null;}},rangeIntersectsNode:function(A,B){var C=B.ownerDocument.createRange();try{C.selectNode(B);}catch(e){nodeRange.selectNodeContents(node);}return A.compareBoundaryPoints(Range.END_TO_START,C)==-1&&A.compareBoundaryPoints(Range.START_TO_END,C)==1;},rangeCompareNode:function(A,B){var C=B.ownerDocument.createRange();try{C.selectNode(B);}catch(e){nodeRange.selectNodeContents(node);}var D=A.compareBoundaryPoints(Range.START_TO_START,C)==1;var E=A.compareBoundaryPoints(Range.END_TO_END,C)==-1;if(D&&!E)return 0;if(!D&&E)return 1;if(D&&E)return 2;return 3;},cleanUpPaste:function(){this.cleanUpChildren(this.doc.body);},cleanUpChildren:function(n){if(!n.childNodes.length){return;}for(var i=n.childNodes.length-1;i>-1;i--){this.cleanUpChild(n.childNodes[i]);}},cleanUpChild:function(A){if(A.nodeName=="#text"){return;}if(A.nodeName=="#comment"){A.parentNode.removeChild(A);return;}if(Roo.form.HtmlEditor.black.indexOf(A.tagName.toLowerCase())>-1){A.parentNode.removeChild(A);return;}if(!A.attributes||!A.attributes.length){this.cleanUpChildren(A);return;}function cleanAttr(n,v){if(v.match(/^\./)||v.match(/^\//)){return;}if(v.match(/^(http|https):\/\//)||v.match(/^mailto:/)){return;}
 Roo.log("(REMOVE)"+A.tagName+'.'+n+'='+v);A.removeAttribute(n);}function cleanStyle(n,v){if(v.match(/expression/)){A.removeAttribute(n);return;}var B=v.split(/;/);Roo.each(B,function(p){p=p.replace(/\s+/g,'');if(!p.length){return;}var l=p.split(':').shift().replace(/\s+/g,'');if(Roo.form.HtmlEditor.cwhite.indexOf(l)<0){Roo.log('(REMOVE)'+A.tagName+'.'+n+':'+l+'='+v);A.removeAttribute(n);return false;}});}for(var i=A.attributes.length-1;i>-1;i--){var a=A.attributes[i];if(Roo.form.HtmlEditor.ablack.indexOf(a.name.toLowerCase())>-1){A.removeAttribute(a.name);return;}if(Roo.form.HtmlEditor.aclean.indexOf(a.name.toLowerCase())>-1){cleanAttr(a.name,a.value);return;}if(a.name=='style'){cleanStyle(a.name,a.value);}if(a.name=='class'){if(a.value.match(/^Mso/)){A.className='';}}}
 this.cleanUpChildren(A);}});Roo.form.HtmlEditor.white=['area','br','img','input','hr','wbr','address','blockquote','center','dd','dir','div','dl','dt','h1','h2','h3','h4','h5','h6','hr','isindex','listing','marquee','menu','multicol','ol','p','plaintext','pre','table','ul','xmp','caption','col','colgroup','tbody','td','tfoot','th','thead','tr','dir','menu','ol','ul','dl','embed','object'];Roo.form.HtmlEditor.black=['applet','base','basefont','bgsound','blink','body','frame','frameset','head','html','ilayer','iframe','layer','link','meta','object','script','style','title','xml'];Roo.form.HtmlEditor.clean=['script','style','title','xml'];Roo.form.HtmlEditor.ablack=['on'];Roo.form.HtmlEditor.aclean=['action','background','codebase','dynsrc','href','lowsrc'];Roo.form.HtmlEditor.pwhite=['http','https','mailto'];Roo.form.HtmlEditor.cwhite=['text-align','font-size'];
 Roo.form.HtmlEditor.ToolbarStandard=function(A){Roo.apply(this,A);}