Upgrade to ExtJS 4.0.1 - Released 05/18/2011
[extjs.git] / docs / output / Ext.Class.js
1 Ext.data.JsonP.Ext_Class({
2   "tagname": "class",
3   "name": "Ext.Class",
4   "doc": "<p>Handles class creation throughout the whole framework. Note that most of the time <a href=\"#/api/Ext-method-define\" rel=\"Ext-method-define\" class=\"docClass\">Ext.define</a> should\nbe used instead, since it's a higher level wrapper that aliases to <a href=\"#/api/Ext.ClassManager-method-create\" rel=\"Ext.ClassManager-method-create\" class=\"docClass\">Ext.ClassManager.create</a>\nto enable namespacing and dynamic dependency resolution.</p>\n\n<h1>Basic syntax:</h1>\n\n<pre><code>Ext.define(className, properties);\n</code></pre>\n\n<p>in which <code>properties</code> is an object represent a collection of properties that apply to the class. See\n<a href=\"#/api/Ext.ClassManager-method-create\" rel=\"Ext.ClassManager-method-create\" class=\"docClass\">Ext.ClassManager.create</a> for more detailed instructions.</p>\n\n<pre><code>Ext.define('Person', {\n     name: 'Unknown',\n\n     constructor: function(name) {\n         if (name) {\n             this.name = name;\n         }\n\n         return this;\n     },\n\n     eat: function(foodType) {\n         alert(\"I'm eating: \" + foodType);\n\n         return this;\n     }\n});\n\nvar aaron = new Person(\"Aaron\");\naaron.eat(\"Sandwich\"); // alert(\"I'm eating: Sandwich\");\n</code></pre>\n\n<p>Ext.Class has a powerful set of extensible <a href=\"#/api/Ext.Class-method-registerPreprocessor\" rel=\"Ext.Class-method-registerPreprocessor\" class=\"docClass\">pre-processors</a> which takes care of\neverything related to class creation, including but not limited to inheritance, mixins, configuration, statics, etc.</p>\n\n<h1>Inheritance:</h1>\n\n<pre><code>Ext.define('Developer', {\n     extend: 'Person',\n\n     constructor: function(name, isGeek) {\n         this.isGeek = isGeek;\n\n         // Apply a method from the parent class' prototype\n         this.callParent([name]);\n\n         return this;\n\n     },\n\n     code: function(language) {\n         alert(\"I'm coding in: \" + language);\n\n         this.eat(\"Bugs\");\n\n         return this;\n     }\n});\n\nvar jacky = new Developer(\"Jacky\", true);\njacky.code(\"JavaScript\"); // alert(\"I'm coding in: JavaScript\");\n                          // alert(\"I'm eating: Bugs\");\n</code></pre>\n\n<p>See <a href=\"#/api/Ext.Base--callParent\" rel=\"Ext.Base--callParent\" class=\"docClass\">Ext.Base.callParent</a> for more details on calling superclass' methods</p>\n\n<h1>Mixins:</h1>\n\n<pre><code>Ext.define('CanPlayGuitar', {\n     playGuitar: function() {\n        alert(\"F#...G...D...A\");\n     }\n});\n\nExt.define('CanComposeSongs', {\n     composeSongs: function() { ... }\n});\n\nExt.define('CanSing', {\n     sing: function() {\n         alert(\"I'm on the highway to hell...\")\n     }\n});\n\nExt.define('Musician', {\n     extend: 'Person',\n\n     mixins: {\n         canPlayGuitar: 'CanPlayGuitar',\n         canComposeSongs: 'CanComposeSongs',\n         canSing: 'CanSing'\n     }\n})\n\nExt.define('CoolPerson', {\n     extend: 'Person',\n\n     mixins: {\n         canPlayGuitar: 'CanPlayGuitar',\n         canSing: 'CanSing'\n     },\n\n     sing: function() {\n         alert(\"Ahem....\");\n\n         this.mixins.canSing.sing.call(this);\n\n         alert(\"[Playing guitar at the same time...]\");\n\n         this.playGuitar();\n     }\n});\n\nvar me = new CoolPerson(\"Jacky\");\n\nme.sing(); // alert(\"Ahem...\");\n           // alert(\"I'm on the highway to hell...\");\n           // alert(\"[Playing guitar at the same time...]\");\n           // alert(\"F#...G...D...A\");\n</code></pre>\n\n<h1>Config:</h1>\n\n<pre><code>Ext.define('SmartPhone', {\n     config: {\n         hasTouchScreen: false,\n         operatingSystem: 'Other',\n         price: 500\n     },\n\n     isExpensive: false,\n\n     constructor: function(config) {\n         this.initConfig(config);\n\n         return this;\n     },\n\n     applyPrice: function(price) {\n         this.isExpensive = (price &gt; 500);\n\n         return price;\n     },\n\n     applyOperatingSystem: function(operatingSystem) {\n         if (!(/^(iOS|Android|BlackBerry)$/i).test(operatingSystem)) {\n             return 'Other';\n         }\n\n         return operatingSystem;\n     }\n});\n\nvar iPhone = new SmartPhone({\n     hasTouchScreen: true,\n     operatingSystem: 'iOS'\n});\n\niPhone.getPrice(); // 500;\niPhone.getOperatingSystem(); // 'iOS'\niPhone.getHasTouchScreen(); // true;\niPhone.hasTouchScreen(); // true\n\niPhone.isExpensive; // false;\niPhone.setPrice(600);\niPhone.getPrice(); // 600\niPhone.isExpensive; // true;\n\niPhone.setOperatingSystem('AlienOS');\niPhone.getOperatingSystem(); // 'Other'\n</code></pre>\n\n<h1>Statics:</h1>\n\n<pre><code>Ext.define('Computer', {\n     statics: {\n         factory: function(brand) {\n            // 'this' in static methods refer to the class itself\n             return new this(brand);\n         }\n     },\n\n     constructor: function() { ... }\n});\n\nvar dellComputer = Computer.factory('Dell');\n</code></pre>\n\n<p>Also see <a href=\"#/api/Ext.Base--statics\" rel=\"Ext.Base--statics\" class=\"docClass\">Ext.Base.statics</a> and <a href=\"#/api/Ext.Base--self\" rel=\"Ext.Base--self\" class=\"docClass\">Ext.Base.self</a> for more details on accessing\nstatic properties within class methods</p>\n",
5   "extends": null,
6   "mixins": [
7
8   ],
9   "alternateClassNames": [
10
11   ],
12   "xtype": null,
13   "author": "Jacky Nguyen <jacky@sencha.com>",
14   "docauthor": "Jacky Nguyen <jacky@sencha.com>",
15   "singleton": false,
16   "private": false,
17   "cfg": [
18
19   ],
20   "method": [
21     {
22       "tagname": "method",
23       "name": "getDefaultPreprocessors",
24       "member": "Ext.Class",
25       "doc": "<p>Retrieve the array stack of default pre-processors</p>\n",
26       "params": [
27
28       ],
29       "return": {
30         "type": "Function",
31         "doc": "<p>defaultPreprocessors</p>\n"
32       },
33       "private": false,
34       "static": false,
35       "filename": "/Users/nick/Projects/sencha/SDK/platform/core/src/class/Class.js",
36       "linenr": 349,
37       "html_filename": "Class.html",
38       "href": "Class.html#Ext-Class-method-getDefaultPreprocessors",
39       "shortDoc": "<p>Retrieve the array stack of default pre-processors</p>\n"
40     },
41     {
42       "tagname": "method",
43       "name": "getPreprocessor",
44       "member": "Ext.Class",
45       "doc": "<p>Retrieve a pre-processor callback function by its name, which has been registered before</p>\n",
46       "params": [
47         {
48           "type": "String",
49           "name": "name",
50           "doc": "\n",
51           "optional": false
52         }
53       ],
54       "return": {
55         "type": "Function",
56         "doc": "<p>preprocessor</p>\n"
57       },
58       "private": false,
59       "static": false,
60       "filename": "/Users/nick/Projects/sencha/SDK/platform/core/src/class/Class.js",
61       "linenr": 335,
62       "html_filename": "Class.html",
63       "href": "Class.html#Ext-Class-method-getPreprocessor",
64       "shortDoc": "<p>Retrieve a pre-processor callback function by its name, which has been registered before</p>\n"
65     },
66     {
67       "tagname": "method",
68       "name": "registerPreprocessor",
69       "member": "Ext.Class",
70       "doc": "<p>Register a new pre-processor to be used during the class creation process registerPreprocessor</p>\n",
71       "params": [
72         {
73           "type": "String",
74           "name": "name",
75           "doc": "<p>The pre-processor's name</p>\n",
76           "optional": false
77         },
78         {
79           "type": "Function",
80           "name": "fn",
81           "doc": "<p>The callback function to be executed. Typical format:</p>\n\n<pre><code>function(cls, data, fn) {\n    // Your code here\n\n    // Execute this when the processing is finished.\n    // Asynchronous processing is perfectly ok\n    if (fn) {\n        fn.call(this, cls, data);\n    }\n});\n</code></pre>\n\n<p>Passed arguments for this function are:</p>\n\n<ul>\n<li><code>{Function} cls</code>: The created class</li>\n<li><code>{Object} data</code>: The set of properties passed in <a href=\"#/api/Ext.Class\" rel=\"Ext.Class\" class=\"docClass\">Ext.Class</a> constructor</li>\n<li><code>{Function} fn</code>: The callback function that <b>must</b> to be executed when this pre-processor finishes,\nregardless of whether the processing is synchronous or aynchronous</li>\n</ul>\n\n",
82           "optional": false
83         },
84         {
85           "type": "Object",
86           "name": "always",
87           "doc": "\n",
88           "optional": false
89         }
90       ],
91       "return": {
92         "type": "Ext.Class",
93         "doc": "<p>this</p>\n"
94       },
95       "private": false,
96       "static": false,
97       "filename": "/Users/nick/Projects/sencha/SDK/platform/core/src/class/Class.js",
98       "linenr": 298,
99       "html_filename": "Class.html",
100       "href": "Class.html#Ext-Class-method-registerPreprocessor",
101       "shortDoc": "<p>Register a new pre-processor to be used during the class creation process registerPreprocessor</p>\n"
102     },
103     {
104       "tagname": "method",
105       "name": "setDefaultPreprocessorPosition",
106       "member": "Ext.Class",
107       "doc": "<p>Insert this pre-processor at a specific position in the stack, optionally relative to\nany existing pre-processor. For example:</p>\n\n<pre><code>Ext.Class.registerPreprocessor('debug', function(cls, data, fn) {\n    // Your code here\n\n    if (fn) {\n        fn.call(this, cls, data);\n    }\n}).insertDefaultPreprocessor('debug', 'last');\n</code></pre>\n",
108       "params": [
109         {
110           "type": "String",
111           "name": "name",
112           "doc": "<p>The pre-processor name. Note that it needs to be registered with\n<a href=\"#/api/Ext--registerPreprocessor\" rel=\"Ext--registerPreprocessor\" class=\"docClass\">registerPreprocessor</a> before this</p>\n",
113           "optional": false
114         },
115         {
116           "type": "String",
117           "name": "offset",
118           "doc": "<p>The insertion position. Four possible values are:\n'first', 'last', or: 'before', 'after' (relative to the name provided in the third argument)</p>\n",
119           "optional": false
120         },
121         {
122           "type": "String",
123           "name": "relativeName",
124           "doc": "\n",
125           "optional": false
126         }
127       ],
128       "return": {
129         "type": "Ext.Class",
130         "doc": "<p>this</p>\n"
131       },
132       "private": false,
133       "static": false,
134       "filename": "/Users/nick/Projects/sencha/SDK/platform/core/src/class/Class.js",
135       "linenr": 370,
136       "html_filename": "Class.html",
137       "href": "Class.html#Ext-Class-method-setDefaultPreprocessorPosition",
138       "shortDoc": "Insert this pre-processor at a specific position in the stack, optionally relative to\nany existing pre-processor. For..."
139     },
140     {
141       "tagname": "method",
142       "name": "setDefaultPreprocessors",
143       "member": "Ext.Class",
144       "doc": "<p>Set the default array stack of default pre-processors</p>\n",
145       "params": [
146         {
147           "type": "Array",
148           "name": "preprocessors",
149           "doc": "\n",
150           "optional": false
151         }
152       ],
153       "return": {
154         "type": "Ext.Class",
155         "doc": "<p>this</p>\n"
156       },
157       "private": false,
158       "static": false,
159       "filename": "/Users/nick/Projects/sencha/SDK/platform/core/src/class/Class.js",
160       "linenr": 358,
161       "html_filename": "Class.html",
162       "href": "Class.html#Ext-Class-method-setDefaultPreprocessors",
163       "shortDoc": "<p>Set the default array stack of default pre-processors</p>\n"
164     }
165   ],
166   "property": [
167
168   ],
169   "event": [
170
171   ],
172   "filename": "/Users/nick/Projects/sencha/SDK/platform/core/src/class/Class.js",
173   "linenr": 1,
174   "html_filename": "Class.html",
175   "href": "Class.html#Ext-Class",
176   "cssVar": [
177
178   ],
179   "cssMixin": [
180
181   ],
182   "component": false,
183   "superclasses": [
184
185   ],
186   "subclasses": [
187
188   ],
189   "mixedInto": [
190
191   ],
192   "allMixins": [
193
194   ]
195 });