]>
git.wh0rd.org - tt-rss.git/blob - lib/dijit/MenuItem.js.uncompressed.js
2 'url:dijit/templates/MenuItem.html':"<tr class=\"dijitReset dijitMenuItem\" data-dojo-attach-point=\"focusNode\" role=\"menuitem\" tabIndex=\"-1\">\n\t<td class=\"dijitReset dijitMenuItemIconCell\" role=\"presentation\">\n\t\t<img src=\"${_blankGif}\" alt=\"\" class=\"dijitIcon dijitMenuItemIcon\" data-dojo-attach-point=\"iconNode\"/>\n\t</td>\n\t<td class=\"dijitReset dijitMenuItemLabel\" colspan=\"2\" data-dojo-attach-point=\"containerNode\"></td>\n\t<td class=\"dijitReset dijitMenuItemAccelKey\" style=\"display: none\" data-dojo-attach-point=\"accelKeyNode\"></td>\n\t<td class=\"dijitReset dijitMenuArrowCell\" role=\"presentation\">\n\t\t<div data-dojo-attach-point=\"arrowWrapper\" style=\"visibility: hidden\">\n\t\t\t<img src=\"${_blankGif}\" alt=\"\" class=\"dijitMenuExpand\"/>\n\t\t\t<span class=\"dijitMenuExpandA11y\">+</span>\n\t\t</div>\n\t</td>\n</tr>\n"}});
3 define("dijit/MenuItem", [
4 "dojo/_base/declare", // declare
5 "dojo/dom", // dom.setSelectable
6 "dojo/dom-attr", // domAttr.set
7 "dojo/dom-class", // domClass.toggle
8 "dojo/_base/kernel", // kernel.deprecated
9 "dojo/sniff", // has("ie")
14 "dojo/text!./templates/MenuItem.html"
15 ], function(declare
, dom
, domAttr
, domClass
, kernel
, has
,
16 _Widget
, _TemplatedMixin
, _Contained
, _CssStateMixin
, template
){
21 return declare("dijit.MenuItem",
22 [_Widget
, _TemplatedMixin
, _Contained
, _CssStateMixin
],
25 // A line item in a Menu Widget
28 // icon, label, and expand arrow (BiDi-dependent) indicating sub-menu
29 templateString
: template
,
31 baseClass
: "dijitMenuItem",
36 _setLabelAttr: function(val
){
37 this.containerNode
.innerHTML
= val
;
38 this._set("label", val
);
39 if(this.textDir
=== "auto"){
40 this.applyTextDir(this.focusNode
, this.label
);
45 // Class to apply to DOMNode to make it display an icon.
46 iconClass
: "dijitNoIcon",
47 _setIconClassAttr
: { node
: "iconNode", type
: "class" },
50 // Text for the accelerator (shortcut) key combination.
51 // Note that although Menu can display accelerator keys there
52 // is no infrastructure to actually catch and execute these
57 // If true, the menu item is disabled.
58 // If false, the menu item is enabled.
61 _fillContent: function(/*DomNode*/ source
){
62 // If button label is specified as srcNodeRef.innerHTML rather than
63 // this.params.label, handle it here.
64 if(source
&& !("label" in this.params
)){
65 this.set('label', source
.innerHTML
);
69 buildRendering: function(){
70 this.inherited(arguments
);
71 var label
= this.id
+"_text";
72 domAttr
.set(this.containerNode
, "id", label
);
73 if(this.accelKeyNode
){
74 domAttr
.set(this.accelKeyNode
, "id", this.id
+ "_accel");
75 label
+= " " + this.id
+ "_accel";
77 this.domNode
.setAttribute("aria-labelledby", label
);
78 dom
.setSelectable(this.domNode
, false);
81 onClick: function(/*Event*/){
83 // User defined function to handle clicks
90 // Focus on this MenuItem
93 // needed for IE8 which won't scroll TR tags into view on focus yet calling scrollIntoView creates flicker (#10275)
94 this.containerNode
.focus();
96 this.focusNode
.focus();
98 // this throws on IE (at least) in some scenarios
102 _onFocus: function(){
104 // This is called by the focus manager when focus
105 // goes to this MenuItem or a child menu.
108 this._setSelected(true);
109 this.getParent()._onItemFocus(this);
111 this.inherited(arguments
);
114 _setSelected: function(selected
){
116 // Indicate that this node is the currently selected one
121 * TODO: remove this method and calls to it, when _onBlur() is working for MenuItem.
122 * Currently _onBlur() gets called when focus is moved from the MenuItem to a child menu.
123 * That's not supposed to happen, but the problem is:
124 * In order to allow dijit.popup's getTopPopup() to work,a sub menu's popupParent
125 * points to the parent Menu, bypassing the parent MenuItem... thus the
126 * MenuItem is not in the chain of active widgets and gets a premature call to
130 domClass
.toggle(this.domNode
, "dijitMenuItemSelected", selected
);
133 setLabel: function(/*String*/ content
){
135 // Deprecated. Use set('label', ...) instead.
138 kernel
.deprecated("dijit.MenuItem.setLabel() is deprecated. Use set('label', ...) instead.", "", "2.0");
139 this.set("label", content
);
142 setDisabled: function(/*Boolean*/ disabled
){
144 // Deprecated. Use set('disabled', bool) instead.
147 kernel
.deprecated("dijit.Menu.setDisabled() is deprecated. Use set('disabled', bool) instead.", "", "2.0");
148 this.set('disabled', disabled
);
150 _setDisabledAttr: function(/*Boolean*/ value
){
152 // Hook for attr('disabled', ...) to work.
153 // Enable or disable this menu item.
155 this.focusNode
.setAttribute('aria-disabled', value
? 'true' : 'false');
156 this._set("disabled", value
);
158 _setAccelKeyAttr: function(/*String*/ value
){
160 // Hook for attr('accelKey', ...) to work.
161 // Set accelKey on this menu item.
163 this.accelKeyNode
.style
.display
=value
?"":"none";
164 this.accelKeyNode
.innerHTML
=value
;
165 //have to use colSpan to make it work in IE
166 domAttr
.set(this.containerNode
,'colSpan',value
?"1":"2");
168 this._set("accelKey", value
);
170 _setTextDirAttr: function(/*String*/ textDir
){
172 // Setter for textDir.
174 // Users shouldn't call this function; they should be calling
175 // set('textDir', value)
179 // only if new textDir is different from the old one
180 // and on widgets creation.
181 if(!this._created
|| this.textDir
!= textDir
){
182 this._set("textDir", textDir
);
183 this.applyTextDir(this.focusNode
, this.label
);