Project

General

Profile

Statistics
| Revision:

root / trunk / web / dojo / dojox / widget / PlaceholderMenuItem.js @ 12

History | View | Annotate | Download (1.68 KB)

1
/*
2
        Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
3
        Available via Academic Free License >= 2.1 OR the modified BSD license.
4
        see: http://dojotoolkit.org/license for details
5
*/
6

    
7

    
8
if(!dojo._hasResource["dojox.widget.PlaceholderMenuItem"]){
9
dojo._hasResource["dojox.widget.PlaceholderMenuItem"]=true;
10
dojo.provide("dojox.widget.PlaceholderMenuItem");
11
dojo.require("dijit.Menu");
12
dojo.declare("dojox.widget.PlaceholderMenuItem",dijit.MenuItem,{_replaced:false,_replacedWith:null,_isPlaceholder:true,postCreate:function(){
13
this.domNode.style.display="none";
14
this._replacedWith=[];
15
if(!this.label){
16
this.label=this.containerNode.innerHTML;
17
}
18
this.inherited(arguments);
19
},replace:function(_1){
20
if(this._replaced){
21
return false;
22
}
23
var _2=this.getIndexInParent();
24
if(_2<0){
25
return false;
26
}
27
var p=this.getParent();
28
dojo.forEach(_1,function(_3){
29
p.addChild(_3,_2++);
30
});
31
this._replacedWith=_1;
32
this._replaced=true;
33
return true;
34
},unReplace:function(_4){
35
if(!this._replaced){
36
return [];
37
}
38
var p=this.getParent();
39
if(!p){
40
return [];
41
}
42
var r=this._replacedWith;
43
dojo.forEach(this._replacedWith,function(_5){
44
p.removeChild(_5);
45
if(_4){
46
_5.destroy();
47
}
48
});
49
this._replacedWith=[];
50
this._replaced=false;
51
return r;
52
}});
53
dojo.extend(dijit.Menu,{getPlaceholders:function(_6){
54
var r=[];
55
var _7=this.getChildren();
56
_7.forEach(function(_8){
57
if(_8._isPlaceholder&&(!_6||_8.label==_6)){
58
r.push(_8);
59
}else{
60
if(_8._started&&_8.popup&&_8.popup.getPlaceholders){
61
r=r.concat(_8.popup.getPlaceholders(_6));
62
}else{
63
if(!_8._started&&_8.dropDownContainer){
64
var _9=dojo.query("[widgetId]",_8.dropDownContainer)[0];
65
var _a=dijit.byNode(_9);
66
if(_a.getPlaceholders){
67
r=r.concat(_a.getPlaceholders(_6));
68
}
69
}
70
}
71
}
72
},this);
73
return r;
74
}});
75
}