| 1 | define([ |
| 2 | "dojo/_base/declare", |
| 3 | "dojo/_base/html", |
| 4 | "dojo/window", |
| 5 | "dijit/Dialog" |
| 6 | ], function(declare, html, win, Dialog){ |
| 7 | |
| 8 | return declare("dojox.grid.enhanced.plugins.Dialog", Dialog, { |
| 9 | refNode: null, |
| 10 | _position: function(){ |
| 11 | if(this.refNode && !this._relativePosition){ |
| 12 | var refPos = html.position(html.byId(this.refNode)), |
| 13 | thisPos = html.position(this.domNode), |
| 14 | viewPort = win.getBox(); |
| 15 | if(thisPos.w && thisPos.h){ |
| 16 | if(refPos.x < 0){ |
| 17 | refPos.x = 0; |
| 18 | } |
| 19 | if(refPos.x + refPos.w > viewPort.w){ |
| 20 | refPos.w = viewPort.w - refPos.x; |
| 21 | } |
| 22 | if(refPos.y < 0){ |
| 23 | refPos.y = 0; |
| 24 | } |
| 25 | if(refPos.y + refPos.h > viewPort.h){ |
| 26 | refPos.h = viewPort.h - refPos.y; |
| 27 | } |
| 28 | refPos.x = refPos.x + refPos.w / 2 - thisPos.w / 2; |
| 29 | refPos.y = refPos.y + refPos.h / 2 - thisPos.h / 2; |
| 30 | if(refPos.x >= 0 && refPos.x + thisPos.w <= viewPort.w && |
| 31 | refPos.y >= 0 && refPos.y + thisPos.h <= viewPort.h){ |
| 32 | this._relativePosition = refPos; |
| 33 | } |
| 34 | } |
| 35 | } |
| 36 | this.inherited(arguments); |
| 37 | } |
| 38 | }); |
| 39 | }); |