manager.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. define("dijit/_base/manager", [
  2. "dojo/_base/array",
  3. "dojo/_base/config", // defaultDuration
  4. "../registry",
  5. ".." // for setting exports to dijit namespace
  6. ], function(array, config, registry, dijit){
  7. // module:
  8. // dijit/_base/manager
  9. // summary:
  10. // Shim to methods on registry, plus a few other declarations.
  11. // New code should access dijit/registry directly when possible.
  12. /*=====
  13. dijit.byId = function(id){
  14. // summary:
  15. // Returns a widget by it's id, or if passed a widget, no-op (like dom.byId())
  16. // id: String|dijit._Widget
  17. return registry.byId(id); // dijit._Widget
  18. };
  19. dijit.getUniqueId = function(widgetType){
  20. // summary:
  21. // Generates a unique id for a given widgetType
  22. // widgetType: String
  23. return registry.getUniqueId(widgetType); // String
  24. };
  25. dijit.findWidgets = function(root){
  26. // summary:
  27. // Search subtree under root returning widgets found.
  28. // Doesn't search for nested widgets (ie, widgets inside other widgets).
  29. // root: DOMNode
  30. return registry.findWidgets(root);
  31. };
  32. dijit._destroyAll = function(){
  33. // summary:
  34. // Code to destroy all widgets and do other cleanup on page unload
  35. return registry._destroyAll();
  36. };
  37. dijit.byNode = function(node){
  38. // summary:
  39. // Returns the widget corresponding to the given DOMNode
  40. // node: DOMNode
  41. return registry.byNode(node); // dijit._Widget
  42. };
  43. dijit.getEnclosingWidget = function(node){
  44. // summary:
  45. // Returns the widget whose DOM tree contains the specified DOMNode, or null if
  46. // the node is not contained within the DOM tree of any widget
  47. // node: DOMNode
  48. return registry.getEnclosingWidget(node);
  49. };
  50. =====*/
  51. array.forEach(["byId", "getUniqueId", "findWidgets", "_destroyAll", "byNode", "getEnclosingWidget"], function(name){
  52. dijit[name] = registry[name];
  53. });
  54. /*=====
  55. dojo.mixin(dijit, {
  56. // defaultDuration: Integer
  57. // The default fx.animation speed (in ms) to use for all Dijit
  58. // transitional fx.animations, unless otherwise specified
  59. // on a per-instance basis. Defaults to 200, overrided by
  60. // `djConfig.defaultDuration`
  61. defaultDuration: 200
  62. });
  63. =====*/
  64. dijit.defaultDuration = config["defaultDuration"] || 200;
  65. return dijit;
  66. });