summaryrefslogtreecommitdiff
path: root/js/dojo/dojox/grid/enhanced/plugins/Dialog.js
blob: 97dbbd4853cac3df1deeeba59708adcc2cb90a73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//>>built
define("dojox/grid/enhanced/plugins/Dialog", [
	"dojo/_base/declare",
	"dojo/_base/html",
	"dojo/window",
	"dijit/Dialog"
], function(declare, html, win, Dialog){

return declare("dojox.grid.enhanced.plugins.Dialog", Dialog, {
	refNode: null,
	_position: function(){
		if(this.refNode && !this._relativePosition){
			var refPos = html.position(html.byId(this.refNode)),
				thisPos = html.position(this.domNode),
				viewPort = win.getBox();
			if(thisPos.w && thisPos.h){
				if(refPos.x < 0){
					refPos.x = 0;
				}
				if(refPos.x + refPos.w > viewPort.w){
					refPos.w = viewPort.w - refPos.x;
				}
				if(refPos.y < 0){
					refPos.y = 0;
				}
				if(refPos.y + refPos.h > viewPort.h){
					refPos.h = viewPort.h - refPos.y;
				}
				refPos.x = refPos.x + refPos.w / 2 - thisPos.w / 2;
				refPos.y = refPos.y + refPos.h / 2 - thisPos.h / 2;
				if(refPos.x >= 0 && refPos.x + thisPos.w <= viewPort.w &&
					refPos.y >= 0 && refPos.y + thisPos.h <= viewPort.h){
					this._relativePosition = refPos;
				}
			}
		}
		this.inherited(arguments);
	}
});
});