,A.wrap.dom.firstChild.nextSibling,true);var ty=Roo.form.HtmlEditor.ToolbarContext.types;this.toolbars={};for(var i in ty){this.toolbars[i]=this.buildToolbar(ty[i],i);}this.tb=this.toolbars.BODY;this.tb.el.show();this.buildFooter();this.footer.show();A.on('hide',function(){this.footer.hide()}
,this);A.on('show',function(){this.footer.show()},this);this.rendered=true;A.on('editorevent',this.updateToolbar,this);},updateToolbar:function(A,ev,B){if(!this.editorcore.activated){this.editor.onFirstFocus();return;}if(ev&&(ev.type=='mouseup'||ev.type=='click')&&ev.target&&ev.target.tagName=='IMG'){B=ev.target;
var C=B.ownerDocument.createRange();try{C.selectNode(B);}catch(e){C.selectNodeContents(B);}var s=this.editorcore.win.getSelection();s.removeAllRanges();s.addRange(C);}var D=this.editorcore.getAllAncestors();var ty=Roo.form.HtmlEditor.ToolbarContext.types;
-if(!B){B=D.length?(D[0]?D[0]:D[1]):this.editorcore.doc.body;B=B?B:this.editorcore.doc.body;B=B.tagName.length?B:this.editorcore.doc.body;}var tn=B.tagName.toUpperCase();var E=this.tb.selectedNode;this.tb.selectedNode=B;var db=Roo.get(B).findParent('[data-block]');
-if(db){var F=Roo.htmleditor['Block'+Roo.get(db).attr('data-block')];if(typeof(F)=='undefined'){tn='*';Roo.log("OOps missing block : "+'Block'+Roo.get(db).attr('data-block'));}else{tn='BLOCK.'+db.getAttribute('data-block');this.tb.selectedNode=db;if(typeof(this.toolbars[tn])=='undefined'){this.toolbars[tn]=this.buildToolbar(F.prototype.context,tn,F.prototype.friendly_name);
-}}}if(this.tb.name==tn&&E==this.tb.selectedNode&&ev!==false){return;}this.tb.el.hide();this.tb=typeof(this.toolbars[tn])!='undefined'?this.toolbars[tn]:this.toolbars['*'];this.tb.el.show();this.tb.items.first().el.innerHTML=tn+': ';if(this.tb.fields){this.tb.fields.each(function(e){if(e.stylename){e.setValue(B.style[e.stylename]);
-return;}e.setValue(B.getAttribute(e.attrname));});}this.updateToolbarStyles(B);this.tb.selectedNode=B;Roo.menu.MenuMgr.hideAll();this.updateFooter(D);},updateToolbarStyles:function(A){var B=false;for(var i in this.styles){B=true;break;}if(B){var st=this.tb.fields.item(0);
-st.store.removeAll();var cn=A.className.split(/\s+/);var C=[];if(this.styles['*']){Roo.each(this.styles['*'],function(v){C.push([v,cn.indexOf(v)>-1?1:0]);});}if(this.styles[tn]){Roo.each(this.styles[tn],function(v){C.push([v,cn.indexOf(v)>-1?1:0]);});}st.store.loadData(C);
-st.collapse();st.setValue(cn);}},updateFooter:function(A){var B='';if(A===false){this.footDisp.dom.innerHTML='';return;}this.footerEls=A.reverse();Roo.each(this.footerEls,function(a,i){if(!a){return;}B+=B.length?' > ':'';B+='<span class="x-ed-loc-'+i+'">'+a.tagName+'</span>';
-});var sz=this.footDisp.up('td').getSize();this.footDisp.dom.style.width=(sz.width-10)+'px';this.footDisp.dom.style.marginLeft='5px';this.footDisp.dom.style.overflow='hidden';this.footDisp.dom.innerHTML=B;},onDestroy:function(){if(this.rendered){this.tb.items.each(function(A){if(A.menu){A.menu.removeAll();
+if(!B){B=D.length?(D[0]?D[0]:D[1]):this.editorcore.doc.body;B=B?B:this.editorcore.doc.body;B=B.tagName.length?B:this.editorcore.doc.body;}var tn=B.tagName.toUpperCase();var E=this.tb.selectedNode;this.tb.selectedNode=B;var F=tn;var db=Roo.get(B).findParent('[data-block]');
+if(db){var G=Roo.htmleditor['Block'+Roo.get(db).attr('data-block')];if(typeof(G)=='undefined'){tn='*';Roo.log("OOps missing block : "+'Block'+Roo.get(db).attr('data-block'));}else{tn='BLOCK.'+db.getAttribute('data-block');this.tb.selectedNode=db;if(typeof(this.toolbars[tn])=='undefined'){this.toolbars[tn]=this.buildToolbar(G.prototype.context,tn,G.prototype.friendly_name);
+}F=G.prototype.friendly_name;}}if(this.tb.name==tn&&E==this.tb.selectedNode&&ev!==false){return;}this.tb.el.hide();this.tb=typeof(this.toolbars[tn])!='undefined'?this.toolbars[tn]:this.toolbars['*'];this.tb.el.show();this.tb.items.first().el.innerHTML=F+': ';
+if(db){var H=new G({node:B});this.tb.fields.each(function(e){e.setValue(dob[e.attrname]);});}else if(this.tb.fields){this.tb.fields.each(function(e){if(e.stylename){e.setValue(B.style[e.stylename]);return;}e.setValue(B.getAttribute(e.attrname));});}this.updateToolbarStyles(B);
+this.tb.selectedNode=B;Roo.menu.MenuMgr.hideAll();this.updateFooter(D);},updateToolbarStyles:function(A){var B=false;for(var i in this.styles){B=true;break;}if(B){var st=this.tb.fields.item(0);st.store.removeAll();var cn=A.className.split(/\s+/);var C=[];
+if(this.styles['*']){Roo.each(this.styles['*'],function(v){C.push([v,cn.indexOf(v)>-1?1:0]);});}if(this.styles[tn]){Roo.each(this.styles[tn],function(v){C.push([v,cn.indexOf(v)>-1?1:0]);});}st.store.loadData(C);st.collapse();st.setValue(cn);}},updateFooter:function(A){var B='';
+if(A===false){this.footDisp.dom.innerHTML='';return;}this.footerEls=A.reverse();Roo.each(this.footerEls,function(a,i){if(!a){return;}B+=B.length?' > ':'';B+='<span class="x-ed-loc-'+i+'">'+a.tagName+'</span>';});var sz=this.footDisp.up('td').getSize();
+this.footDisp.dom.style.width=(sz.width-10)+'px';this.footDisp.dom.style.marginLeft='5px';this.footDisp.dom.style.overflow='hidden';this.footDisp.dom.innerHTML=B;},onDestroy:function(){if(this.rendered){this.tb.items.each(function(A){if(A.menu){A.menu.removeAll();
if(A.menu.el){A.menu.el.destroy();}}A.destroy();});}},onFirstFocus:function(){this.tb.items.each(function(A){A.enable();});},buildToolbar:function(A,nm,B){var C=this.editor;var D=this.editorcore;var E=C.wrap.createChild({tag:'div'},C.wrap.dom.firstChild.nextSibling,true);
var tb=new Roo.Toolbar(E);tb.name=nm;tb.add((typeof(B)=='undefined'?nm:B)+": ");var F=Array.from(this.styles);if(F&&F.length){tb.addField(new Roo.form.ComboBox({store:new Roo.data.SimpleStore({id:'val',fields:['val','selected'],data:[]}),name:'-roo-edit-className',attrname:'className',displayField:'val',typeAhead:false,mode:'local',editable:false,triggerAction:'all',emptyText:'Select Style',selectOnFocus:true,width:130,listeners:{'select':function(c,r,i){tb.selectedNode.className=r?r.get('val'):'';
D.syncValue();}}}));}var G=Roo.form.HtmlEditor.ToolbarContext;var H=G.options;for(var i in A){var I=A[i];tb.add(I.title+": ");var J=I.opts?I.opts:false;if(I.optname){J=H[I.optname];}if(J){tb.addField(new Roo.form.ComboBox({store:typeof(G.stores[i])!='undefined'?Roo.factory(G.stores[i],Roo.data):new Roo.data.SimpleStore({id:'val',fields:['val','display'],data:J}
var tn = sel.tagName.toUpperCase();
var lastSel = this.tb.selectedNode;
this.tb.selectedNode = sel;
-
+ var left_label = tn;
// ok see if we are editing a block?
if (typeof(this.toolbars[tn]) == 'undefined') {
this.toolbars[tn] = this.buildToolbar( cls.prototype.context,tn ,cls.prototype.friendly_name);
}
+ left_label = cls.prototype.friendly_name;
}
}
this.tb.el.show();
// update name
- this.tb.items.first().el.innerHTML = tn + ': ';
+ this.tb.items.first().el.innerHTML = left_label + ': ';
// update attributes
- if (this.tb.fields) {
+ if (db) {
+ var dbo = new cls({node : sel});
+ this.tb.fields.each(function(e) {
+ e.setValue(dob[e.attrname]);
+ });
+
+
+ } else if (this.tb.fields) {
this.tb.fields.each(function(e) {
if (e.stylename) {
e.setValue(sel.style[e.stylename]);
return;
}
- e.setValue(sel.getAttribute(e.attrname));
+ e.setValue(sel.getAttribute(e.attrname));
});
}
this.updateToolbarStyles(sel);
var tn = sel.tagName.toUpperCase();
var lastSel = this.tb.selectedNode;
this.tb.selectedNode = sel;
-
+ var left_label = tn;
// ok see if we are editing a block?
if (typeof(this.toolbars[tn]) == 'undefined') {
this.toolbars[tn] = this.buildToolbar( cls.prototype.context,tn ,cls.prototype.friendly_name);
}
+ left_label = cls.prototype.friendly_name;
}
}
this.tb.el.show();
// update name
- this.tb.items.first().el.innerHTML = tn + ': ';
+ this.tb.items.first().el.innerHTML = left_label + ': ';
// update attributes
- if (this.tb.fields) {
+ if (db) {
+ var dbo = new cls({node : sel});
+ this.tb.fields.each(function(e) {
+ e.setValue(dob[e.attrname]);
+ });
+
+
+ } else if (this.tb.fields) {
this.tb.fields.each(function(e) {
if (e.stylename) {
e.setValue(sel.style[e.stylename]);
return;
}
- e.setValue(sel.getAttribute(e.attrname));
+ e.setValue(sel.getAttribute(e.attrname));
});
}
this.updateToolbarStyles(sel);
,A.wrap.dom.firstChild.nextSibling,true);var ty=Roo.form.HtmlEditor.ToolbarContext.types;this.toolbars={};for(var i in ty){this.toolbars[i]=this.buildToolbar(ty[i],i);}this.tb=this.toolbars.BODY;this.tb.el.show();this.buildFooter();this.footer.show();A.on('hide',function(){this.footer.hide()}
,this);A.on('show',function(){this.footer.show()},this);this.rendered=true;A.on('editorevent',this.updateToolbar,this);},updateToolbar:function(A,ev,B){if(!this.editorcore.activated){this.editor.onFirstFocus();return;}if(ev&&(ev.type=='mouseup'||ev.type=='click')&&ev.target&&ev.target.tagName=='IMG'){B=ev.target;
var C=B.ownerDocument.createRange();try{C.selectNode(B);}catch(e){C.selectNodeContents(B);}var s=this.editorcore.win.getSelection();s.removeAllRanges();s.addRange(C);}var D=this.editorcore.getAllAncestors();var ty=Roo.form.HtmlEditor.ToolbarContext.types;
-if(!B){B=D.length?(D[0]?D[0]:D[1]):this.editorcore.doc.body;B=B?B:this.editorcore.doc.body;B=B.tagName.length?B:this.editorcore.doc.body;}var tn=B.tagName.toUpperCase();var E=this.tb.selectedNode;this.tb.selectedNode=B;var db=Roo.get(B).findParent('[data-block]');
-if(db){var F=Roo.htmleditor['Block'+Roo.get(db).attr('data-block')];if(typeof(F)=='undefined'){tn='*';Roo.log("OOps missing block : "+'Block'+Roo.get(db).attr('data-block'));}else{tn='BLOCK.'+db.getAttribute('data-block');this.tb.selectedNode=db;if(typeof(this.toolbars[tn])=='undefined'){this.toolbars[tn]=this.buildToolbar(F.prototype.context,tn,F.prototype.friendly_name);
-}}}if(this.tb.name==tn&&E==this.tb.selectedNode&&ev!==false){return;}this.tb.el.hide();this.tb=typeof(this.toolbars[tn])!='undefined'?this.toolbars[tn]:this.toolbars['*'];this.tb.el.show();this.tb.items.first().el.innerHTML=tn+': ';if(this.tb.fields){this.tb.fields.each(function(e){if(e.stylename){e.setValue(B.style[e.stylename]);
-return;}e.setValue(B.getAttribute(e.attrname));});}this.updateToolbarStyles(B);this.tb.selectedNode=B;Roo.menu.MenuMgr.hideAll();this.updateFooter(D);},updateToolbarStyles:function(A){var B=false;for(var i in this.styles){B=true;break;}if(B){var st=this.tb.fields.item(0);
-st.store.removeAll();var cn=A.className.split(/\s+/);var C=[];if(this.styles['*']){Roo.each(this.styles['*'],function(v){C.push([v,cn.indexOf(v)>-1?1:0]);});}if(this.styles[tn]){Roo.each(this.styles[tn],function(v){C.push([v,cn.indexOf(v)>-1?1:0]);});}st.store.loadData(C);
-st.collapse();st.setValue(cn);}},updateFooter:function(A){var B='';if(A===false){this.footDisp.dom.innerHTML='';return;}this.footerEls=A.reverse();Roo.each(this.footerEls,function(a,i){if(!a){return;}B+=B.length?' > ':'';B+='<span class="x-ed-loc-'+i+'">'+a.tagName+'</span>';
-});var sz=this.footDisp.up('td').getSize();this.footDisp.dom.style.width=(sz.width-10)+'px';this.footDisp.dom.style.marginLeft='5px';this.footDisp.dom.style.overflow='hidden';this.footDisp.dom.innerHTML=B;},onDestroy:function(){if(this.rendered){this.tb.items.each(function(A){if(A.menu){A.menu.removeAll();
+if(!B){B=D.length?(D[0]?D[0]:D[1]):this.editorcore.doc.body;B=B?B:this.editorcore.doc.body;B=B.tagName.length?B:this.editorcore.doc.body;}var tn=B.tagName.toUpperCase();var E=this.tb.selectedNode;this.tb.selectedNode=B;var F=tn;var db=Roo.get(B).findParent('[data-block]');
+if(db){var G=Roo.htmleditor['Block'+Roo.get(db).attr('data-block')];if(typeof(G)=='undefined'){tn='*';Roo.log("OOps missing block : "+'Block'+Roo.get(db).attr('data-block'));}else{tn='BLOCK.'+db.getAttribute('data-block');this.tb.selectedNode=db;if(typeof(this.toolbars[tn])=='undefined'){this.toolbars[tn]=this.buildToolbar(G.prototype.context,tn,G.prototype.friendly_name);
+}F=G.prototype.friendly_name;}}if(this.tb.name==tn&&E==this.tb.selectedNode&&ev!==false){return;}this.tb.el.hide();this.tb=typeof(this.toolbars[tn])!='undefined'?this.toolbars[tn]:this.toolbars['*'];this.tb.el.show();this.tb.items.first().el.innerHTML=F+': ';
+if(db){var H=new G({node:B});this.tb.fields.each(function(e){e.setValue(dob[e.attrname]);});}else if(this.tb.fields){this.tb.fields.each(function(e){if(e.stylename){e.setValue(B.style[e.stylename]);return;}e.setValue(B.getAttribute(e.attrname));});}this.updateToolbarStyles(B);
+this.tb.selectedNode=B;Roo.menu.MenuMgr.hideAll();this.updateFooter(D);},updateToolbarStyles:function(A){var B=false;for(var i in this.styles){B=true;break;}if(B){var st=this.tb.fields.item(0);st.store.removeAll();var cn=A.className.split(/\s+/);var C=[];
+if(this.styles['*']){Roo.each(this.styles['*'],function(v){C.push([v,cn.indexOf(v)>-1?1:0]);});}if(this.styles[tn]){Roo.each(this.styles[tn],function(v){C.push([v,cn.indexOf(v)>-1?1:0]);});}st.store.loadData(C);st.collapse();st.setValue(cn);}},updateFooter:function(A){var B='';
+if(A===false){this.footDisp.dom.innerHTML='';return;}this.footerEls=A.reverse();Roo.each(this.footerEls,function(a,i){if(!a){return;}B+=B.length?' > ':'';B+='<span class="x-ed-loc-'+i+'">'+a.tagName+'</span>';});var sz=this.footDisp.up('td').getSize();
+this.footDisp.dom.style.width=(sz.width-10)+'px';this.footDisp.dom.style.marginLeft='5px';this.footDisp.dom.style.overflow='hidden';this.footDisp.dom.innerHTML=B;},onDestroy:function(){if(this.rendered){this.tb.items.each(function(A){if(A.menu){A.menu.removeAll();
if(A.menu.el){A.menu.el.destroy();}}A.destroy();});}},onFirstFocus:function(){this.tb.items.each(function(A){A.enable();});},buildToolbar:function(A,nm,B){var C=this.editor;var D=this.editorcore;var E=C.wrap.createChild({tag:'div'},C.wrap.dom.firstChild.nextSibling,true);
var tb=new Roo.Toolbar(E);tb.name=nm;tb.add((typeof(B)=='undefined'?nm:B)+": ");var F=Array.from(this.styles);if(F&&F.length){tb.addField(new Roo.form.ComboBox({store:new Roo.data.SimpleStore({id:'val',fields:['val','selected'],data:[]}),name:'-roo-edit-className',attrname:'className',displayField:'val',typeAhead:false,mode:'local',editable:false,triggerAction:'all',emptyText:'Select Style',selectOnFocus:true,width:130,listeners:{'select':function(c,r,i){tb.selectedNode.className=r?r.get('val'):'';
D.syncValue();}}}));}var G=Roo.form.HtmlEditor.ToolbarContext;var H=G.options;for(var i in A){var I=A[i];tb.add(I.title+": ");var J=I.opts?I.opts:false;if(I.optname){J=H[I.optname];}if(J){tb.addField(new Roo.form.ComboBox({store:typeof(G.stores[i])!='undefined'?Roo.factory(G.stores[i],Roo.data):new Roo.data.SimpleStore({id:'val',fields:['val','display'],data:J}