roojs-ui.js
authorAlan Knowles <alan@roojs.com>
Tue, 20 Aug 2013 05:10:14 +0000 (13:10 +0800)
committerAlan Knowles <alan@roojs.com>
Tue, 20 Aug 2013 05:10:14 +0000 (13:10 +0800)
roojs-ui-debug.js

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

index 6e64852..35c524e 100644 (file)
@@ -27313,18 +27313,22 @@ Roo.form.HtmlEditor.ToolbarContext.types = {
     }
 
 };
+
+// fixme - these need to be configurable..
+
 Roo.form.HtmlEditor.ToolbarContext[ 'font-family']  = {
     title : "font",
     style : 'fontFamily',
+    displayField: 'display',
     opts : [
-        [""],
-        [ 'Arial'],
-        [ 'Courier New'],
-        [ 'Tahoma'],
-        [ 'Times New Roman'],
-        [ 'Verdana' ]
+        ["" , '--None--'],
+        [ 'helvetica,Arial,sans-serif', 'Helvetica'],
+        [ 'Courier New', 'Courier New'],
+        [ 'Tahoma', 'Tahoma'],
+        [ 'Times New Roman,serif', 'Times'],
+        [ 'Verdana','Verdana' ]
     ],
-    width: 160
+    width: 140
 
 };
 
@@ -27631,7 +27635,7 @@ Roo.apply(Roo.form.HtmlEditor.ToolbarContext.prototype,  {
                 }),
                 name : '-roo-edit-className',
                 attrname : 'className',
-                displayField:'val',
+                displayField: 'val',
                 typeAhead: false,
                 mode: 'local',
                 editable : false,
@@ -27665,13 +27669,14 @@ Roo.apply(Roo.form.HtmlEditor.ToolbarContext.prototype,  {
                 tb.addField( new Roo.form.ComboBox({
                     store: new Roo.data.SimpleStore({
                         id : 'val',
-                        fields: ['val'],
+                        fields: ['val', 'display'],
                         data : item.opts  
                     }),
                     name : '-roo-edit-' + i,
                     attrname : i,
                     stylename : item.style ? item.style : false,
-                    displayField:'val',
+                    displayField: item.displayField ? item.displayField : 'val',
+                    valueField :  'val',
                     typeAhead: false,
                     mode: 'local',
                     editable : false,
index f63c88c..2e69392 100644 (file)
@@ -593,7 +593,7 @@ this.editor.toggleSourceEdit(A);},buttonTips:{bold:{title:'Bold (Ctrl+B)',text:'
 A.destroy();});}},onFirstFocus:function(){this.tb.items.each(function(A){A.enable();});}});
 //Roo/form/HtmlEditor/ToolbarContext.js
 Roo.form.HtmlEditor.ToolbarContext=function(A){Roo.apply(this,A);this.styles=this.styles||{};}
-Roo.form.HtmlEditor.ToolbarContext.types={'IMG':{width:{title:"Width",width:40},height:{title:"Height",width:40},align:{title:"Align",opts:[[""],["left"],["right"],["center"],["top"]],width:80},border:{title:"Border",width:40},alt:{title:"Alt",width:120},src:{title:"Src",width:220}},'A':{name:{title:"Name",width:50},href:{title:"Href",width:220}},'TABLE':{rows:{title:"Rows",width:20},cols:{title:"Cols",width:20},width:{title:"Width",width:40},height:{title:"Height",width:40},border:{title:"Border",width:20}},'TD':{width:{title:"Width",width:40},height:{title:"Height",width:40},align:{title:"Align",opts:[[""],["left"],["center"],["right"],["justify"],["char"]],width:80},valign:{title:"Valign",opts:[[""],["top"],["middle"],["bottom"],["baseline"]],width:80},colspan:{title:"Colspan",width:20}},'INPUT':{name:{title:"name",width:120},value:{title:"Value",width:120},width:{title:"Width",width:40}},'LABEL':{'for':{title:"For",width:120}},'TEXTAREA':{name:{title:"name",width:120},rows:{title:"Rows",width:20},cols:{title:"Cols",width:20}},'SELECT':{name:{title:"name",width:120},selectoptions:{title:"Options",width:200}},'BODY':{title:{title:"title",width:200,disabled:true}},'*':{}};Roo.form.HtmlEditor.ToolbarContext['font-family']={title:"font",style:'fontFamily',opts:[[""],['Arial'],['Courier New'],['Tahoma'],['Times New Roman'],['Verdana']],width:160};Roo.each(['SPAN','DIV','TD','P'],function(tg){var cx=Roo.form.HtmlEditor.ToolbarContext;if(typeof(cx.types[tg])=='undefined'){cx.types[tg]={};}
+Roo.form.HtmlEditor.ToolbarContext.types={'IMG':{width:{title:"Width",width:40},height:{title:"Height",width:40},align:{title:"Align",opts:[[""],["left"],["right"],["center"],["top"]],width:80},border:{title:"Border",width:40},alt:{title:"Alt",width:120},src:{title:"Src",width:220}},'A':{name:{title:"Name",width:50},href:{title:"Href",width:220}},'TABLE':{rows:{title:"Rows",width:20},cols:{title:"Cols",width:20},width:{title:"Width",width:40},height:{title:"Height",width:40},border:{title:"Border",width:20}},'TD':{width:{title:"Width",width:40},height:{title:"Height",width:40},align:{title:"Align",opts:[[""],["left"],["center"],["right"],["justify"],["char"]],width:80},valign:{title:"Valign",opts:[[""],["top"],["middle"],["bottom"],["baseline"]],width:80},colspan:{title:"Colspan",width:20}},'INPUT':{name:{title:"name",width:120},value:{title:"Value",width:120},width:{title:"Width",width:40}},'LABEL':{'for':{title:"For",width:120}},'TEXTAREA':{name:{title:"name",width:120},rows:{title:"Rows",width:20},cols:{title:"Cols",width:20}},'SELECT':{name:{title:"name",width:120},selectoptions:{title:"Options",width:200}},'BODY':{title:{title:"title",width:200,disabled:true}},'*':{}};Roo.form.HtmlEditor.ToolbarContext['font-family']={title:"font",style:'fontFamily',displayField:'display',opts:[["",'--None--'],['helvetica,Arial,sans-serif','Helvetica'],['Courier New','Courier New'],['Tahoma','Tahoma'],['Times New Roman,serif','Times'],['Verdana','Verdana']],width:140};Roo.each(['SPAN','DIV','TD','P'],function(tg){var cx=Roo.form.HtmlEditor.ToolbarContext;if(typeof(cx.types[tg])=='undefined'){cx.types[tg]={};}
 cx.types[tg]['font-family']=cx['font-family'];});Roo.form.HtmlEditor.ToolbarContext.types
 Roo.apply(Roo.form.HtmlEditor.ToolbarContext.prototype,{tb:false,rendered:false,editor:false,disable:false,styles:false,toolbars:false,init:function(A){this.editor=A;var B=A.frameId;var C=this;function btn(id,E,F){var G=B+'-'+id;return {id:G,cmd:id,cls:'x-btn-icon x-edit-'+id,enableToggle:E!==false,scope:A,handler:F||A.relayBtnCmd,clickEvent:'mousedown',tooltip:C.buttonTips[id]||undefined,tabIndex:-1};}var D=A.wrap.createChild({tag:'div'},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.editor.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=A.win.getSelection();s.removeAllRanges();s.addRange(C);}var D=B?false:true;var E=this.editor.getAllAncestors();var ty=Roo.form.HtmlEditor.ToolbarContext.types;if(!B){B=E.length?(E[0]?E[0]:E[1]):this.editor.doc.body;B=B?B:this.editor.doc.body;B=B.tagName.length?B:this.editor.doc.body;}var tn=B.tagName.toUpperCase();tn=B.tagName.toUpperCase();var F=this.tb.selectedNode
@@ -601,7 +601,7 @@ this.tb.selectedNode=B;if((this.tb.name!=tn)||(F!=this.tb.selectedNode)){this.tb
 st.store.loadData(H);st.collapse();st.setValue(cn);}
 this.tb.selectedNode=B;Roo.menu.MenuMgr.hideAll();}if(!D){return;}var I='';this.footerEls=E.reverse();Roo.each(this.footerEls,function(a,i){if(!a){return;}
 I+=I.length?' &gt; ':'';I+='<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=I;},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){var B=this.editor;var C=B.wrap.createChild({tag:'div'},B.wrap.dom.firstChild.nextSibling,true);var tb=new Roo.Toolbar(C);tb.add(nm+":&nbsp;");var D=[];for(var i in this.styles){D.push(i);}if(D&&D.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'):'';B.syncValue();}}}));}for(var i in A){var E=A[i];tb.add(E.title+":&nbsp;");if(E.opts){tb.addField(new Roo.form.ComboBox({store:new Roo.data.SimpleStore({id:'val',fields:['val'],data:E.opts}),name:'-roo-edit-'+i,attrname:i,stylename:E.style?E.style:false,displayField:'val',typeAhead:false,mode:'local',editable:false,triggerAction:'all',emptyText:'Select',selectOnFocus:true,width:E.width?E.width:130,listeners:{'select':function(c,r,i){if(c.stylename){tb.selectedNode.style[c.stylename]=r.get('val');return;}
+A.destroy();});}},onFirstFocus:function(){this.tb.items.each(function(A){A.enable();});},buildToolbar:function(A,nm){var B=this.editor;var C=B.wrap.createChild({tag:'div'},B.wrap.dom.firstChild.nextSibling,true);var tb=new Roo.Toolbar(C);tb.add(nm+":&nbsp;");var D=[];for(var i in this.styles){D.push(i);}if(D&&D.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'):'';B.syncValue();}}}));}for(var i in A){var E=A[i];tb.add(E.title+":&nbsp;");if(E.opts){tb.addField(new Roo.form.ComboBox({store:new Roo.data.SimpleStore({id:'val',fields:['val','display'],data:E.opts}),name:'-roo-edit-'+i,attrname:i,stylename:E.style?E.style:false,displayField:E.displayField?E.displayField:'val',valueField:'val',typeAhead:false,mode:'local',editable:false,triggerAction:'all',emptyText:'Select',selectOnFocus:true,width:E.width?E.width:130,listeners:{'select':function(c,r,i){if(c.stylename){tb.selectedNode.style[c.stylename]=r.get('val');return;}
 tb.selectedNode.setAttribute(c.attrname,r.get('val'));}}}));continue;tb.addField(new Roo.form.TextField({name:i,width:100,value:''}));continue;}
 tb.addField(new Roo.form.TextField({name:'-roo-edit-'+i,attrname:i,width:E.width,value:'',listeners:{'change':function(f,nv,ov){tb.selectedNode.setAttribute(f.attrname,nv);}}}));}
 tb.addFill();var F=this;tb.addButton({text:'Remove Tag',listeners:{click:function(){var sn=tb.selectedNode;var pn=sn.parentNode;var G=sn.childNodes[0];var en=sn.childNodes[sn.childNodes.length-1];while(sn.childNodes.length){var H=sn.childNodes[0];sn.removeChild(H);pn.insertBefore(H,sn);}