root / trunk / web / dojo / dijit / TitlePane.js @ 12
History | View | Annotate | Download (4.41 KB)
| 1 |
/*
|
|---|---|
| 2 |
Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
| 3 |
Available via Academic Free License >= 2.1 OR the modified BSD license.
|
| 4 |
see: http://dojotoolkit.org/license for details
|
| 5 |
*/
|
| 6 |
|
| 7 |
|
| 8 |
if(!dojo._hasResource["dijit.TitlePane"]){ |
| 9 |
dojo._hasResource["dijit.TitlePane"]=true; |
| 10 |
dojo.provide("dijit.TitlePane");
|
| 11 |
dojo.require("dojo.fx");
|
| 12 |
dojo.require("dijit._Templated");
|
| 13 |
dojo.require("dijit.layout.ContentPane");
|
| 14 |
dojo.require("dijit._CssStateMixin");
|
| 15 |
dojo.declare("dijit.TitlePane",[dijit.layout.ContentPane,dijit._Templated,dijit._CssStateMixin],{title:"",open:true,toggleable:true,tabIndex:"0",duration:dijit.defaultDuration,baseClass:"dijitTitlePane",templateString:dojo.cache("dijit","templates/TitlePane.html","<div>\n\t<div dojoAttachEvent=\"onclick:_onTitleClick, onkeypress:_onTitleKey\"\n\t\t\tclass=\"dijitTitlePaneTitle\" dojoAttachPoint=\"titleBarNode\">\n\t\t<div class=\"dijitTitlePaneTitleFocus\" dojoAttachPoint=\"focusNode\">\n\t\t\t<img src=\"${_blankGif}\" alt=\"\" dojoAttachPoint=\"arrowNode\" class=\"dijitArrowNode\" waiRole=\"presentation\"\n\t\t\t/><span dojoAttachPoint=\"arrowNodeInner\" class=\"dijitArrowNodeInner\"></span\n\t\t\t><span dojoAttachPoint=\"titleNode\" class=\"dijitTitlePaneTextNode\"></span>\n\t\t</div>\n\t</div>\n\t<div class=\"dijitTitlePaneContentOuter\" dojoAttachPoint=\"hideNode\" waiRole=\"presentation\">\n\t\t<div class=\"dijitReset\" dojoAttachPoint=\"wipeNode\" waiRole=\"presentation\">\n\t\t\t<div class=\"dijitTitlePaneContentInner\" dojoAttachPoint=\"containerNode\" waiRole=\"region\" tabindex=\"-1\" id=\"${id}_pane\">\n\t\t\t\t<!-- nested divs because wipeIn()/wipeOut() doesn't work right on node w/padding etc. Put padding on inner div. -->\n\t\t\t</div>\n\t\t</div>\n\t</div>\n</div>\n"),attributeMap:dojo.delegate(dijit.layout.ContentPane.prototype.attributeMap,{title:{node:"titleNode",type:"innerHTML"},tooltip:{node:"focusNode",type:"attribute",attribute:"title"},id:""}),postCreate:function(){ |
| 16 |
if(!this.open){ |
| 17 |
this.hideNode.style.display=this.wipeNode.style.display="none"; |
| 18 |
} |
| 19 |
if(this.toggleable){ |
| 20 |
this._trackMouseState(this.titleBarNode,"dijitTitlePaneTitle"); |
| 21 |
} |
| 22 |
this._setCss();
|
| 23 |
dojo.setSelectable(this.titleNode,false); |
| 24 |
var _1=this.hideNode,_2=this.wipeNode; |
| 25 |
this._wipeIn=dojo.fx.wipeIn({node:this.wipeNode,duration:this.duration,beforeBegin:function(){ |
| 26 |
_1.style.display="";
|
| 27 |
}}); |
| 28 |
this._wipeOut=dojo.fx.wipeOut({node:this.wipeNode,duration:this.duration,onEnd:function(){ |
| 29 |
_1.style.display="none";
|
| 30 |
}}); |
| 31 |
this.inherited(arguments); |
| 32 |
},_setOpenAttr:function(_3){ |
| 33 |
if(this.open!==_3){ |
| 34 |
this.toggle();
|
| 35 |
} |
| 36 |
dijit.setWaiState(this.containerNode,"hidden",this.open?"false":"true"); |
| 37 |
dijit.setWaiState(this.focusNode,"pressed",this.open?"true":"false"); |
| 38 |
},_setToggleableAttr:function(_4){ |
| 39 |
this.toggleable=_4;
|
| 40 |
dijit.setWaiRole(this.focusNode,_4?"button":"heading"); |
| 41 |
if(_4){
|
| 42 |
dijit.setWaiState(this.focusNode,"controls",this.id+"_pane"); |
| 43 |
dojo.attr(this.focusNode,"tabIndex",this.tabIndex); |
| 44 |
}else{
|
| 45 |
dojo.removeAttr(this.focusNode,"tabIndex"); |
| 46 |
} |
| 47 |
this._setCss();
|
| 48 |
},_setContentAttr:function(_5){ |
| 49 |
if(!this.open||!this._wipeOut||this._wipeOut.status()=="playing"){ |
| 50 |
this.inherited(arguments); |
| 51 |
}else{
|
| 52 |
if(this._wipeIn&&this._wipeIn.status()=="playing"){ |
| 53 |
this._wipeIn.stop();
|
| 54 |
} |
| 55 |
dojo.marginBox(this.wipeNode,{h:dojo.marginBox(this.wipeNode).h}); |
| 56 |
this.inherited(arguments); |
| 57 |
if(this._wipeIn){ |
| 58 |
this._wipeIn.play();
|
| 59 |
}else{
|
| 60 |
this.hideNode.style.display=""; |
| 61 |
} |
| 62 |
} |
| 63 |
},toggle:function(){ |
| 64 |
dojo.forEach([this._wipeIn,this._wipeOut],function(_6){ |
| 65 |
if(_6&&_6.status()=="playing"){ |
| 66 |
_6.stop(); |
| 67 |
} |
| 68 |
}); |
| 69 |
var _7=this[this.open?"_wipeOut":"_wipeIn"]; |
| 70 |
if(_7){
|
| 71 |
_7.play(); |
| 72 |
}else{
|
| 73 |
this.hideNode.style.display=this.open?"":"none"; |
| 74 |
} |
| 75 |
this.open=!this.open; |
| 76 |
if(this.open){ |
| 77 |
this._onShow();
|
| 78 |
}else{
|
| 79 |
this.onHide();
|
| 80 |
} |
| 81 |
this._setCss();
|
| 82 |
},_setCss:function(){ |
| 83 |
var _8=this.titleBarNode||this.focusNode; |
| 84 |
if(this._titleBarClass){ |
| 85 |
dojo.removeClass(_8,this._titleBarClass);
|
| 86 |
} |
| 87 |
this._titleBarClass="dijit"+(this.toggleable?"":"Fixed")+(this.open?"Open":"Closed"); |
| 88 |
dojo.addClass(_8,this._titleBarClass);
|
| 89 |
this.arrowNodeInner.innerHTML=this.open?"-":"+"; |
| 90 |
},_onTitleKey:function(e){ |
| 91 |
if(e.charOrCode==dojo.keys.ENTER||e.charOrCode==" "){ |
| 92 |
if(this.toggleable){ |
| 93 |
this.toggle();
|
| 94 |
} |
| 95 |
dojo.stopEvent(e); |
| 96 |
}else{
|
| 97 |
if(e.charOrCode==dojo.keys.DOWN_ARROW&&this.open){ |
| 98 |
this.containerNode.focus();
|
| 99 |
e.preventDefault(); |
| 100 |
} |
| 101 |
} |
| 102 |
},_onTitleClick:function(){ |
| 103 |
if(this.toggleable){ |
| 104 |
this.toggle();
|
| 105 |
} |
| 106 |
},setTitle:function(_9){ |
| 107 |
dojo.deprecated("dijit.TitlePane.setTitle() is deprecated. Use set('title', ...) instead.","","2.0"); |
| 108 |
this.set("title",_9); |
| 109 |
}}); |
| 110 |
} |