Xinha.prototype.updateToolbar=function()

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


Xinha.prototype.updateToolbar=function(_125){
var doc=this._doc;
var text=(this._editMode=="textmode");
var _128=null;
if(!text){
_128=this.getAllAncestors();
if(this.config.statusBar&&!_125){
while(this._statusBarItems.length){
var item=this._statusBarItems.pop();
item.el=null;
item.editor=null;
item.onclick=null;
item.oncontextmenu=null;
item._xinha_dom0Events["click"]=null;
item._xinha_dom0Events["contextmenu"]=null;
item=null;
}
this._statusBarTree.innerHTML=Xinha._lc("Path")+": ";
for(var i=_128.length;--i>=0;){
var el=_128[i];
if(!el){
continue;
}
var a=document.createElement("a");
a.href="javascript:void(0)";
a.el=el;
a.editor=this;
this._statusBarItems.push(a);
Xinha.addDom0Event(a,"click",function(){
this.blur();
this.editor.selectNodeContents(this.el);
this.editor.updateToolbar(true);
return false;
});
Xinha.addDom0Event(a,"contextmenu",function(){
this.blur();
var info="Inline style:\n\n";
info+=this.el.style.cssText.split(/;\s*/).join(";\n");
alert(info);
return false;
});
var txt=el.tagName.toLowerCase();
if(typeof el.style!="undefined"){
a.title=el.style.cssText;
}
if(el.id){
txt+="#"+el.id;
}
if(el.className){
txt+="."+el.className;
}
a.appendChild(document.createTextNode(txt));
this._statusBarTree.appendChild(a);
if(i!==0){
this._statusBarTree.appendChild(document.createTextNode(String.fromCharCode(187)));
}
Xinha.freeLater(a);
}
}
}
for(var cmd in this._toolbarObjects){
var btn=this._toolbarObjects[cmd];
var _131=true;
if(typeof (btn.state)!="function"){
continue;
}
if(btn.context&&!text){
_131=false;
var _132=btn.context;
var _133=[];
if(/(.*)\[(.*?)\]/.test(_132)){
_132=RegExp.$1;
_133=RegExp.$2.split(",");
}
_132=_132.toLowerCase();
var _134=(_132=="*");
for(var k=0;k<_128.length;++k){
if(!_128[k]){
continue;
}
if(_134||(_128[k].tagName.toLowerCase()==_132)){
_131=true;
var _136=null;
var att=null;
var comp=null;
var _139=null;
for(var ka=0;ka<_133.length;++ka){
_136=_133[ka].match(/(.*)(==|!=|===|!==|>|>=|<|<=)(.*)/);
att=_136[1];
comp=_136[2];
_139=_136[3];
if(!eval(_128[k][att]+comp+_139)){
_131=false;
break;
}
}
if(_131){
break;
}
}
}
}
btn.state("enabled",(!text||btn.text)&&_131);
if(typeof cmd=="function"){
continue;
}
var _13b=this.config.customSelects[cmd];
if((!text||btn.text)&&(typeof _13b!="undefined")){
_13b.refresh(this);
continue;
}
switch(cmd){
case "fontname":
case "fontsize":
if(!text){
try{
var _13c=(""+doc.queryCommandValue(cmd)).toLowerCase();
if(!_13c){
btn.element.selectedIndex=0;
break;
}
var _13d=this.config[cmd];
var _13e=0;
for(var j in _13d){
if((j.toLowerCase()==_13c)||(_13d[j].substr(0,_13c.length).toLowerCase()==_13c)){
btn.element.selectedIndex=_13e;
throw "ok";
}
++_13e;
}
btn.element.selectedIndex=0;
}
catch(ex){
}
}
break;
case "formatblock":
var _140=[];
for(var _141 in this.config.formatblock){
if(typeof this.config.formatblock[_141]=="string"){
_140[_140.length]=this.config.formatblock[_141];
}
}
var _142=this._getFirstAncestor(this.getSelection(),_140);
if(_142){
for(var x=0;x<_140.length;x++){
if(_140[x].toLowerCase()==_142.tagName.toLowerCase()){
btn.element.selectedIndex=x;
}
}
}else{
btn.element.selectedIndex=0;
}
break;
case "textindicator":
if(!text){
try{
var _144=btn.element.style;
_144.backgroundColor=Xinha._makeColor(doc.queryCommandValue(Xinha.is_ie?"backcolor":"hilitecolor"));
if(/transparent/i.test(_144.backgroundColor)){
_144.backgroundColor=Xinha._makeColor(doc.queryCommandValue("backcolor"));
}
_144.color=Xinha._makeColor(doc.queryCommandValue("forecolor"));
_144.fontFamily=doc.queryCommandValue("fontname");
_144.fontWeight=doc.queryCommandState("bold")?"bold":"normal";
_144.fontStyle=doc.queryCommandState("italic")?"italic":"normal";
}
catch(ex){
}
}
break;
case "htmlmode":
btn.state("active",text);
break;
case "lefttoright":
case "righttoleft":
var _145=this.getParentElement();
while(_145&&!Xinha.isBlockElement(_145)){
_145=_145.parentNode;
}
if(_145){
btn.state("active",(_145.style.direction==((cmd=="righttoleft")?"rtl":"ltr")));
}
break;
default:
cmd=cmd.replace(/(un)?orderedlist/i,"insert$1orderedlist");
try{
btn.state("active",(!text&&doc.queryCommandState(cmd)));
}
catch(ex){
}
break;
}
}
if(this._customUndo&&!this._timerUndo){
this._undoTakeSnapshot();
var _146=this;
this._timerUndo=setTimeout(function(){
_146._timerUndo=null;
},this.config.undoTimeout);
}
if(0&&Xinha.is_gecko){
var s=this.getSelection();
if(s&&s.isCollapsed&&s.anchorNode&&s.anchorNode.parentNode.tagName.toLowerCase()!="body"&&s.anchorNode.nodeType==3&&s.anchorOffset==s.anchorNode.length&&!(s.anchorNode.parentNode.nextSibling&&s.anchorNode.parentNode.nextSibling.nodeType==3)&&!Xinha.isBlockElement(s.anchorNode.parentNode)){
try{
s.anchorNode.parentNode.parentNode.insertBefore(this._doc.createTextNode("\t"),s.anchorNode.parentNode.nextSibling);
}
catch(ex){
}
}
}
for(var _148 in this.plugins){
var _149=this.plugins[_148].instance;
if(_149&&typeof _149.onUpdateToolbar=="function"){
_149.onUpdateToolbar();
}
}
};