]>
git.wh0rd.org - tt-rss.git/blob - lib/dijit/TitlePane.js.uncompressed.js
2 'url:dijit/templates/TitlePane.html' : "<div> \n\t <div data-dojo-attach-event= \" onclick:_onTitleClick, onkeydown:_onTitleKey \"\n\t\t\t class= \" dijitTitlePaneTitle \" data-dojo-attach-point= \" titleBarNode \" id= \" ${id} _titleBarNode \" > \n\t\t <div class= \" dijitTitlePaneTitleFocus \" data-dojo-attach-point= \" focusNode \" > \n\t\t\t <img src= \" ${_blankGif} \" alt= \"\" data-dojo-attach-point= \" arrowNode \" class= \" dijitArrowNode \" role= \" presentation \"\n\t\t\t /><span data-dojo-attach-point= \" arrowNodeInner \" class= \" dijitArrowNodeInner \" ></span \n\t\t\t ><span data-dojo-attach-point= \" titleNode \" class= \" dijitTitlePaneTextNode \" ></span> \n\t\t </div> \n\t </div> \n\t <div class= \" dijitTitlePaneContentOuter \" data-dojo-attach-point= \" hideNode \" role= \" presentation \" > \n\t\t <div class= \" dijitReset \" data-dojo-attach-point= \" wipeNode \" role= \" presentation \" > \n\t\t\t <div class= \" dijitTitlePaneContentInner \" data-dojo-attach-point= \" containerNode \" role= \" region \" id= \" ${id} _pane \" aria-labelledby= \" ${id} _titleBarNode \" > \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 " }});
3 define ( "dijit/TitlePane" , [
4 "dojo/_base/array" , // array.forEach
5 "dojo/_base/declare" , // declare
6 "dojo/dom" , // dom.setSelectable
7 "dojo/dom-attr" , // domAttr.set or get domAttr.remove
8 "dojo/dom-class" , // domClass.replace
9 "dojo/dom-geometry" , // domGeometry.setMarginBox domGeometry.getMarginBox
10 "dojo/_base/event" , // event.stop
11 "dojo/fx" , // fxUtils.wipeIn fxUtils.wipeOut
12 "dojo/_base/kernel" , // kernel.deprecated
13 "dojo/keys" , // keys.DOWN_ARROW keys.ENTER
16 "./layout/ContentPane" ,
17 "dojo/text!./templates/TitlePane.html" ,
18 "./_base/manager" // defaultDuration
19 ], function ( array
, declare
, dom
, domAttr
, domClass
, domGeometry
, event
, fxUtils
, kernel
, keys
,
20 _CssStateMixin
, _TemplatedMixin
, ContentPane
, template
, manager
){
26 return declare ( "dijit.TitlePane" , [ ContentPane
, _TemplatedMixin
, _CssStateMixin
], {
28 // A pane with a title on top, that can be expanded or collapsed.
31 // An accessible container with a title Heading, and a content
32 // section that slides open and closed. TitlePane is an extension to
33 // `dijit/layout/ContentPane`, providing all the useful content-control aspects from it.
36 // | // load a TitlePane from remote file:
37 // | var foo = new dijit.TitlePane({ href: "foobar.html", title:"Title" });
41 // | <!-- markup href example: -->
42 // | <div data-dojo-type="dijit/TitlePane" data-dojo-props="href: 'foobar.html', title: 'Title'"></div>
45 // | <!-- markup with inline data -->
46 // | <div data-dojo-type="dijit/TitlePane" title="Title">
47 // | <p>I am content</p>
53 _setTitleAttr
: { node
: "titleNode" , type
: "innerHTML" }, // override default where title becomes a hover tooltip
56 // Whether pane is opened or closed.
59 // toggleable: Boolean
60 // Whether pane can be opened or closed by clicking the title bar.
64 // Tabindex setting for the title (so users can tab to the title then
65 // use space/enter to open/close the title pane)
69 // Time in milliseconds to fade in/fade out
70 duration
: manager
. defaultDuration
,
72 // baseClass: [protected] String
73 // The root className to be placed on this widget's domNode.
74 baseClass
: "dijitTitlePane" ,
76 templateString
: template
,
78 // doLayout: [protected] Boolean
79 // Don't change this parameter from the default value.
80 // This ContentPane parameter doesn't make sense for TitlePane, since TitlePane
81 // is never a child of a layout container, nor should TitlePane try to control
82 // the size of an inner widget.
85 // Tooltip is defined in _WidgetBase but we need to handle the mapping to DOM here
86 _setTooltipAttr
: { node
: "focusNode" , type
: "attribute" , attribute
: "title" }, // focusNode spans the entire width, titleNode doesn't
88 buildRendering : function (){
89 this . inherited ( arguments
);
90 dom
. setSelectable ( this . titleNode
, false );
93 postCreate : function (){
94 this . inherited ( arguments
);
96 // Hover and focus effect on title bar, except for non-toggleable TitlePanes
97 // This should really be controlled from _setToggleableAttr() but _CssStateMixin
98 // doesn't provide a way to disconnect a previous _trackMouseState() call
100 this . _trackMouseState ( this . titleBarNode
, "dijitTitlePaneTitle" );
103 // setup open/close animations
104 var hideNode
= this . hideNode
, wipeNode
= this . wipeNode
;
105 this . _wipeIn
= fxUtils
. wipeIn ({
107 duration
: this . duration
,
108 beforeBegin : function (){
109 hideNode
. style
. display
= "" ;
112 this . _wipeOut
= fxUtils
. wipeOut ({
114 duration
: this . duration
,
116 hideNode
. style
. display
= "none" ;
121 _setOpenAttr : function ( /*Boolean*/ open
, /*Boolean*/ animate
){
123 // Hook to make set("open", boolean) control the open/closed state of the pane.
125 // True if you want to open the pane, false if you want to close it.
127 array
. forEach ([ this . _wipeIn
, this . _wipeOut
], function ( animation
){
128 if ( animation
&& animation
. status () == "playing" ){
134 var anim
= this [ open
? "_wipeIn" : "_wipeOut" ];
137 this . hideNode
. style
. display
= this . wipeNode
. style
. display
= open
? "" : "none" ;
140 // load content (if this is the first time we are opening the TitlePane
141 // and content is specified as an href, or href was set when hidden)
150 this . containerNode
. setAttribute ( "aria-hidden" , open
? "false" : "true" );
151 this . focusNode
. setAttribute ( "aria-pressed" , open
? "true" : "false" );
153 this . _set ( "open" , open
);
158 _setToggleableAttr : function ( /*Boolean*/ canToggle
){
160 // Hook to make set("toggleable", boolean) work.
161 // canToggle: Boolean
162 // True to allow user to open/close pane by clicking title bar.
164 this . focusNode
. setAttribute ( "role" , canToggle
? "button" : "heading" );
166 this . focusNode
. setAttribute ( "aria-controls" , this . id
+ "_pane" );
167 this . focusNode
. setAttribute ( "tabIndex" , this . tabIndex
);
168 this . focusNode
. setAttribute ( "aria-pressed" , this . open
);
170 domAttr
. remove ( this . focusNode
, "aria-controls" );
171 domAttr
. remove ( this . focusNode
, "tabIndex" );
172 domAttr
. remove ( this . focusNode
, "aria-pressed" );
175 this . _set ( "toggleable" , canToggle
);
180 _setContentAttr : function ( /*String|DomNode|Nodelist*/ content
){
182 // Hook to make set("content", ...) work.
183 // Typically called when an href is loaded. Our job is to make the animation smooth.
185 if (! this . open
|| ! this . _wipeOut
|| this . _wipeOut
. status () == "playing" ){
186 // we are currently *closing* the pane (or the pane is closed), so just let that continue
187 this . inherited ( arguments
);
189 if ( this . _wipeIn
&& this . _wipeIn
. status () == "playing" ){
193 // freeze container at current height so that adding new content doesn't make it jump
194 domGeometry
. setMarginBox ( this . wipeNode
, { h
: domGeometry
. getMarginBox ( this . wipeNode
). h
});
196 // add the new content (erasing the old content, if any)
197 this . inherited ( arguments
);
199 // call _wipeIn.play() to animate from current height to new height
203 this . hideNode
. style
. display
= "" ;
210 // Switches between opened and closed state
214 this . _setOpenAttr (! this . open
, true );
219 // Set the open/close css state for the TitlePane
223 var node
= this . titleBarNode
|| this . focusNode
;
224 var oldCls
= this . _titleBarClass
;
225 this . _titleBarClass
= "dijit" + ( this . toggleable
? "" : "Fixed" ) + ( this . open
? "Open" : "Closed" );
226 domClass
. replace ( node
, this . _titleBarClass
, oldCls
|| "" );
228 this . arrowNodeInner
. innerHTML
= this . open
? "-" : "+" ;
231 _onTitleKey : function ( /*Event*/ e
){
233 // Handler for when user hits a key
237 if ( e
. keyCode
== keys
. ENTER
|| e
. keyCode
== keys
. SPACE
){
242 } else if ( e
. keyCode
== keys
. DOWN_ARROW
&& this . open
){
243 this . containerNode
. focus ();
248 _onTitleClick : function (){
250 // Handler when user clicks the title bar
258 setTitle : function ( /*String*/ title
){
260 // Deprecated. Use set('title', ...) instead.
263 kernel
. deprecated ( "dijit.TitlePane.setTitle() is deprecated. Use set('title', ...) instead." , "" , "2.0" );
264 this . set ( "title" , title
);