source: [view]
d.mixin(this, params);
var _t = this,
t = _t.transition,
tt = _t._transitions = {},
idm = _t._idMap = {},
tp = _t.transitionParams = eval("({ " + _t.transitionParams + " })"),
node = _t._domNode = dojo.byId(node),
cb = _t._domNodeContentBox = d.contentBox(node), // we are going to assume the rotator will not be changing size
// default styles to apply to all the container node and rotator's panes
p = {
left: 0,
top: 0
},
warn = function(bt, dt){
console.warn(_t.declaredClass, ' - Unable to find transition "', bt, '", defaulting to "', dt, '".');
};
// if we don't have an id, then generate one
_t.id = node.id || (new Date()).getTime();
// force the rotator DOM node to a relative position and attach the container node to it
if(d.style(node, "position") == "static"){
d.style(node, "position", "relative");
}
// create our object for caching transition objects
tt[t] = d.getObject(t);
if(!tt[t]){
warn(t, _defaultTransition);
tt[_t.transition = _defaultTransition] = d.getObject(_defaultTransition);
}
// clean up the transition params
if(!tp.duration){
tp.duration = _defaultTransitionDuration;
}
// if there are any panes being passed in, add them to this node
d.forEach(_t.panes, function(p){
d.create("div", p, node);
});
// zero out our panes array to store the real pane instance
var pp = _t.panes = [];
// find and initialize the panes
d.query(">", node).forEach(function(n, i){
var q = { node: n, idx: i, params: d.mixin({}, tp, eval("({ " + (d.attr(n, "transitionParams") || "") + " })")) },
r = q.trans = d.attr(n, "transition") || _t.transition;
// cache each pane's title, duration, and waitForEvent attributes
d.forEach(["id", "title", "duration", "waitForEvent"], function(a){
q[a] = d.attr(n, a);
});
if(q.id){
idm[q.id] = i;
}
// cache the transition function
if(!tt[r] && !(tt[r] = d.getObject(r))){
warn(r, q.trans = _t.transition);
}
p.position = "absolute";
p.display = _noneStr;
// find the selected pane and initialize styles
if(_t.idx == null || d.attr(n, "selected")){
if(_t.idx != null){
d.style(pp[_t.idx].node, _displayStr, _noneStr);
}
_t.idx = i;
p.display = "";
}
d.style(n, p);
// check for any declarative script blocks
d.query("> script[type^='dojo/method']", n).orphan().forEach(function(s){
var e = d.attr(s, "event");
if(e){
q[e] = d.parser._functionFromScript(s);
}
});
// add this pane to the array of panes
pp.push(q);
});
_t._controlSub = d.subscribe(_t.id + "/rotator/control", _t, "control");