mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-27 00:58:55 +01:00
Just commiting current state of my work on the 'dataview' (grid), does NOT do anything usefull right now
This commit is contained in:
parent
6a2d5d8b36
commit
97418ebbbb
@ -604,3 +604,58 @@ function et2_uniqueId()
|
||||
return _et2_uniqueId++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Functions to work with ranges and range intersection (used in the dataview)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Common functions used in most view classes
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns an "range" object with the given top position and height
|
||||
*/
|
||||
function et2_range(_top, _height)
|
||||
{
|
||||
return {
|
||||
"top": _top,
|
||||
"bottom": _top + _height
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an "area" object with the given top- and bottom position
|
||||
*/
|
||||
function et2_bounds(_top, _bottom)
|
||||
{
|
||||
return {
|
||||
"top": _top,
|
||||
"bottom": _bottom
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether two range objects intersect each other
|
||||
*/
|
||||
function et2_rangeIntersect(_ar1, _ar2)
|
||||
{
|
||||
return ! (_ar1.bottom < _ar2.top || _ar1.top > _ar2.bottom);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether two ranges intersect (result = 0) or their relative position
|
||||
* to each other (used to do a binary search inside a list of sorted range objects).
|
||||
*/
|
||||
function et2_rangeIntersectDir(_ar1, _ar2)
|
||||
{
|
||||
if (_ar1.bottom < _ar2.top)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (_ar1.top > _ar2.bottom)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
23
etemplate/js/et2_dataview_interfaces.js
Normal file
23
etemplate/js/et2_dataview_interfaces.js
Normal file
@ -0,0 +1,23 @@
|
||||
/**
|
||||
* eGroupWare eTemplate2 - Contains the dataview base object.
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage dataview
|
||||
* @link http://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2011
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
var et2_dataview_IInvalidatable = new Interface({
|
||||
|
||||
invalidate: function();
|
||||
|
||||
});
|
||||
|
||||
var et2_dataview_IDataRow = new Interface({
|
||||
|
||||
updateData: function(_data);
|
||||
|
||||
});
|
94
etemplate/js/et2_dataview_view_container.js
Normal file
94
etemplate/js/et2_dataview_view_container.js
Normal file
@ -0,0 +1,94 @@
|
||||
/**
|
||||
* eGroupWare eTemplate2 - Class which contains the "row" base class
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage dataview
|
||||
* @link http://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2011
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
"use strict"
|
||||
|
||||
/*egw:uses
|
||||
et2_dataview_interfaces;
|
||||
*/
|
||||
|
||||
var et2_dataview_container = Class.extend({
|
||||
|
||||
init: function(_data, _invalidationElem) {
|
||||
this._dataProvider = _data;
|
||||
this._invalidationElem = _invalidationElem;
|
||||
|
||||
this._node = null;
|
||||
},
|
||||
|
||||
setJNode: function(_node) {
|
||||
// Replace the old node with the new one
|
||||
if (this._node[0].parent)
|
||||
{
|
||||
this._node.replaceWith(_node);
|
||||
}
|
||||
|
||||
this._node = _node;
|
||||
},
|
||||
|
||||
getJNode: function() {
|
||||
return this._node;
|
||||
},
|
||||
|
||||
invalidate: function() {
|
||||
this._invalidationElem.invalidate();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Returns the height of the container in pixels and zero if the element is not
|
||||
* visible. The height is clamped to positive values.
|
||||
* The browser switch is placed at this position as the getHeight function is one
|
||||
* of the mostly called functions in the whole grid code and should stay
|
||||
* quite fast.
|
||||
*/
|
||||
if ($j.browser.mozilla)
|
||||
{
|
||||
et2_dataview_container.prototype.getHeight = function()
|
||||
{
|
||||
if (this.node)
|
||||
{
|
||||
// Firefox sometimes provides fractional pixel values - we are
|
||||
// forced to use those - we can obtain the fractional pixel height
|
||||
// by using the window.getComputedStyle function
|
||||
var compStyle = getComputedStyle(this._node, null);
|
||||
if (compStyle)
|
||||
{
|
||||
var styleHeightStr = compStyle.getPropertyValue("height");
|
||||
var height = parseFloat(styleHeightStr.substr(0, styleHeightStr.length - 2));
|
||||
|
||||
if (isNaN(height) || height < 1)
|
||||
{
|
||||
height = false;
|
||||
}
|
||||
}
|
||||
|
||||
return height;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
et2_dataview_container.prototype.getHeight = function()
|
||||
{
|
||||
if (this.node)
|
||||
{
|
||||
return this._node.offsetHeight;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
36
etemplate/js/et2_dataview_view_grid.js
Normal file
36
etemplate/js/et2_dataview_view_grid.js
Normal file
@ -0,0 +1,36 @@
|
||||
/**
|
||||
* eGroupWare eTemplate2 - Class which contains the "grid" base class
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage dataview
|
||||
* @link http://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2011
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
/*egw:uses
|
||||
et2_dataview_view_row;
|
||||
et2_dataview_view_partitionTree;
|
||||
*/
|
||||
|
||||
var et2_dataview_grid = Class.extend({
|
||||
|
||||
init: function(_dataProvider, _count, _avgHeight) {
|
||||
// Create the partition tree object which is used to organize the tree
|
||||
// items.
|
||||
this._partitionTree = new et2_dataview_partitionTree(_dataProvider,
|
||||
_count, _avgHeight);
|
||||
},
|
||||
|
||||
destroy: function() {
|
||||
// Free the partition tree
|
||||
this._partitionTree.free();
|
||||
},
|
||||
|
||||
|
||||
|
||||
});
|
1006
etemplate/js/et2_dataview_view_partitionTree.js
Normal file
1006
etemplate/js/et2_dataview_view_partitionTree.js
Normal file
File diff suppressed because it is too large
Load Diff
44
etemplate/js/et2_dataview_view_row.js
Normal file
44
etemplate/js/et2_dataview_view_row.js
Normal file
@ -0,0 +1,44 @@
|
||||
/**
|
||||
* eGroupWare eTemplate2 - Class which contains a factory method for rows
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage dataview
|
||||
* @link http://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2011
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
/*egw:uses
|
||||
et2_dataview_interfaces;
|
||||
*/
|
||||
|
||||
var et2_dataview_row = et2_dataview_container.extend({
|
||||
|
||||
init: function(_dataProvider, _rowProvider, _idx) {
|
||||
this._dataProvider = _dataProvider;
|
||||
this._rowProvider = _rowProvider;
|
||||
this._idx = _idx;
|
||||
this._node = null;
|
||||
this._rowImpl = null;
|
||||
|
||||
// Register this row in the dataprovider - if data is available for this
|
||||
// row the "updateData" function will be called immediately.
|
||||
this._dataProvider.registerDataRow(_idx, this);
|
||||
|
||||
if (this._node == null)
|
||||
{
|
||||
}
|
||||
},
|
||||
|
||||
destroy: function() {
|
||||
this._dataProvider.unregisterDataRow(_idx);
|
||||
},
|
||||
|
||||
updateData: function(_data) {
|
||||
}
|
||||
|
||||
});
|
90
etemplate/js/et2_dataview_view_rowProvider.js
Normal file
90
etemplate/js/et2_dataview_view_rowProvider.js
Normal file
@ -0,0 +1,90 @@
|
||||
/**
|
||||
* eGroupWare eTemplate2 - Class which contains a factory method for rows
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage dataview
|
||||
* @link http://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2011
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/*egw:uses
|
||||
jquery.jquery;
|
||||
et2_core_inheritance;
|
||||
*/
|
||||
|
||||
/**
|
||||
* The row provider contains prototypes (full clonable dom-trees)
|
||||
* for all registered row types.
|
||||
*/
|
||||
var et2_dataview_rowProvider = Class.extend({
|
||||
|
||||
init: function(_gridId, _columnIds) {
|
||||
// Copy the given parameters
|
||||
this._dataProvider = _dataProvider;
|
||||
this._gridId = _gridId;
|
||||
this._columnIds = _columnIds;
|
||||
this._prototypes = {};
|
||||
|
||||
// Create the default row "prototypes"
|
||||
this._createFullRowPrototype();
|
||||
this._createDefaultPrototype();
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a clone of the prototype with the given name. If the generator
|
||||
* callback function is given, this function is called if the prototype
|
||||
* does not yet registered.
|
||||
*/
|
||||
getPrototype: function(_name, _generator, _context) {
|
||||
if (typeof this._prototypes[_name] == "undefined")
|
||||
{
|
||||
if (typeof _generator != "undefined")
|
||||
{
|
||||
this._prototypes[_name] = _generator.call(_context, _gridId,
|
||||
_columnIds);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return this._prototypes[_name].clone();
|
||||
},
|
||||
|
||||
/* ---- PRIVATE FUNCTIONS ---- */
|
||||
|
||||
_createFullRowPrototype: function() {
|
||||
var tr = $j(document.createElement("tr"));
|
||||
var td = $j(document.createElement("td"))
|
||||
.attr("span", this._columnIds.length)
|
||||
.appendTo(tr);
|
||||
var div = $j(document.createElement("div"))
|
||||
.addClass(this._gridId + "_div_fullRow")
|
||||
.appendTo(td);
|
||||
|
||||
this._prototypes["fullRow"] = tr;
|
||||
},
|
||||
|
||||
_createDefaultPrototype: function() {
|
||||
var tr = $j(document.createElement("tr"));
|
||||
|
||||
// Append a td for each column
|
||||
for (var i = 0; i < this._columnIds.length; i++)
|
||||
{
|
||||
var td = $j(document.createElement("td"))
|
||||
.addClass(this._gridId + "_td_" + this._columnIds[i])
|
||||
.appendTo(tr);
|
||||
var div = $j(document.createElement("div"))
|
||||
.addClass(this._gridId + "_div_" + this._columnIds[i])
|
||||
.appendTo(td);
|
||||
}
|
||||
|
||||
this._prototypes["default"] = tr;
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -9,7 +9,7 @@
|
||||
body, table, td {
|
||||
font-family: Lucida Grande, sans-serif;
|
||||
font-size: 10pt;
|
||||
overflow: hidden;
|
||||
/* overflow: hidden;*/
|
||||
}
|
||||
|
||||
#linklist a {
|
||||
|
Loading…
Reference in New Issue
Block a user