| /* |
| Copyright (c) 2004-2005, The Dojo Foundation |
| All Rights Reserved. |
| |
| Licensed under the Academic Free License version 2.1 or above OR the |
| modified BSD license. For more information on Dojo licensing, see: |
| |
| http://dojotoolkit.org/community/licensing.shtml |
| */ |
| |
| /* |
| * bootstrap2.js - runs after the hostenv_*.js file. |
| */ |
| |
| /* |
| * This method taks a "map" of arrays which one can use to optionally load dojo |
| * modules. The map is indexed by the possible dojo.hostenv.name_ values, with |
| * two additional values: "default" and "common". The items in the "default" |
| * array will be loaded if none of the other items have been choosen based on |
| * the hostenv.name_ item. The items in the "common" array will _always_ be |
| * loaded, regardless of which list is chosen. Here's how it's normally |
| * called: |
| * |
| * dojo.hostenv.conditionalLoadModule({ |
| * browser: [ |
| * ["foo.bar.baz", true, true], // an example that passes multiple args to loadModule() |
| * "foo.sample.*", |
| * "foo.test, |
| * ], |
| * default: [ "foo.sample.*" ], |
| * common: [ "really.important.module.*" ] |
| * }); |
| */ |
| dojo.hostenv.conditionalLoadModule = function(modMap){ |
| var common = modMap["common"]||[]; |
| var result = (modMap[dojo.hostenv.name_]) ? common.concat(modMap[dojo.hostenv.name_]||[]) : common.concat(modMap["default"]||[]); |
| |
| for(var x=0; x<result.length; x++){ |
| var curr = result[x]; |
| if(curr.constructor == Array){ |
| dojo.hostenv.loadModule.apply(dojo.hostenv, curr); |
| }else{ |
| dojo.hostenv.loadModule(curr); |
| } |
| } |
| } |
| |
| dojo.hostenv.require = dojo.hostenv.loadModule; |
| dojo.require = function(){ |
| dojo.hostenv.loadModule.apply(dojo.hostenv, arguments); |
| } |
| dojo.requireAfter = dojo.require; |
| |
| dojo.requireIf = function(){ |
| if((arguments[0] === true)||(arguments[0]=="common")||(dojo.render[arguments[0]].capable)){ |
| var args = []; |
| for (var i = 1; i < arguments.length; i++) { args.push(arguments[i]); } |
| dojo.require.apply(dojo, args); |
| } |
| } |
| |
| dojo.requireAfterIf = dojo.requireIf; |
| dojo.conditionalRequire = dojo.requireIf; |
| |
| dojo.kwCompoundRequire = function(){ |
| dojo.hostenv.conditionalLoadModule.apply(dojo.hostenv, arguments); |
| } |
| |
| dojo.hostenv.provide = dojo.hostenv.startPackage; |
| dojo.provide = function(){ |
| return dojo.hostenv.startPackage.apply(dojo.hostenv, arguments); |
| } |
| |
| dojo.setModulePrefix = function(module, prefix){ |
| return dojo.hostenv.setModulePrefix(module, prefix); |
| } |
| |
| // stub |
| dojo.profile = { start: function(){}, end: function(){}, dump: function(){} }; |
| |
| // determine if an object supports a given method |
| // useful for longer api chains where you have to test each object in the chain |
| dojo.exists = function(obj, name){ |
| var p = name.split("."); |
| for(var i = 0; i < p.length; i++){ |
| if(!(obj[p[i]])) return false; |
| obj = obj[p[i]]; |
| } |
| return true; |
| } |