mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-08-19 21:53:19 +00:00
Style
This commit is contained in:
@@ -8,13 +8,13 @@
|
||||
*
|
||||
*/
|
||||
var SOGoDataTableInterface = {
|
||||
|
||||
|
||||
// Object variables initialized with "bind"
|
||||
columnsCount: null,
|
||||
rowModel: null,
|
||||
rowHeight: 0,
|
||||
body: null,
|
||||
|
||||
|
||||
// Object variables
|
||||
dataSource: null,
|
||||
rowTop: null,
|
||||
@@ -22,14 +22,14 @@ var SOGoDataTableInterface = {
|
||||
renderedIndex: -1,
|
||||
renderedCount: 0,
|
||||
rowRenderCallback: null,
|
||||
|
||||
|
||||
// Constants
|
||||
overflow: 30, // must be lower than the overflow of the data source class
|
||||
renderDelay: 0.2, // delay (in seconds) before which the table is rendered upon scrolling
|
||||
|
||||
|
||||
bind: function() {
|
||||
this.observe("scroll" , this.render.bind(this));
|
||||
|
||||
|
||||
this.body = this.down("tbody");
|
||||
this.rowModel = this.body.down("tr");
|
||||
|
||||
@@ -87,12 +87,12 @@ var SOGoDataTableInterface = {
|
||||
|
||||
this.rowBottom = new Element('tr', {'id': 'rowBottom'}).update(new Element('td'));
|
||||
this.body.insertBefore(this.rowBottom, this.rowModel);
|
||||
|
||||
|
||||
this.columnsCount = this.rowModel.select("td").length;
|
||||
this.rowHeight = this.rowModel.getHeight();
|
||||
// log ("DataTable.bind() row height = " + this.rowHeight + "px");
|
||||
},
|
||||
|
||||
|
||||
setRowRenderCallback: function(callbackFunction) {
|
||||
// Each time a row is created or updated with new data, this callback
|
||||
// function will be called.
|
||||
@@ -121,20 +121,20 @@ var SOGoDataTableInterface = {
|
||||
if (Object.isHash(urlParams) && urlParams.keys().length > 0) this.dataSource.load(urlParams);
|
||||
else this.dataSource.load(new Hash());
|
||||
},
|
||||
|
||||
|
||||
visibleRowCount: function() {
|
||||
var divHeight = this.getHeight();
|
||||
var visibleRowCount = Math.ceil(divHeight/this.rowHeight);
|
||||
|
||||
return visibleRowCount;
|
||||
},
|
||||
|
||||
|
||||
firstVisibleRowIndex: function() {
|
||||
var firstRowIndex = Math.floor(this.scrollTop/this.rowHeight);
|
||||
|
||||
|
||||
return firstRowIndex;
|
||||
},
|
||||
|
||||
|
||||
refresh: function() {
|
||||
this.render(true);
|
||||
},
|
||||
@@ -161,7 +161,7 @@ var SOGoDataTableInterface = {
|
||||
|
||||
// Query the data source only if at least one row is not loaded
|
||||
if (refresh === true ||
|
||||
this.renderedIndex < 0 ||
|
||||
this.renderedIndex < 0 ||
|
||||
this.renderedIndex > index ||
|
||||
this.renderedCount < count ||
|
||||
(index + count) > (this.renderedIndex + this.renderedCount)) {
|
||||
@@ -199,7 +199,7 @@ var SOGoDataTableInterface = {
|
||||
if (Prototype.Browser.IE)
|
||||
this.rowBottom.setStyle({ 'height': h + 'px', 'line-height': h + 'px' });
|
||||
this.rowBottom.firstChild.setStyle({ 'height': h + 'px', 'line-height': h + 'px' });
|
||||
|
||||
|
||||
if (this.renderedIndex < 0) {
|
||||
this.renderedIndex = 0;
|
||||
this.renderedCount = 0;
|
||||
@@ -242,7 +242,7 @@ var SOGoDataTableInterface = {
|
||||
for (i = start; i > this.renderedIndex; i--) {
|
||||
this.body.removeChild(rows[i - this.renderedIndex]);
|
||||
}
|
||||
|
||||
|
||||
// Add bottom rows
|
||||
for (j = this.renderedIndex + this.renderedCount - start, i = this.renderedIndex + this.renderedCount;
|
||||
j < data.length;
|
||||
@@ -277,7 +277,7 @@ var SOGoDataTableInterface = {
|
||||
// Update references to selected rows
|
||||
this.body.refreshSelectionByIds();
|
||||
// log ("DataTable._render() top gap/bottom gap/total rows = " + this.rowTop.getStyle('height') + "/" + this.rowBottom.getStyle('height') + "/" + this.body.select("tr").length + " (height = " + this.down("table").getHeight() + "px)");
|
||||
|
||||
|
||||
// Save current rendered view index and count
|
||||
this.renderedIndex = start;
|
||||
this.renderedCount = data.length;
|
||||
@@ -326,18 +326,18 @@ var SOGoDataTableInterface = {
|
||||
}
|
||||
return index;
|
||||
},
|
||||
|
||||
|
||||
_emptyTable: function() {
|
||||
var rows = this.body.select("tr");
|
||||
var currentCount = rows.length;
|
||||
|
||||
|
||||
for (var i = currentCount - 1; i >= 0; i--) {
|
||||
if (rows[i] != this.rowModel &&
|
||||
rows[i] != this.rowTop &&
|
||||
rows[i] != this.rowBottom)
|
||||
this.body.removeChild(rows[i]);
|
||||
}
|
||||
|
||||
|
||||
this.body.deselectAll();
|
||||
this.renderedIndex = -1;
|
||||
this.renderedCount = 0;
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/* -*- Mode: js2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
|
||||
SOGoMailDataSource = Class.create({
|
||||
|
||||
|
||||
initialize: function(dataTable, url) {
|
||||
// Instance variables
|
||||
this.dataTable = dataTable;
|
||||
this.id = url;
|
||||
this.url = url;
|
||||
|
||||
|
||||
this.uids = new Array();
|
||||
this.threaded = false;
|
||||
this.cache = new Hash();
|
||||
|
||||
|
||||
this.loaded = false;
|
||||
this.delayedGetData = false;
|
||||
this.ajaxGetData = false;
|
||||
@@ -19,7 +19,7 @@ SOGoMailDataSource = Class.create({
|
||||
// Constants
|
||||
this.overflow = 50; // must be higher or equal to the overflow of the data table class
|
||||
},
|
||||
|
||||
|
||||
destroy: function() {
|
||||
this.uids.clear();
|
||||
var keys = this.cache.keys();
|
||||
@@ -71,7 +71,7 @@ SOGoMailDataSource = Class.create({
|
||||
this.loaded = true;
|
||||
// log ("MailDataSource.init() " + this.uids.length + " UIDs, " + this.cache.keys().length + " headers");
|
||||
},
|
||||
|
||||
|
||||
load: function(urlParams) {
|
||||
var params;
|
||||
this.loaded = false;
|
||||
@@ -89,7 +89,7 @@ SOGoMailDataSource = Class.create({
|
||||
params,
|
||||
{ "Content-type": "application/x-www-form-urlencoded" });
|
||||
},
|
||||
|
||||
|
||||
_loadCallback: function(http) {
|
||||
if (http.status == 200) {
|
||||
if (http.responseText.length > 0) {
|
||||
@@ -108,7 +108,7 @@ SOGoMailDataSource = Class.create({
|
||||
log("SOGoMailDataSource._loadCallback Error " + http.status + ": " + http.responseText);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
getData: function(id, index, count, callbackFunction, delay) {
|
||||
if (this.loaded == false) {
|
||||
// UIDs are not yet loaded -- delay the call until loading the data is completed.
|
||||
@@ -124,12 +124,12 @@ SOGoMailDataSource = Class.create({
|
||||
callbackFunction
|
||||
).delay(delay);
|
||||
},
|
||||
|
||||
|
||||
_getData: function(id, index, count, callbackFunction) {
|
||||
var start, end;
|
||||
var i, j;
|
||||
var missingUids = new Array();
|
||||
|
||||
|
||||
if (count > 1) {
|
||||
// Compute last index depending on number of UIDs
|
||||
start = index - (this.overflow/2);
|
||||
@@ -170,7 +170,7 @@ SOGoMailDataSource = Class.create({
|
||||
else if (callbackFunction)
|
||||
this._returnData(callbackFunction, id, start, end);
|
||||
},
|
||||
|
||||
|
||||
_getRemoteData: function(callbackData, urlParams) {
|
||||
if (this.ajaxGetData) {
|
||||
this.ajaxGetData.aborted = true;
|
||||
@@ -184,7 +184,7 @@ SOGoMailDataSource = Class.create({
|
||||
urlParams,
|
||||
{ "Content-type": "application/x-www-form-urlencoded" });
|
||||
},
|
||||
|
||||
|
||||
_getRemoteDataCallback: function(http) {
|
||||
if (http.status == 200) {
|
||||
if (http.responseText.length > 0) {
|
||||
@@ -207,7 +207,7 @@ SOGoMailDataSource = Class.create({
|
||||
log("SOGoMailDataSource._getRemoteDataCallback Error " + http.status + ": " + http.responseText);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
_returnData: function(callbackFunction, id, start, end) {
|
||||
var i, j;
|
||||
var data = new Array();
|
||||
|
||||
Reference in New Issue
Block a user