_createViewPort: function()
{
- // No need to cache - this function only called once.
- var settitle = this.setMessageListTitle.bind(this);
-
this.viewport = new ViewPort({
- content_container: 'msgList',
- empty_container: 'msgList_empty',
- error_container: 'msgList_error',
- fetch_action: 'ListMessages',
+ // Mandatory config
+ ajax_url: DIMP.conf.URI_IMP + '/ViewPort',
+ content: 'msgList',
template: this.message_list_template,
+
+ // Optional config
+ ajax_opts: DimpCore.doActionOpts,
buffer_pages: DIMP.conf.buffer_pages,
+ content_class: 'msglist',
+ empty_msg: DIMP.text.vp_empty,
+ error_msg: DIMP.text.vp_error,
limit_factor: DIMP.conf.limit_factor,
- viewport_wait: DIMP.conf.viewport_wait,
+ page_size: DIMP.conf.splitbar_pos,
show_split_pane: DIMP.conf.preview_pref,
+ split_bar: 'splitBar',
split_pane: 'previewPane',
- splitbar: 'splitBar',
- content_class: 'msglist',
- row_class: 'msgRow',
- selected_class: 'selectedRow',
- ajaxRequest: DimpCore.doAction.bind(DimpCore),
- norows: true,
- page_size: DIMP.conf.splitbar_pos,
- onScrollIdle: settitle,
- onSlide: settitle,
+ wait: DIMP.conf.viewport_wait,
+
+ // Callbacks
+ onAjaxRequest: function(id) {
+ var p = this.isSearch(id)
+ ? $H({
+ qsearch: $F('quicksearch'),
+ qsearchmbox: this.sfolder
+ })
+ : $H();
+ return DimpCore.addRequestParams(p);
+ }.bind(this),
+ onAjaxResponse: DimpCore.doActionComplete.bind(DimpCore),
+ onCachedList: function(id) {
+ var tmp, vs;
+ if (!this.cacheids[id]) {
+ vs = this.viewport.getSelection(id, true);
+ if (!vs.size()) {
+ return '';
+ }
+
+ if (vs.getBuffer().getMetaData('search')) {
+ this.cacheids[id] = vs.get('uid').toJSON();
+ } else {
+ tmp = {};
+ tmp[id] = vs.get('uid').clone();
+ this.cacheids[id] = DimpCore.toRangeString(tmp);
+ }
+ }
+ return this.cacheids[id];
+ }.bind(this),
+ onCacheUpdate: function(id) {
+ delete this.cacheids[id];
+ }.bind(this),
+ onClearRows: function(r) {
+ r.each(function(row) {
+ if (row.readAttribute('id')) {
+ this._removeMouseEvents(row);
+ }
+ }, this);
+ }.bind(this),
onContent: function(row) {
- var bg, re, search, u,
+ var bg, re, u,
thread = this.viewport.getMetaData('thread') || $H();
row.subjectdata = row.status = '';
}
/* Generate the status flags. */
- row.flag.each(function(a) {
- var ptr = DIMP.conf.flags[a];
- if (ptr.p) {
- if (!ptr.elt) {
- /* Until text-overflow is supported on all
- * browsers, need to truncate label text
- * ourselves. */
- ptr.elt = '<span class="' + ptr.c + '" title="' + ptr.l + '" style="background:' + ptr.b + '">' + ptr.l.truncate(10) + '</span>';
- }
- row.subjectdata += ptr.elt;
- } else {
- if (!ptr.elt) {
- ptr.elt = '<div class="msgflags ' + ptr.c + '" title="' + ptr.l + '"></div>';
+ if (row.flag) {
+ row.flag.each(function(a) {
+ var ptr = DIMP.conf.flags[a];
+ if (ptr.p) {
+ if (!ptr.elt) {
+ /* Until text-overflow is supported on all
+ * browsers, need to truncate label text
+ * ourselves. */
+ ptr.elt = '<span class="' + ptr.c + '" title="' + ptr.l + '" style="background:' + ptr.b + '">' + ptr.l.truncate(10) + '</span>';
+ }
+ row.subjectdata += ptr.elt;
+ } else {
+ if (!ptr.elt) {
+ ptr.elt = '<div class="msgflags ' + ptr.c + '" title="' + ptr.l + '"></div>';
+ }
+ row.status += ptr.elt;
+
+ row.bg.push(ptr.c);
+
+ if (ptr.b) {
+ bg = ptr.b;
+ }
}
- row.status += ptr.elt;
-
- row.bg_string += ' ' + ptr.c;
-
- if (ptr.b) {
- bg = ptr.b;
- }
- }
- });
+ });
+ }
// Set bg
if (bg) {
this.setSortColumns(ssc);
}.bind(this),
- onFetch: this.msgListLoading.bind(this, true),
+ onDeselect: this._deselect.bind(this),
onEndFetch: this.msgListLoading.bind(this, false),
- onCacheUpdate: function(id) {
- delete this.cacheids[id];
- }.bind(this),
- onWait: function() {
- if ($('dimpmain_folder').visible()) {
- DimpCore.showNotifications([ { type: 'horde.warning', message: DIMP.text.listmsg_wait } ]);
- }
- },
onFail: function() {
if ($('dimpmain_folder').visible()) {
DimpCore.showNotifications([ { type: 'horde.error', message: DIMP.text.listmsg_timeout } ]);
}
this.msgListLoading(false);
}.bind(this),
- onClearRows: function(r) {
- r.each(function(row) {
- if (row.readAttribute('id')) {
- this._removeMouseEvents(row);
- }
- }, this);
- }.bind(this),
- onCachedList: function(id) {
- var tmp, vs;
- if (!this.cacheids[id]) {
- vs = this.viewport.getSelection(id, true);
- if (!vs.size()) {
- return '';
- }
-
- if (vs.getBuffer().getMetaData('search')) {
- this.cacheids[id] = vs.get('uid').toJSON();
- } else {
- tmp = {};
- tmp[id] = vs.get('uid').clone();
- this.cacheids[id] = DimpCore.toRangeString(tmp);
- }
- }
- return this.cacheids[id];
- }.bind(this),
- requestParams: function(id) {
- return this.isSearch(id)
- ? $H({
- qsearch: $F('quicksearch'),
- qsearchmbox: this.sfolder
- })
- : $H();
- }.bind(this),
+ onFetch: this.msgListLoading.bind(this, true),
+ onSelect: this._select.bind(this),
+ onSlide: this.setMessageListTitle.bind(this),
onSplitBarChange: function() {
this._updatePrefs('dimp_splitbar', this.viewport.getPageSize());
}.bind(this),
- selectCallback: this._select.bind(this),
- deselectCallback: this._deselect.bind(this)
+ onWait: function() {
+ if ($('dimpmain_folder').visible()) {
+ DimpCore.showNotifications([ { type: 'horde.warning', message: DIMP.text.listmsg_wait } ]);
+ }
+ }
});
// If starting in no preview mode, need to set the no preview class
var elt = e.element(),
tmp;
- if (!elt.hasClassName('msgRow')) {
- elt = elt.up('.msgRow');
+ if (!elt.hasClassName('vpRow')) {
+ elt = elt.up('.vpRow');
}
if (elt) {
hasFlag: function(f, r)
{
- return this.convertFlag(f, r.flag.include(f));
+ return r.flag && this.convertFlag(f, r.flag.include(f));
},
convertFlag: function(f, set)
_updateFlag: function(ob, flag, add)
{
- ob.flag = ob.flag.without(flag);
+ ob.flag = ob.flag
+ ? ob.flag.without(flag)
+ : [];
+
if (add) {
ob.flag.push(flag);
}
/* Need to register a callback function for doAction to catch viewport
* information returned from the server. */
DimpCore.onDoActionComplete = function(r) {
- if (DimpBase.viewport && r.response.viewport) {
- DimpBase.viewport.ajaxResponse(r.response.viewport);
+ if (DimpBase.viewport) {
+ DimpBase.viewport.parseJSONResponse(r);
}
};
/**
* ViewPort.js - Code to create a viewport window in a web browser.
*
+ * Usage:
+ * ======
+ * var viewport = new ViewPort({ options });
+ *
+ * Required options:
+ * -----------------
+ * ajax_url: (string) TODO
+ * Response: 'ViewPort'
+ * content: (Element/string) A DOM element/ID of the container to hold the
+ * viewport rows.
+ * template: (string) TODO DIV with 'vpData'
+ * Class: 'vpRow' 'vpRowSelected'
+ *
+ * Optional options:
+ * -----------------
+ * ajax_opts: (object) TODO
+ * buffer_pages: (integer) The number of viewable pages to send to the browser
+ * per server access when listing rows.
+ * empty_msg: (string) A string to display when the view is empty. Inserted in
+ * a SPAN element with class 'vpEmpty'.
+ * error_msg: (string) A string to display when an error is encountered.
+ * Inserted in a SPAN element with class 'vpError'.
+ * limit_factor: (integer) When browsing through a list, if a user comes
+ * within this percentage of the end of the current cached
+ * viewport, send a background request to the server to retrieve
+ * the next slice.
+ * page_size: (integer) Default page size to view on load.
+ * show_split_pane: (boolean) Show the split pane on load?
+ * split_bar: (Element/string) A DOM element/ID of the element used to display
+ * the split bar.
+ * split_pane: (Element/string) A DOM element/ID of the container to hold
+ * the split pane info.
+ * wait: (integer) How long, in seconds, to wait before displaying an
+ * informational message to users that the message list is still being
+ * built.
+ *
+ * Callbacks:
+ * ----------
+ * onAjaxRequest
+ * onAjaxResponse
+ * onCachedList
+ * onCacheUpdate
+ * onClearRows
+ * onContent
+ * onContentComplete
+ * onDeselect
+ * onEndFetch
+ * onFail
+ * onFetch
+ * onSelect
+ * onSlide
+ * onSplitBarChange
+ * onWait
+ *
* Requires prototypejs 1.6+, DimpSlider.js, scriptaculous 1.8+ (effects.js
* only), and Horde's dragdrop2.js.
*
*/
var ViewPort = Class.create({
- // Required: content_container, fetch_action, template,
- // cachecheck_action, ajaxRequest, buffer_pages,
- // limit_factor, content_class, row_class, selected_class
- // Optional: requestParams, show_split_pane, page_size
initialize: function(opts)
{
- opts.content = $(opts.content_container);
- opts.empty = opts.empty_container ? $(opts.empty_container) : null;
- opts.error = opts.error_container ? $(opts.error_container) : null;
- this.opts = opts;
+ this.opts = Object.extend({
+ buffer_pages: 5,
+ limit_factor: 35
+ }, opts);
+
+ this.opts.content = $(opts.content);
+ this.opts.split_pane = $(opts.split_pane);
this.scroller = new ViewPort_Scroller(this);
this.template = new Template(opts.template);
- this.current_req_lookup = $H();
- this.current_req = $H();
- this.fetch_hash = $H();
- this.views = $H();
+ this.current_req_lookup = {};
+ this.current_req = {};
+ this.fetch_hash = {};
+ this.views = {};
- this.splitbar_loc = opts.page_size;
- this.showSplitPane(opts.show_split_pane);
+ this.split_bar_loc = opts.page_size;
+ this.show_split_pane = opts.show_split_pane;
- this.isbusy = this.line_height = this.old_page_size = this.page_size = this.splitbar = this.viewport_init = null;
+ this.isbusy = this.line_height = this.page_size = this.split_bar = this.viewport_init = null;
this.request_num = 1;
+
+ // Init empty string now.
+ this.empty_msg = new Element('SPAN', { className: 'vpEmpty' }).insert(opts.empty_msg);
+
+ // Set up AJAX response function.
+ this.ajax_response = this.opts.onAjaxResponse || this._ajaxRequestComplete.bind(this);
},
// view = ID of view.
if (this.page_size === null) {
ps = this.getPageSize(this.show_split_pane ? 'default' : 'max');
if (isNaN(ps)) {
- this.loadView.bind(this, view, search, background).defer();
- return;
+ return this.loadView.bind(this, view, search, background).defer();
}
this.page_size = ps;
}
if (this.view) {
if (!background) {
// Need to store current buffer to save current offset
- this.views.set(this.view, { buffer: this._getBuffer(), offset: this.currentOffset() });
+ buffer = this._getBuffer();
+ buffer.setMetaData({ offset: this.currentOffset() }, true);
+ this.views[this.view] = buffer;
}
init = false;
}
}
}
- curr = this.views.get(view);
+ curr = this.views[view];
if (curr) {
- this._updateContent(curr.offset, opts);
+ this._updateContent(curr.getMetaData('offset') || 0, opts);
if (!background) {
- this.opts.ajaxRequest(this.opts.fetch_action, this.addRequestParams({ checkcache: 1, rownum: this.currentOffset() + 1 }));
+ this._ajaxRequest({ checkcache: 1, rownum: this.currentOffset() + 1 });
}
- return true;
+ return;
}
if (!init) {
if (this.opts.onClearRows) {
- this.opts.onClearRows(this.opts.content.childElements());
+ this.opts.onClearRows(this.visibleRows());
}
this.opts.content.update();
this.scroller.clear();
}
- buffer = this._getBuffer(view, true);
- this.views.set(view, { buffer: buffer, offset: 0 });
+ this.views[view] = buffer = this._getBuffer(view, true);
if (search) {
opts.search = search;
opts.offset = 0;
}
this._fetchBuffer(opts);
-
- return false;
},
// view = ID of view
deleteView: function(view)
{
- this.views.unset(view);
+ delete this.views[view];
},
// rownum = (integer) Row number
isVisible: function(rownum)
{
var offset = this.currentOffset();
- return (rownum < offset + 1) ? -1 :
- ((rownum > (offset + this.getPageSize('current'))) ? 1 : 0);
+ return (rownum < offset + 1)
+ ? -1
+ : ((rownum > (offset + this.getPageSize('current'))) ? 1 : 0);
},
// params = TODO
// nowait = (boolean) TODO
onResize: function(noupdate, nowait)
{
- if (!this.opts.content.childElements().size() ||
- !this.opts.content.visible()) {
+ if (!this.opts.content.visible() ||
+ !this.visibleRows().size()) {
return;
}
}
if (nowait) {
- this._onResize(noupdate);
+ this._renderViewport(noupdate);
} else {
- this.resizefunc = this._onResize.bind(this, noupdate).delay(0.1);
- }
- },
-
- _onResize: function(noupdate)
- {
- if (this.opts.onBeforeResize) {
- this.opts.onBeforeResize();
- }
-
- this._renderViewport(noupdate);
-
- if (this.opts.onAfterResize) {
- this.opts.onAfterResize();
+ this.resizefunc = this._renderViewport.bind(this, noupdate).delay(0.1);
}
},
//
// Outgoing request has the following params:
// rownum: (integer) TODO
- // request_id: (string) TODO
+ // request_id: (integer) TODO
// rows: (JSON array) TODO [optional]
//
// search: (JSON object)
}
var view = (opts.view || this.view),
- action = this.opts.fetch_action,
allrows,
b = this._getBuffer(view),
cr,
- lb,
params = $H(opts.params),
request_id,
request_string,
request_old,
rlist,
- rowlist,
+ tmp,
type,
value,
viewable;
if (opts.search) {
type = 'search';
value = opts.search;
- lb = this._lookbehind(view);
+ tmp = this._lookbehind(view);
- params.update({ search_before: lb, search_after: b.bufferSize() - lb });
+ params.update({ search_before: tmp, search_after: b.bufferSize() - tmp });
} else {
type = 'rownum';
value = opts.offset + 1;
// This gets the list of rows needed which do not already appear
// in the buffer.
allrows = b.getAllRows(true);
- rowlist = opts.rowlist ? opts.rowlist : this._getSliceBounds(value, opts.nearing, view);
- rlist = $A($R(rowlist.start, rowlist.end)).diff(allrows);
+ tmp = opts.rowlist || this._getSliceBounds(value, opts.nearing, view);
+ rlist = $A($R(tmp.start, tmp.end)).diff(allrows);
+
if (!opts.purge && !rlist.size()) {
this.isbusy = false;
return;
// Since javascript does not have a native hashing function, use a
// local lookup table instead.
request_string = [ view, type, value ].toJSON();
- request_id = this.fetch_hash.get(request_string);
+ request_id = this.fetch_hash[request_string];
// If we have a current request pending in the current view, figure
// out if we need to send a new request
- cr = this.current_req.get(view);
+ cr = this.current_req[view];
if (cr) {
if (request_id && cr.get(request_id)) {
// Check for repeat request. We technically should never
}
if (!request_id) {
- request_id = this.fetch_hash.set(request_string, this.request_num++);
+ request_id = this.fetch_hash[request_string] = this.request_num++;
}
params.set('request_id', request_id);
this._addRequest(view, request_id, { background: opts.background, offset: value - 1, rlist: rlist });
- this.opts.ajaxRequest(action, this.addRequestParams(params, { noslice: true, view: view }));
+ this._ajaxRequest(params, { noslice: true, view: view });
this._handleWait();
this.isbusy = false;
},
var cid = this.getMetaData('cacheid', opts.view),
cached, params, rowlist;
- params = this.opts.requestParams
- ? this.opts.requestParams(opts.view || this.view)
+ params = this.opts.onAjaxRequest
+ ? this.opts.onAjaxRequest(opts.view || this.view)
: $H();
params.update({ view: opts.view || this.view });
return params.merge(args);
},
+ // params - (object) A list of parameters to send to server
+ // opts - (object) Args to pass to addRequestParams().
+ _ajaxRequest: function(params, other)
+ {
+ new Ajax.Request(this.opts.ajax_url, Object.extend(this.opts.ajax_opts || {}, {
+ evalJS: false,
+ evalJSON: true,
+ onComplete: this.ajax_response,
+ parameters: this.addRequestParams(params, other)
+ }));
+ },
+
+ _ajaxRequestComplete: function(r)
+ {
+ if (r.responseJSON) {
+ this.parseJSONResponse(r.responseJSON);
+ }
+ },
+
+ // r - (object) responseJSON returned from the server.
+ parseJSONResponse: function(r)
+ {
+ if (r.ViewPort) {
+ this._ajaxResponse(r.ViewPort);
+ }
+ },
+
// r = (Object) viewport response object. Properties:
// cacheid
// data
- // id
// label
// metadata (optional)
// partial (optional) - TODO
// totalrows
// update (optional) - If set, update the rowlist instead of
// overwriting it.
- ajaxResponse: function(r)
+ // view
+ _ajaxResponse: function(r)
{
if (this.isbusy) {
- this.ajaxResponse.bind(this, r).defer();
+ this._ajaxResponse.bind(this, r).defer();
return;
}
this._clearWait();
var buffer, cr_id,
- id = (r.request_id) ? this.current_req_lookup.get(r.request_id) : r.id,
- cr = this.current_req.get(id);
+ view = r.request_id ? this.current_req_lookup[r.request_id] : r.view,
+ cr = this.current_req[view];
if (cr && r.request_id) {
cr_id = cr.get(r.request_id);
}
- if (this.viewport_init) {
- this.viewport_init = 2;
- }
-
- buffer = this._getBuffer(id);
+ buffer = this._getBuffer(view);
buffer.update(Object.isArray(r.data) ? {} : r.data, Object.isArray(r.rowlist) ? {} : r.rowlist, r.metadata || {}, { partial: r.partial, reset: r.reset, resetmd: r.resetmd, update: r.update });
if (!r.partial) {
}
if (this.opts.onCacheUpdate) {
- this.opts.onCacheUpdate(id);
+ this.opts.onCacheUpdate(view);
}
if (r.request_id) {
- this._removeRequest(id, r.request_id);
+ this._removeRequest(view, r.request_id);
}
this.isbusy = false;
if (r.partial) {
- this.select(this.getSelection(id));
+ this.select(this.getSelection(view));
} else {
// Don't update the viewport if we are now in a different view, or
// if we are loading in the background.
- if (!(this.view == id || r.search) ||
+ if (!(this.view == view || r.search) ||
(cr_id && cr_id.background) ||
!this._updateContent((cr_id && cr_id.offset) ? cr_id.offset : (r.rownum ? parseInt(r.rownum) - 1 : this.currentOffset()))) {
return;
// params = (object) [background, offset, rlist]
_addRequest: function(view, r_id, params)
{
- var req_view = this.current_req.get(view), req;
+ var req_view = this.current_req[view], req;
if (!req_view) {
- req_view = this.current_req.set(view, $H());
+ req_view = this.current_req[view] = $H();
}
req = req_view.get(r_id);
}
});
- this.current_req_lookup.set(r_id, view);
+ this.current_req_lookup[r_id] = view;
},
// Removes a request to the current request queue.
// r_id = (string) The request ID to remove
_removeRequest: function(view, r_id)
{
- var cr = this.current_req.get(view);
+ var cr = this.current_req[view];
if (cr) {
cr.unset(r_id);
if (!cr.size()) {
- this.current_req.unset(view);
+ delete this.current_req[view];
}
}
- this.current_req_lookup.unset(r_id);
+ delete this.current_req_lookup[r_id];
},
// offset = (integer) TODO
c_nodes = rows.get('dataob');
c.update(c_nodes.collect(this.prepareRow.bind(this)).join(''));
} else {
- // If loading a viewport for the first time, show a blank
- // viewport rather than the empty viewport status message.
- c.update((this.opts.empty && this.viewport_init != 1) ? this.opts.empty.innerHTML : '');
+ c.update(this.empty_msg);
}
if (this.opts.onContentComplete) {
{
var r = Object.clone(row);
- if (r.bg) {
- r.bg = row.bg.clone();
- if (this.getSelected().contains('uid', r.vp_id)) {
- r.bg.push(this.opts.selected_class);
- }
- r.bg_string = r.bg.join(' ');
- } else {
- r.bg_string = '';
+ r.bg = r.bg
+ ? row.bg.clone()
+ : [];
+
+ if (this.getSelected().contains('uid', r.vp_id)) {
+ r.bg.push('vpRowSelected');
}
+ r.bg.unshift('vpRow');
+
if (this.opts.onContent) {
this.opts.onContent(r);
}
+ // Mandatory DOM ID and class information.
+ r.vpData = 'id="' + r.domid + '" class="' + r.bg.join(' ') + '"';
+
return this.template.evaluate(r);
},
this.opts.onFail();
}
- if (this.opts.error) {
- this.opts.content.update(this.opts.error.innerHTML);
+ if (this.opts.errormsg) {
+ this.opts.content.update(new Element('SPAN', { className: 'vpError' }).insert(this.opts.errormsg));
}
},
_getBuffer: function(view, create)
{
view = view || this.view;
- if (!create) {
- var b = this.views.get(view);
- if (b) {
- return b.buffer;
- }
- }
- return new ViewPort_Buffer(this, this.opts.buffer_pages, this.opts.limit_factor, view);
+
+ return (!create && this.views[view])
+ ? this.views[view]
+ : new ViewPort_Buffer(this, this.opts.buffer_pages, this.opts.limit_factor, view);
},
currentOffset: function()
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();
+ var d = new Element('DIV', { className: this.opts.content_class }).insert(new Element('DIV', { className: 'vpRow' })).hide();
$(document.body).insert(d);
this.line_height = d.getHeight();
d.remove();
return this._renderViewport.bind(this, noupdate).defer();
}
- var diff, h, pane, setpane,
+ var diff, h, setpane,
c = $(this.opts.content),
de = document.documentElement,
lh = this._getLineHeight();
// Get split pane dimensions
if (this.opts.split_pane) {
- pane = $(this.opts.split_pane);
if (this.show_split_pane) {
- if (!pane.visible()) {
+ if (!this.opts.split_pane.visible()) {
this._initSplitBar();
- if (this.splitbar_loc &&
- this.splitbar_loc > 0) {
- this.splitbar_loc = this.page_size = Math.min(this.splitbar_loc, this.getPageSize('splitmax'));
+ if (this.split_bar_loc &&
+ this.split_bar_loc > 0) {
+ this.split_bar_loc = this.page_size = Math.min(this.split_bar_loc, this.getPageSize('splitmax'));
} else {
this.page_size = this.getPageSize('default');
}
}
setpane = true;
- } else if (pane.visible()) {
- this.splitbar_loc = this.page_size;
- $(pane, this.splitbar).invoke('hide');
+ } else if (this.opts.split_pane.visible()) {
+ this.split_bar_loc = this.page_size;
+ [ this.opts.split_pane, this.split_bar ].invoke('hide');
}
}
h = lh * this.page_size;
c.setStyle({ height: h + 'px' });
if (setpane) {
- pane.setStyle({ height: (this._getMaxHeight() - h - lh) + 'px' }).show();
- this.splitbar.show();
+ this.opts.split_pane.setStyle({ height: (this._getMaxHeight() - h - lh) + 'px' }).show();
+ this.split_bar.show();
} else if (diff = de.scrollHeight - de.clientHeight) {
c.setStyle({ height: (lh * (this.page_size - 1)) + 'px' });
}
_initSplitBar: function()
{
- if (this.splitbar) {
+ if (this.split_bar) {
return;
}
- this.splitbar = $(this.opts.splitbar);
- new Drag(this.splitbar, {
+ this.split_bar = $(this.opts.split_bar);
+ new Drag(this.split_bar, {
constraint: 'vertical',
ghosting: true,
nodrop: true,
}
}.bind(this)
});
- this.splitbar.observe('dblclick', function() {
+ this.split_bar.observe('dblclick', function() {
var old_size = this.page_size;
this.page_size = this.getPageSize('default');
this._renderViewport();
if (!opts.add) {
sel = this.getSelected();
b.deselect(sel, true);
- sel.get('div').invoke('removeClassName', this.opts.selected_class);
+ sel.get('div').invoke('removeClassName', 'vpRowSelected');
}
b.select(vs);
- vs.get('div').invoke('addClassName', this.opts.selected_class);
- if (this.opts.selectCallback) {
- this.opts.selectCallback(vs, opts);
+ vs.get('div').invoke('addClassName', 'vpRowSelected');
+ if (this.opts.onSelect) {
+ this.opts.onSelect(vs, opts);
}
},
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)
+ vs.get('div').invoke('removeClassName', 'vpRowSelected');
+ if (this.opts.onDeselect) {
+ this.opts.onDeselect(vs, opts)
}
}
},
* ViewPort_Scroller
*/
ViewPort_Scroller = Class.create({
+ // Variables initialized to undefined: noupdate
initialize: function(vp)
{
_onScroll: function()
{
if (!this.noupdate) {
- if (this.vp.opts.onScroll) {
- this.vp.opts.onScroll();
- }
-
this.vp.requestContentRefresh(this.currentOffset());
-
- if (this.vp.opts.onScrollIdle) {
- this.vp.opts.onScrollIdle();
- }
}
},
clear: function()
{
this.data = $H();
- this.partial = $H();
this.mdata = $H({ total_rows: 0 });
- this.usermdata = $H();
+ this.partial = $H();
this.rowlist = $H();
this.selected = new ViewPort_Selection(this);
this.uidlist = $H();
+ this.usermdata = $H();
},
getMetaData: function(id)
add: function(format, d)
{
var c = this._convert(format, d);
- this.data = (this.data.size()) ? this.data.concat(c).uniq() : c;
+ this.data = this.data.size() ? this.data.concat(c).uniq() : c;
},
remove: function(format, d)
_convert: function(format, d)
{
d = Object.isArray(d) ? d : [ d ];
+
switch (format) {
case 'dataob':
return d.pluck('vp_id');