diff options
author | Andrew Dolgov <[email protected]> | 2011-11-08 20:40:44 +0400 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2011-11-08 20:40:44 +0400 |
commit | 81bea17aefb26859f825b9293c7c99192874806e (patch) | |
tree | fb244408ca271affa2899adb634788802c9a89d8 /lib/dijit/PopupMenuItem.js | |
parent | 870a70e109ac9e80a88047044530de53d0404ec7 (diff) |
upgrade Dojo to 1.6.1
Diffstat (limited to 'lib/dijit/PopupMenuItem.js')
-rw-r--r-- | lib/dijit/PopupMenuItem.js | 99 |
1 files changed, 65 insertions, 34 deletions
diff --git a/lib/dijit/PopupMenuItem.js b/lib/dijit/PopupMenuItem.js index 29a011cc0..da44a23f7 100644 --- a/lib/dijit/PopupMenuItem.js +++ b/lib/dijit/PopupMenuItem.js @@ -1,43 +1,74 @@ /* - Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved. + Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved. Available via Academic Free License >= 2.1 OR the modified BSD license. see: http://dojotoolkit.org/license for details */ -if(!dojo._hasResource["dijit.PopupMenuItem"]){ -dojo._hasResource["dijit.PopupMenuItem"]=true; +if(!dojo._hasResource["dijit.PopupMenuItem"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dijit.PopupMenuItem"] = true; dojo.provide("dijit.PopupMenuItem"); dojo.require("dijit.MenuItem"); -dojo.declare("dijit.PopupMenuItem",dijit.MenuItem,{_fillContent:function(){ -if(this.srcNodeRef){ -var _1=dojo.query("*",this.srcNodeRef); -dijit.PopupMenuItem.superclass._fillContent.call(this,_1[0]); -this.dropDownContainer=this.srcNodeRef; -} -},startup:function(){ -if(this._started){ -return; -} -this.inherited(arguments); -if(!this.popup){ -var _2=dojo.query("[widgetId]",this.dropDownContainer)[0]; -this.popup=dijit.byNode(_2); -} -dojo.body().appendChild(this.popup.domNode); -this.popup.startup(); -this.popup.domNode.style.display="none"; -if(this.arrowWrapper){ -dojo.style(this.arrowWrapper,"visibility",""); -} -dijit.setWaiState(this.focusNode,"haspopup","true"); -},destroyDescendants:function(){ -if(this.popup){ -if(!this.popup._destroyed){ -this.popup.destroyRecursive(); -} -delete this.popup; -} -this.inherited(arguments); -}}); + + +dojo.declare("dijit.PopupMenuItem", + dijit.MenuItem, + { + _fillContent: function(){ + // summary: + // When Menu is declared in markup, this code gets the menu label and + // the popup widget from the srcNodeRef. + // description: + // srcNodeRefinnerHTML contains both the menu item text and a popup widget + // The first part holds the menu item text and the second part is the popup + // example: + // | <div dojoType="dijit.PopupMenuItem"> + // | <span>pick me</span> + // | <popup> ... </popup> + // | </div> + // tags: + // protected + + if(this.srcNodeRef){ + var nodes = dojo.query("*", this.srcNodeRef); + dijit.PopupMenuItem.superclass._fillContent.call(this, nodes[0]); + + // save pointer to srcNode so we can grab the drop down widget after it's instantiated + this.dropDownContainer = this.srcNodeRef; + } + }, + + startup: function(){ + if(this._started){ return; } + this.inherited(arguments); + + // we didn't copy the dropdown widget from the this.srcNodeRef, so it's in no-man's + // land now. move it to dojo.doc.body. + if(!this.popup){ + var node = dojo.query("[widgetId]", this.dropDownContainer)[0]; + this.popup = dijit.byNode(node); + } + dojo.body().appendChild(this.popup.domNode); + this.popup.startup(); + + this.popup.domNode.style.display="none"; + if(this.arrowWrapper){ + dojo.style(this.arrowWrapper, "visibility", ""); + } + dijit.setWaiState(this.focusNode, "haspopup", "true"); + }, + + destroyDescendants: function(){ + if(this.popup){ + // Destroy the popup, unless it's already been destroyed. This can happen because + // the popup is a direct child of <body> even though it's logically my child. + if(!this.popup._destroyed){ + this.popup.destroyRecursive(); + } + delete this.popup; + } + this.inherited(arguments); + } + }); + } |