root / trunk / web / dojo / dojox / widget / Dialog.js
History | View | Annotate | Download (3.9 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["dojox.widget.Dialog"]){ |
||
9 | dojo._hasResource["dojox.widget.Dialog"]=true; |
||
10 | dojo.provide("dojox.widget.Dialog");
|
||
11 | dojo.experimental("dojox.widget.Dialog");
|
||
12 | dojo.require("dojo.window");
|
||
13 | dojo.require("dijit.Dialog");
|
||
14 | dojo.require("dojox.layout.ContentPane");
|
||
15 | dojo.require("dojox.fx");
|
||
16 | dojo.declare("dojox.widget.Dialog",[dojox.layout.ContentPane,dijit._DialogBase],{templateString:dojo.cache("dojox.widget","Dialog/Dialog.html","<div class=\"dojoxDialog\" tabindex=\"-1\" waiRole=\"dialog\" waiState=\"labelledby-${id}_title\">\n\t<div dojoAttachPoint=\"titleBar\" class=\"dojoxDialogTitleBar\">\n\t\t<span dojoAttachPoint=\"titleNode\" class=\"dojoxDialogTitle\" id=\"${id}_title\">${title}</span>\n\t</div>\n\t<div dojoAttachPoint=\"dojoxDialogWrapper\">\n\t\t<div dojoAttachPoint=\"containerNode\" class=\"dojoxDialogPaneContent\"></div>\n\t</div>\n\t<div dojoAttachPoint=\"closeButtonNode\" class=\"dojoxDialogCloseIcon\" dojoAttachEvent=\"onclick: onCancel\">\n\t\t\t<span dojoAttachPoint=\"closeText\" class=\"closeText\">x</span>\n\t</div>\n</div>\n"),sizeToViewport:false,viewportPadding:35,dimensions:null,easing:null,sizeDuration:dijit._defaultDuration,sizeMethod:"chain",showTitle:false,draggable:false,modal:false,constructor:function(_1,_2){ |
||
17 | this.easing=_1.easing||dojo._defaultEasing;
|
||
18 | this.dimensions=_1.dimensions||[300,300]; |
||
19 | },_setup:function(){ |
||
20 | this.inherited(arguments); |
||
21 | if(!this._alreadyInitialized){ |
||
22 | this._navIn=dojo.fadeIn({node:this.closeButtonNode}); |
||
23 | this._navOut=dojo.fadeOut({node:this.closeButtonNode}); |
||
24 | if(!this.showTitle){ |
||
25 | dojo.addClass(this.domNode,"dojoxDialogNoTitle"); |
||
26 | } |
||
27 | } |
||
28 | },layout:function(e){ |
||
29 | this._setSize();
|
||
30 | this.inherited(arguments); |
||
31 | },_setSize:function(){ |
||
32 | this._vp=dojo.window.getBox();
|
||
33 | var tc=this.containerNode,_3=this.sizeToViewport; |
||
34 | return this._displaysize={w:_3?tc.scrollWidth:this.dimensions[0],h:_3?tc.scrollHeight:this.dimensions[1]}; |
||
35 | },show:function(){ |
||
36 | if(this.open){ |
||
37 | return;
|
||
38 | } |
||
39 | this._setSize();
|
||
40 | dojo.style(this.closeButtonNode,"opacity",0); |
||
41 | dojo.style(this.domNode,{overflow:"hidden",opacity:0,width:"1px",height:"1px"}); |
||
42 | dojo.style(this.containerNode,{opacity:0,overflow:"hidden"}); |
||
43 | this.inherited(arguments); |
||
44 | if(this.modal){ |
||
45 | this._modalconnects.push(dojo.connect(dojo.body(),"onkeypress",function(e){ |
||
46 | if(e.charOrCode==dojo.keys.ESCAPE){
|
||
47 | dojo.stopEvent(e); |
||
48 | } |
||
49 | })); |
||
50 | }else{
|
||
51 | this._modalconnects.push(dojo.connect(dijit._underlay.domNode,"onclick",this,"onCancel")); |
||
52 | } |
||
53 | this._modalconnects.push(dojo.connect(this.domNode,"onmouseenter",this,"_handleNav")); |
||
54 | this._modalconnects.push(dojo.connect(this.domNode,"onmouseleave",this,"_handleNav")); |
||
55 | },_handleNav:function(e){ |
||
56 | var _4="_navOut",_5="_navIn",_6=(e.type=="mouseout"?_5:_4),_7=(e.type=="mouseout"?_4:_5); |
||
57 | this[_6].stop();
|
||
58 | this[_7].play();
|
||
59 | },_position:function(){ |
||
60 | if(!this._started){ |
||
61 | return;
|
||
62 | } |
||
63 | if(this._sizing){ |
||
64 | this._sizing.stop();
|
||
65 | this.disconnect(this._sizingConnect); |
||
66 | delete this._sizing; |
||
67 | } |
||
68 | this.inherited(arguments); |
||
69 | if(!this.open){ |
||
70 | dojo.style(this.containerNode,"opacity",0); |
||
71 | } |
||
72 | var _8=this.viewportPadding*2; |
||
73 | var _9={node:this.domNode,duration:this.sizeDuration||dijit._defaultDuration,easing:this.easing,method:this.sizeMethod}; |
||
74 | var ds=this._displaysize||this._setSize(); |
||
75 | _9["width"]=ds.w=(ds.w+_8>=this._vp.w||this.sizeToViewport)?this._vp.w-_8:ds.w; |
||
76 | _9["height"]=ds.h=(ds.h+_8>=this._vp.h||this.sizeToViewport)?this._vp.h-_8:ds.h; |
||
77 | this._sizing=dojox.fx.sizeTo(_9);
|
||
78 | this._sizingConnect=this.connect(this._sizing,"onEnd","_showContent"); |
||
79 | this._sizing.play();
|
||
80 | },_showContent:function(e){ |
||
81 | var _a=this.containerNode; |
||
82 | dojo.style(this.domNode,{overflow:"visible",opacity:1}); |
||
83 | dojo.style(this.closeButtonNode,"opacity",1); |
||
84 | dojo.style(_a,{height:this._displaysize.h-this.titleNode.offsetHeight+"px",width:this._displaysize.w+"px",overflow:"auto"}); |
||
85 | dojo.anim(_a,{opacity:1}); |
||
86 | }}); |
||
87 | } |