this.sbdownsize = this.sbupsize = this.value = 0;
this.active = this.dragging = false;
- if (this._showScroll()) {
+ if (this.needScroll()) {
this._initScroll();
}
}
},
- updateHandleLength: function(pagesize, totalsize)
+ setHandleLength: function(pagesize, totalsize)
{
this.options.pagesize = pagesize;
this.options.totalsize = totalsize;
- if (!this._showScroll()) {
+ },
+
+ updateHandleLength: function()
+ {
+ if (!this.needScroll()) {
this.value = 0;
this.track.hide();
- return;
- }
- if (!this._initScroll()) {
+ } else if (!this._initScroll()) {
this.track.show();
this._updateHandleLength();
}
setScrollPosition: function(val)
{
- if (this._showScroll()) {
- var oldval = this.getValue();
- this._setScrollPosition('val', val);
- if (oldval != this.getValue()) {
- this._updateFinished();
- }
+ var oldval = this.getValue();
+ this._setScrollPosition('val', val);
+ if (oldval != this.getValue()) {
+ this._updateFinished();
}
},
this.handle.setStyle({ top: this.handlevalue + 'px' });
},
- _showScroll: function()
+ needScroll: function()
{
return (this.options.pagesize < this.options.totalsize);
}
break;
}
- this.scroller.onResize();
+ this.requestContentRefresh(this.currentOffset());
},
// offset = (integer) TODO
this.opts.onClear(this.visibleRows());
}
- this.scroller.updateSize();
+ this.scroller.setSize(page_size, this.getMetaData('total_rows'));
this.scrollTo(offset + 1, { noupdate: true, top: true });
offset = this.currentOffset();
this.opts.onContentComplete(c_nodes);
}
+ this.scroller.updateDisplay();
+
return true;
},
*/
ViewPort_Scroller = Class.create({
// Variables initialized to undefined:
- // lastpane, noupdate, scrollDiv, scrollbar, scrollsize, vp
+ // noupdate, scrollDiv, scrollbar, vertscroll, vp
initialize: function(vp)
{
}.bindAsEventListener(this));
},
- onResize: function()
+ setSize: function(viewsize, totalsize)
{
- // Update the scrollbar size
- this.updateSize();
-
- // Update displayed content.
- this.vp.requestContentRefresh(this.currentOffset());
+ this._createScrollBar();
+ this.scrollbar.setHandleLength(viewsize, totalsize);
},
- updateSize: function()
+ updateDisplay: function()
{
- this._createScrollBar();
- this.scrollbar.updateHandleLength(this.vp.getPageSize(), this.vp.getMetaData('total_rows'));
-
var c = this.vp.opts.content,
- w = this.scrollDiv.getWidth();
+ vs = false;
- if (this.scrollDiv.visible()) {
+ if (this.scrollbar.needScroll()) {
switch (this.vp.pane_mode) {
case 'horiz':
- this.scrollDiv.setStyle({ float: 'left', marginLeft: '-' + w + 'px', position: null });
+ this.scrollDiv.setStyle({ float: 'left', marginLeft: '-' + this.scrollDiv.getWidth() + 'px', position: null });
break;
case 'vert':
- if (this.lastpane != this.vp.pane_mode) {
- c.setStyle({ width: (c.clientWidth - w) + 'px' });
- }
this.scrollDiv.setStyle({ float: 'left', marginLeft: 0, position: null });
+ if (!this.vertscroll) {
+ c.setStyle({ width: (c.clientWidth - this.scrollDiv.getWidth()) + 'px' });
+ }
+ vs = true;
break;
default:
- this.scrollDiv.setStyle({ marginLeft: '-' + w + 'px', position: 'absolute', right: 0, top: 0 });
+ this.scrollDiv.setStyle({ float: 'none', marginLeft: '-' + this.scrollDiv.getWidth() + 'px', position: 'absolute', right: 0, top: 0 });
break;
}
this.scrollDiv.setStyle({ height: c.clientHeight + 'px' });
- this.scrollsize = c.clientHeight;
- } else if (this.vp.pane_mode == 'vert' &&
- this.lastpane == this.vp.pane_mode) {
- c.setStyle({ width: (c.clientWidth + w) + 'px' });
+ } else if ((this.vp.pane_mode =='vert') && this.vertscroll) {
+ c.setStyle({ width: (c.clientWidth + this.scrollDiv.getWidth()) + 'px' });
}
- this.lastpane = this.vp.pane_mode;
+ this.vertscroll = vs;
+ this.scrollbar.updateHandleLength();
},
clear: function()
{
- if (this.scrollDiv) {
- this.scrollbar.updateHandleLength(0, 0);
- }
+ this.setSize(0, 0);
},
// offset = (integer) Offset to move the scrollbar to