// background = Load view in background?
loadView: function(view, search, background)
{
- var buffer, curr, init, opts = {}, ps;
+ var buffer, curr, init = true, opts = {}, ps;
this._clearWait();
// Need to store current buffer to save current offset
this.views.set(this.view, { buffer: this._getBuffer(), offset: this.currentOffset() });
}
- } else {
- init = true;
+ init = false;
}
- curr = this.views.get(view);
-
if (background) {
opts = { background: true, view: view };
} else {
}
}
+ curr = this.views.get(view);
+
if (curr) {
this._updateContent(curr.offset, opts);
if (!background) {
this.opts.ajaxRequest(this.opts.fetch_action, this.addRequestParams({ checkcache: 1, rownum: this.currentOffset() + 1 }));
}
return true;
- } else if (!init) {
+ }
+
+ if (!init) {
if (this.opts.onClearRows) {
this.opts.onClearRows(this.opts.content.childElements());
}
buffer = this._getBuffer(view, true);
this.views.set(view, { buffer: buffer, offset: 0 });
+
if (search) {
opts.search = search;
} else {
},
// rownum = (integer) Row number
- // noupdate = (Object)
+ // opts = (Object) [noupdate, top]
scrollTo: function(rownum, opts)
{
var s = this.scroller;
},
// offset = (integer) TODO
- // opts = (object) TODO [view]
+ // opts = (object) TODO [background, view]
_updateContent: function(offset, opts)
{
opts = opts || {};
if (this.opts.onFail) {
this.opts.onFail();
}
+
if (this.opts.error) {
this.opts.content.update(this.opts.error.innerHTML);
}
return this.scroller.currentOffset();
},
- // vs = (Viewport_Selection) A Viewport_Selection object.
- // cname = (string) Class name.
- // add = (boolean) Whether to set/unset flag.
- _updateClass: function(vs, cname, add)
- {
- vs.get('div').invoke(add ? 'addClassName' : 'removeClassName', cname);
- },
-
_getLineHeight: function()
{
- if (this.line_height) {
- return this.line_height;
+ if (!this.line_height) {
+ // To avoid hardcoding the line height, create a temporary row to
+ // figure out what the CSS says.
+ var d = new Element('DIV', { className: this.opts.content_class }).insert(new Element('DIV', { className: this.opts.row_class })).hide();
+ $(document.body).insert(d);
+ this.line_height = d.getHeight();
+ d.remove();
}
- // To avoid hardcoding the line height, create a temporary row to
- // figure out what the CSS says.
- var d = new Element('DIV', { className: this.opts.content_class }).insert(new Element('DIV', { className: this.opts.row_class })).hide();
- $(document.body).insert(d);
- this.line_height = d.getHeight();
- d.remove();
-
return this.line_height;
},
if (setpane) {
pane.setStyle({ height: (this._getMaxHeight() - h - lh) + 'px' }).show();
this.splitbar.show();
- } else {
- if (diff = de.scrollHeight - de.clientHeight) {
- c.setStyle({ height: (lh * (this.page_size - 1)) + 'px' });
- }
+ } else if (diff = de.scrollHeight - de.clientHeight) {
+ c.setStyle({ height: (lh * (this.page_size - 1)) + 'px' });
}
if (!noupdate) {
onStart: function() {
// Cache these values since we will be using them multiple
// times in snap().
- this.sp = { lh: this._getLineHeight(), pos: $(this.opts.content).positionedOffset()[1], max: this.getPageSize('splitmax'), lines: this.page_size, orig: this.page_size };
+ this.sp = {
+ lh: this._getLineHeight(),
+ lines: this.page_size,
+ max: this.getPageSize('splitmax'),
+ orig: this.page_size,
+ pos: $(this.opts.content).positionedOffset()[1]
+ };
}.bind(this),
snap: function(x, y, elt) {
var l = parseInt((y - this.sp.pos) / this.sp.lh);
if (!opts.add) {
sel = this.getSelected();
b.deselect(sel, true);
- this._updateClass(sel, this.opts.selected_class, false);
+ sel.get('div').invoke('removeClassName', this.opts.selected_class);
}
b.select(vs);
- this._updateClass(vs, this.opts.selected_class, true);
+ vs.get('div').invoke('addClassName', this.opts.selected_class);
if (this.opts.selectCallback) {
this.opts.selectCallback(vs, opts);
}
{
opts = opts || {};
- if (!vs.size()) {
- return;
- }
-
- if (this._getBuffer().deselect(vs, opts && opts.clearall)) {
- this._updateClass(vs, this.opts.selected_class, false);
+ if (vs.size() &&
+ this._getBuffer().deselect(vs, opts && opts.clearall)) {
+ vs.get('div').invoke('removeClassName', this.opts.selected_class);
if (this.opts.deselectCallback) {
this.opts.deselectCallback(vs, opts)
}
var c = this.vp.opts.content;
// Create the outer div.
- this.scrollDiv = new Element('DIV', { className: 'sbdiv', style: 'height:' + c.getHeight() + 'px;' }).hide();
+ this.scrollDiv = new Element('DIV', { className: 'sbdiv' }).setStyle({ height: c.getHeight() + 'px' }).hide();
// Add scrollbar to parent viewport and give our parent a right
// margin just big enough to accomodate the scrollbar.
// Mouse wheel handler.
c.observe(Prototype.Browser.Gecko ? 'DOMMouseScroll' : 'mousewheel', function(e) {
// Fix issue on FF 3 (as of 3.0) that triggers two events
- if (Prototype.Browser.Gecko && e.eventPhase == 2) {
- return;
+ if (!e.eventPhase == 2) {
+ var move_num = Math.min(this.vp.getPageSize(), 3);
+ this.moveScroll(this.currentOffset() + ((e.wheelDelta >= 0 || e.detail < 0) ? (-1 * move_num) : move_num));
}
- var move_num = this.vp.getPageSize();
- move_num = (move_num > 3) ? 3 : move_num;
- this.moveScroll(this.currentOffset() + ((e.wheelDelta >= 0 || e.detail < 0) ? (-1 * move_num) : move_num));
}.bindAsEventListener(this));
return true;
},
numericSort: function()
{
- return this.collect(Number).sort(function(a,b) {
+ return this.collect(Number).sort(function(a, b) {
return (a > b) ? 1 : ((a < b) ? -1 : 0);
});
}