Dialog.js 1.0 KB

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