Changeset 9936

Show
Ignore:
Timestamp:
08/03/07 04:55:10 (16 months ago)
Author:
alex
Message:

slight variable factoring for size. Refs #3961

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • dojo/trunk/parser.js

    r9747 r9936  
    44dojo.parser = new function(){ 
    55 
     6        var d = dojo; 
     7 
    68        function val2type(/*Object*/ value){ 
    79                // summary: 
    810                //              Returns name of type of given value. 
    911 
    10                 if(dojo.isString(value)){ return "string"; } 
     12                if(d.isString(value)){ return "string"; } 
    1113                if(typeof value == "number"){ return "number"; } 
    1214                if(typeof value == "boolean"){ return "boolean"; } 
    13                 if(dojo.isFunction(value)){ return "function"; } 
    14                 if(dojo.isArray(value)){ return "array"; } // typeof [] == "object" 
     15                if(d.isFunction(value)){ return "function"; } 
     16                if(d.isArray(value)){ return "array"; } // typeof [] == "object" 
    1517                if(value instanceof Date) { return "date"; } // assume timestamp 
    16                 if(value instanceof dojo._Url){ return "url"; } 
     18                if(value instanceof d._Url){ return "url"; } 
    1719                return "object"; 
    1820        } 
     
    2931                                return typeof value == "boolean" ? value : !(value.toLowerCase()=="false"); 
    3032                        case "function": 
    31                                 if(dojo.isFunction(value)){ 
     33                                if(d.isFunction(value)){ 
    3234                                        // IE gives us a function, even when we say something like onClick="foo" 
    3335                                        // (in which case it gives us an invalid function "function(){ foo }").  
    3436                                        //  Therefore, convert to string 
    3537                                        value=value.toString(); 
    36                                         value=dojo.trim(value.substring(value.indexOf('{')+1, value.length-1)); 
     38                                        value=d.trim(value.substring(value.indexOf('{')+1, value.length-1)); 
    3739                                } 
    3840                                try{ 
    3941                                        if(value.search(/[^\w\.]+/i) != -1){ 
    4042                                                // TODO: "this" here won't work 
    41                                                 value = dojo.parser._nameAnonFunc(new Function(value), this); 
     43                                                value = d.parser._nameAnonFunc(new Function(value), this); 
    4244                                        } 
    43                                         return dojo.getObject(value, false); 
     45                                        return d.getObject(value, false); 
    4446                                }catch(e){ return new Function(); } 
    4547                        case "array": 
    4648                                return value.split(/\s*,\s*/); 
    4749                        case "date": 
    48                                 return dojo.date.stamp.fromISOString(value); 
     50                                return d.date.stamp.fromISOString(value); 
    4951                        case "url": 
    50                                 return dojo.baseUrl + value; 
     52                                return d.baseUrl + value; 
    5153                        default: 
    52                                 return dojo.fromJson(value); 
     54                                return d.fromJson(value); 
    5355                } 
    5456        } 
     
    7173                if(!instanceClasses[className]){ 
    7274                        // get pointer to widget class 
    73                         var cls = dojo.getObject(className); 
    74                         if(!dojo.isFunction(cls)){ 
     75                        var cls = d.getObject(className); 
     76                        if(!d.isFunction(cls)){ 
    7577                                throw new Error("Could not load class '" + className + 
    7678                                        "'. Did you spell the name correctly and use a full path, like 'dijit.form.Button'?"); 
     
    9698                var argsStr = script.getAttribute("args"); 
    9799                if(argsStr){ 
    98                         dojo.forEach(argsStr.split(/\s*,\s*/), function(part, idx){ 
     100                        d.forEach(argsStr.split(/\s*,\s*/), function(part, idx){ 
    99101                                preamble += "var "+part+" = arguments["+idx+"]; "; 
    100102                        }); 
     
    102104                var withStr = script.getAttribute("with"); 
    103105                if(withStr && withStr.length){ 
    104                         dojo.forEach(withStr.split(/\s*,\s*/), function(part){ 
     106                        d.forEach(withStr.split(/\s*,\s*/), function(part){ 
    105107                                preamble += "with("+part+"){"; 
    106108                                suffix += "}"; 
     
    118120                        if(mode && (mode == "connect")){ 
    119121                                // FIXME: need to implement EL here!! 
    120                                 dojo.connect(instance, source, instance, nf); 
     122                                d.connect(instance, source, instance, nf); 
    121123                        }else{ 
    122124                                instance[source] = nf; 
     
    133135                //              any children             
    134136                var thelist = []; 
    135                 dojo.forEach(nodes, function(node){ 
     137                d.forEach(nodes, function(node){ 
    136138                        if(!node){ return; } 
    137139                        var type = node.getAttribute("dojoType"); 
     
    141143                        for(var attrName in clsInfo.params){ 
    142144                                var attrValue = node.getAttribute(attrName); 
    143                                 if(attrValue && !dojo.isAlien(attrValue)){ // see bug#3074; ignore builtin attributes 
     145                                if(attrValue && !d.isAlien(attrValue)){ // see bug#3074; ignore builtin attributes 
    144146                                        var attrType = clsInfo.params[attrName]; 
    145147                                        var val = str2obj(attrValue, attrType); 
     
    156158 
    157159                        // preambles are magic. Handle it. 
    158                         var preambles = dojo.query("> script[type='dojo/method'][event='preamble']", node).orphan(); 
     160                        var preambles = d.query("> script[type='dojo/method'][event='preamble']", node).orphan(); 
    159161                        if(preambles.length){ 
    160162                                // we only support one preamble. So be it. 
    161                                 params.preamble = dojo.parser._functionFromScript(preambles[0]); 
     163                                params.preamble = d.parser._functionFromScript(preambles[0]); 
    162164                        } 
    163165 
    164166                        // grab the rest of the scripts for processing later 
    165                         var scripts = dojo.query("> script[type='dojo/method']", node).orphan(); 
     167                        var scripts = d.query("> script[type='dojo/method']", node).orphan(); 
    166168 
    167169                        var clazz = clsInfo.cls; 
     
    177179                        var jsname = node.getAttribute("jsId"); 
    178180                        if(jsname){ 
    179                                 dojo.setObject(jsname, instance); 
     181                                d.setObject(jsname, instance); 
    180182                        } 
    181183 
    182184                        // check to see if we need to hook up events for non-declare()-built classes 
    183185                        scripts.forEach(function(script){ 
    184                                 dojo.parser._wireUpMethod(instance, script); 
     186                                d.parser._wireUpMethod(instance, script); 
    185187                        }); 
    186188                }); 
     
    189191                // widgets).  Parent widgets will recursively call startup on their 
    190192                // (non-top level) children 
    191                 dojo.forEach(thelist, function(instance){ 
     193                d.forEach(thelist, function(instance){ 
    192194                        if(     instance  &&  
    193195                                (instance.startup) &&  
     
    205207                //              and instantiate them Searches for 
    206208                //              dojoType="qualified.class.name" 
    207                 var list = dojo.query('[dojoType]', rootNode); 
     209                var list = d.query('[dojoType]', rootNode); 
    208210                // go build the object instances 
    209211                var instances = this.instantiate(list); 
     
    211213                // FIXME: clean up any dangling scripts that we may need to run 
    212214                /* 
    213                 var scripts = dojo.query("script[type='dojo/method']", rootNode).orphan(); 
     215                var scripts = d.query("script[type='dojo/method']", rootNode).orphan(); 
    214216                scripts.forEach(function(script){ 
    215217                        wireUpMethod(instance, script);