Dialog.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. Copyright (c) 2004-2012, 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. if(!dojo._hasResource["dojox.grid.enhanced.plugins.Dialog"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
  7. dojo._hasResource["dojox.grid.enhanced.plugins.Dialog"] = true;
  8. dojo.provide("dojox.grid.enhanced.plugins.Dialog");
  9. dojo.require("dijit.Dialog");
  10. dojo.require("dojo.window");
  11. dojo.declare("dojox.grid.enhanced.plugins.Dialog", dijit.Dialog, {
  12. refNode: null,
  13. _position: function(){
  14. if(this.refNode && !this._relativePosition){
  15. var refPos = dojo.position(dojo.byId(this.refNode)),
  16. thisPos = dojo.position(this.domNode),
  17. viewPort = dojo.window.getBox();
  18. if(refPos.x < 0){
  19. refPos.x = 0;
  20. }
  21. if(refPos.x + refPos.w > viewPort.w){
  22. refPos.w = viewPort.w - refPos.x;
  23. }
  24. if(refPos.y < 0){
  25. refPos.y = 0;
  26. }
  27. if(refPos.y + refPos.h > viewPort.h){
  28. refPos.h = viewPort.h - refPos.y;
  29. }
  30. refPos.x = refPos.x + refPos.w / 2 - thisPos.w / 2;
  31. refPos.y = refPos.y + refPos.h / 2 - thisPos.h / 2;
  32. if(refPos.x >= 0 && refPos.x + thisPos.w <= viewPort.w &&
  33. refPos.y >= 0 && refPos.y + thisPos.h <= viewPort.h){
  34. this._relativePosition = refPos;
  35. }
  36. }
  37. this.inherited(arguments);
  38. }
  39. });
  40. }