source: [view]
var pcv = this.pagerContainerView;
var _h = (this.orientation == "horizontal");
var style = dojo.style;
if(_h){
var pagerH = dojo.marginBox(this.pagerContainerPager).h;
var statusH = dojo.marginBox(this.pagerContainerStatus).h;
if (this.pagerPos != 'center'){
var addonHeight = pagerH+statusH;
}else{
var addonHeight = statusH;
var widthSub = this.pagerIconNext.width;
var containerWidth = style(pcv, 'width');
var newWidth = containerWidth-(2*widthSub);
style(pcv, {
width: newWidth+'px',
marginLeft: this.pagerIconNext.width+'px',
marginRight: this.pagerIconNext.width+'px'
});
}
var totalH = style(this.pagerContainer, 'height') - addonHeight;
style(this.pagerContainerView, 'height', totalH+'px');
var itemSpace = Math.floor(style(pcv, 'width') / this.itemsPage);
if(this.statusPos == 'trailing'){
if(this.pagerPos != 'center'){
style(pcv, 'marginTop', pagerH+'px');
}
style(pcv, 'marginBottom', statusH+'px');
}else{
style(pcv, 'marginTop', statusH+'px');
if (this.pagerPos != 'center'){
style(pcv, 'marginTop', pagerH+'px');
}
}
}else{
var pagerW = dojo.marginBox(this.pagerContainerPager).w;
var statusW = dojo.marginBox(this.pagerContainerStatus).w;
var containerW = style(this.pagerContainer, 'width');
if(this.pagerPos != 'center'){
var addonWidth = pagerW + statusW;
}else{
var addonWidth = statusW;
var heightSub = this.pagerIconNext.height;
var containerHeight = style(pcv, 'height');
var newHeight = containerHeight - (2 * heightSub);
style(pcv,{
height: newHeight+'px',
marginTop: this.pagerIconNext.height+'px',
marginBottom: this.pagerIconNext.height+'px'
});
}
var totalW = style(this.pagerContainer, 'width') - addonWidth;
style(pcv, 'width', totalW+'px');
var itemSpace = Math.floor(style(pcv, 'height') / this.itemsPage);
if(this.statusPos == 'trailing'){
if (this.pagerPos != 'center'){
style(pcv, 'marginLeft', pagerW + 'px');
}
style(pcv, 'marginRight', statusW + 'px');
}else{
style(pcv, 'marginLeft', statusW + 'px');
if(this.pagerPos != 'center'){
style(pcv, 'marginRight', pagerW+'px');
}
}
}
var _PagerItem = dojo.getObject(this.itemClass);
var paddingLead = "padding" + (_h ? "Left" : "Top");
var paddingTrail = "padding" + (_h ? "Right" : "Bottom");
dojo.forEach(this.items, function(item, cnt){
var contentContainer = dojo.create('div', {
innerHTML: item.content
});
var pagerItem = new _PagerItem({
id: this.id + '-item-' + (cnt + 1)
}, contentContainer);
this.pagerItems.appendChild(pagerItem.domNode);
var containerProps = {};
containerProps[(_h ? "width" : "height")] = (itemSpace - this.itemSpace) + "px";
var p = (_h ? "height" : "width");
containerProps[p] = style(pcv, p) + "px";
style(pagerItem.containerNode, containerProps);
if(this.resizeChildren){
pagerItem.resizeChildren();
}
pagerItem.parseChildren();
// only display amount of items as defined in itemsPage
style(pagerItem.domNode, "position", "absolute");
if (cnt < this.itemsPage){
var pos = (cnt) * itemSpace;
var trailingDir = (_h ? "left" : "top");
var dir = (_h ? "top" : "left");
style(pagerItem.domNode, dir, "0px");
style(pagerItem.domNode, trailingDir, pos+"px");
}else{
style(pagerItem.domNode, "top", "-1000px");
style(pagerItem.domNode, "left", "-1000px");
}
style(pagerItem.domNode, paddingTrail, (this.itemSpace/2)+"px");
style(pagerItem.domNode, paddingLead, (this.itemSpace/2)+"px");
}, this);