1 if(!dojo._hasResource["dijit.TitlePane"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource["dijit.TitlePane"] = true;
3 dojo.provide("dijit.TitlePane");
5 dojo.require("dojo.fx");
7 dojo.require("dijit._Templated");
8 dojo.require("dijit.layout.ContentPane");
12 [dijit.layout.ContentPane, dijit._Templated],
14 // summary: A pane with a title on top, that can be opened or collapsed.
16 // description: An accessible container with a Title Heading, and a content
17 // section that slides open and closed. TitlePane is an extension to
18 // ContentPane, providing all the usesful content-control aspects from.
21 // | // load a TitlePane from remote file:
22 // | var foo = new dijit.TitlePane({ href: "foobar.html", title:"Title" });
26 // | <!-- markup href example: -->
27 // | <div dojoType="dijit.TitlePane" href="foobar.html" title="Title"></div>
30 // | <!-- markup with inline data -->
31 // | <div dojoType="dijit.TitlePane" title="Title">
32 // | <p>I am content</p>
40 // Whether pane is opened or closed.
44 // Time in milliseconds to fade in/fade out
48 // The root className to use for the various states of this widget
49 baseClass: "dijitTitlePane",
51 templateString:"<div class=\"${baseClass}\">\n\t<div dojoAttachEvent=\"onclick:toggle,onkeypress: _onTitleKey,onfocus:_handleFocus,onblur:_handleFocus\" tabindex=\"0\"\n\t\t\twaiRole=\"button\" class=\"dijitTitlePaneTitle\" dojoAttachPoint=\"titleBarNode,focusNode\">\n\t\t<div dojoAttachPoint=\"arrowNode\" class=\"dijitInline dijitArrowNode\"><span dojoAttachPoint=\"arrowNodeInner\" class=\"dijitArrowNodeInner\"></span></div>\n\t\t<div dojoAttachPoint=\"titleNode\" class=\"dijitTitlePaneTextNode\"></div>\n\t</div>\n\t<div class=\"dijitTitlePaneContentOuter\" dojoAttachPoint=\"hideNode\">\n\t\t<div class=\"dijitReset\" dojoAttachPoint=\"wipeNode\">\n\t\t\t<div class=\"dijitTitlePaneContentInner\" dojoAttachPoint=\"containerNode\" waiRole=\"region\" tabindex=\"-1\">\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",
53 postCreate: function(){
54 this.setTitle(this.title);
56 this.hideNode.style.display = this.wipeNode.style.display = "none";
59 dojo.setSelectable(this.titleNode, false);
60 this.inherited(arguments);
61 dijit.setWaiState(this.containerNode, "labelledby", this.titleNode.id);
62 dijit.setWaiState(this.focusNode, "haspopup", "true");
64 // setup open/close animations
65 var hideNode = this.hideNode, wipeNode = this.wipeNode;
66 this._wipeIn = dojo.fx.wipeIn({
68 duration: this.duration,
69 beforeBegin: function(){
70 hideNode.style.display="";
73 this._wipeOut = dojo.fx.wipeOut({
75 duration: this.duration,
77 hideNode.style.display="none";
82 setContent: function(content){
84 // Typically called when an href is loaded. Our job is to make the animation smooth
85 if(!this.open || this._wipeOut.status() == "playing"){
86 // we are currently *closing* the pane (or the pane is closed), so just let that continue
87 this.inherited(arguments);
89 if(this._wipeIn.status() == "playing"){
93 // freeze container at current height so that adding new content doesn't make it jump
94 dojo.marginBox(this.wipeNode, { h: dojo.marginBox(this.wipeNode).h });
96 // add the new content (erasing the old content, if any)
97 this.inherited(arguments);
99 // call _wipeIn.play() to animate from current height to new height
105 // summary: switches between opened and closed state
106 dojo.forEach([this._wipeIn, this._wipeOut], function(animation){
107 if(animation.status() == "playing"){
112 this[this.open ? "_wipeOut" : "_wipeIn"].play();
113 this.open =! this.open;
115 // load content (if this is the first time we are opening the TitlePane
116 // and content is specified as an href, or we have setHref when hidden)
123 // summary: set the open/close css state for the TitlePane
124 var classes = ["dijitClosed", "dijitOpen"];
125 var boolIndex = this.open;
126 var node = this.titleBarNode || this.focusNode
127 dojo.removeClass(node, classes[!boolIndex+0]);
128 node.className += " " + classes[boolIndex+0];
130 // provide a character based indicator for images-off mode
131 this.arrowNodeInner.innerHTML = this.open ? "-" : "+";
134 _onTitleKey: function(/*Event*/ e){
135 // summary: callback when user hits a key
136 if(e.keyCode == dojo.keys.ENTER || e.charCode == dojo.keys.SPACE){
138 }else if(e.keyCode == dojo.keys.DOWN_ARROW && this.open){
139 this.containerNode.focus();
144 _handleFocus: function(/*Event*/ e){
145 // summary: handle blur and focus for this widget
147 // add/removeClass is safe to call without hasClass in this case
148 dojo[(e.type == "focus" ? "addClass" : "removeClass")](this.focusNode, this.baseClass + "Focused");
151 setTitle: function(/*String*/ title){
152 // summary: sets the text of the title
153 this.titleNode.innerHTML = title;