extjs 소스 분석 -006(Ext.override/Ext.extend)


        override : function(origclass, overrides){// , , 
            if(overrides){
                var p = origclass.prototype;
                Ext.apply(p, overrides);// apply 
                if(Ext.isIE && overrides.hasOwnProperty('toString')){
                    p.toString = overrides.toString;
                }
            }
        },
        extend : function(){//Ext 
            // inline overrides
            var io = function(o){// io
                for(var m in o){
                    this[m] = o[m];
                }
            };
            var oc = Object.prototype.constructor;//Object 

            return function(sb, sp, overrides){
                if(typeof sp == 'object'){// object 
                       overrides = sp;// 
                    sp = sb;
                 // 
                    sb = overrides.constructor != oc ? overrides.constructor : function(){sp.apply(this, arguments);};
                }
                var F = function(){},
                    sbp,
                    spp = sp.prototype;

                F.prototype = spp;
                sbp = sb.prototype = new F();
                sbp.constructor=sb;
                sb.superclass=spp;
                if(spp.constructor == oc){
                    spp.constructor=sp;
                }
                sb.override = function(o){
                    Ext.override(sb, o);
                };
                sbp.superclass = sbp.supr = (function(){
                    return spp;
                });
                sbp.override = io;
                Ext.override(sb, overrides);
                sb.extend = function(o){return Ext.extend(sb, o);};
                return sb;
            };
        }()

좋은 웹페이지 즐겨찾기