Debian Codegraph @

dijit/PopupMenuItem.js

raw symbols SCIP
1 define([
2 "dojo/_base/declare", // declare
3 "dojo/dom-style", // domStyle.set
4 "dojo/_base/lang",
5 "dojo/query", // query
6 "./popup",
7 "./registry", // registry.byNode
8 "./MenuItem",
9 "./hccss"
10 ], function(declare, domStyle, lang, query, pm, registry, MenuItem){
11
12 // module:
13 // dijit/PopupMenuItem
14
15 return declare("dijit.PopupMenuItem", MenuItem, {
16 // summary:
17 // An item in a Menu that spawn a drop down (usually a drop down menu)
18
19 baseClass: "dijitMenuItem dijitPopupMenuItem",
20
21 _fillContent: function(){
22 // summary:
23 // When Menu is declared in markup, this code gets the menu label and
24 // the popup widget from the srcNodeRef.
25 // description:
26 // srcNodeRef.innerHTML contains both the menu item text and a popup widget
27 // The first part holds the menu item text and the second part is the popup
28 // example:
29 // | <div data-dojo-type="dijit/PopupMenuItem">
30 // | <span>pick me</span>
31 // | <popup> ... </popup>
32 // | </div>
33 // tags:
34 // protected
35
36 if(this.srcNodeRef){
37 var nodes = query("*", this.srcNodeRef);
38 this.inherited(arguments, [nodes[0]]);
39
40 // save pointer to srcNode so we can grab the drop down widget after it's instantiated
41 this.dropDownContainer = this.srcNodeRef;
42 }
43 },
44
45 _openPopup: function(/*Object*/ params, /*Boolean*/ focus){
46 // summary:
47 // Open the popup to the side of/underneath this MenuItem, and optionally focus first item
48 // tags:
49 // protected
50
51 var popup = this.popup;
52
53 pm.open(lang.delegate(params, {
54 popup: this.popup,
55 around: this.domNode
56 }));
57
58 if(focus && popup.focus){
59 popup.focus();
60 }
61 },
62
63 _closePopup: function(){
64 pm.close(this.popup);
65 this.popup.parentMenu = null;
66 },
67
68 startup: function(){
69 if(this._started){ return; }
70 this.inherited(arguments);
71
72 // We didn't copy the dropdown widget from the this.srcNodeRef, so it's in no-man's
73 // land now. Move it to <body>.
74 if(!this.popup){
75 var node = query("[widgetId]", this.dropDownContainer)[0];
76 this.popup = registry.byNode(node);
77 }
78 this.ownerDocumentBody.appendChild(this.popup.domNode);
79 this.popup.domNode.setAttribute("aria-labelledby", this.containerNode.id);
80 this.popup.startup();
81
82 this.popup.domNode.style.display="none";
83 if(this.arrowWrapper){
84 domStyle.set(this.arrowWrapper, "visibility", "");
85 }
86 this.focusNode.setAttribute("aria-haspopup", "true");
87 },
88
89 destroyDescendants: function(/*Boolean*/ preserveDom){
90 if(this.popup){
91 // Destroy the popup, unless it's already been destroyed. This can happen because
92 // the popup is a direct child of <body> even though it's logically my child.
93 if(!this.popup._destroyed){
94 this.popup.destroyRecursive(preserveDom);
95 }
96 delete this.popup;
97 }
98 this.inherited(arguments);
99 }
100 });
101 });