如果直接看EXT的一些实例代码,也许可以依画葫芦,做出几个效果,但自己绝对也摸不着什么头脑。所以打算从它的内核开始学起,按顺序今天先学Ext.js。
这应该是ExtJS核心的核心,看起来有点晕,先列一下大钢,以后慢慢学
1、定义了一个对象ExtExt = {version: '*.*'};2、给Ext添加一个appay方法,注释是Copies all the properties of config to obj.拷贝所有的c属性到obj对象
Ext.apply = function(o, c, defaults){ ... };3、执行一个匿名函数,用来附于Ext一系列的属性和方法。
(function(){ ... // in intellij using keyword "namespace" causes parsing errors Ext.ns = Ext.namespace; })();4、初始化一系列命名空间
Ext.ns("Ext", "Ext.util", "Ext.grid", "Ext.dd", "Ext.tree", "Ext.data", "Ext.form", "Ext.menu", "Ext.state", "Ext.lib", "Ext.layout", "Ext.app", "Ext.ux");5、利用Ext分别给Function,String,Array,Number,Date添加方法
Ext.apply(Function.prototype, {...}); Ext.applyIf(String, {...}); String.prototype.toggle = function(value, other){ return this == value ? other : value; }; String.prototype.trim = function(){ var re = /^/s+|/s+$/g; return function(){ return this.replace(re, ""); }; }(); Ext.applyIf(Number.prototype, {...}); Ext.applyIf(Array.prototype, {...}); Date.prototype.getElapsed = function(date) { return Math.abs((date || new Date()).getTime()-this.getTime()); };