Skip to content

Instantly share code, notes, and snippets.

@phiggins42
Created April 28, 2010 13:51
Show Gist options
  • Save phiggins42/382167 to your computer and use it in GitHub Desktop.
Save phiggins42/382167 to your computer and use it in GitHub Desktop.
dojo.provide("plugd.layout");
(function(d){
var clsCache = {},
doit = function(part){
// do some mangling:
var dtype = part.type, kids = part.children;
if(!clsCache[dtype]){ clsCache[dtype] = d.getObject(dtype); }
if(part.id){ part.props.id = part.id; }
// create the instance from the cached function
var c = clsCache[dtype], main = new c(part.props, part.id);
// process the children recursively
kids && d.forEach(kids, function(kid){
doit(kid).placeAt(main);
});
return main; // dijit._Widget
}
;
dojo.createLayout = function(def){
// summary: Create a Layout from a passed definition
// def: Object
// The layout definition.
// returns: dijit._Widget
return doit(def);
}
})(dojo);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment