]>
git.wh0rd.org - tt-rss.git/blob - lib/dijit/TooltipDialog.js.uncompressed.js
2 'url:dijit/templates/TooltipDialog.html':"<div role=\"presentation\" tabIndex=\"-1\">\n\t<div class=\"dijitTooltipContainer\" role=\"presentation\">\n\t\t<div class =\"dijitTooltipContents dijitTooltipFocusNode\" data-dojo-attach-point=\"containerNode\" role=\"dialog\"></div>\n\t</div>\n\t<div class=\"dijitTooltipConnector\" role=\"presentation\"></div>\n</div>\n"}});
3 define("dijit/TooltipDialog", [
4 "dojo/_base/declare", // declare
5 "dojo/dom-class", // domClass.replace
6 "dojo/_base/event", // event.stop
8 "dojo/_base/lang", // lang.hitch
10 "./layout/ContentPane",
14 "dojo/text!./templates/TooltipDialog.html",
15 "." // exports methods to dijit global
16 ], function(declare
, domClass
, event
, keys
, lang
,
17 focus
, ContentPane
, _DialogMixin
, _FormMixin
, _TemplatedMixin
, template
, dijit
){
20 var ContentPane = dijit.layout.ContentPane;
21 var _DialogMixin = dijit._DialogMixin;
22 var _FormMixin = dijit.form._FormMixin;
23 var _TemplatedMixin = dijit._TemplatedMixin;
27 // dijit/TooltipDialog
29 // Pops up a dialog that appears like a Tooltip
32 return declare("dijit.TooltipDialog",
33 [ContentPane
, _TemplatedMixin
, _FormMixin
, _DialogMixin
], {
35 // Pops up a dialog that appears like a Tooltip
38 // Description of tooltip dialog (required for a11y)
41 // doLayout: [protected] Boolean
42 // Don't change this parameter from the default value.
43 // This ContentPane parameter doesn't make sense for TooltipDialog, since TooltipDialog
44 // is never a child of a layout container, nor can you specify the size of
45 // TooltipDialog in order to control the size of an inner widget.
49 // A Toggle to modify the default focus behavior of a Dialog, which
50 // is to focus on the first dialog element after opening the dialog.
51 // False will disable autofocusing. Default: true
54 // baseClass: [protected] String
55 // The root className to use for the various states of this widget
56 baseClass
: "dijitTooltipDialog",
58 // _firstFocusItem: [private] [readonly] DomNode
59 // The pointer to the first focusable node in the dialog.
60 // Set by `dijit._DialogMixin._getFocusItems`.
61 _firstFocusItem
: null,
63 // _lastFocusItem: [private] [readonly] DomNode
64 // The pointer to which node has focus prior to our dialog.
65 // Set by `dijit._DialogMixin._getFocusItems`.
68 templateString
: template
,
70 _setTitleAttr: function(/*String*/ title
){
71 this.containerNode
.title
= title
;
72 this._set("title", title
)
75 postCreate: function(){
76 this.inherited(arguments
);
77 this.connect(this.containerNode
, "onkeypress", "_onKey");
80 orient: function(/*DomNode*/ node
, /*String*/ aroundCorner
, /*String*/ corner
){
82 // Configure widget to be displayed in given position relative to the button.
83 // This is called from the dijit.popup code, and should not be called
87 var newC
= "dijitTooltipAB" + (corner
.charAt(1) == 'L' ? "Left" : "Right")
89 + (corner
.charAt(0) == 'T' ? "Below" : "Above");
91 domClass
.replace(this.domNode
, newC
, this._currentOrientClass
|| "");
92 this._currentOrientClass
= newC
;
97 // Focus on first field
98 this._getFocusItems(this.containerNode
);
99 focus
.focus(this._firstFocusItem
);
102 onOpen: function(/*Object*/ pos
){
104 // Called when dialog is displayed.
105 // This is called from the dijit.popup code, and should not be called directly.
109 this.orient(this.domNode
,pos
.aroundCorner
, pos
.corner
);
110 this._onShow(); // lazy load trigger
115 // Called when dialog is hidden.
116 // This is called from the dijit.popup code, and should not be called directly.
122 _onKey: function(/*Event*/ evt
){
124 // Handler for keyboard events
126 // Keep keyboard focus in dialog; close dialog on escape key
130 var node
= evt
.target
;
131 if(evt
.charOrCode
=== keys
.TAB
){
132 this._getFocusItems(this.containerNode
);
134 var singleFocusItem
= (this._firstFocusItem
== this._lastFocusItem
);
135 if(evt
.charOrCode
== keys
.ESCAPE
){
136 // Use setTimeout to avoid crash on IE, see #10396.
137 setTimeout(lang
.hitch(this, "onCancel"), 0);
139 }else if(node
== this._firstFocusItem
&& evt
.shiftKey
&& evt
.charOrCode
=== keys
.TAB
){
140 if(!singleFocusItem
){
141 focus
.focus(this._lastFocusItem
); // send focus to last item in dialog
144 }else if(node
== this._lastFocusItem
&& evt
.charOrCode
=== keys
.TAB
&& !evt
.shiftKey
){
145 if(!singleFocusItem
){
146 focus
.focus(this._firstFocusItem
); // send focus to first item in dialog
149 }else if(evt
.charOrCode
=== keys
.TAB
){
150 // we want the browser's default tab handling to move focus
151 // but we don't want the tab to propagate upwards
152 evt
.stopPropagation();