root / trunk / web / dojo / dijit / _base / popup.js @ 12
History | View | Annotate | Download (4.3 KB)
1 | 9 | andrej.cim | /*
|
---|---|---|---|
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["dijit._base.popup"]){ |
||
9 | dojo._hasResource["dijit._base.popup"]=true; |
||
10 | dojo.provide("dijit._base.popup");
|
||
11 | dojo.require("dijit._base.focus");
|
||
12 | dojo.require("dijit._base.place");
|
||
13 | dojo.require("dijit._base.window");
|
||
14 | dijit.popup={_stack:[],_beginZIndex:1000,_idGen:1,moveOffScreen:function(_1){ |
||
15 | var _2=_1.parentNode;
|
||
16 | if(!_2||!dojo.hasClass(_2,"dijitPopup")){ |
||
17 | _2=dojo.create("div",{"class":"dijitPopup",style:{visibility:"hidden",top:"-9999px"}},dojo.body()); |
||
18 | dijit.setWaiRole(_2,"presentation");
|
||
19 | _2.appendChild(_1); |
||
20 | } |
||
21 | var s=_1.style;
|
||
22 | s.display="";
|
||
23 | s.visibility="";
|
||
24 | s.position="";
|
||
25 | s.top="0px";
|
||
26 | dojo.style(_2,{visibility:"hidden",top:"-9999px"}); |
||
27 | },getTopPopup:function(){ |
||
28 | var _3=this._stack; |
||
29 | for(var pi=_3.length-1;pi>0&&_3[pi].parent===_3[pi-1].widget;pi--){ |
||
30 | } |
||
31 | return _3[pi];
|
||
32 | },open:function(_4){ |
||
33 | var _5=this._stack,_6=_4.popup,_7=_4.orient||((_4.parent?_4.parent.isLeftToRight():dojo._isBodyLtr())?{"BL":"TL","BR":"TR","TL":"BL","TR":"BR"}:{"BR":"TR","BL":"TL","TR":"BR","TL":"BL"}),_8=_4.around,id=(_4.around&&_4.around.id)?(_4.around.id+"_dropdown"):("popup_"+this._idGen++); |
||
34 | var _9=_6.domNode.parentNode;
|
||
35 | if(!_9||!dojo.hasClass(_9,"dijitPopup")){ |
||
36 | this.moveOffScreen(_6.domNode);
|
||
37 | _9=_6.domNode.parentNode; |
||
38 | } |
||
39 | dojo.attr(_9,{id:id,style:{zIndex:this._beginZIndex+_5.length},"class":"dijitPopup "+(_6.baseClass||_6["class"]||"").split(" ")[0]+"Popup",dijitPopupParent:_4.parent?_4.parent.id:""}); |
||
40 | if(dojo.isIE||dojo.isMoz){
|
||
41 | var _a=_9.childNodes[1]; |
||
42 | if(!_a){
|
||
43 | _a=new dijit.BackgroundIframe(_9);
|
||
44 | } |
||
45 | } |
||
46 | var _b=_8?dijit.placeOnScreenAroundElement(_9,_8,_7,_6.orient?dojo.hitch(_6,"orient"):null):dijit.placeOnScreen(_9,_4,_7=="R"?["TR","BR","TL","BL"]:["TL","BL","TR","BR"],_4.padding); |
||
47 | _9.style.visibility="visible";
|
||
48 | _6.domNode.style.visibility="visible";
|
||
49 | var _c=[];
|
||
50 | _c.push(dojo.connect(_9,"onkeypress",this,function(_d){ |
||
51 | if(_d.charOrCode==dojo.keys.ESCAPE&&_4.onCancel){
|
||
52 | dojo.stopEvent(_d); |
||
53 | _4.onCancel(); |
||
54 | }else{
|
||
55 | if(_d.charOrCode===dojo.keys.TAB){
|
||
56 | dojo.stopEvent(_d); |
||
57 | var _e=this.getTopPopup(); |
||
58 | if(_e&&_e.onCancel){
|
||
59 | _e.onCancel(); |
||
60 | } |
||
61 | } |
||
62 | } |
||
63 | })); |
||
64 | if(_6.onCancel){
|
||
65 | _c.push(dojo.connect(_6,"onCancel",_4.onCancel));
|
||
66 | } |
||
67 | _c.push(dojo.connect(_6,_6.onExecute?"onExecute":"onChange",this,function(){ |
||
68 | var _f=this.getTopPopup(); |
||
69 | if(_f&&_f.onExecute){
|
||
70 | _f.onExecute(); |
||
71 | } |
||
72 | })); |
||
73 | _5.push({wrapper:_9,iframe:_a,widget:_6,parent:_4.parent,onExecute:_4.onExecute,onCancel:_4.onCancel,onClose:_4.onClose,handlers:_c}); |
||
74 | if(_6.onOpen){
|
||
75 | _6.onOpen(_b); |
||
76 | } |
||
77 | return _b;
|
||
78 | },close:function(_10){ |
||
79 | var _11=this._stack; |
||
80 | while(dojo.some(_11,function(_12){ |
||
81 | return _12.widget==_10;
|
||
82 | })){ |
||
83 | var top=_11.pop(),_13=top.wrapper,_14=top.iframe,_15=top.widget,_16=top.onClose;
|
||
84 | if(_15.onClose){
|
||
85 | _15.onClose(); |
||
86 | } |
||
87 | dojo.forEach(top.handlers,dojo.disconnect); |
||
88 | if(_15&&_15.domNode){
|
||
89 | this.moveOffScreen(_15.domNode);
|
||
90 | }else{
|
||
91 | dojo.destroy(_13); |
||
92 | } |
||
93 | if(_16){
|
||
94 | _16(); |
||
95 | } |
||
96 | } |
||
97 | }}; |
||
98 | dijit._frames=new function(){ |
||
99 | var _17=[];
|
||
100 | this.pop=function(){ |
||
101 | var _18;
|
||
102 | if(_17.length){
|
||
103 | _18=_17.pop(); |
||
104 | _18.style.display="";
|
||
105 | }else{
|
||
106 | if(dojo.isIE){
|
||
107 | var _19=dojo.config["dojoBlankHtmlUrl"]||(dojo.moduleUrl("dojo","resources/blank.html")+"")||"javascript:\"\""; |
||
108 | var _1a="<iframe src='"+_19+"'"+" style='position: absolute; left: 0px; top: 0px;"+"z-index: -1; filter:Alpha(Opacity=\"0\");'>"; |
||
109 | _18=dojo.doc.createElement(_1a); |
||
110 | }else{
|
||
111 | _18=dojo.create("iframe");
|
||
112 | _18.src="javascript:\"\"";
|
||
113 | _18.className="dijitBackgroundIframe";
|
||
114 | dojo.style(_18,"opacity",0.1); |
||
115 | } |
||
116 | _18.tabIndex=-1;
|
||
117 | dijit.setWaiRole(_18,"presentation");
|
||
118 | } |
||
119 | return _18;
|
||
120 | }; |
||
121 | this.push=function(_1b){ |
||
122 | _1b.style.display="none";
|
||
123 | _17.push(_1b); |
||
124 | }; |
||
125 | }(); |
||
126 | dijit.BackgroundIframe=function(_1c){ |
||
127 | if(!_1c.id){
|
||
128 | throw new Error("no id"); |
||
129 | } |
||
130 | if(dojo.isIE||dojo.isMoz){
|
||
131 | var _1d=dijit._frames.pop();
|
||
132 | _1c.appendChild(_1d); |
||
133 | if(dojo.isIE<7){ |
||
134 | this.resize(_1c);
|
||
135 | this._conn=dojo.connect(_1c,"onresize",this,function(){ |
||
136 | this.resize(_1c);
|
||
137 | }); |
||
138 | }else{
|
||
139 | dojo.style(_1d,{width:"100%",height:"100%"}); |
||
140 | } |
||
141 | this.iframe=_1d;
|
||
142 | } |
||
143 | }; |
||
144 | dojo.extend(dijit.BackgroundIframe,{resize:function(_1e){ |
||
145 | if(this.iframe&&dojo.isIE<7){ |
||
146 | dojo.style(this.iframe,{width:_1e.offsetWidth+"px",height:_1e.offsetHeight+"px"}); |
||
147 | } |
||
148 | },destroy:function(){ |
||
149 | if(this._conn){ |
||
150 | dojo.disconnect(this._conn);
|
||
151 | this._conn=null; |
||
152 | } |
||
153 | if(this.iframe){ |
||
154 | dijit._frames.push(this.iframe);
|
||
155 | delete this.iframe; |
||
156 | } |
||
157 | }}); |
||
158 | } |