123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- if(!dojo._hasResource["dojox.widget.PlaceholderMenuItem"]){
- dojo._hasResource["dojox.widget.PlaceholderMenuItem"] = true;
- dojo.provide("dojox.widget.PlaceholderMenuItem");
- dojo.experimental("dojox.widget.PlaceholderMenuItem");
- dojo.require("dijit.Menu");
- dojo.declare("dojox.widget.PlaceholderMenuItem", dijit.MenuItem, {
-
-
-
-
-
- _replaced: false,
- _replacedWith: null,
- _isPlaceholder: true,
- postCreate: function(){
- this.domNode.style.display = "none";
- this._replacedWith = [];
- if(!this.label){
- this.label = this.containerNode.innerHTML;
- }
- this.inherited(arguments);
- },
-
- replace: function(/*dijit.MenuItem[]*/ menuItems){
-
-
-
-
-
-
- if(this._replaced){ return false; }
- var index = this.getIndexInParent();
- if(index < 0){ return false; }
- var p = this.getParent();
- dojo.forEach(menuItems, function(item){
- p.addChild(item, index++);
- });
- this._replacedWith = menuItems;
- this._replaced = true;
- return true;
- },
-
- unReplace: function(/*Boolean?*/ destroy){
-
-
-
-
-
-
-
-
-
- if(!this._replaced){ return []; }
- var p = this.getParent();
- if(!p){ return []; }
- var r = this._replacedWith;
- dojo.forEach(this._replacedWith, function(item){
- p.removeChild(item);
- if(destroy){
- item.destroyRecursive();
- }
- });
- this._replacedWith = [];
- this._replaced = false;
- return r;
- }
- });
- dojo.extend(dijit.Menu, {
- getPlaceholders: function(/*String?*/ label){
-
-
-
-
-
-
-
-
- var r = [];
- var children = this.getChildren();
- dojo.forEach(children, function(child){
- if(child._isPlaceholder && (!label || child.label == label)){
- r.push(child);
- }else if(child._started && child.popup && child.popup.getPlaceholders){
- r = r.concat(child.popup.getPlaceholders(label));
- }else if(!child._started && child.dropDownContainer){
- var node = dojo.query("[widgetId]", child.dropDownContainer)[0];
- var menu = dijit.byNode(node);
- if(menu.getPlaceholders){
- r = r.concat(menu.getPlaceholders(label));
- }
- }
- }, this);
- return r;
- }
- });
- }
|