You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

125 lines
5.0 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>The source code</title>
  6. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  7. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  8. <style type="text/css">
  9. .highlight { display: block; background-color: #ddd; }
  10. </style>
  11. <script type="text/javascript">
  12. function highlight() {
  13. document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
  14. }
  15. </script>
  16. </head>
  17. <body onload="prettyPrint(); highlight();">
  18. <pre class="prettyprint lang-js"><span id='Ext-AbstractManager'>/**
  19. </span> * @class Ext.AbstractManager
  20. * @extends Object
  21. * Base Manager class - extended by ComponentMgr and PluginMgr
  22. */
  23. Ext.AbstractManager = Ext.extend(Object, {
  24. <span id='Ext-AbstractManager-property-typeName'> typeName: 'type',
  25. </span>
  26. <span id='Ext-AbstractManager-method-constructor'> constructor: function(config) {
  27. </span> Ext.apply(this, config || {});
  28. <span id='Ext-AbstractManager-property-all'> /**
  29. </span> * Contains all of the items currently managed
  30. * @property all
  31. * @type Ext.util.MixedCollection
  32. */
  33. this.all = new Ext.util.MixedCollection();
  34. this.types = {};
  35. },
  36. <span id='Ext-AbstractManager-method-get'> /**
  37. </span> * Returns a component by {@link Ext.Component#id id}.
  38. * For additional details see {@link Ext.util.MixedCollection#get}.
  39. * @param {String} id The component {@link Ext.Component#id id}
  40. * @return Ext.Component The Component, &lt;code&gt;undefined&lt;/code&gt; if not found, or &lt;code&gt;null&lt;/code&gt; if a
  41. * Class was found.
  42. */
  43. get : function(id){
  44. return this.all.get(id);
  45. },
  46. <span id='Ext-AbstractManager-method-register'> /**
  47. </span> * Registers an item to be managed
  48. * @param {Mixed} item The item to register
  49. */
  50. register: function(item) {
  51. this.all.add(item);
  52. },
  53. <span id='Ext-AbstractManager-method-unregister'> /**
  54. </span> * Unregisters a component by removing it from this manager
  55. * @param {Mixed} item The item to unregister
  56. */
  57. unregister: function(item) {
  58. this.all.remove(item);
  59. },
  60. <span id='Ext-AbstractManager-method-registerType'> /**
  61. </span> * &lt;p&gt;Registers a new Component constructor, keyed by a new
  62. * {@link Ext.Component#xtype}.&lt;/p&gt;
  63. * &lt;p&gt;Use this method (or its alias {@link Ext#reg Ext.reg}) to register new
  64. * subclasses of {@link Ext.Component} so that lazy instantiation may be used when specifying
  65. * child Components.
  66. * see {@link Ext.Container#items}&lt;/p&gt;
  67. * @param {String} xtype The mnemonic string by which the Component class may be looked up.
  68. * @param {Constructor} cls The new Component class.
  69. */
  70. registerType : function(type, cls){
  71. this.types[type] = cls;
  72. cls[this.typeName] = type;
  73. },
  74. <span id='Ext-AbstractManager-method-isRegistered'> /**
  75. </span> * Checks if a Component type is registered.
  76. * @param {Ext.Component} xtype The mnemonic string by which the Component class may be looked up
  77. * @return {Boolean} Whether the type is registered.
  78. */
  79. isRegistered : function(type){
  80. return this.types[type] !== undefined;
  81. },
  82. <span id='Ext-AbstractManager-method-create'> /**
  83. </span> * Creates and returns an instance of whatever this manager manages, based on the supplied type and config object
  84. * @param {Object} config The config object
  85. * @param {String} defaultType If no type is discovered in the config object, we fall back to this type
  86. * @return {Mixed} The instance of whatever this manager is managing
  87. */
  88. create: function(config, defaultType) {
  89. var type = config[this.typeName] || config.type || defaultType,
  90. Constructor = this.types[type];
  91. if (Constructor == undefined) {
  92. throw new Error(String.format(&quot;The '{0}' type has not been registered with this manager&quot;, type));
  93. }
  94. return new Constructor(config);
  95. },
  96. <span id='Ext-AbstractManager-method-onAvailable'> /**
  97. </span> * Registers a function that will be called when a Component with the specified id is added to the manager. This will happen on instantiation.
  98. * @param {String} id The component {@link Ext.Component#id id}
  99. * @param {Function} fn The callback function
  100. * @param {Object} scope The scope (&lt;code&gt;this&lt;/code&gt; reference) in which the callback is executed. Defaults to the Component.
  101. */
  102. onAvailable : function(id, fn, scope){
  103. var all = this.all;
  104. all.on(&quot;add&quot;, function(index, o){
  105. if (o.id == id) {
  106. fn.call(scope || o, o);
  107. all.un(&quot;add&quot;, fn, scope);
  108. }
  109. });
  110. }
  111. });</pre>
  112. </body>
  113. </html>