]>
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\tdata-dojo-attach-event=\"onmouseenter:_onHover,onmouseleave:_onUnhover,ondijitclick:_onClick\">\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/event", // event.stop
9 "dojo/_base/kernel", // kernel.deprecated
10 "dojo/_base/sniff", // has("ie")
15 "dojo/text!./templates/MenuItem.html"
16 ], function(declare
, dom
, domAttr
, domClass
, event
, kernel
, has
,
17 _Widget
, _TemplatedMixin
, _Contained
, _CssStateMixin
, template
){
20 var _Widget = dijit._Widget;
21 var _TemplatedMixin = dijit._TemplatedMixin;
22 var _Contained = dijit._Contained;
23 var _CssStateMixin = dijit._CssStateMixin;
29 // A line item in a Menu Widget
32 return declare("dijit.MenuItem",
33 [_Widget
, _TemplatedMixin
, _Contained
, _CssStateMixin
],
36 // A line item in a Menu Widget
39 // icon, label, and expand arrow (BiDi-dependent) indicating sub-menu
40 templateString
: template
,
42 baseClass
: "dijitMenuItem",
47 _setLabelAttr
: { node
: "containerNode", type
: "innerHTML" },
50 // Class to apply to DOMNode to make it display an icon.
51 iconClass
: "dijitNoIcon",
52 _setIconClassAttr
: { node
: "iconNode", type
: "class" },
55 // Text for the accelerator (shortcut) key combination.
56 // Note that although Menu can display accelerator keys there
57 // is no infrastructure to actually catch and execute these
62 // If true, the menu item is disabled.
63 // If false, the menu item is enabled.
66 _fillContent: function(/*DomNode*/ source
){
67 // If button label is specified as srcNodeRef.innerHTML rather than
68 // this.params.label, handle it here.
69 if(source
&& !("label" in this.params
)){
70 this.set('label', source
.innerHTML
);
74 buildRendering: function(){
75 this.inherited(arguments
);
76 var label
= this.id
+"_text";
77 domAttr
.set(this.containerNode
, "id", label
);
78 if(this.accelKeyNode
){
79 domAttr
.set(this.accelKeyNode
, "id", this.id
+ "_accel");
80 label
+= " " + this.id
+ "_accel";
82 this.domNode
.setAttribute("aria-labelledby", label
);
83 dom
.setSelectable(this.domNode
, false);
88 // Handler when mouse is moved onto menu item
91 this.getParent().onItemHover(this);
94 _onUnhover: function(){
96 // Handler when mouse is moved off of menu item,
97 // possibly to a child menu, or maybe to a sibling
98 // menuitem or somewhere else entirely.
102 // if we are unhovering the currently selected item
104 this.getParent().onItemUnhover(this);
106 // When menu is hidden (collapsed) due to clicking a MenuItem and having it execute,
107 // FF and IE don't generate an onmouseout event for the MenuItem.
108 // So, help out _CssStateMixin in this case.
109 this._set("hovering", false);
112 _onClick: function(evt
){
114 // Internal handler for click events on MenuItem.
117 this.getParent().onItemClick(this, evt
);
121 onClick: function(/*Event*/){
123 // User defined function to handle clicks
130 // Focus on this MenuItem
133 // needed for IE8 which won't scroll TR tags into view on focus yet calling scrollIntoView creates flicker (#10275)
134 this.containerNode
.focus();
136 this.focusNode
.focus();
138 // this throws on IE (at least) in some scenarios
142 _onFocus: function(){
144 // This is called by the focus manager when focus
145 // goes to this MenuItem or a child menu.
148 this._setSelected(true);
149 this.getParent()._onItemFocus(this);
151 this.inherited(arguments
);
154 _setSelected: function(selected
){
156 // Indicate that this node is the currently selected one
161 * TODO: remove this method and calls to it, when _onBlur() is working for MenuItem.
162 * Currently _onBlur() gets called when focus is moved from the MenuItem to a child menu.
163 * That's not supposed to happen, but the problem is:
164 * In order to allow dijit.popup's getTopPopup() to work,a sub menu's popupParent
165 * points to the parent Menu, bypassing the parent MenuItem... thus the
166 * MenuItem is not in the chain of active widgets and gets a premature call to
170 domClass
.toggle(this.domNode
, "dijitMenuItemSelected", selected
);
173 setLabel: function(/*String*/ content
){
175 // Deprecated. Use set('label', ...) instead.
178 kernel
.deprecated("dijit.MenuItem.setLabel() is deprecated. Use set('label', ...) instead.", "", "2.0");
179 this.set("label", content
);
182 setDisabled: function(/*Boolean*/ disabled
){
184 // Deprecated. Use set('disabled', bool) instead.
187 kernel
.deprecated("dijit.Menu.setDisabled() is deprecated. Use set('disabled', bool) instead.", "", "2.0");
188 this.set('disabled', disabled
);
190 _setDisabledAttr: function(/*Boolean*/ value
){
192 // Hook for attr('disabled', ...) to work.
193 // Enable or disable this menu item.
195 this.focusNode
.setAttribute('aria-disabled', value
? 'true' : 'false');
196 this._set("disabled", value
);
198 _setAccelKeyAttr: function(/*String*/ value
){
200 // Hook for attr('accelKey', ...) to work.
201 // Set accelKey on this menu item.
203 this.accelKeyNode
.style
.display
=value
?"":"none";
204 this.accelKeyNode
.innerHTML
=value
;
205 //have to use colSpan to make it work in IE
206 domAttr
.set(this.containerNode
,'colSpan',value
?"1":"2");
208 this._set("accelKey", value
);