popup.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. define("dijit/_base/popup", [
  2. "dojo/dom-class", // domClass.contains
  3. "../popup",
  4. "../BackgroundIframe" // just loading for back-compat, in case client code is referencing it
  5. ], function(domClass, popup){
  6. // module:
  7. // dijit/_base/popup
  8. // summary:
  9. // Old module for popups, new code should use dijit/popup directly
  10. // Hack support for old API passing in node instead of a widget (to various methods)
  11. var origCreateWrapper = popup._createWrapper;
  12. popup._createWrapper = function(widget){
  13. if(!widget.declaredClass){
  14. // make fake widget to pass to new API
  15. widget = {
  16. _popupWrapper: (widget.parentNode && domClass.contains(widget.parentNode, "dijitPopup")) ?
  17. widget.parentNode : null,
  18. domNode: widget,
  19. destroy: function(){}
  20. };
  21. }
  22. return origCreateWrapper.call(this, widget);
  23. };
  24. // Support old format of orient parameter
  25. var origOpen = popup.open;
  26. popup.open = function(/*dijit.popup.__OpenArgs*/ args){
  27. // Convert old hash structure (ex: {"BL": "TL", ...}) of orient to format compatible w/new popup.open() API.
  28. // Don't do conversion for:
  29. // - null parameter (that means to use the default positioning)
  30. // - "R" or "L" strings used to indicate positioning for context menus (when there is no around node)
  31. // - new format, ex: ["below", "above"]
  32. // - return value from deprecated dijit.getPopupAroundAlignment() method,
  33. // ex: ["below", "above"]
  34. if(args.orient && typeof args.orient != "string" && !("length" in args.orient)){
  35. var ary = [];
  36. for(var key in args.orient){
  37. ary.push({aroundCorner: key, corner: args.orient[key]});
  38. }
  39. args.orient = ary;
  40. }
  41. return origOpen.call(this, args);
  42. };
  43. return popup;
  44. });