wf.Component=function(cfg){
cfg=cfg||{};
wf.apply(this,cfg);
this.el=wf.get(cfg.el);
this.initComponent();
this.id=this.el.id;
wf.ComponentMgr.register(this.id,this);};
wf.extend(wf.Component,wf.Observable,{
disabledClass:"x-item-disabled",
initComponent:function(){
if(!this.inited){
this.addEvents("show","hide");
if(this.cls){
this.getActionEl().addClass(this.cls);
delete this.cls;}
if(this.style){
this.getActionEl().applyStyles(this.style);
delete this.style;}
if(this.hidden){
this.hide();}
if(this.disabled){
this.disable();}
this.init();
this.inited=true;}},
init:wf.emptyFn,
child:function(ss,p){
var c;
if(p&&p instanceof Object){
c=p.child(ss);}else{
c=this.el.child(ss);}
return c;},
getActionEl:function(){
return this.el;},
disable:function(){
this.disabled=true;
this.getActionEl().addClass(this.disabledClass);},
setDisabled:function(flag){
if(flag){
this.disable();}else{
this.enable();}},
enable:function(){
this.disabled=false;
this.getActionEl().removeClass(this.disabledClass);},
show:function(){
this.hidden=false;
this.getActionEl().removeClass('x-hide-display');
this.getActionEl().show();
this.fireEvent("show",this);},
hide:function(){
this.hidden=true;
this.getActionEl().addClass('x-hide-display');
this.getActionEl().hide();
this.fireEvent("hide",this);}});
wf.BoxComponent=wf.extend(wf.Component,{
init:function(){
if(this.width||this.height){
this.setSize(this.width,this.height);}
if(this.x||this.y){
this.setPosition(this.x,this.y);}},
getSize:function(){
return this.getPositionEl().getSize();},
setSize:function(w,h){
var adj=this.adjustSize(w,h);
var aw=adj.width,ah=adj.height;
if(aw!==undefined||ah!==undefined){
var rz=this.getResizeEl();
rz.setSize(aw,ah);}
this.onResize(aw,ah,w,h);},
showMask:function(){
if(!this.mask){
this.mask=this.getPositionEl().createChild({
cls:"ext-el-mask"});
this.mask.setStyle("z-index",9000);
var s=this.getSize();
this.mask.setSize(s.w,s.h);}
wf.getBody().addClass("x-body-masked");
this.mask.show();},
unmask:function(){
wf.getBody().removeClass("x-body-masked");
this.mask.hide();},
onResize:function(aw,ah,w,h){},
setPagePosition:function(x,y){
if(x&&typeof x[1]=='number'){
y=x[1];
x=x[0];}
this.pageX=x;
this.pageY=y;
if(x===undefined||y===undefined){
return;}
var p=this.el.translatePoints(x,y);
this.setPosition(p.left,p.top);
return this;},
setPosition:function(x,y){
this.x=x;
this.y=y;
var adj=this.adjustPosition(x,y);
var ax=adj.x,ay=adj.y;
var el=this.getPositionEl();
if(ax!==undefined||ay!==undefined){
el.setLeftTop(ax,ay);}
return this;},
adjustSize:function(w,h){
if(this.autoWidth){
w='auto';}
if(this.autoHeight){
h='auto';}
return{
width:w,
height:h};},
adjustPosition:function(x,y){
return{
x:x,
y:y};},
getPositionEl:function(){
return this.positionEl||this.el;},
getResizeEl:function(){
return this.resizeEl||this.el;}});
wf.ComponentMgr=function(){
var all={};
return{
register:function(id,c){
if(id&&c){
all[id]=c;}},
unRegister:function(id){
if(id){
all[id]=null;
delete all[id];}},
get:function(id){
return all[id];}};}();
wf.getCmp=wf.ComponentMgr.get;
wf.Panel=wf.extend(wf.BoxComponent,{
labelWidth:80,
fieldWidth:150,
labelAlign:'left',
headAlign:'left',
buttonAlign:'center',
border:true,
params:{},
layout:'auto',
layoutConfig:{},
items:[],
init:function(){
this.addEvents("beforeexpand","beforecollapse","expand","collapse");
if(!this.bwrap){
this.bwrap=this.child('.'+this.baseCls+'-bwrap');}
if(!this.bd){
this.bd=this.child('.'+this.baseCls+'-body');}
if(!this.header){
this.header=this.child('.'+this.baseCls+'-header');}
if(!this.tbar){
this.tbar=this.child('.'+this.baseCls+'-tbar');}
if(!this.bbar){
this.bbar=this.child('.'+this.baseCls+'-bbar');}
if(this.frame){
this.footer=this.el.child('div.'+this.baseCls+'-bl');}
else{
this.footer=this.child('div.'+this.baseCls+'-footer');}
wf.Panel.superclass.init.call(this);
if(!this.header){
this.bd.addClass(this.baseCls+'-body-noheader');}
else{
if(this.iconCls){
this.setIconClass(this.iconCls);}
if(this.collapsible){
this.setCollapsible(true);}
if(this.collapsed){
this.setCollapsed(true);}
this.header.setStyle("textAlign",this.headAlign);}
if(this.autoScroll){
this.bd.setStyle("overflow","auto");}
if(!this.border){
this.el.addClass(this.baseCls+"-noborder");
this.bd.addClass(this.baseCls+"-body-noborder");
if(this.header){
this.header.addClass(this.baseCls+"-header-noborder");}}
if(this.bodyStyle){
this.bd.applyStyles(this.bodyStyle);}
var bEl=this.child('div.x-panel-btns');
if(bEl){
bEl.addClass('x-panel-btns-'+this.buttonAlign);}
if(this.frame&&this.footer&&!bEl){
this.footer.addClass(this.baseCls+'-nofooter');}
if(this.layout){
if(typeof this.layout=='string'){
this.layout=new wf.LAYOUTS[this.layout.toLowerCase()](this.layoutConfig);}
if(this.childCfg){
for(var i=0;i<this.items.length;i++){
var id=this.items[i].id;
var cfg=this.getChildConfig(id);
if(cfg){
wf.apply(this.items[i],cfg);}}}
this.layout.setContainer(this);
this.lay();}
if(this.lazy){
this.load();}},
load:function(url,params){
var u=url||this.url;
var p=params||this.params;
this.bd.load({
url:u,
params:p,
scripts:true,
text:'装载中...'});},
lay:function(){
this.layout.layout();},
setTitle:function(title,iconCls){
this.title=title;
if(this.header){
this.header.child('span').update(title);}
if(iconCls){
this.setIconClass(iconCls);}
return this;},
initFields:function(fields){
for(var i=0;i<this.items.length;i++){
var item=this.items[i];
if(item.items){
item.initFields(fields);}else if(item.isFormField){
this.initItem(item);
fields.push(item);}}},
initItem:function(item){
if(!item.width&&item.isFormField){
item.setSize(this.fieldWidth);}},
getComponent:function(comp){
if(typeof comp=='object'){
return comp;}
for(var i=0;i<this.items.length;i++){
if(this.items[i].el.id==comp){
return this.items[i];}}
return null;},
getChildConfig:function(id){
for(var i=0;i<this.childCfg.length;i++){
var c=this.childCfg[i];
if(c.id==id){
return c.cfg;}}
return null;},
setCollapsible:function(col){
this.collapsible=col;
if(this.collapsible&&!this.tool){
this.tool=wf.DomHelper.doInsert(this.header.dom,{tag:'div',cls:'x-tool x-tool-toggle'},'afterBegin',true);
this.tool.on('click',this.toogle,this);
this.tool.addClassOnOver('x-tool-toggle-over');}},
setCollapsed:function(col){
if(col){
this.collapse();}
this.collapsed=col;},
setIconClass:function(cls){
var old=this.iconCls;
this.iconCls=cls;
if(this.frame){
this.header.addClass('x-panel-icon');
this.header.replaceClass(old,this.iconCls);}
else{
var hd=this.header.dom;
var img=hd.firstChild&&String(hd.firstChild.tagName).toLowerCase()=='img'?hd.firstChild:null;
if(img){
wf.fly(img).replaceClass(old,this.iconCls);}
else{
wf.DomHelper.doInsert(hd.firstChild,{
tag:'img',
src:wf.BLANK_IMAGE_URL,
cls:this.baseCls+'-inline-icon '+this.iconCls},"afterBegin");}}},
getFrameWidth:function(){
var w=this.el.getFrameWidth('lr');
if(this.frame){
var l=this.bwrap.child('div');
w+=(l.getFrameWidth('l')+l.child('div').getFrameWidth('r'));
var mc=this.bwrap.child('div[class*='+this.baseCls+'-mc]');
if(mc){
w+=mc.getFrameWidth('lr');}}
return w;},
getFrameHeight:function(){
var h=this.el.getFrameWidth('tb');
h+=(this.tbar?this.tbar.getSize().height:0)+(this.bbar?this.bbar.getSize().height:0);
if(this.frame){
var hd=this.header;
var ft=this.footer;
if(hd&&hd.dom){
h+=hd.dom.offsetHeight;}
if(ft&&ft.dom){
h+=ft.dom.offsetHeight;}
var mc=this.el.child('.'+this.baseCls+'-mc');
if(mc){
h+=mc.getFrameWidth('tb');}}
else{
h+=(this.header?this.header.getSize().height:0)+(this.footer?this.footer.getSize().height:0);}
return h;},
getLayoutTarget:function(){
return this.bd;},
onResize:function(w,h){
if(w!==undefined||h!==undefined){
if(!this.collapsed){
w=(w=='auto')?w:w-this.getFrameWidth();
h=(h=='auto')?h:h-this.getFrameHeight();
this.getBody().setSize(w,h-8);
if(typeof this.layout!='string'){
this.lay();}}}},
getBody:function(){
if(!this.bd){
this.bd=this.child("."+this.baseCls+"-body");}
return this.bd;},
toogle:function(){
if(this.collapsed){
this.expand();}
else{
this.collapse();}},
expand:function(){
if(!this.collapsed||this.fireEvent('beforeexpand',this)===false){
return;}
this.el.removeClass('x-panel-collapsed');
this.bwrap.show();
this.collapsed=false;
this.fireEvent('expand',this);},
collapse:function(){
if(this.collapsed||this.fireEvent('beforecollapse',this)===false){
return;}
this.el.addClass('x-panel-collapsed');
this.bwrap.hide();
if(!wf.isIE&&this.items){
for(var i=0;i<this.items.length;i++){
var item=this.items[i];
if(item&&item.collapse){
item.collapse();}}}
this.collapsed=true;
this.fireEvent('collapse',this);}});
wf.layout.ContainerLayout=function(cfg){
wf.apply(this,cfg);};
wf.layout.ContainerLayout.prototype={
activeItem:null,
layout:function(){
var target=this.container.getLayoutTarget();
this.onLayout(this.container,target);},
setContainer:function(c){
this.container=c;},
onLayout:function(ct,target){
if(!this.activeItem){
this.activeItem=ct.items[0];}
this.renderAll(ct,target);},
renderAll:function(ct,target){
var items=ct.items;
for(var i=0,len=items.length;i<len;i++){
var c=items[i];
if(c){
this.renderItem(c,i,target);}}},
parseMargins:function(v){
var ms=v.split(' ');
var len=ms.length;
if(len==1){
ms[1]=ms[0];
ms[2]=ms[0];
ms[3]=ms[0];}
if(len==2){
ms[2]=ms[0];
ms[3]=ms[1];}
return{
top:parseInt(ms[0],10)||0,
right:parseInt(ms[1],10)||0,
bottom:parseInt(ms[2],10)||0,
left:parseInt(ms[3],10)||0};},
renderItem:function(c,position,target){
if(this.extraCls){
c.el.addClass(this.extraCls);}
if(this.renderHidden&&c!=this.activeItem){
c.hide();}}};
wf.layout.FitLayout=wf.extend(wf.layout.ContainerLayout,{
onLayout:function(ct,target){
wf.layout.FitLayout.superclass.onLayout.call(this,ct,target);
if(!this.container.collapsed){
this.setItemSize(this.activeItem,target.getStyleSize());}},
setItemSize:function(item,size){
if(item&&size.height>0){
item.setSize(size.width,size.height-1);}}});
wf.layout.CardLayout=wf.extend(wf.layout.FitLayout,{
renderHidden:true,
setActiveItem:function(item){
item=this.container.getComponent(item);
if(this.activeItem!=item){
if(this.activeItem){
this.activeItem.hide();}
this.activeItem=item;
item.show();
this.layout();}}});
wf.layout.Accordion=wf.extend(wf.layout.ContainerLayout,{
renderItem:function(c,position,target){
var size=target.getStyleSize();
if(c.header){
c.header.addClass('x-accordion-hd');}
c.setCollapsible(true);
if(this.activeItem!=c){
c.setSize(size.width,this.getMinHeight(c));
c.setCollapsed(true);}else{
if(size.height>1000){
c.setSize(size.width,420);}else{
c.setSize(size.width,size.height-this.getActiveHeight(c));}}
wf.layout.Accordion.superclass.renderItem.apply(this,arguments);
c.on('beforeexpand',this.beforeExpand,this);
c.on('beforecollapse',this.beforeCollapse,this);},
beforeExpand:function(p,anim){
var ai=this.activeItem;
var target=this.container.getLayoutTarget();
var size=target.getStyleSize();
if(ai!=p){
ai.collapse();
ai.setSize(size.width,this.getMinHeight(ai));}
var h=size.height-this.getActiveHeight(p);
p.setSize(size.width,h);
p.getBody().setSize(size.width,h-p.getFrameHeight());
this.activeItem=p;
return true;},
getMinHeight:function(p){
var hh;
if(p.header){
hh=p.header.getSize().height;}else{
hh="auto";}
return hh;},
getActiveHeight:function(item){
var items=this.container.items;
var hh=0;
for(var i=0,len=items.length;i<len;i++){
var p=items[i];
if(p!=item){
hh+=this.getMinHeight(p);}}
return hh;},
beforeCollapse:function(p,anim){
var ai=this.activeItem;
if(ai==p){
var target=this.container.getLayoutTarget();
var size=target.getStyleSize();
ai.setSize(size.width,this.getMinHeight(p));}
return true;}});
wf.layout.ColumnLayout=wf.extend(wf.layout.ContainerLayout,{
onLayout:function(ct,target){
this.extraCls='x-column';
wf.layout.ColumnLayout.superclass.onLayout.call(this,ct,target);
var cs=ct.items,len=cs.length,c,i;
if(!this.innerCt){
target.addClass('x-column-layout-ct');
this.innerCt=target.child('.x-column-inner');}
var size=target.getViewSize();
if(size.width<1&&size.height<1){
return;}
var w=size.width-target.getPadding('lr'),
h=size.height-target.getPadding('tb'),
pw=w;
this.innerCt.setSize(w);
for(i=0;i<len;i++){
c=cs[i];
if(!c.columnWidth){
pw-=(c.getSize().width+c.el.getMargins('lr'));}}
pw=pw<0?0:pw;
for(i=0;i<len;i++){
c=cs[i];
if(c.columnWidth){
c.setSize(Math.floor(c.columnWidth*pw)-c.el.getMargins('lr'));}}}});
wf.layout.TableLayout=wf.extend(wf.layout.ContainerLayout,{
onLayout:function(ct,target){
var cs=ct.items,len=cs.length,c,i;
target.addClass('x-table-layout-ct');}});
wf.layout.BorderLayout=wf.extend(wf.layout.ContainerLayout,{
onLayout:function(ct,target){
if(!this.inited){
var collapsed=[];
target.position();
target.addClass('x-border-layout-ct');
var items=ct.items;
for(var i=0,len=items.length;i<len;i++){
var c=items[i];
var pos=c.region;
if(c.collapsed){
collapsed.push(c);}
c.collapsed=false;
c.cls=c.cls?c.cls+' x-border-panel':'x-border-panel';
c.el.addClass(c.cls);
this[pos]=new wf.layout.BorderLayout.Region(this,c.cfg,pos);
this[pos].render(target,c);}}
var size=target.getViewSize();
if(size.width<20||size.height<20){
if(collapsed){
this.restoreCollapsed=collapsed;}
return;}else if(this.restoreCollapsed){
collapsed=this.restoreCollapsed;
delete this.restoreCollapsed;}
var w=size.width,h=size.height;
var centerW=w,centerH=h,centerY=0,centerX=0;
var n=this.north,s=this.south,west=this.west,e=this.east,c=this.center;
if(!c){
throw 'No center region defined in BorderLayout '+ct.id;}
if(n&&n.isVisible()){
var b=n.getSize();
var el=n.el;
var m=n.getMargins();
b.width=w-(m.left+m.right);
b.x=m.left;
b.y=m.top;
if(wf.isIE){
b.height=b.height-18;}
centerY=b.height+b.y+m.bottom;
centerH-=centerY;
n.applyLayout(b);}
if(s&&s.isVisible()){
var b=s.getSize();
var m=s.getMargins();
b.width=w-(m.left+m.right);
b.x=m.left;
var totalHeight=(b.height+m.top+m.bottom);
b.y=h-totalHeight+m.top;
centerH-=totalHeight;
s.applyLayout(b);}
if(west&&west.isVisible()){
var b=west.getSize();
var m=west.getMargins();
b.height=centerH-(m.top+m.bottom);
b.x=m.left;
b.y=centerY+m.top;
var totalWidth=(b.width+m.left+m.right);
centerX+=totalWidth;
centerW-=totalWidth;
west.applyLayout(b);}
if(e&&e.isVisible()){
var b=e.getSize();
var m=e.getMargins();
b.height=centerH-(m.top+m.bottom);
var totalWidth=(b.width+m.left+m.right);
b.x=w-totalWidth+m.left;
b.y=centerY+m.top;
centerW-=totalWidth;
e.applyLayout(b);}
var m=c.getMargins();
var centerBox={
x:centerX+m.left,
y:centerY+m.top,
width:centerW-(m.left+m.right),
height:centerH-(m.top+m.bottom)};
c.applyLayout(centerBox);
if(collapsed){
for(var i=0,len=collapsed.length;i<len;i++){
collapsed[i].collapse();}}
this.inited=true;}});
wf.layout.BorderLayout.Region=function(layout,config,pos){
wf.apply(this,config);
this.layout=layout;
this.position=pos;
if(typeof this.margins=='string'){
this.margins=this.layout.parseMargins(this.margins);}
this.margins=wf.applyIf(this.margins||{},this.defaultMargins);
if(this.collapsible){
if(typeof this.cmargins=='string'){
this.cmargins=this.layout.parseMargins(this.cmargins);}
this.cmargins=wf.applyIf(this.cmargins||{},
pos=='north'||pos=='south'?this.defaultNSCMargins:this.defaultEWCMargins);}};
wf.layout.BorderLayout.Region.prototype={
collapsible:false,
defaultMargins:{left:0,top:0,right:0,bottom:0},
defaultNSCMargins:{left:5,top:5,right:5,bottom:5},
defaultEWCMargins:{left:5,top:0,right:5,bottom:0},
isCollapsed:false,
render:function(ct,p){
this.panel=p;
this.targetEl=ct;
this.el=p.el;
var ps=this.position;
if(ps!='center'){
p.on("beforecollapse",this.beforeCollapse,this);
p.on("collapse",this.onCollapse,this);
p.on("beforeexpand",this.beforeExpand,this);
p.on("expand",this.onExpand,this);
p.on("hide",this.onHide,this);
p.on("show",this.onShow,this);
if(this.collapsible){
p.collapseEl='el';}
if(p.tool){
p.tool.addClass('x-tool-collapse-'+ps);
p.tool.addClassOnOver('x-tool-collapse-'+ps+'-over');}}},
beforeCollapse:function(p){
this.getCollapsedEl().show();
this.panel.el.setStyle('z-index',100);
this.isCollapsed=true;
this.layout.layout();},
onCollapse:function(animate){
this.panel.el.setStyle('z-index',1);
this.getCollapsedEl().dom.style.visibility='visible';
this.panel.el.hide();},
beforeExpand:function(animate){
var c=this.getCollapsedEl();
this.el.show();
if(this.position=='east'||this.position=='west'){
this.panel.setSize(undefined,c.getSize().height);}else{
this.panel.setSize(c.getSize().height,undefined);}
c.hide();
c.dom.style.visibility='hidden';
this.panel.el.setStyle('z-index',100);},
onExpand:function(){
this.isCollapsed=false;
this.layout.layout();
this.panel.el.setStyle('z-index',1);},
getMargins:function(){
return this.isCollapsed&&this.cmargins?this.cmargins:this.margins;},
getSize:function(){
if(this.isCollapsed){
return this.getCollapsedEl().getSize();}else{
return this.panel.getSize();}},
isVisible:function(){
return !this.panel.hidden;},
applyLayoutCollapsed:function(box){
var ce=this.getCollapsedEl();
ce.setLeftTop(box.x,box.y);
ce.setSize(box.width,box.height);},
applyLayout:function(box){
if(this.isCollapsed){
this.applyLayoutCollapsed(box);}else{
this.panel.setPosition(box.x,box.y);
this.panel.setSize(box.width,box.height);}},
getCollapsedEl:function(){
if(!this.collapsedEl){
this.collapsedEl=this.targetEl.createChild({
cls:"x-layout-collapsed x-layout-collapsed-"+this.position});
var t=this.collapsedEl.createChild({
cls:"x-tool x-tool-expand-"+this.position});
t.addClassOnOver('x-tool-expand-'+this.position+'-over');
t.on('click',this.onExpandClick,this,{stopEvent:true});
this.collapsedEl.addClassOnOver("x-layout-collapsed-over");}
return this.collapsedEl;},
onExpandClick:function(e){
this.panel.expand();},
onCollapseClick:function(e){
this.panel.collapse();},
onHide:function(){
if(this.isCollapsed){
this.getCollapsedEl().hide();}},
onShow:function(){
if(this.isCollapsed){
this.getCollapsedEl().show();}}};
wf.layout.FormLayout=wf.extend(wf.layout.ContainerLayout,{
setContainer:function(ct){
wf.layout.FormLayout.superclass.setContainer.call(this,ct);
if(ct.labelAlign){
ct.el.addClass('x-form-label-'+ct.labelAlign);}
if(typeof ct.labelWidth=='number'){
var pad=(typeof ct.labelPad=='number'?ct.labelPad:5);
this.labelAdjust=ct.labelWidth+pad;
this.labelStyle="width:"+ct.labelWidth+"px;";
this.elementStyle=(ct.labelWidth+pad)+'px';}
if(ct.labelAlign=='top'){
this.labelStyle="width:auto;";
this.labelAdjust=0;
this.elementStyle="0";}},
renderItem:function(c,position,target){
if(c&&c.isFormField&&c.inputType!='hidden'){
c.setLabelStyle(this.labelStyle);
c.setElementStyle(this.elementStyle);}else{
wf.layout.FormLayout.superclass.renderItem.apply(this,arguments);}},
getAnchorViewSize:function(ct,target){
return ct.getBody().getStyleSize();},
onLayout:function(ct,target){
wf.layout.FormLayout.superclass.onLayout.call(this,ct,target);
var size=this.getAnchorViewSize(ct,target);
var w=size.width,h=size.height;
if(w<20||h<20){
return;}
var aw,ah;
aw=ct.width;
ah=ct.height;
var cs=ct.items,len=cs.length,i,c,a,cw,ch;
for(i=0;i<len;i++){
c=cs[i];
if(c.anchor){
a=c.anchorSpec;
if(!a){
var vs=c.anchor.split(' ');
c.anchorSpec=a={
right:this.parseAnchor(vs[0],c.initialConfig.width,aw),
bottom:this.parseAnchor(vs[1],c.initialConfig.height,ah)};}
cw=a.right?this.adjustWidthAnchor(a.right(w),c):undefined;
ch=a.bottom?this.adjustHeightAnchor(a.bottom(h),c):undefined;
if(cw||ch){
c.setSize(cw||undefined,ch||undefined);}}}},
parseAnchor:function(a,start,cstart){
if(a&&a!='none'){
var last;
if(/^(r|right|b|bottom)$/i.test(a)){
var diff=cstart-start;
return function(v){
if(v!==last){
last=v;
return v-diff;}}}else if(a.indexOf('%')!=-1){
var ratio=parseFloat(a.replace('%',''))*.01;
return function(v){
if(v!==last){
last=v;
return Math.floor(v*ratio);}}}else{
a=parseInt(a,10);
if(!isNaN(a)){
return function(v){
if(v!==last){
last=v;
return v+a;}}}}}
return false;},
adjustWidthAnchor:function(value,comp){
return value-(comp.hideLabel?0:this.labelAdjust);},
adjustHeightAnchor:function(value,comp){
return value;}});
wf.LAYOUTS=[];
wf.LAYOUTS['auto']=wf.layout.ContainerLayout;
wf.LAYOUTS['fit']=wf.layout.FitLayout;
wf.LAYOUTS['accordion']=wf.layout.Accordion;
wf.LAYOUTS['column']=wf.layout.ColumnLayout;
wf.LAYOUTS['table']=wf.layout.TableLayout;
wf.LAYOUTS['border']=wf.layout.BorderLayout;
wf.LAYOUTS['card']=wf.layout.CardLayout;
wf.LAYOUTS['form']=wf.layout.FormLayout;
wf.Button=wf.extend(wf.Component,{
baseCls:'x-btn',
init:function(){
this.addEvents("click");
this.el.on("mouseover",this.onMouseOver,this);
this.el.on("mouseout",this.onMouseOut,this);
this.el.on("mousedown",this.onMouseDown,this);
this.el.on("click",this.onClick,this);
if(this.minWidth){
if(this.el.getSize().width<this.minWidth){
this.el.setSize(this.minWidth);}}
if(this.iconCls){
if(this.text){
this.el.addClass(this.baseCls+'-text-icon');}
else{
this.el.addClass(this.baseCls+'-icon');}
this.getActionEl().addClass(this.iconCls);}},
onMouseOver:function(e){
if(!this.disabled){
this.el.addClass(this.baseCls+'-over');}},
onMouseOut:function(e){
if(!this.disabled){
this.el.removeClass(this.baseCls+'-over');}},
onMouseDown:function(e){
if(!this.disabled&&e.button==0){
this.el.addClass(this.baseCls+'-click');
wf.getDoc().on('mouseup',this.onMouseUp,this);}},
onMouseUp:function(e){
if(e.button==0){
this.el.removeClass(this.baseCls+"-click");
wf.getDoc().un('mouseup',this.onMouseUp,this);}},
onClick:function(e){
if(e){
e.preventDefault();}
if(e.button!=0){
return;}
if(!this.disabled){
this.fireEvent("click",this,e);
if(this.handler){
this.handler.call(this.scope||this,e,this);}}},
setText:function(txt){
this.getActionEl().update(txt);},
getActionEl:function(){
return this.child('button');}});
wf.MenuButton=wf.extend(wf.Button,{
menuAlign:"tl-bl?",
init:function(){
wf.MenuButton.superclass.init.call(this);
if(this.menu){
this.menu=wf.getMenu(this.menu);
this.menu.on("show",this.onMenuShow,this);
this.menu.on("hide",this.onMenuHide,this);}
var arrowEl=this.el.child('.x-btn-menu-arrow-wrap');
if(arrowEl){
arrowEl.on('click',this.onArrowClick,this);}},
onMenuShow:function(e){
this.el.addClass("x-btn-menu-active");},
onMenuHide:function(e){
this.el.removeClass("x-btn-menu-active");},
showMenu:function(){
if(this.menu){
this.menu.show(this.el,this.menuAlign);}
return this;},
onArrowClick:function(){
if(this.menu){
if(!this.menu.isVisible()){
this.showMenu();}else{
this.hideMenu();}}},
hideMenu:function(){
if(this.menu){
this.menu.hide();}
return this;}});
wf.Tip=wf.extend(wf.Panel,{
defaultAlign:"tl-bl?",
mouseOffset:[15,18],
width:100,
init:function(){
wf.Tip.superclass.init.call(this);},
attach:function(target){
if(!target){
target=wf.getDoc();}else{
this.target=wf.get(target);}
this.target.on('mouseover',this.onTargetOver,this);
this.target.on('mouseout',this.onTargetOut,this);
this.target.on('mousemove',this.onMouseMove,this);},
onMouseMove:function(e){
this.targetXY=e.getXY();
if(!this.hidden){
this.setPagePosition(this.getTargetXY());}},
onTargetOver:function(e){
if(this.disabled){
return;}
this.targetXY=e.getXY();
this.show();},
onTargetOut:function(e){
if(this.disabled){
return;}
this.hide();},
getTargetXY:function(){
var txy=wf.tabXY;
if(txy){
this.targetXY[0]=this.targetXY[0]+txy[0];
this.targetXY[1]=this.targetXY[1]+txy[1];}
return[this.targetXY[0]+this.mouseOffset[0],this.targetXY[1]+this.mouseOffset[1]];},
show:function(){
this.showAt(this.getTargetXY());
wf.getDoc().on('mousedown',this.onDocMouseDown,this);},
hide:function(){
wf.Tip.superclass.hide.call(this);
wf.getDoc().un('mousedown',this.onDocMouseDown,this);},
onDocMouseDown:function(e){
this.hide();},
showAt:function(xy){
wf.Tip.superclass.show.call(this);
this.el.setXY(500,100);},
showBy:function(el,pos){
this.showAt(this.el.getAlignToXY(el,pos||this.defaultAlign));}});
wf.QuickTip=wf.extend(wf.Tip,{
init:function(){
this.targets=this.targets||{};
wf.QuickTip.superclass.init.call(this);},
register:function(config){
var cs=config instanceof Array?config:arguments;
for(var i=0,len=cs.length;i<len;i++){
var c=cs[i];
var target=c.target;
if(target){
this.targets[wf.id(target)]=c;}}},
unregister:function(el){
delete this.targets[wf.id(el)];},
showAt:function(xy){
var t=this.activeTarget;
if(t){
if(t.width){
this.setSize(t.width);}else{
this.setSize(this.width);}
this.setTitle(t.title||'');
this.getBody().update(t.text);
if(this.lastCls){
this.el.removeClass(this.lastCls);
delete this.lastCls;}
if(t.cls){
this.el.addClass(t.cls);
this.lastCls=t.cls;}}
wf.QuickTip.superclass.showAt.call(this,xy);},
hide:function(){
delete this.activeTarget;
wf.QuickTip.superclass.hide.call(this);},
onTargetOver:function(e){
if(this.disabled){
return;}
this.targetXY=e.getXY();
var t=e.getTarget();
if(!t||t.nodeType!==1||t==document||t==document.body){
return;}
if(this.activeTarget&&t==this.activeTarget.el){
this.show();
return;}
if(t&&this.targets[t.id]){
this.activeTarget=this.targets[t.id];
this.activeTarget.el=t;
this.show();
return;}}});
wf.QuickTips=function(){
var tip,locks=[];
return{
init:function(cfg){
if(!tip){
tip=new wf.QuickTip(cfg);}},
attach:function(target){
tip.attach(target);},
register:function(){
tip.register.apply(tip,arguments);},
unregister:function(){
tip.unregister.apply(tip,arguments);}};}();
wf.regTip=wf.QuickTips.register;