| 1 |
define([ |
| 2 |
"dojo", "dojox", "dojo/text!./Dialog/Dialog.html", |
| 3 |
"dijit/Dialog", "dojo/window", "dojox/fx", "./DialogSimple" |
| 4 |
], function(dojo, dojox, template){ |
| 5 |
|
| 6 |
dojo.getObject('widget', true, dojox); |
| 7 |
|
| 8 |
return dojo.declare('dojox.widget.Dialog', dojox.widget.DialogSimple, |
| 9 |
{ |
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
templateString: template, |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
sizeToViewport: false, |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
viewportPadding: 35, |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
dimensions: null, |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
easing: null, |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
sizeDuration: dijit._defaultDuration, |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
sizeMethod: "chain", |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
showTitle: false, |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
draggable: false, |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
modal: false, |
| 69 |
|
| 70 |
constructor: function(props, node){ |
| 71 |
this.easing = props.easing || dojo._defaultEasing; |
| 72 |
this.dimensions = props.dimensions || [300, 300]; |
| 73 |
}, |
| 74 |
|
| 75 |
_setup: function(){ |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
this.inherited(arguments); |
| 80 |
if(!this._alreadyInitialized){ |
| 81 |
this._navIn = dojo.fadeIn({ node: this.closeButtonNode }); |
| 82 |
this._navOut = dojo.fadeOut({ node: this.closeButtonNode }); |
| 83 |
if(!this.showTitle){ |
| 84 |
dojo.addClass(this.domNode,"dojoxDialogNoTitle"); |
| 85 |
} |
| 86 |
} |
| 87 |
}, |
| 88 |
|
| 89 |
layout: function(e){ |
| 90 |
this._setSize(); |
| 91 |
this.inherited(arguments); |
| 92 |
}, |
| 93 |
|
| 94 |
_setSize: function(){ |
| 95 |
|
| 96 |
|
| 97 |
this._vp = dojo.window.getBox(); |
| 98 |
var tc = this.containerNode, |
| 99 |
vpSized = this.sizeToViewport |
| 100 |
; |
| 101 |
return this._displaysize = { |
| 102 |
w: vpSized ? tc.scrollWidth : this.dimensions[0], |
| 103 |
h: vpSized ? tc.scrollHeight : this.dimensions[1] |
| 104 |
}; |
| 105 |
}, |
| 106 |
|
| 107 |
show: function(){ |
| 108 |
if(this.open){ return; } |
| 109 |
|
| 110 |
this._setSize(); |
| 111 |
dojo.style(this.closeButtonNode,"opacity", 0); |
| 112 |
dojo.style(this.domNode, { |
| 113 |
overflow: "hidden", |
| 114 |
opacity: 0, |
| 115 |
width: "1px", |
| 116 |
height: "1px" |
| 117 |
}); |
| 118 |
dojo.style(this.containerNode, { |
| 119 |
opacity: 0, |
| 120 |
overflow: "hidden" |
| 121 |
}); |
| 122 |
|
| 123 |
this.inherited(arguments); |
| 124 |
|
| 125 |
if(this.modal){ |
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
this._modalconnects.push(dojo.connect(dojo.body(), "onkeypress", function(e){ |
| 130 |
if(e.charOrCode == dojo.keys.ESCAPE){ |
| 131 |
dojo.stopEvent(e); |
| 132 |
} |
| 133 |
})); |
| 134 |
}else{ |
| 135 |
|
| 136 |
this._modalconnects.push(dojo.connect(dijit._underlay.domNode, "onclick", this, "onCancel")); |
| 137 |
} |
| 138 |
this._modalconnects.push(dojo.connect(this.domNode,"onmouseenter",this,"_handleNav")); |
| 139 |
this._modalconnects.push(dojo.connect(this.domNode,"onmouseleave",this,"_handleNav")); |
| 140 |
|
| 141 |
}, |
| 142 |
|
| 143 |
_handleNav: function(e){ |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
var navou = "_navOut", |
| 148 |
navin = "_navIn", |
| 149 |
animou = (e.type == "mouseout" ? navin : navou), |
| 150 |
animin = (e.type == "mouseout" ? navou : navin) |
| 151 |
; |
| 152 |
|
| 153 |
this[animou].stop(); |
| 154 |
this[animin].play(); |
| 155 |
|
| 156 |
}, |
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
_position: function(){ |
| 197 |
|
| 198 |
if(!this._started){ return; } |
| 199 |
|
| 200 |
if(this._sizing){ |
| 201 |
this._sizing.stop(); |
| 202 |
this.disconnect(this._sizingConnect); |
| 203 |
delete this._sizing; |
| 204 |
} |
| 205 |
|
| 206 |
this.inherited(arguments); |
| 207 |
|
| 208 |
if(!this.open){ dojo.style(this.containerNode, "opacity", 0); } |
| 209 |
var pad = this.viewportPadding * 2; |
| 210 |
|
| 211 |
var props = { |
| 212 |
node: this.domNode, |
| 213 |
duration: this.sizeDuration || dijit._defaultDuration, |
| 214 |
easing: this.easing, |
| 215 |
method: this.sizeMethod |
| 216 |
}; |
| 217 |
|
| 218 |
var ds = this._displaysize || this._setSize(); |
| 219 |
props['width'] = ds.w = (ds.w + pad >= this._vp.w || this.sizeToViewport) |
| 220 |
? this._vp.w - pad : ds.w; |
| 221 |
|
| 222 |
props['height'] = ds.h = (ds.h + pad >= this._vp.h || this.sizeToViewport) |
| 223 |
? this._vp.h - pad : ds.h; |
| 224 |
|
| 225 |
this._sizing = dojox.fx.sizeTo(props); |
| 226 |
this._sizingConnect = this.connect(this._sizing,"onEnd","_showContent"); |
| 227 |
this._sizing.play(); |
| 228 |
|
| 229 |
}, |
| 230 |
|
| 231 |
_showContent: function(e){ |
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
var container = this.containerNode; |
| 236 |
dojo.style(this.domNode, { |
| 237 |
overflow: "visible", |
| 238 |
opacity: 1 |
| 239 |
}); |
| 240 |
dojo.style(this.closeButtonNode,"opacity",1); |
| 241 |
dojo.style(container, { |
| 242 |
height: this._displaysize.h - this.titleNode.offsetHeight + "px", |
| 243 |
width: this._displaysize.w + "px", |
| 244 |
overflow:"auto" |
| 245 |
}); |
| 246 |
dojo.anim(container, { opacity:1 }); |
| 247 |
} |
| 248 |
|
| 249 |
}); |
| 250 |
}); |
| 251 |
|