]> git.wh0rd.org - tt-rss.git/blob - lib/dijit/MenuItem.js.uncompressed.js
update dojo to 1.7.3
[tt-rss.git] / lib / dijit / MenuItem.js.uncompressed.js
1 require({cache:{
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")
11 "./_Widget",
12 "./_TemplatedMixin",
13 "./_Contained",
14 "./_CssStateMixin",
15 "dojo/text!./templates/MenuItem.html"
16 ], function(declare, dom, domAttr, domClass, event, kernel, has,
17 _Widget, _TemplatedMixin, _Contained, _CssStateMixin, template){
18
19 /*=====
20 var _Widget = dijit._Widget;
21 var _TemplatedMixin = dijit._TemplatedMixin;
22 var _Contained = dijit._Contained;
23 var _CssStateMixin = dijit._CssStateMixin;
24 =====*/
25
26 // module:
27 // dijit/MenuItem
28 // summary:
29 // A line item in a Menu Widget
30
31
32 return declare("dijit.MenuItem",
33 [_Widget, _TemplatedMixin, _Contained, _CssStateMixin],
34 {
35 // summary:
36 // A line item in a Menu Widget
37
38 // Make 3 columns
39 // icon, label, and expand arrow (BiDi-dependent) indicating sub-menu
40 templateString: template,
41
42 baseClass: "dijitMenuItem",
43
44 // label: String
45 // Menu text
46 label: '',
47 _setLabelAttr: { node: "containerNode", type: "innerHTML" },
48
49 // iconClass: String
50 // Class to apply to DOMNode to make it display an icon.
51 iconClass: "dijitNoIcon",
52 _setIconClassAttr: { node: "iconNode", type: "class" },
53
54 // accelKey: String
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
58 // accelerators.
59 accelKey: "",
60
61 // disabled: Boolean
62 // If true, the menu item is disabled.
63 // If false, the menu item is enabled.
64 disabled: false,
65
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);
71 }
72 },
73
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";
81 }
82 this.domNode.setAttribute("aria-labelledby", label);
83 dom.setSelectable(this.domNode, false);
84 },
85
86 _onHover: function(){
87 // summary:
88 // Handler when mouse is moved onto menu item
89 // tags:
90 // protected
91 this.getParent().onItemHover(this);
92 },
93
94 _onUnhover: function(){
95 // summary:
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.
99 // tags:
100 // protected
101
102 // if we are unhovering the currently selected item
103 // then unselect it
104 this.getParent().onItemUnhover(this);
105
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);
110 },
111
112 _onClick: function(evt){
113 // summary:
114 // Internal handler for click events on MenuItem.
115 // tags:
116 // private
117 this.getParent().onItemClick(this, evt);
118 event.stop(evt);
119 },
120
121 onClick: function(/*Event*/){
122 // summary:
123 // User defined function to handle clicks
124 // tags:
125 // callback
126 },
127
128 focus: function(){
129 // summary:
130 // Focus on this MenuItem
131 try{
132 if(has("ie") == 8){
133 // needed for IE8 which won't scroll TR tags into view on focus yet calling scrollIntoView creates flicker (#10275)
134 this.containerNode.focus();
135 }
136 this.focusNode.focus();
137 }catch(e){
138 // this throws on IE (at least) in some scenarios
139 }
140 },
141
142 _onFocus: function(){
143 // summary:
144 // This is called by the focus manager when focus
145 // goes to this MenuItem or a child menu.
146 // tags:
147 // protected
148 this._setSelected(true);
149 this.getParent()._onItemFocus(this);
150
151 this.inherited(arguments);
152 },
153
154 _setSelected: function(selected){
155 // summary:
156 // Indicate that this node is the currently selected one
157 // tags:
158 // private
159
160 /***
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
167 * _onBlur()
168 */
169
170 domClass.toggle(this.domNode, "dijitMenuItemSelected", selected);
171 },
172
173 setLabel: function(/*String*/ content){
174 // summary:
175 // Deprecated. Use set('label', ...) instead.
176 // tags:
177 // deprecated
178 kernel.deprecated("dijit.MenuItem.setLabel() is deprecated. Use set('label', ...) instead.", "", "2.0");
179 this.set("label", content);
180 },
181
182 setDisabled: function(/*Boolean*/ disabled){
183 // summary:
184 // Deprecated. Use set('disabled', bool) instead.
185 // tags:
186 // deprecated
187 kernel.deprecated("dijit.Menu.setDisabled() is deprecated. Use set('disabled', bool) instead.", "", "2.0");
188 this.set('disabled', disabled);
189 },
190 _setDisabledAttr: function(/*Boolean*/ value){
191 // summary:
192 // Hook for attr('disabled', ...) to work.
193 // Enable or disable this menu item.
194
195 this.focusNode.setAttribute('aria-disabled', value ? 'true' : 'false');
196 this._set("disabled", value);
197 },
198 _setAccelKeyAttr: function(/*String*/ value){
199 // summary:
200 // Hook for attr('accelKey', ...) to work.
201 // Set accelKey on this menu item.
202
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");
207
208 this._set("accelKey", value);
209 }
210 });
211 });