ContextMenu.prototype.getContextMenu=function()

in blocks/cocoon-forms/cocoon-forms-impl/src/main/resources/org/apache/cocoon/forms/resources/xinha/plugins/ContextMenu/context-menu.js [14:192]


ContextMenu.prototype.getContextMenu=function(_5){
var _6=this;
var _7=this.editor;
var _8=_7.config;
var _9=[];
var _a=this.editor.plugins.TableOperations;
if(_a){
_a=_a.instance;
}
var _b=_7.hasSelectedText();
if(!HTMLArea.is_gecko){
if(_b){
_9.push([HTMLArea._lc("Cut","ContextMenu"),function(){
_7.execCommand("cut");
},null,_8.btnList["cut"][1]],[HTMLArea._lc("Copy","ContextMenu"),function(){
_7.execCommand("copy");
},null,_8.btnList["copy"][1]]);
_9.push([HTMLArea._lc("Paste","ContextMenu"),function(){
_7.execCommand("paste");
},null,_8.btnList["paste"][1]]);
}
}
var _c=_5;
var _d=[];
var _e=null;
var _f=null;
var tr=null;
var td=null;
var img=null;
function tableOperation(_13){
_a.buttonPress(_7,_13);
}
function insertPara(_14){
var el=_c;
var par=el.parentNode;
var p=_7._doc.createElement("p");
p.appendChild(_7._doc.createElement("br"));
par.insertBefore(p,_14?el.nextSibling:el);
var sel=_7._getSelection();
var _19=_7._createRange(sel);
if(!HTMLArea.is_ie){
sel.removeAllRanges();
_19.selectNodeContents(p);
_19.collapse(true);
sel.addRange(_19);
}else{
_19.moveToElementText(p);
_19.collapse(true);
_19.select();
}
}
for(;_5;_5=_5.parentNode){
var tag=_5.tagName;
if(!tag){
continue;
}
tag=tag.toLowerCase();
switch(tag){
case "img":
img=_5;
_d.push(null,[HTMLArea._lc("_Image Properties...","ContextMenu"),function(){
_7._insertImage(img);
},HTMLArea._lc("Show the image properties dialog","ContextMenu"),_8.btnList["insertimage"][1]]);
break;
case "a":
_e=_5;
_d.push(null,[HTMLArea._lc("_Modify Link...","ContextMenu"),function(){
_7.config.btnList["createlink"][3](_7);
},HTMLArea._lc("Current URL is","ContextMenu")+": "+_e.href,_8.btnList["createlink"][1]],[HTMLArea._lc("Chec_k Link...","ContextMenu"),function(){
window.open(_e.href);
},HTMLArea._lc("Opens this link in a new window","ContextMenu")],[HTMLArea._lc("_Remove Link...","ContextMenu"),function(){
if(confirm(HTMLArea._lc("Please confirm that you want to unlink this element.","ContextMenu")+"\n"+HTMLArea._lc("Link points to:","ContextMenu")+" "+_e.href)){
while(_e.firstChild){
_e.parentNode.insertBefore(_e.firstChild,_e);
}
_e.parentNode.removeChild(_e);
}
},HTMLArea._lc("Unlink the current element","ContextMenu")]);
break;
case "td":
td=_5;
if(!_a){
break;
}
_d.push(null,[HTMLArea._lc("C_ell Properties...","ContextMenu"),function(){
tableOperation("TO-cell-prop");
},HTMLArea._lc("Show the Table Cell Properties dialog","ContextMenu"),_8.btnList["TO-cell-prop"][1]],[HTMLArea._lc("Insert Cell After","ContextMenu"),function(){
tableOperation("TO-cell-insert-after");
},HTMLArea._lc("Insert Cell After","ContextMenu"),_8.btnList["TO-cell-insert-after"][1]],[HTMLArea._lc("Insert Cell Before","ContextMenu"),function(){
tableOperation("TO-cell-insert-before");
},HTMLArea._lc("Insert Cell After","ContextMenu"),_8.btnList["TO-cell-insert-before"][1]],[HTMLArea._lc("Delete Cell","ContextMenu"),function(){
tableOperation("TO-cell-delete");
},HTMLArea._lc("Delete Cell","ContextMenu"),_8.btnList["TO-cell-delete"][1]],[HTMLArea._lc("Merge Cells","ContextMenu"),function(){
tableOperation("TO-cell-merge");
},HTMLArea._lc("Merge Cells","ContextMenu"),_8.btnList["TO-cell-merge"][1]]);
break;
case "tr":
tr=_5;
if(!_a){
break;
}
_d.push(null,[HTMLArea._lc("Ro_w Properties...","ContextMenu"),function(){
tableOperation("TO-row-prop");
},HTMLArea._lc("Show the Table Row Properties dialog","ContextMenu"),_8.btnList["TO-row-prop"][1]],[HTMLArea._lc("I_nsert Row Before","ContextMenu"),function(){
tableOperation("TO-row-insert-above");
},HTMLArea._lc("Insert a new row before the current one","ContextMenu"),_8.btnList["TO-row-insert-above"][1]],[HTMLArea._lc("In_sert Row After","ContextMenu"),function(){
tableOperation("TO-row-insert-under");
},HTMLArea._lc("Insert a new row after the current one","ContextMenu"),_8.btnList["TO-row-insert-under"][1]],[HTMLArea._lc("_Delete Row","ContextMenu"),function(){
tableOperation("TO-row-delete");
},HTMLArea._lc("Delete the current row","ContextMenu"),_8.btnList["TO-row-delete"][1]]);
break;
case "table":
_f=_5;
if(!_a){
break;
}
_d.push(null,[HTMLArea._lc("_Table Properties...","ContextMenu"),function(){
tableOperation("TO-table-prop");
},HTMLArea._lc("Show the Table Properties dialog","ContextMenu"),_8.btnList["TO-table-prop"][1]],[HTMLArea._lc("Insert _Column Before","ContextMenu"),function(){
tableOperation("TO-col-insert-before");
},HTMLArea._lc("Insert a new column before the current one","ContextMenu"),_8.btnList["TO-col-insert-before"][1]],[HTMLArea._lc("Insert C_olumn After","ContextMenu"),function(){
tableOperation("TO-col-insert-after");
},HTMLArea._lc("Insert a new column after the current one","ContextMenu"),_8.btnList["TO-col-insert-after"][1]],[HTMLArea._lc("De_lete Column","ContextMenu"),function(){
tableOperation("TO-col-delete");
},HTMLArea._lc("Delete the current column","ContextMenu"),_8.btnList["TO-col-delete"][1]]);
break;
case "body":
_d.push(null,[HTMLArea._lc("Justify Left","ContextMenu"),function(){
_7.execCommand("justifyleft");
},null,_8.btnList["justifyleft"][1]],[HTMLArea._lc("Justify Center","ContextMenu"),function(){
_7.execCommand("justifycenter");
},null,_8.btnList["justifycenter"][1]],[HTMLArea._lc("Justify Right","ContextMenu"),function(){
_7.execCommand("justifyright");
},null,_8.btnList["justifyright"][1]],[HTMLArea._lc("Justify Full","ContextMenu"),function(){
_7.execCommand("justifyfull");
},null,_8.btnList["justifyfull"][1]]);
break;
}
}
if(_b&&!_e){
_9.push(null,[HTMLArea._lc("Make lin_k...","ContextMenu"),function(){
_7.config.btnList["createlink"][3](_7);
},HTMLArea._lc("Create a link","ContextMenu"),_8.btnList["createlink"][1]]);
}
for(var i=0;i<_d.length;++i){
_9.push(_d[i]);
}
if(!/html|body/i.test(_c.tagName)){
_9.push(null,[HTMLArea._lc({string:"Remove the $elem Element...",replace:{elem:"&lt;"+_c.tagName+"&gt;"}},"ContextMenu"),function(){
if(confirm(HTMLArea._lc("Please confirm that you want to remove this element:","ContextMenu")+" "+_c.tagName)){
var el=_c;
var p=el.parentNode;
p.removeChild(el);
if(HTMLArea.is_gecko){
if(p.tagName.toLowerCase()=="td"&&!p.hasChildNodes()){
p.appendChild(_7._doc.createElement("br"));
}
_7.forceRedraw();
_7.focusEditor();
_7.updateToolbar();
if(_f){
var _1e=_f.style.borderCollapse;
_f.style.borderCollapse="collapse";
_f.style.borderCollapse="separate";
_f.style.borderCollapse=_1e;
}
}
}
},HTMLArea._lc("Remove this node from the document","ContextMenu")],[HTMLArea._lc("Insert paragraph before","ContextMenu"),function(){
insertPara(false);
},HTMLArea._lc("Insert a paragraph before the current node","ContextMenu")],[HTMLArea._lc("Insert paragraph after","ContextMenu"),function(){
insertPara(true);
},HTMLArea._lc("Insert a paragraph after the current node","ContextMenu")]);
}
if(!_9[0]){
_9.shift();
}
return _9;
};