]> git.wh0rd.org - tt-rss.git/blame - lib/dijit/MenuItem.js.uncompressed.js
add prototype simple remover of baaaad tags based on domdocument
[tt-rss.git] / lib / dijit / MenuItem.js.uncompressed.js
CommitLineData
f0cfe83e
AD
1require({cache:{
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"}});
3define("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")
10 "./_Widget",
11 "./_TemplatedMixin",
12 "./_Contained",
13 "./_CssStateMixin",
14 "dojo/text!./templates/MenuItem.html"
15], function(declare, dom, domAttr, domClass, kernel, has,
16 _Widget, _TemplatedMixin, _Contained, _CssStateMixin, template){
17
18 // module:
19 // dijit/MenuItem
20
21 return declare("dijit.MenuItem",
22 [_Widget, _TemplatedMixin, _Contained, _CssStateMixin],
23 {
24 // summary:
25 // A line item in a Menu Widget
26
27 // Make 3 columns
28 // icon, label, and expand arrow (BiDi-dependent) indicating sub-menu
29 templateString: template,
30
31 baseClass: "dijitMenuItem",
32
33 // label: String
34 // Menu text
35 label: "",
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);
41 }
42 },
43
44 // iconClass: String
45 // Class to apply to DOMNode to make it display an icon.
46 iconClass: "dijitNoIcon",
47 _setIconClassAttr: { node: "iconNode", type: "class" },
48
49 // accelKey: String
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
53 // accelerators.
54 accelKey: "",
55
56 // disabled: Boolean
57 // If true, the menu item is disabled.
58 // If false, the menu item is enabled.
59 disabled: false,
60
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);
66 }
67 },
68
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";
76 }
77 this.domNode.setAttribute("aria-labelledby", label);
78 dom.setSelectable(this.domNode, false);
79 },
80
81 onClick: function(/*Event*/){
82 // summary:
83 // User defined function to handle clicks
84 // tags:
85 // callback
86 },
87
88 focus: function(){
89 // summary:
90 // Focus on this MenuItem
91 try{
92 if(has("ie") == 8){
93 // needed for IE8 which won't scroll TR tags into view on focus yet calling scrollIntoView creates flicker (#10275)
94 this.containerNode.focus();
95 }
96 this.focusNode.focus();
97 }catch(e){
98 // this throws on IE (at least) in some scenarios
99 }
100 },
101
102 _onFocus: function(){
103 // summary:
104 // This is called by the focus manager when focus
105 // goes to this MenuItem or a child menu.
106 // tags:
107 // protected
108 this._setSelected(true);
109 this.getParent()._onItemFocus(this);
110
111 this.inherited(arguments);
112 },
113
114 _setSelected: function(selected){
115 // summary:
116 // Indicate that this node is the currently selected one
117 // tags:
118 // private
119
120 /***
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
127 * _onBlur()
128 */
129
130 domClass.toggle(this.domNode, "dijitMenuItemSelected", selected);
131 },
132
133 setLabel: function(/*String*/ content){
134 // summary:
135 // Deprecated. Use set('label', ...) instead.
136 // tags:
137 // deprecated
138 kernel.deprecated("dijit.MenuItem.setLabel() is deprecated. Use set('label', ...) instead.", "", "2.0");
139 this.set("label", content);
140 },
141
142 setDisabled: function(/*Boolean*/ disabled){
143 // summary:
144 // Deprecated. Use set('disabled', bool) instead.
145 // tags:
146 // deprecated
147 kernel.deprecated("dijit.Menu.setDisabled() is deprecated. Use set('disabled', bool) instead.", "", "2.0");
148 this.set('disabled', disabled);
149 },
150 _setDisabledAttr: function(/*Boolean*/ value){
151 // summary:
152 // Hook for attr('disabled', ...) to work.
153 // Enable or disable this menu item.
154
155 this.focusNode.setAttribute('aria-disabled', value ? 'true' : 'false');
156 this._set("disabled", value);
157 },
158 _setAccelKeyAttr: function(/*String*/ value){
159 // summary:
160 // Hook for attr('accelKey', ...) to work.
161 // Set accelKey on this menu item.
162
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");
167
168 this._set("accelKey", value);
169 },
170 _setTextDirAttr: function(/*String*/ textDir){
171 // summary:
172 // Setter for textDir.
173 // description:
174 // Users shouldn't call this function; they should be calling
175 // set('textDir', value)
176 // tags:
177 // private
178
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);
184 }
185 }
186 });
187});