Ext singleton

The Ext namespace (global object) encapsulates all classes, singletons, and utility methods provided by Sencha's libraries.(Ext名称空间(全局对象)封装了Sencha类库提供的所有的类,单例对象,实用方法。)
Most user interface Components are at a lower level of nesting in the namespace, but many common utility functions are provided as direct properties of the Ext namespace.(大多数用户界面组件都是使用多层嵌套名称空间,但许多常见的实用功能作为Ext命名空间的属性提供。)
 
Also many frequently used methods from other classes are provided as shortcuts within the Ext namespace. (也有许多其他类提供的频繁使用的方法提供包含Ext命名空间的快捷名称。)For example Ext.getCmp aliases Ext.ComponentManager.get.(比如Ext.getCmp是Ext.ComponentManager.get的别名。)
 
Many applications are initiated with Ext.onReady which is called once the DOM is ready. (当DOM准备好了之后就会调用Ext.onReady,Ext.onReady会初始化很多应用程序。)This ensures all scripts have been loaded, preventing dependency issues.(这确保了很多脚本已经加载了,防止了依赖事件。) For example:
 
 
  1. Ext.onReady(function(){ 
  2.     new Ext.Component({ 
  3.         renderTo: document.body, 
  4.         html: 'DOM ready!' 
  5.     }); 
  6. }); 
For more information about how to use the Ext classes, see:(关于如何使用Ext类的更多信息,请看)
    The Learning Center
    The FAQ
    The forums(论坛)

 

 ------------------------------------------------------------------------------------

create( [String name], [Object... args] ) : Object

Instantiate a class by either full name, alias or alternate name.用类的完整名字,别名或者是可选的名字创建对象实例

If Ext.Loader is enabled and the class has not been defined yet, it will attempt to load the class via synchronous loading.(如果ext装载机是启用并哟啊创建的类没有定义,但它将尝试通过同步加载类。)

For example, all these three lines return the same result:(例如,下面三行将返回相同的结果:)

 
  1. Ext.onReady(function(){ 
  2.  
  3.     // alias 
  4.     var window1 = Ext.create('widget.window', { 
  5.       title:'window1'
  6.       width: 600, 
  7.       height: 100, 
  8.      //... 
  9.  }); 
  10. window1.show(); 
  11.  // alternate name 
  12.  var window2 = Ext.create('Ext.Window', { 
  13.      title:'window2'
  14.      width: 600, 
  15.      height: 100, 
  16.      //... 
  17.  }); 
  18. window2.show(); 
  19.  
  20.  // full class name 
  21.  var window3 = Ext.create('Ext.window.Window', { 
  22.      title:'window3'
  23.      width: 600, 
  24.      height: 100, 
  25.      //... 
  26.  }); 
  27. window3.show(); 
  28.  // single object with xclass property: 
  29.  var window4 = Ext.create({ 
  30.      xclass: 'Ext.window.Window'// any valid value for 'name' (above) 
  31.      title:'window4'
  32.      width: 600, 
  33.      height: 100, 
  34.      //... 
  35.  }); 
  36. window4.show(); 
  37.  // full class name 
  38.  var window5 = Ext.create('Ext.window.Window', { 
  39.      title:'window5'
  40.      width: 600, 
  41.      height: 100 
  42.     // ... 
  43.  }); 
  44.  window5.show(); 
  45. }); 

Parameters

    name : String (optional)

    The class name or alias. Can be specified as xclass property if only one object parameter is specified.(类名或者别名。如果一个对象属性指定了,就可以指定xclass属性)

    args : Object... (optional)

    Additional arguments after the name will be passed to the class' constructor.(名字后面的附加参数会传递给类的构造函数。)

Returns

    Object

    instance

---------------------------------------------------------

 

define( String className, Object data, Function createdFn ) : Ext.Base

Defines a class or override. A basic class is defined like this:(定义一个类或者重载。一个基本类是像下面这样定义的:)

 
  1. Ext.onReady(function(){ 
  2.  Ext.define('My.awesome.Class', { 
  3.      someProperty: 'something'
  4.      someMethod: function(s) { 
  5.          alert(s + this.someProperty); 
  6.      } 
  7.      //... 
  8.  }); 
  9.  
  10.  var obj = new My.awesome.Class(); 
  11.  
  12.  obj.someMethod('Say '); // alerts 'Say something' 
  13. }); 

 To defines an override, include the override property.(重载类,包括重载属性) The content of an override is aggregated with the specified class in order to extend or modify that class. (重载类将会聚合指定类以去扩展和修改类)This can be as simple as setting default property values or it can extend and/or replace methods.(这和设置默认的属性值一样简单,或者它可以拓展或替换方法) This can also extend the statics of the class.(这也可以拓展类静态的方法和属性)

One use for an override is to break a large class into manageable pieces.(重载的一个用途就是把一个很大的类分成可以管理的各个部分。)

 
  1. // File: /src/app/Panel.js 
  2.  
  3.  
  4.  
  5. Ext.define('My.app.Panel', { 
  6.  
  7.     extend: 'Ext.panel.Panel'
  8.  
  9.     requires: [ 
  10.  
  11.         'My.app.PanelPart2'
  12.  
  13.         'My.app.PanelPart3' 
  14.  
  15.     ] 
  16.  
  17.  
  18.  
  19.     constructor: function (config) { 
  20.  
  21.         this.callParent(arguments); // calls Ext.panel.Panel's constructor 
  22.  
  23.         //... 
  24.  
  25.     }, 
  26.  
  27.  
  28.  
  29.     statics: { 
  30.  
  31.         method: function () { 
  32.  
  33.             return 'abc'
  34.  
  35.         } 
  36.  
  37.     } 
  38.  
  39. }); 

 

 
  1. // File: /src/app/PanelPart2.js 
  2.  
  3. Ext.define('My.app.PanelPart2', { 
  4.  
  5.     override: 'My.app.Panel'
  6.  
  7.  
  8.  
  9.     constructor: function (config) { 
  10.  
  11.         this.callParent(arguments); // calls My.app.Panel's constructor 
  12.  
  13.         //... 
  14.  
  15.     } 
  16.  
  17. }); 

Another use of overrides is to provide optional parts of classes that can be independently required. In this case, the class may even be unaware of the override altogether.(重载类的另一个用途就是提供单独要求的可选的类的部分,在这样的例子中,类甚至不能意识到已经重载了。)

 
  1. Ext.define('My.ux.CoolTip', { 
  2.  
  3.     override: 'Ext.tip.ToolTip'
  4.  
  5.  
  6.  
  7.     constructor: function (config) { 
  8.  
  9.         this.callParent(arguments); // calls Ext.tip.ToolTip's constructor 
  10.  
  11.         //... 
  12.  
  13.     } 
  14.  
  15. }); 

The above override can now be required as normal.

 
  1. Ext.define('My.app.App', { 
  2.  
  3.     requires: [ 
  4.  
  5.         'My.ux.CoolTip' 
  6.  
  7.     ] 
  8.  
  9. }); 

Overrides can also contain statics:

 
  1. Ext.define('My.app.BarMod', { 
  2.  
  3.     override: 'Ext.foo.Bar'
  4.  
  5.  
  6.  
  7.     statics: { 
  8.  
  9.         method: function (x) { 
  10.  
  11.             return this.callParent([x * 2]); // call Ext.foo.Bar.method 
  12.  
  13.         } 
  14.  
  15.     } 
  16.  
  17. }); 

IMPORTANT: An override is only included in a build if the class it overrides is required. Otherwise, the override, like the target class, is not included.(如果被重载的类在重载的时候是要求的,重载在编译的时候就会包含进来。否则的话,重载,例如目标类是不会被包含进来的)

Parameters

    className : String

    The class name to create in string dot-namespaced format, for example: 'My.very.awesome.Class', 'FeedViewer.plugin.CoolPager'(创建的类名使用字符串点-命名空间的格式,例如'My.very.awesome.Class', 'FeedViewer.plugin.CoolPager') It is highly recommended to follow this simple convention: - The root and the class name are 'CamelCased' - Everything else is lower-cased(下面这个公约是强烈要求的-根和类名是骆驼拼写形式,其他的全都是小写)

    data : Object

    The key - value pairs of properties to apply to this class. (键值对属性应用到这个类)Property names can be of any valid strings, except those in the reserved listed below: - mixins - statics - config - alias - self - singleton - alternateClassName - override(属性名可以是任何合法的字符,出了下面提供的列表- mixins - statics - config - alias - self - singleton - alternateClassName - override)

    createdFn : Function

    Optional callback to execute after the class is created, the execution scope of which (this) will be the newly created class itself.(在类创建之后执行可选的回调方法,这个指定的范围将会是新创建的类的自身)

Returns

    Ext.Base

-----------------------------------------------------------------------------------

 

apply( Object object, Object config, [Object defaults] ) : Object

Copies all the properties of config to the specified object. Note that if recursive merging and cloning without referencing the original objects / arrays is needed, use Ext.Object.merge instead.

(拷贝配置中的所有属性到一个指定的对象中。注意到如果递归合并和没有拷贝原始对象和数组的引用,可以使用Ext.Object.merge)

Parameters

   object : Object

       The receiver of the properties(接受属性的对象)

   config : Object

       The source of the properties(被拷贝属性的对象)

   defaults : Object (optional)

       A different object that will also be applied for default values(另一个将要使用默认值的对象)

   Returns

     Object

     returns obj

 

1111111