MsAjaxMixin.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /***************************************************************
  2. USAGE:
  3. 1. Include this script before your client object class definition.
  4. 2. Call the MsAjaxMixin right after your function definition,
  5. so that it attaches the necessary methods to the prototype
  6. RadControlsNamespace.MsAjaxMixin.Initialize(RadMenu, 'RadMenu');
  7. 3. Change your client object initialization:
  8. - rework your construction logic so that the constructor accepts only one element -- a DOM node.
  9. - pass any additional data to an Initalize() method after the object is constructed.
  10. 4. Call the initializeBase method in the constructor of your JavaScript object:
  11. function RadMenu(element)
  12. {
  13. ...
  14. if (typeof(RadMenu.initializeBase) == "function")
  15. {
  16. RadMenu.initializeBase(this, [element]);
  17. }
  18. }
  19. 5. Create a static factory method that will create a new object. Let it accept a client ID only:
  20. RadMenu.Create = function(clientID)
  21. {
  22. return new RadMenu(document.getElementById(clientID));
  23. }
  24. 6. Change your InitScript rendering:
  25. - it should not call new RadMenu() directly. use the factory method instead: RadMenu.Create()
  26. Look below for a sample RadMenu.Create() implementation. That method will create your object and
  27. register it with the MS AJAX script runtime if it is present on the page.
  28. ***************************************************************/
  29. //RadMenu.Create = function ()
  30. //{
  31. // var clientID = arguments[0];
  32. //
  33. // if (typeof ($create) == "function")
  34. // {
  35. // //the global RadMenu function object
  36. // var type = this;
  37. //
  38. // //{name : 'value'} will trigger a menuInstance.set_name('value');
  39. // var properties = {};
  40. //
  41. // //{itemClick : OnItemClick} will trigger a menuInstance.add_itemClick(OnItemClick);
  42. // var events = {};
  43. //
  44. // //{"Treeview" : "RadTreeView1} will trigger a menuInstance.set_Treeview($find('RadTreeView1'));
  45. // var references = {};
  46. //
  47. // //the DOM element that this component will attach to. crucial for partial updates and disposes
  48. // var domElement = $get(clientID);
  49. // return $create(type, properties, events, references, domElement);
  50. // }
  51. // else
  52. // {
  53. // var element = document.getElementById(clientID);
  54. // return new this(element);
  55. // }
  56. //}
  57. if (typeof window.RadControlsNamespace == "undefined")
  58. {
  59. window.RadControlsNamespace = {};
  60. }
  61. if (
  62. typeof(window.RadControlsNamespace.MsAjaxMixin) == "undefined" ||
  63. typeof(window.RadControlsNamespace.MsAjaxMixin.Version) == null ||
  64. window.RadControlsNamespace.MsAjaxMixin.Version < 1
  65. )
  66. {
  67. RadControlsNamespace.MsAjaxMixin =
  68. {
  69. Version : 1,
  70. Initialize : function(type, typeName)
  71. {
  72. if (typeof(type.registerClass) != "function")
  73. {
  74. return;
  75. }
  76. type.inheritsFrom(Sys.UI.Control);
  77. type.registerClass(typeName, Sys.UI.Control, Sys.IDisposable);
  78. type.prototype.initialize = function()
  79. {
  80. Sys.UI.Control.callBaseMethod(this, 'initialize');
  81. }
  82. type.prototype.dispose = function()
  83. {
  84. Sys.UI.Control.callBaseMethod(this, 'dispose');
  85. this.Dispose();
  86. }
  87. }
  88. }
  89. }
  90. //BEGIN_ATLAS_NOTIFY
  91. if (typeof(Sys) != "undefined")
  92. {
  93. if (Sys.Application != null && Sys.Application.notifyScriptLoaded != null)
  94. {
  95. Sys.Application.notifyScriptLoaded();
  96. }
  97. }
  98. //END_ATLAS_NOTIFY