roojs-ui.js
authorAlan <alan@roojs.com>
Thu, 4 Nov 2021 04:40:51 +0000 (12:40 +0800)
committerAlan <alan@roojs.com>
Thu, 4 Nov 2021 04:40:51 +0000 (12:40 +0800)
roojs-ui-debug.js
roojs-all.js
roojs-debug.js

roojs-all.js
roojs-debug.js
roojs-ui-debug.js
roojs-ui.js

index c7684e7..7ab8dfa 100644 (file)
@@ -2060,16 +2060,17 @@ var C=B.frameId;var D=this;function btn(id,F,G){var H=C+'-'+id;return {id:H,cmd:
 ,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;
 this.editorcore.selectNode(B);}var C=this.editorcore.getAllAncestors();var ty=Roo.form.HtmlEditor.ToolbarContext.types;if(!B){B=C.length?(C[0]?C[0]:C[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 D=this.tb.selectedNode;this.tb.selectedNode=B;var E=tn;var db=Roo.get(B).findParent('[data-block]');var F=Roo.get(B).findParent('[contenteditable=true]');if(db&&F&&F.tagName!='BODY'){db=false;}var G=false;if(db&&!B.hasAttribute('contenteditable')&&B.getAttribute('contenteditable')!='true'){G=Roo.htmleditor.Block.factory(db);
-if(G){tn='BLOCK.'+db.getAttribute('data-block');this.tb.selectedNode=db;this.editorcore.selectNode(db);if(typeof(this.toolbars[tn])=='undefined'){this.toolbars[tn]=this.buildToolbar(G.context||G.contextMenu(this),tn,G.friendly_name);}E=G.friendly_name;C=this.editorcore.getAllAncestors();
-}}if(this.tb.name==tn&&D==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=E+':&nbsp;';if(G){this.tb.fields.each(function(e){e.setValue(G[e.attrname]);
-});}else if(this.tb.fields&&this.tb.selectedNode){this.tb.fields.each(function(e){if(e.stylename){e.setValue(this.tb.selectedNode.style[e.stylename]);return;}e.setValue(this.tb.selectedNode.getAttribute(e.attrname));},this);this.updateToolbarStyles(this.tb.selectedNode);
-}Roo.menu.MenuMgr.hideAll();this.updateFooter(C);},updateToolbarStyles:function(A){var B=false;for(var i in this.styles){B=true;break;}if(B&&this.tb.hasStyles){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?' &gt; ':'';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.hasStyles=false;tb.name=nm;tb.add((typeof(B)=='undefined'?nm:B)+":&nbsp;");
-var F=Array.from(this.styles);if(F&&F.length){tb.hasStyles=true;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'):'';
+}var tn=B.tagName.toUpperCase();var D=this.tb.selectedNode;this.tb.selectedNode=B;var E=tn;var F=Roo.get(B);var db=F.attr('data-block')==undefined?F.findParent('[data-block]'):B;var G=Roo.get(B).findParent('[contenteditable=true]');if(db&&G&&G.tagName!='BODY'){db=false;
+}var H=false;if(db&&!B.hasAttribute('contenteditable')&&B.getAttribute('contenteditable')!='true'){H=Roo.htmleditor.Block.factory(db);if(H){tn='BLOCK.'+db.getAttribute('data-block');this.tb.selectedNode=db;this.editorcore.selectNode(db);if(typeof(this.toolbars[tn])=='undefined'){this.toolbars[tn]=this.buildToolbar(H.context||H.contextMenu(this),tn,H.friendly_name);
+}E=H.friendly_name;C=this.editorcore.getAllAncestors();}}if(this.tb.name==tn&&D==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=E+':&nbsp;';
+if(H){this.tb.fields.each(function(e){e.setValue(H[e.attrname]);});}else if(this.tb.fields&&this.tb.selectedNode){this.tb.fields.each(function(e){if(e.stylename){e.setValue(this.tb.selectedNode.style[e.stylename]);return;}e.setValue(this.tb.selectedNode.getAttribute(e.attrname));
+},this);this.updateToolbarStyles(this.tb.selectedNode);}Roo.menu.MenuMgr.hideAll();this.updateFooter(C);},updateToolbarStyles:function(A){var B=false;for(var i in this.styles){B=true;break;}if(B&&this.tb.hasStyles){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?' &gt; ':'';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.hasStyles=false;tb.name=nm;tb.add((typeof(B)=='undefined'?nm:B)+":&nbsp;");var F=Array.from(this.styles);if(F&&F.length){tb.hasStyles=true;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;for(var i in A){if(typeof(A[i].xtype)!='undefined'){tb.add(Roo.factory(A[i]));continue;}var H=A[i];tb.add(H.title+":&nbsp;");var I=H.opts?H.opts:false;if(H.optname){I=Roo.form.HtmlEditor.ToolbarContext.options[H.optname];
 }if(I){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:I}),name:'-roo-edit-'+i,attrname:i,stylename:H.style?H.style:false,displayField:H.displayField?H.displayField:'val',valueField:'val',typeAhead:false,mode:typeof(G.stores[i])!='undefined'?'remote':'local',editable:false,triggerAction:'all',emptyText:'Select',selectOnFocus:true,width:H.width?H.width:130,listeners:{'select':function(c,r,i){if(tb.selectedNode.hasAttribute('data-block')){var b=Roo.htmleditor.Block.factory(tb.selectedNode);
 b[c.attrname]=r.get('val');b.updateElement(tb.selectedNode);D.syncValue();return;}if(c.stylename){tb.selectedNode.style[c.stylename]=r.get('val');D.syncValue();return;}if(r===false){tb.selectedNode.removeAttribute(c.attrname);D.syncValue();return;}tb.selectedNode.setAttribute(c.attrname,r.get('val'));
index 38579b9..01a148c 100644 (file)
@@ -49383,7 +49383,8 @@ Roo.apply(Roo.form.HtmlEditor.ToolbarContext.prototype,  {
      *
      * Note you can force an update by calling on('editorevent', scope, false)
      */
-    updateToolbar: function(editor ,ev, sel){
+    updateToolbar: function(editor ,ev, sel)
+    {
 
         //Roo.log(ev);
         // capture mouse up - this is handy for selecting images..
@@ -49434,8 +49435,9 @@ Roo.apply(Roo.form.HtmlEditor.ToolbarContext.prototype,  {
         var left_label = tn;
         
         // ok see if we are editing a block?
+        var sel_el = Roo.get(sel);
         
-        var db = Roo.get(sel).findParent('[data-block]');
+        var db = sel_el.attr('data-block')  == undefined ?  sel_el.findParent('[data-block]') : sel;
         var cepar = Roo.get(sel).findParent('[contenteditable=true]');
         if (db && cepar && cepar.tagName != 'BODY') {
             db = false; // we are inside an editable block.. = not sure how we are going to handle nested blocks!?
index bb96419..671d747 100644 (file)
@@ -25415,7 +25415,8 @@ Roo.apply(Roo.form.HtmlEditor.ToolbarContext.prototype,  {
      *
      * Note you can force an update by calling on('editorevent', scope, false)
      */
-    updateToolbar: function(editor ,ev, sel){
+    updateToolbar: function(editor ,ev, sel)
+    {
 
         //Roo.log(ev);
         // capture mouse up - this is handy for selecting images..
@@ -25466,8 +25467,9 @@ Roo.apply(Roo.form.HtmlEditor.ToolbarContext.prototype,  {
         var left_label = tn;
         
         // ok see if we are editing a block?
+        var sel_el = Roo.get(sel);
         
-        var db = Roo.get(sel).findParent('[data-block]');
+        var db = sel_el.attr('data-block')  == undefined ?  sel_el.findParent('[data-block]') : sel;
         var cepar = Roo.get(sel).findParent('[contenteditable=true]');
         if (db && cepar && cepar.tagName != 'BODY') {
             db = false; // we are inside an editable block.. = not sure how we are going to handle nested blocks!?
index 29211ec..352f3e8 100644 (file)
@@ -1136,16 +1136,17 @@ var C=B.frameId;var D=this;function btn(id,F,G){var H=C+'-'+id;return {id:H,cmd:
 ,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;
 this.editorcore.selectNode(B);}var C=this.editorcore.getAllAncestors();var ty=Roo.form.HtmlEditor.ToolbarContext.types;if(!B){B=C.length?(C[0]?C[0]:C[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 D=this.tb.selectedNode;this.tb.selectedNode=B;var E=tn;var db=Roo.get(B).findParent('[data-block]');var F=Roo.get(B).findParent('[contenteditable=true]');if(db&&F&&F.tagName!='BODY'){db=false;}var G=false;if(db&&!B.hasAttribute('contenteditable')&&B.getAttribute('contenteditable')!='true'){G=Roo.htmleditor.Block.factory(db);
-if(G){tn='BLOCK.'+db.getAttribute('data-block');this.tb.selectedNode=db;this.editorcore.selectNode(db);if(typeof(this.toolbars[tn])=='undefined'){this.toolbars[tn]=this.buildToolbar(G.context||G.contextMenu(this),tn,G.friendly_name);}E=G.friendly_name;C=this.editorcore.getAllAncestors();
-}}if(this.tb.name==tn&&D==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=E+':&nbsp;';if(G){this.tb.fields.each(function(e){e.setValue(G[e.attrname]);
-});}else if(this.tb.fields&&this.tb.selectedNode){this.tb.fields.each(function(e){if(e.stylename){e.setValue(this.tb.selectedNode.style[e.stylename]);return;}e.setValue(this.tb.selectedNode.getAttribute(e.attrname));},this);this.updateToolbarStyles(this.tb.selectedNode);
-}Roo.menu.MenuMgr.hideAll();this.updateFooter(C);},updateToolbarStyles:function(A){var B=false;for(var i in this.styles){B=true;break;}if(B&&this.tb.hasStyles){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?' &gt; ':'';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.hasStyles=false;tb.name=nm;tb.add((typeof(B)=='undefined'?nm:B)+":&nbsp;");
-var F=Array.from(this.styles);if(F&&F.length){tb.hasStyles=true;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'):'';
+}var tn=B.tagName.toUpperCase();var D=this.tb.selectedNode;this.tb.selectedNode=B;var E=tn;var F=Roo.get(B);var db=F.attr('data-block')==undefined?F.findParent('[data-block]'):B;var G=Roo.get(B).findParent('[contenteditable=true]');if(db&&G&&G.tagName!='BODY'){db=false;
+}var H=false;if(db&&!B.hasAttribute('contenteditable')&&B.getAttribute('contenteditable')!='true'){H=Roo.htmleditor.Block.factory(db);if(H){tn='BLOCK.'+db.getAttribute('data-block');this.tb.selectedNode=db;this.editorcore.selectNode(db);if(typeof(this.toolbars[tn])=='undefined'){this.toolbars[tn]=this.buildToolbar(H.context||H.contextMenu(this),tn,H.friendly_name);
+}E=H.friendly_name;C=this.editorcore.getAllAncestors();}}if(this.tb.name==tn&&D==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=E+':&nbsp;';
+if(H){this.tb.fields.each(function(e){e.setValue(H[e.attrname]);});}else if(this.tb.fields&&this.tb.selectedNode){this.tb.fields.each(function(e){if(e.stylename){e.setValue(this.tb.selectedNode.style[e.stylename]);return;}e.setValue(this.tb.selectedNode.getAttribute(e.attrname));
+},this);this.updateToolbarStyles(this.tb.selectedNode);}Roo.menu.MenuMgr.hideAll();this.updateFooter(C);},updateToolbarStyles:function(A){var B=false;for(var i in this.styles){B=true;break;}if(B&&this.tb.hasStyles){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?' &gt; ':'';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.hasStyles=false;tb.name=nm;tb.add((typeof(B)=='undefined'?nm:B)+":&nbsp;");var F=Array.from(this.styles);if(F&&F.length){tb.hasStyles=true;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;for(var i in A){if(typeof(A[i].xtype)!='undefined'){tb.add(Roo.factory(A[i]));continue;}var H=A[i];tb.add(H.title+":&nbsp;");var I=H.opts?H.opts:false;if(H.optname){I=Roo.form.HtmlEditor.ToolbarContext.options[H.optname];
 }if(I){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:I}),name:'-roo-edit-'+i,attrname:i,stylename:H.style?H.style:false,displayField:H.displayField?H.displayField:'val',valueField:'val',typeAhead:false,mode:typeof(G.stores[i])!='undefined'?'remote':'local',editable:false,triggerAction:'all',emptyText:'Select',selectOnFocus:true,width:H.width?H.width:130,listeners:{'select':function(c,r,i){if(tb.selectedNode.hasAttribute('data-block')){var b=Roo.htmleditor.Block.factory(tb.selectedNode);
 b[c.attrname]=r.get('val');b.updateElement(tb.selectedNode);D.syncValue();return;}if(c.stylename){tb.selectedNode.style[c.stylename]=r.get('val');D.syncValue();return;}if(r===false){tb.selectedNode.removeAttribute(c.attrname);D.syncValue();return;}tb.selectedNode.setAttribute(c.attrname,r.get('val'));