]>
Commit | Line | Data |
---|---|---|
f0cfe83e AD |
1 | define("dijit/PopupMenuItem", [ |
2 | "dojo/_base/declare", // declare | |
3 | "dojo/dom-style", // domStyle.set | |
4 | "dojo/query", // query | |
5 | "./registry", // registry.byNode | |
6 | "./MenuItem", | |
7 | "./hccss" | |
8 | ], function(declare, domStyle, query, registry, MenuItem){ | |
9 | ||
10 | // module: | |
11 | // dijit/PopupMenuItem | |
12 | ||
13 | return declare("dijit.PopupMenuItem", MenuItem, { | |
14 | // summary: | |
15 | // An item in a Menu that spawn a drop down (usually a drop down menu) | |
16 | ||
17 | _fillContent: function(){ | |
18 | // summary: | |
19 | // When Menu is declared in markup, this code gets the menu label and | |
20 | // the popup widget from the srcNodeRef. | |
21 | // description: | |
22 | // srcNodeRefinnerHTML contains both the menu item text and a popup widget | |
23 | // The first part holds the menu item text and the second part is the popup | |
24 | // example: | |
25 | // | <div data-dojo-type="dijit/PopupMenuItem"> | |
26 | // | <span>pick me</span> | |
27 | // | <popup> ... </popup> | |
28 | // | </div> | |
29 | // tags: | |
30 | // protected | |
31 | ||
32 | if(this.srcNodeRef){ | |
33 | var nodes = query("*", this.srcNodeRef); | |
34 | this.inherited(arguments, [nodes[0]]); | |
35 | ||
36 | // save pointer to srcNode so we can grab the drop down widget after it's instantiated | |
37 | this.dropDownContainer = this.srcNodeRef; | |
38 | } | |
39 | }, | |
40 | ||
41 | startup: function(){ | |
42 | if(this._started){ return; } | |
43 | this.inherited(arguments); | |
44 | ||
45 | // we didn't copy the dropdown widget from the this.srcNodeRef, so it's in no-man's | |
46 | // land now. move it to win.doc.body. | |
47 | if(!this.popup){ | |
48 | var node = query("[widgetId]", this.dropDownContainer)[0]; | |
49 | this.popup = registry.byNode(node); | |
50 | } | |
51 | this.ownerDocumentBody.appendChild(this.popup.domNode); | |
52 | this.popup.startup(); | |
53 | ||
54 | this.popup.domNode.style.display="none"; | |
55 | if(this.arrowWrapper){ | |
56 | domStyle.set(this.arrowWrapper, "visibility", ""); | |
57 | } | |
58 | this.focusNode.setAttribute("aria-haspopup", "true"); | |
59 | }, | |
60 | ||
61 | destroyDescendants: function(/*Boolean*/ preserveDom){ | |
62 | if(this.popup){ | |
63 | // Destroy the popup, unless it's already been destroyed. This can happen because | |
64 | // the popup is a direct child of <body> even though it's logically my child. | |
65 | if(!this.popup._destroyed){ | |
66 | this.popup.destroyRecursive(preserveDom); | |
67 | } | |
68 | delete this.popup; | |
69 | } | |
70 | this.inherited(arguments); | |
71 | } | |
72 | }); | |
73 | }); |