Xinha.prototype.generate=function()

in blocks/cocoon-forms/cocoon-forms-impl/src/main/resources/org/apache/cocoon/forms/resources/xinha/XinhaCore.js [811:1069]


Xinha.prototype.generate=function(){
if(!Xinha.isSupportedBrowser){
return;
}
var i;
var _90=this;
var url;
if(!document.getElementById("XinhaCoreDesign")){
Xinha.loadStyle(typeof _editor_css=="string"?_editor_css:"Xinha.css",null,"XinhaCoreDesign");
}
if(Xinha.is_ie){
url=_editor_url+"modules/InternetExplorer/InternetExplorer.js";
if(typeof InternetExplorer=="undefined"&&!document.getElementById(url)){
Xinha.loadPlugin("InternetExplorer",function(){
_90.generate();
},url);
return false;
}
_90._browserSpecificPlugin=_90.registerPlugin("InternetExplorer");
}else{
url=_editor_url+"modules/Gecko/Gecko.js";
if(typeof Gecko=="undefined"&&!document.getElementById(url)){
Xinha.loadPlugin("Gecko",function(){
_90.generate();
},url);
return false;
}
_90._browserSpecificPlugin=_90.registerPlugin("Gecko");
}
if(typeof Dialog=="undefined"&&!Xinha._loadback(_editor_url+"modules/Dialogs/dialog.js",this.generate,this)){
return false;
}
if(typeof Xinha.Dialog=="undefined"&&!Xinha._loadback(_editor_url+"modules/Dialogs/inline-dialog.js",this.generate,this)){
return false;
}
url=_editor_url+"modules/FullScreen/full-screen.js";
if(typeof FullScreen=="undefined"&&!document.getElementById(url)){
Xinha.loadPlugin("FullScreen",function(){
_90.generate();
},url);
return false;
}
url=_editor_url+"modules/ColorPicker/ColorPicker.js";
if(typeof ColorPicker=="undefined"&&!document.getElementById(url)){
Xinha.loadPlugin("ColorPicker",function(){
_90.generate();
},url);
return false;
}else{
if(typeof ColorPicker!="undefined"){
_90.registerPlugin("ColorPicker");
}
}
var _92=_90.config.toolbar;
for(i=_92.length;--i>=0;){
for(var j=_92[i].length;--j>=0;){
switch(_92[i][j]){
case "popupeditor":
_90.registerPlugin("FullScreen");
break;
case "insertimage":
url=_editor_url+"modules/InsertImage/insert_image.js";
if(typeof InsertImage=="undefined"&&typeof Xinha.prototype._insertImage=="undefined"&&!document.getElementById(url)){
Xinha.loadPlugin("InsertImage",function(){
_90.generate();
},url);
return false;
}else{
if(typeof InsertImage!="undefined"){
_90.registerPlugin("InsertImage");
}
}
break;
case "createlink":
url=_editor_url+"modules/CreateLink/link.js";
if(typeof CreateLink=="undefined"&&typeof Xinha.prototype._createLink=="undefined"&&typeof Linker=="undefined"&&!document.getElementById(url)){
Xinha.loadPlugin("CreateLink",function(){
_90.generate();
},url);
return false;
}else{
if(typeof CreateLink!="undefined"){
_90.registerPlugin("CreateLink");
}
}
break;
case "inserttable":
url=_editor_url+"modules/InsertTable/insert_table.js";
if(typeof InsertTable=="undefined"&&typeof Xinha.prototype._insertTable=="undefined"&&!document.getElementById(url)){
Xinha.loadPlugin("InsertTable",function(){
_90.generate();
},url);
return false;
}else{
if(typeof InsertTable!="undefined"){
_90.registerPlugin("InsertTable");
}
}
break;
}
}
}
if(Xinha.is_gecko&&(_90.config.mozParaHandler=="best"||_90.config.mozParaHandler=="dirty")){
switch(this.config.mozParaHandler){
case "dirty":
var _94=_editor_url+"modules/Gecko/paraHandlerDirty.js";
break;
default:
var _94=_editor_url+"modules/Gecko/paraHandlerBest.js";
break;
}
if(typeof EnterParagraphs=="undefined"&&!document.getElementById(_94)){
Xinha.loadPlugin("EnterParagraphs",function(){
_90.generate();
},_94);
return false;
}
_90.registerPlugin("EnterParagraphs");
}
switch(this.config.getHtmlMethod){
case "TransformInnerHTML":
var _95=_editor_url+"modules/GetHtml/TransformInnerHTML.js";
break;
default:
var _95=_editor_url+"modules/GetHtml/DOMwalk.js";
break;
}
if(typeof GetHtmlImplementation=="undefined"&&!document.getElementById(_95)){
Xinha.loadPlugin("GetHtmlImplementation",function(){
_90.generate();
},_95);
return false;
}else{
_90.registerPlugin("GetHtmlImplementation");
}
if(_editor_skin!==""){
var _96=false;
var _97=document.getElementsByTagName("head")[0];
var _98=document.getElementsByTagName("link");
for(i=0;i<_98.length;i++){
if((_98[i].rel=="stylesheet")&&(_98[i].href==_editor_url+"skins/"+_editor_skin+"/skin.css")){
_96=true;
}
}
if(!_96){
var _99=document.createElement("link");
_99.type="text/css";
_99.href=_editor_url+"skins/"+_editor_skin+"/skin.css";
_99.rel="stylesheet";
_97.appendChild(_99);
}
}
this.setLoadingMessage(Xinha._lc("Generate Xinha framework"));
this._framework={"table":document.createElement("table"),"tbody":document.createElement("tbody"),"tb_row":document.createElement("tr"),"tb_cell":document.createElement("td"),"tp_row":document.createElement("tr"),"tp_cell":this._panels.top.container,"ler_row":document.createElement("tr"),"lp_cell":this._panels.left.container,"ed_cell":document.createElement("td"),"rp_cell":this._panels.right.container,"bp_row":document.createElement("tr"),"bp_cell":this._panels.bottom.container,"sb_row":document.createElement("tr"),"sb_cell":document.createElement("td")};
Xinha.freeLater(this._framework);
var fw=this._framework;
fw.table.border="0";
fw.table.cellPadding="0";
fw.table.cellSpacing="0";
fw.tb_row.style.verticalAlign="top";
fw.tp_row.style.verticalAlign="top";
fw.ler_row.style.verticalAlign="top";
fw.bp_row.style.verticalAlign="top";
fw.sb_row.style.verticalAlign="top";
fw.ed_cell.style.position="relative";
fw.tb_row.appendChild(fw.tb_cell);
fw.tb_cell.colSpan=3;
fw.tp_row.appendChild(fw.tp_cell);
fw.tp_cell.colSpan=3;
fw.ler_row.appendChild(fw.lp_cell);
fw.ler_row.appendChild(fw.ed_cell);
fw.ler_row.appendChild(fw.rp_cell);
fw.bp_row.appendChild(fw.bp_cell);
fw.bp_cell.colSpan=3;
fw.sb_row.appendChild(fw.sb_cell);
fw.sb_cell.colSpan=3;
fw.tbody.appendChild(fw.tb_row);
fw.tbody.appendChild(fw.tp_row);
fw.tbody.appendChild(fw.ler_row);
fw.tbody.appendChild(fw.bp_row);
fw.tbody.appendChild(fw.sb_row);
fw.table.appendChild(fw.tbody);
var _9b=this._framework.table;
this._htmlArea=_9b;
Xinha.freeLater(this,"_htmlArea");
_9b.className="htmlarea";
this._framework.tb_cell.appendChild(this._createToolbar());
var _9c=document.createElement("iframe");
_9c.src=_editor_url+_90.config.URIs.blank;
_9c.id="XinhaIFrame_"+this._textArea.id;
this._framework.ed_cell.appendChild(_9c);
this._iframe=_9c;
this._iframe.className="xinha_iframe";
Xinha.freeLater(this,"_iframe");
var _9d=this._createStatusBar();
this._framework.sb_cell.appendChild(_9d);
var _9e=this._textArea;
_9e.parentNode.insertBefore(_9b,_9e);
_9e.className="xinha_textarea";
Xinha.removeFromParent(_9e);
this._framework.ed_cell.appendChild(_9e);
Xinha.addDom0Event(this._textArea,"click",function(){
if(Xinha._currentlyActiveEditor!=this){
_90.updateToolbar();
}
return true;
});
if(_9e.form){
Xinha.prependDom0Event(this._textArea.form,"submit",function(){
_90._textArea.value=_90.outwardHtml(_90.getHTML());
return true;
});
var _9f=_9e.value;
Xinha.prependDom0Event(this._textArea.form,"reset",function(){
_90.setHTML(_90.inwardHtml(_9f));
_90.updateToolbar();
return true;
});
if(!_9e.form.xinha_submit){
try{
_9e.form.xinha_submit=_9e.form.submit;
_9e.form.submit=function(){
this.onsubmit();
this.xinha_submit();
};
}
catch(ex){
}
}
}
Xinha.prependDom0Event(window,"unload",function(){
_9e.value=_90.outwardHtml(_90.getHTML());
if(!Xinha.is_ie){
_9b.parentNode.replaceChild(_9e,_9b);
}
return true;
});
_9e.style.display="none";
_90.initSize();
this.setLoadingMessage(Xinha._lc("Finishing"));
_90._iframeLoadDone=false;
if(Xinha.is_opera){
Xinha._addEvent(this._iframe.contentWindow,"load",function(e){
if(!_90._iframeLoadDone){
_90._iframeLoadDone=true;
_90.initIframe();
}
return true;
});
}else{
Xinha._addEvent(this._iframe,"load",function(e){
if(!_90._iframeLoadDone){
_90._iframeLoadDone=true;
_90.initIframe();
}
return true;
});
}
};