popup.js.uncompressed.js 1.8 KB

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