mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-07 16:44:20 +01:00
remove 11.1 felamimail grid, unused since 14.1
This commit is contained in:
parent
99714aa9e9
commit
c5523c649c
@ -1,335 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* eGroupWare API: egw action grid columns classes
|
||||
*
|
||||
* @link http://www.egroupware.org
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package api
|
||||
* @subpackage egw action grid
|
||||
* @author Andreas Stöckel
|
||||
* @copyright (c) 2011 Stylite
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**
|
||||
* The egw_grid_columns class in this file is the PHP counterpart to the implementation
|
||||
* in the JS file egw_grid_columns.js. It can generate column json data, verify
|
||||
* it and store user settings for columns in the preferences
|
||||
*/
|
||||
|
||||
class egw_json_object
|
||||
{
|
||||
private $supported_properties = array(
|
||||
"id" => array(
|
||||
"types" => "string",
|
||||
"default" => ""
|
||||
)
|
||||
);
|
||||
|
||||
protected $data = array();
|
||||
|
||||
/**
|
||||
* Merges the given properties into the supported properties array.
|
||||
*
|
||||
* @param array $props are the supported properties which will be added to the
|
||||
* object.
|
||||
*/
|
||||
protected function add_supported_properties($props)
|
||||
{
|
||||
$this->supported_properties = array_merge($this->supported_properties, $props);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the object data from the
|
||||
*/
|
||||
public function load_assoc(array $assoc)
|
||||
{
|
||||
/**
|
||||
* Calls the magic setter for each data element
|
||||
*/
|
||||
foreach ($assoc as $key => $data)
|
||||
{
|
||||
$this->$key = $data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an associative array with the object data
|
||||
*/
|
||||
public function store_assoc($include_defaults = false)
|
||||
{
|
||||
$result = array();
|
||||
|
||||
foreach ($this->supported_properties as $key => $opt)
|
||||
{
|
||||
if (!array_key_exists("store", $opt) || $opt[$store])
|
||||
{
|
||||
$val = $this->$key;
|
||||
|
||||
if ($val != $opt["default"] || $include_defaults )
|
||||
{
|
||||
$result[$key] = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic setter function - checks whether the specified key is supported by the
|
||||
* the object and the given value is of the supported type.
|
||||
*/
|
||||
public function __set($key,$val)
|
||||
{
|
||||
if (array_key_exists($key, $this->supported_properties))
|
||||
{
|
||||
$sup_entry = $this->supported_properties[$key];
|
||||
|
||||
// Test for the type (PHP-Docu says not to use gettype here)
|
||||
$correct_type = true;
|
||||
|
||||
if (array_key_exists("types", $sup_entry))
|
||||
{
|
||||
$types = explode(",", $sup_entry["types"]);
|
||||
|
||||
foreach ($types as $type)
|
||||
{
|
||||
switch ($type)
|
||||
{
|
||||
case "bool":
|
||||
$correct_type = $correct_type || is_bool($val);
|
||||
break;
|
||||
case "string":
|
||||
$correct_type = $correct_type || is_string($val);
|
||||
break;
|
||||
case "int":
|
||||
$correct_type = $correct_type || is_int($val);
|
||||
break;
|
||||
case "float":
|
||||
$correct_type = $correct_type || is_float($val);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set the value in the data array or call a setter function an inherited
|
||||
// class might have specified
|
||||
if ($correct_type)
|
||||
{
|
||||
if (method_exists($this, "set_".$key))
|
||||
{
|
||||
call_user_func(array($this, "set_".$key), $val);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->data[$key] = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter function - returns the default value if the data key has not
|
||||
* been set yet, returns null if the property does not exists.
|
||||
*/
|
||||
public function __get($key) {
|
||||
if (array_key_exists($key, $this->supported_properties))
|
||||
{
|
||||
// Check whether the inherited class has a special getter implemented
|
||||
if (method_exists($this, "get_".$key))
|
||||
{
|
||||
return call_user_func(array($this, "get_".$key), $val);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (array_key_exists($key, $this->data))
|
||||
{
|
||||
return $this->data[$key];
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->supported_properties[$key]["default"];
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Define some constants as they occur in egw_grid_columns.js
|
||||
*/
|
||||
define("EGW_COL_TYPE_DEFAULT", 0);
|
||||
define("EGW_COL_TYPE_NAME_ICON_FIXED", 1);
|
||||
define("EGW_COL_TYPE_CHECKBOX", 2);
|
||||
|
||||
define("EGW_COL_VISIBILITY_ALWAYS", 0);
|
||||
define("EGW_COL_VISIBILITY_VISIBLE", 1);
|
||||
define("EGW_COL_VISIBILITY_INVISIBLE", 2);
|
||||
define("EGW_COL_VISIBILITY_ALWAYS_NOSELECT", 3);
|
||||
|
||||
define("EGW_COL_SORTABLE_NONE", 0);
|
||||
define("EGW_COL_SORTABLE_ALPHABETIC", 1);
|
||||
define("EGW_COL_SORTABLE_NUMERICAL", 2);
|
||||
define("EGW_COL_SORTABLE_NATURAL", 3);
|
||||
define("EGW_COL_SORTABLE_EXTERNAL", 4);
|
||||
|
||||
define("EGW_COL_SORTMODE_NONE", 0);
|
||||
define("EGW_COL_SORTMODE_ASC", 1);
|
||||
define("EGW_COL_SORTMODE_DESC", 2);
|
||||
|
||||
define("EGW_COL_DEFAULT_FETCH", -10000);
|
||||
|
||||
/**
|
||||
* Object which represents a single column
|
||||
*/
|
||||
class egw_grid_column extends egw_json_object
|
||||
{
|
||||
public function __construct($id = "")
|
||||
{
|
||||
// Add the supported properties
|
||||
$this->add_supported_properties(array(
|
||||
"width" => array("types" => "bool,int,string", "default" => false),
|
||||
"maxWidth" => array("types" => "int,bool", "default" => false),
|
||||
"caption" => array("types" => "string", "default" => ""),
|
||||
"visibility" => array("types" => "int", "default" => EGW_COL_VISIBILITY_VISIBLE),
|
||||
"visible" => array("types" => "bool", "default" => true, "store" => false),
|
||||
"sortable" => array("types" => "int", "default" => EGW_COL_SORTABLE_NONE),
|
||||
"sortmode" => array("types" => "int", "default" => EGW_COL_SORTMODE_NONE),
|
||||
"default" => array("types" => "string,int", "default" => EGW_COL_DEFAULT_FETCH),
|
||||
"type" => array("types" => "int", "default" => EGW_COL_TYPE_DEFAULT)
|
||||
));
|
||||
|
||||
// Set the column id
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function get_visible()
|
||||
{
|
||||
return $this->visibility != EGW_COL_VISIBILITY_INVISIBLE;
|
||||
}
|
||||
|
||||
public function set_visible($val)
|
||||
{
|
||||
if ($this->visibility != EGW_COL_VISIBILITY_ALWAYS &&
|
||||
$this->visibility != EGW_COL_VISIBILITY_ALWAYS_NOSELECT)
|
||||
{
|
||||
$this->visibility = $val ? EGW_COL_VISIBILITY_VISIBLE : EGW_COL_VISIBILITY_INVISIBLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class egw_grid_columns
|
||||
{
|
||||
private $app_name;
|
||||
private $grid_name;
|
||||
|
||||
private $grid_data = array();
|
||||
|
||||
public function __construct($app_name, $grid_name = "main")
|
||||
{
|
||||
$this->app_name = $app_name;
|
||||
$this->grid_name = $grid_name;
|
||||
}
|
||||
|
||||
public function load_grid_data($data)
|
||||
{
|
||||
foreach ($data as $col)
|
||||
{
|
||||
$colobj = new egw_grid_column();
|
||||
$colobj->load_assoc($col);
|
||||
|
||||
$this->grid_data[] = $colobj;
|
||||
}
|
||||
}
|
||||
|
||||
private function get_col($id)
|
||||
{
|
||||
foreach ($this->grid_data as $col)
|
||||
{
|
||||
if ($col->id == $id)
|
||||
{
|
||||
return $col;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the given column data in the user preferences for this grid
|
||||
*/
|
||||
private function get_userdata()
|
||||
{
|
||||
if ($GLOBALS['egw_info']['user']['preferences'][$this->app_name][$this->grid_name.'_column_data'])
|
||||
{
|
||||
return unserialize($GLOBALS['egw_info']['user']['preferences'][$this->app_name][$this->grid_name.'_column_data']);
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the given column data in the user preferences for this grid
|
||||
*/
|
||||
private function set_userdata($data)
|
||||
{
|
||||
$GLOBALS['egw']->preferences->read_repository();
|
||||
|
||||
$GLOBALS['egw']->preferences->change($this->app_name, $this->grid_name.'_column_data',
|
||||
serialize($data));
|
||||
|
||||
$GLOBALS['egw']->preferences->save_repository(true);
|
||||
}
|
||||
|
||||
public function load_userdata()
|
||||
{
|
||||
// Read the userdata from the user preferences
|
||||
$data = $this->get_userdata();
|
||||
|
||||
// Merge the userdata into the column data
|
||||
foreach ($data as $col_id => $col_data)
|
||||
{
|
||||
$col = $this->get_col($col_id);
|
||||
if ($col && is_array($col_data))
|
||||
{
|
||||
$col->load_assoc($col_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function store_userdata($data)
|
||||
{
|
||||
$store_data = array();
|
||||
|
||||
// Check whether the specified columns exists
|
||||
foreach ($data as $col_id => $col_data)
|
||||
{
|
||||
$col = $this->get_col($col_id);
|
||||
if ($col)
|
||||
{
|
||||
$store_data[$col_id] = $col_data;
|
||||
}
|
||||
}
|
||||
|
||||
// Store the verified data columns
|
||||
$this->set_userdata($store_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the associative array containing the column data which can be
|
||||
* JSON-encoded and sent to the client
|
||||
*/
|
||||
public function get_assoc()
|
||||
{
|
||||
$result = array();
|
||||
foreach ($this->grid_data as $col)
|
||||
{
|
||||
$result[] = $col->store_assoc();
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
@ -1,293 +0,0 @@
|
||||
/**
|
||||
* eGroupWare egw_action framework - egw action framework
|
||||
*
|
||||
* @link http://www.egroupware.org
|
||||
* @author Andreas Stöckel <as@stylite.de>
|
||||
* @copyright 2011 by Andreas Stöckel
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package egw_action
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/*egw:uses
|
||||
jquery.jquery;
|
||||
egw_action;
|
||||
egw_grid_columns;
|
||||
egw_grid_data;
|
||||
egw_grid_view;
|
||||
*/
|
||||
|
||||
function egwGrid(_parentNode, _columns, _objectManager, _fetchCallback,
|
||||
_columnChangeCallback, _context)
|
||||
{
|
||||
this.parentNode = _parentNode;
|
||||
this.objectManager = _objectManager;
|
||||
|
||||
this.columnChangeCallback = _columnChangeCallback;
|
||||
this.context = _context;
|
||||
|
||||
this.width = 0;
|
||||
this.height = 0;
|
||||
|
||||
// Create the column handler and connect its update event to this object
|
||||
this.columns = new egwGridColumns(_columns, this.columnsUpdate, this);
|
||||
|
||||
// Create the read queue
|
||||
this.readQueue = new egwGridDataQueue(_fetchCallback, _context);
|
||||
|
||||
this.selectedChangeCallback = null;
|
||||
this.sortColsCallback = null;
|
||||
|
||||
// Create the root data element
|
||||
this.dataRoot = new egwGridDataElement("", null, this.columns, this.readQueue,
|
||||
_objectManager);
|
||||
var self = this;
|
||||
this.dataRoot.actionObject.setSelectedCallback = function() {
|
||||
if (self.gridOuter.checkbox || self.selectedChangeCallback)
|
||||
{
|
||||
var allSelected = this.getAllSelected();
|
||||
if (self.gridOuter.checkbox)
|
||||
{
|
||||
self.gridOuter.checkbox.attr("checked", allSelected)
|
||||
}
|
||||
|
||||
if (self.selectedChangeCallback)
|
||||
{
|
||||
self.selectedChangeCallback.call(self.context, allSelected);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Create the outer view component and pass the dataRoot element so that
|
||||
// the grid outer element will be capable of fetching the root data and
|
||||
// can create a spacer for that.
|
||||
this.gridOuter = new egwGridViewOuter(_parentNode, this.dataRoot,
|
||||
this.selectcolsClick, this.toggleAllClick, this.sortColsClick, this);
|
||||
this.gridOuter.updateColumns(this.columns.getColumnData());
|
||||
}
|
||||
|
||||
var EGW_SELECTMODE_DEFAULT = 0;
|
||||
var EGW_SELECTMODE_TOGGLE = 1;
|
||||
|
||||
egwGrid.prototype.setSelectmode = function(_mode)
|
||||
{
|
||||
this.gridOuter.grid.selectmode = _mode;
|
||||
}
|
||||
|
||||
egwGrid.prototype.setActionLinkGroup = function(_group, _links)
|
||||
{
|
||||
this.dataRoot.actionLinkGroups[_group] = _links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the action link groups.
|
||||
*
|
||||
* @param object _groups is an object used as associative array, which will be
|
||||
* merged into the existing actionLinkGroups
|
||||
* @param boolean _replace specifies whether existing action link groups will
|
||||
* be deleted. Defaults to false.
|
||||
*/
|
||||
egwGrid.prototype.setActionLinkGroups = function(_groups, _replace)
|
||||
{
|
||||
if (typeof _replace == "undefined")
|
||||
{
|
||||
_replace = false;
|
||||
}
|
||||
|
||||
if (_replace)
|
||||
{
|
||||
this.dataRoot.actionLinkGroups = {};
|
||||
}
|
||||
|
||||
for (var k in _groups)
|
||||
{
|
||||
this.dataRoot.actionLinkGroups[k] = _groups[k];
|
||||
}
|
||||
}
|
||||
|
||||
egwGrid.prototype.resize = function(_w, _h)
|
||||
{
|
||||
// if (_w != this.width)
|
||||
{
|
||||
this.columns.setTotalWidth(_w - this.gridOuter.scrollbarWidth - 2);
|
||||
this.gridOuter.updateColumns(this.columns.getColumnData());
|
||||
this.height = -1;
|
||||
}
|
||||
|
||||
// if (_h != this.height)
|
||||
{
|
||||
this.gridOuter.setHeight(_h);
|
||||
}
|
||||
|
||||
this.height = _h;
|
||||
this.width = _w;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the columns have changed, call the gridOuter "updateColumns" function,
|
||||
* which will rebuild the view.
|
||||
*/
|
||||
egwGrid.prototype.columnsUpdate = function(_column)
|
||||
{
|
||||
if (this.gridOuter)
|
||||
{
|
||||
this.gridOuter.updateColumns(this.columns.getColumnData());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the selectcols callback
|
||||
*/
|
||||
egwGrid.prototype.selectcolsClick = function(_at)
|
||||
{
|
||||
var column_data = this.columns.getColumnVisibilitySet();
|
||||
|
||||
// Create a menu which contains these elements and show it
|
||||
var menu_data = [];
|
||||
for (var k in column_data)
|
||||
{
|
||||
var col = column_data[k];
|
||||
// strip html from caption
|
||||
var strippedCaption = col.caption.replace(/&(lt|gt);/g, function (strMatch, p1) {
|
||||
return (p1 == "lt")? "<" : ">";});
|
||||
strippedCaption = strippedCaption.replace(/<\/?[^>]+(>|$)/g,"");
|
||||
menu_data.push(
|
||||
{
|
||||
"id": k,
|
||||
"caption": strippedCaption,
|
||||
"enabled": col.enabled,
|
||||
"checkbox": true,
|
||||
"checked": col.visible
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
var menu = new egwMenu();
|
||||
menu.loadStructure(menu_data);
|
||||
|
||||
var self = this;
|
||||
menu.setGlobalOnClick(function(_elem) {
|
||||
column_data[_elem.id].visible = _elem.checked;
|
||||
|
||||
if (self.columnChangeCallback)
|
||||
{
|
||||
// Create the user data column visibility set
|
||||
var set = {};
|
||||
for (var k in column_data)
|
||||
{
|
||||
set[k] = {
|
||||
"visible": column_data[k].visible
|
||||
};
|
||||
}
|
||||
|
||||
// Call the column change callback with the user data
|
||||
if (self.columnChangeCallback)
|
||||
{
|
||||
self.columnChangeCallback.call(self.context, set);
|
||||
}
|
||||
}
|
||||
|
||||
self.columns.setColumnVisibilitySet(column_data);
|
||||
});
|
||||
|
||||
menu.showAt(_at.offset().left, _at.offset().top);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the toggle all click
|
||||
*/
|
||||
egwGrid.prototype.toggleAllClick = function(_checked)
|
||||
{
|
||||
this.dataRoot.actionObject.toggleAllSelected(_checked);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles clicking on a sortable column header
|
||||
*/
|
||||
egwGrid.prototype.sortColsClick = function(_columnIdx)
|
||||
{
|
||||
var col = this.columns.columns[_columnIdx];
|
||||
if (col.sortable == EGW_COL_SORTABLE_EXTERNAL)
|
||||
{
|
||||
if (this.sortColsCallback)
|
||||
{
|
||||
this.sortColsCallback.call(this.context, col.id);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var dir = EGW_COL_SORTMODE_ASC;
|
||||
|
||||
if (col.sortmode == EGW_COL_SORTMODE_ASC)
|
||||
{
|
||||
dir = EGW_COL_SORTMODE_DESC
|
||||
}
|
||||
|
||||
this.sortData(col.id, dir);
|
||||
}
|
||||
}
|
||||
|
||||
egwGrid.prototype.sortData = function(_columnId, _dir)
|
||||
{
|
||||
var col = this.columns.getColumnById(_columnId);
|
||||
|
||||
if (col && col.sortable != EGW_COL_SORTABLE_NONE && col.sortable != EGW_COL_SORTABLE_EXTERNAL)
|
||||
{
|
||||
this.dataRoot.sortChildren(col.id, _dir, col.sortable, function() {
|
||||
// Set the new sort direction
|
||||
col.set_sortmode(_dir);
|
||||
|
||||
this.displaySortMode();
|
||||
|
||||
// Rebuild the inner grid
|
||||
this.reload();
|
||||
}, this);
|
||||
}
|
||||
}
|
||||
|
||||
egwGrid.prototype.displaySortMode = function()
|
||||
{
|
||||
// Update the column data of the grid
|
||||
this.gridOuter.updateColumns(this.columns.getColumnData());
|
||||
|
||||
// Update the column header
|
||||
for (var i = 0; i < this.columns.columns.length; i++)
|
||||
{
|
||||
this.gridOuter.updateColSortmode(i);
|
||||
}
|
||||
}
|
||||
|
||||
egwGrid.prototype.resetSort = function()
|
||||
{
|
||||
for (var i = 0; i < this.columns.columns.length; i++)
|
||||
{
|
||||
fileGrid.columns.columns[i].set_sortmode(EGW_COL_SORTMODE_NONE);
|
||||
}
|
||||
|
||||
this.displaySortMode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Emptys the grid
|
||||
*/
|
||||
egwGrid.prototype.empty = function()
|
||||
{
|
||||
this.dataRoot.empty();
|
||||
|
||||
this.gridOuter.grid.empty();
|
||||
}
|
||||
|
||||
egwGrid.prototype.reload = function()
|
||||
{
|
||||
this.gridOuter.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the height of the data inserted into the grid
|
||||
*/
|
||||
egwGrid.prototype.getDataHeight = function()
|
||||
{
|
||||
return this.gridOuter.grid.getHeight();
|
||||
}
|
||||
|
||||
|
@ -1,589 +0,0 @@
|
||||
/**
|
||||
* eGroupWare egw_action framework - egw action framework
|
||||
*
|
||||
* @link http://www.egroupware.org
|
||||
* @author Andreas Stöckel <as@stylite.de>
|
||||
* @copyright 2011 by Andreas Stöckel
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package egw_action
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/*egw:uses
|
||||
egw_action_common;
|
||||
*/
|
||||
|
||||
/**
|
||||
* Contains logic for the column class. The column class represents the unique set
|
||||
* of columns a grid view owns. The parameters of the columns (except for visibility)
|
||||
* di normaly not change.
|
||||
*/
|
||||
|
||||
var EGW_COL_TYPE_DEFAULT = 0;
|
||||
var EGW_COL_TYPE_NAME_ICON_FIXED = 1;
|
||||
var EGW_COL_TYPE_CHECKBOX = 2;
|
||||
|
||||
var EGW_COL_VISIBILITY_ALWAYS = 0;
|
||||
var EGW_COL_VISIBILITY_VISIBLE = 1;
|
||||
var EGW_COL_VISIBILITY_INVISIBLE = 2;
|
||||
var EGW_COL_VISIBILITY_ALWAYS_NOSELECT = 3;
|
||||
|
||||
var EGW_COL_SORTABLE_NONE = 0;
|
||||
var EGW_COL_SORTABLE_ALPHABETIC = 1;
|
||||
var EGW_COL_SORTABLE_NUMERICAL = 2;
|
||||
var EGW_COL_SORTABLE_NATURAL = 3;
|
||||
var EGW_COL_SORTABLE_EXTERNAL = 4;
|
||||
|
||||
|
||||
var EGW_COL_SORTMODE_NONE = 0;
|
||||
var EGW_COL_SORTMODE_ASC = 1;
|
||||
var EGW_COL_SORTMODE_DESC = 2;
|
||||
|
||||
var EGW_COL_DEFAULT_FETCH = -10000;
|
||||
|
||||
|
||||
/**
|
||||
* Class representing a single grid column.
|
||||
*/
|
||||
function egwGridColumn(_context, _visiblityChangeCallback, _sortmodeChangeCallback)
|
||||
{
|
||||
if (typeof _context == "undefined")
|
||||
{
|
||||
_context = null;
|
||||
}
|
||||
|
||||
if (typeof _visiblityChangeCallback == "undefined")
|
||||
{
|
||||
_visiblityChangeCallback == null;
|
||||
}
|
||||
|
||||
this.id = "";
|
||||
this.fixedWidth = false;
|
||||
this.relativeWidth = false;
|
||||
this.maxWidth = false;
|
||||
this.caption = "";
|
||||
this.type = EGW_COL_TYPE_DEFAULT;
|
||||
this.visibility = EGW_COL_VISIBILITY_VISIBLE;
|
||||
this.sortable = EGW_COL_SORTABLE_NONE;
|
||||
this.sortmode = EGW_COL_SORTMODE_NONE;
|
||||
this["default"] = EGW_COL_DEFAULT_FETCH;
|
||||
|
||||
this.context = _context;
|
||||
this.visibilityChangeCallback = _visiblityChangeCallback;
|
||||
this.sortmodeChangeCallback = _sortmodeChangeCallback;
|
||||
}
|
||||
|
||||
egwGridColumn.prototype.loadData = function(_data)
|
||||
{
|
||||
egwActionStoreJSON(_data, this, true);
|
||||
}
|
||||
|
||||
egwGridColumn.prototype.set_width = function(_value)
|
||||
{
|
||||
// Parse the width parameter. Posible values are:
|
||||
// 1. "100" => fixedWidth 100px
|
||||
// 2. "100px" => fixedWidth 100px
|
||||
// 3. "50%" => relativeWidth 50%
|
||||
if (_value)
|
||||
{
|
||||
if (typeof _value == "string")
|
||||
{
|
||||
var w = _value;
|
||||
if (w.charAt(w.length - 1) == "%" && !isNaN(w.substr(0, w.length - 1)))
|
||||
{
|
||||
this.relativeWidth = parseInt(w.substr(0, w.length - 1)) / 100;
|
||||
|
||||
// Relative widths with more than 100% are not allowed!
|
||||
if (this.relativeWidth > 1)
|
||||
{
|
||||
this.relativeWidth = false;
|
||||
}
|
||||
}
|
||||
else if (w.substr(w.length - 2, 2) == "px" && !isNaN(w.substr(0, w.length - 2)))
|
||||
{
|
||||
this.fixedWidth = parseInt(w.substr(0, w.length - 2));
|
||||
}
|
||||
else if (!isNaN(w))
|
||||
{
|
||||
this.fixedWidth = parseInt(w);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
egwGridColumn.prototype.set_maxWidth = function(_value)
|
||||
{
|
||||
if (!isNaN(_value) && _value > 0)
|
||||
{
|
||||
this.maxWidth = _value;
|
||||
}
|
||||
}
|
||||
|
||||
egwGridColumn.prototype.set_default = function(_value)
|
||||
{
|
||||
if (typeof _value == "string")
|
||||
{
|
||||
this["default"] = _value;
|
||||
}
|
||||
else if (typeof _value == "number" && (_value == EGW_COL_DEFAULT_FETCH))
|
||||
{
|
||||
this["default"] = _value;
|
||||
}
|
||||
}
|
||||
|
||||
egwGridColumn.prototype.set_id = function(_value)
|
||||
{
|
||||
this.id = _value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for the column type.
|
||||
*/
|
||||
egwGridColumn.prototype.set_type = function(_value)
|
||||
{
|
||||
if (typeof _value == "number" && (_value == EGW_COL_TYPE_DEFAULT ||
|
||||
_value == EGW_COL_TYPE_NAME_ICON_FIXED || _value == EGW_COL_TYPE_CHECKBOX))
|
||||
{
|
||||
this.type = _value;
|
||||
|
||||
if (this.type == EGW_COL_TYPE_CHECKBOX)
|
||||
{
|
||||
this.set_width("23px");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for the visibility of the column. Checks whether the given value is in
|
||||
* the allowed range and calls the visibilityChangeCallback.
|
||||
*/
|
||||
egwGridColumn.prototype.set_visibility = function(_value)
|
||||
{
|
||||
if (typeof _value == "number" && (_value == EGW_COL_VISIBILITY_ALWAYS ||
|
||||
_value == EGW_COL_VISIBILITY_INVISIBLE || _value == EGW_COL_VISIBILITY_VISIBLE ||
|
||||
_value == EGW_COL_VISIBILITY_ALWAYS_NOSELECT))
|
||||
{
|
||||
if (_value != this.visibility)
|
||||
{
|
||||
this.visibility = _value;
|
||||
|
||||
if (this.visibilityChangeCallback)
|
||||
{
|
||||
this.visibilityChangeCallback.call(this.context, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the sortmode of the column and informs the parent about it.
|
||||
*/
|
||||
egwGridColumn.prototype.set_sortmode = function(_value)
|
||||
{
|
||||
if (typeof _value == "number" && (_value == EGW_COL_SORTMODE_NONE ||
|
||||
_value == EGW_COL_SORTMODE_ASC || _value == EGW_COL_SORTMODE_DESC))
|
||||
{
|
||||
if (this.sortable == EGW_COL_SORTABLE_NONE)
|
||||
{
|
||||
this.sortmode = EGW_COL_SORTMODE_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_value != this.sortmode)
|
||||
{
|
||||
if (this.sortmodeChangeCallback)
|
||||
{
|
||||
this.sortmodeChangeCallback.call(this.context, this);
|
||||
}
|
||||
this.sortmode = _value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
egwGridColumn.prototype.set_sortable = function(_value)
|
||||
{
|
||||
if (typeof _value == "number" && (_value == EGW_COL_SORTABLE_ALPHABETIC ||
|
||||
_value == EGW_COL_SORTABLE_NONE || _value == EGW_COL_SORTABLE_NATURAL ||
|
||||
_value == EGW_COL_SORTABLE_NUMERICAL || _value == EGW_COL_SORTABLE_EXTERNAL))
|
||||
{
|
||||
if (_value == EGW_COL_SORTABLE_NONE)
|
||||
{
|
||||
this.sortmode = EGW_COL_SORTABLE_NONE;
|
||||
}
|
||||
|
||||
this.sortable = _value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
egwGridColumn.prototype.set_caption = function(_value)
|
||||
{
|
||||
this.caption = _value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Object which is used inside egwGrid to manage the grid columns.
|
||||
*/
|
||||
function egwGridColumns(_columns, _updateCallback, _context, _columnSpace)
|
||||
{
|
||||
// Default the coulumn padding value to two
|
||||
if (typeof _columnSpace == "undefined")
|
||||
{
|
||||
this.columnSpace = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.columnSpace = _columnSpace;
|
||||
}
|
||||
|
||||
this.totalWidth = false;
|
||||
this.inUpdate = false;
|
||||
this.sortChanged = null;
|
||||
this.visibilityChanged = false;
|
||||
this.columnWidths = [];
|
||||
|
||||
this.context = _context;
|
||||
this.updateCallback = _updateCallback;
|
||||
|
||||
this._beginUpdate();
|
||||
|
||||
this.columns = [];
|
||||
for (var i = 0; i < _columns.length; i++)
|
||||
{
|
||||
var column = new egwGridColumn(this, this._visibilityCallback, this._sortCallback);
|
||||
column.loadData(_columns[i]);
|
||||
|
||||
this.columns.push(column);
|
||||
}
|
||||
|
||||
this._endUpdate();
|
||||
}
|
||||
|
||||
egwGridColumns.prototype._beginUpdate = function()
|
||||
{
|
||||
this.inUpdate = true;
|
||||
this.sortChanged = null;
|
||||
this.visibilityChanged = false;
|
||||
}
|
||||
|
||||
egwGridColumns.prototype._endUpdate = function()
|
||||
{
|
||||
this.inUpdate = false;
|
||||
|
||||
// Call the sort update again in order to update the other columns
|
||||
if (this.sortChanged)
|
||||
{
|
||||
this._sortCallback(this.sortCallback);
|
||||
}
|
||||
|
||||
if (this.visibilityChanged || this.sortChanged)
|
||||
{
|
||||
this.updateCallback.call(this.context, this);
|
||||
}
|
||||
|
||||
this.sortChanged = null;
|
||||
this.visibilityChanged = false;
|
||||
}
|
||||
|
||||
egwGridColumns.prototype._visibilityCallback = function(_elem)
|
||||
{
|
||||
if (this.inUpdate)
|
||||
{
|
||||
this.visibilityChanged = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.updateCallback.call(this.context, this);
|
||||
}
|
||||
}
|
||||
|
||||
egwGridColumns.prototype._sortCallback = function(_elem)
|
||||
{
|
||||
if (this.inUpdate)
|
||||
{
|
||||
this.sortChanged = _elem;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Reset the sortmode of all other elements.
|
||||
for (var i = 0; i < this.columns.length; i++)
|
||||
{
|
||||
if (this.columns[i] != _elem)
|
||||
{
|
||||
this.columns[i].sortmode = EGW_COL_SORTMODE_NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
egwGridColumns.prototype._calculateWidths = function()
|
||||
{
|
||||
// Reset some values which are used during the calculation
|
||||
for (var i = 0; i < this.columns.length; i++)
|
||||
{
|
||||
this.columns[i].larger = false;
|
||||
this.columns[i].newWidth = false;
|
||||
}
|
||||
|
||||
// Remove the spacing between the columns from the total width
|
||||
var tw = this.totalWidth;// - (Math.max(this.getVisibleCount() - 1, 0)) * this.columnSpace;
|
||||
|
||||
// Calculate how many space is - relatively - not occupied with columns with
|
||||
// relative or fixed width
|
||||
var remRelWidth = 1;
|
||||
var noWidthCount = 0
|
||||
|
||||
for (var i = 0; i < this.columns.length; i++)
|
||||
{
|
||||
var col = this.columns[i];
|
||||
if (col.visibility != EGW_COL_VISIBILITY_INVISIBLE)
|
||||
{
|
||||
if (col.relativeWidth)
|
||||
{
|
||||
remRelWidth -= col.relativeWidth;
|
||||
}
|
||||
else if (col.fixedWidth)
|
||||
{
|
||||
remRelWidth -= col.fixedWidth / tw;
|
||||
}
|
||||
else
|
||||
{
|
||||
noWidthCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check whether the width of columns with relative width is larger than their
|
||||
// maxWidth
|
||||
var done = true;
|
||||
do
|
||||
{
|
||||
done = true;
|
||||
|
||||
var noWidth = remRelWidth / noWidthCount;
|
||||
|
||||
for (var i = 0; i < this.columns.length; i++)
|
||||
{
|
||||
var col = this.columns[i];
|
||||
|
||||
if (col.visibility != EGW_COL_VISIBILITY_INVISIBLE)
|
||||
{
|
||||
if (col.maxWidth && !col.larger)
|
||||
{
|
||||
if (col.relativeWidth)
|
||||
{
|
||||
var w = col.relativeWidth * tw;
|
||||
col.larger = w > col.maxWidth;
|
||||
if (col.larger)
|
||||
{
|
||||
// Recalculate the remaining relative width:
|
||||
// col.maxWidth / w is the relative amount of space p which
|
||||
// is remaining for the element. E.g. an element with
|
||||
// w = 150px and maxWidth = 100px => p = 2/3
|
||||
// The space which got removed is 1 - p => 1/3
|
||||
// ==> we have to add 1/3 * oldRelWidth to the remRelWidth
|
||||
// variable.
|
||||
remRelWidth += col.relativeWidth * (1 - col.maxWidth / w);
|
||||
done = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
col.larger = noWidth * tw > col.maxWidth;
|
||||
if (col.larger)
|
||||
{
|
||||
remRelWidth -= col.maxWidth / tw;
|
||||
noWidthCount--;
|
||||
done = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// As some columns take their max width, new space might come available, which
|
||||
// requires other columns to take their maximum width.
|
||||
} while (!done);
|
||||
|
||||
|
||||
// Check whether the columns where a relative width is specified have more
|
||||
// space than the remaining columns - if yes, make the relative ones larger
|
||||
for (var i = 0; i < this.columns.length; i++)
|
||||
{
|
||||
var col = this.columns[i];
|
||||
|
||||
if (col.visibility != EGW_COL_VISIBILITY_INVISIBLE)
|
||||
{
|
||||
if (col.relativeWidth && !col.larger)
|
||||
{
|
||||
if (col.relativeWidth < noWidth)
|
||||
{
|
||||
noWidthCount++;
|
||||
remRelWidth += col.relativeWidth;
|
||||
col.newWidth = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
col.newWidth = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now calculate the absolute width of the columns in pixels
|
||||
this.columnWidths = [];
|
||||
for (var i = 0; i < this.columns.length; i++)
|
||||
{
|
||||
var w = 0;
|
||||
var col = this.columns[i];
|
||||
if (col.visibility != EGW_COL_VISIBILITY_INVISIBLE)
|
||||
{
|
||||
if (col.larger)
|
||||
{
|
||||
w = col.maxWidth;
|
||||
}
|
||||
else if (col.fixedWidth)
|
||||
{
|
||||
w = col.fixedWidth;
|
||||
}
|
||||
else if (col.relativeWidth && !col.newWidth)
|
||||
{
|
||||
w = Math.round(tw * col.relativeWidth);
|
||||
}
|
||||
else
|
||||
{
|
||||
w = Math.round(tw * (remRelWidth / noWidthCount));
|
||||
}
|
||||
|
||||
if (w < 0)
|
||||
{
|
||||
w = 0;
|
||||
}
|
||||
}
|
||||
this.columnWidths.push(w);
|
||||
}
|
||||
}
|
||||
|
||||
egwGridColumns.prototype.setTotalWidth = function(_value)
|
||||
{
|
||||
if (_value < 100)
|
||||
{
|
||||
_value = 100;
|
||||
}
|
||||
|
||||
this.totalWidth = _value;
|
||||
this._calculateWidths();
|
||||
}
|
||||
|
||||
egwGridColumns.prototype.getColumnIndexById = function(_id)
|
||||
{
|
||||
for (var i = 0; i < this.columns.length; i++)
|
||||
{
|
||||
if (this.columns[i].id == _id)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
egwGridColumns.prototype.getColumnById = function(_id)
|
||||
{
|
||||
var idx = this.getColumnIndexById(_id);
|
||||
return (idx == -1) ? null : this.columns[idx];
|
||||
}
|
||||
|
||||
egwGridColumns.prototype.getVisibleCount = function()
|
||||
{
|
||||
var cnt = 0;
|
||||
for (var i = 0; i < this.columns.length; i++)
|
||||
{
|
||||
if (this.columns[i].visibility != EGW_COL_VISIBILITY_INVISIBLE)
|
||||
{
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
egwGridColumns.prototype.getColumnVisibilitySet = function()
|
||||
{
|
||||
var result = {};
|
||||
|
||||
for (var i = 0; i < this.columns.length; i++)
|
||||
{
|
||||
if (this.columns[i].visibility != EGW_COL_VISIBILITY_ALWAYS_NOSELECT)
|
||||
{
|
||||
result[this.columns[i].id] = {
|
||||
"caption": this.columns[i].caption,
|
||||
"enabled": (this.columns[i].visibility != EGW_COL_VISIBILITY_ALWAYS) &&
|
||||
(this.columns[i].type != EGW_COL_TYPE_NAME_ICON_FIXED),
|
||||
"visible": this.columns[i].visibility != EGW_COL_VISIBILITY_INVISIBLE
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
egwGridColumns.prototype.setColumnVisibilitySet = function(_set)
|
||||
{
|
||||
this._beginUpdate();
|
||||
|
||||
for (var k in _set)
|
||||
{
|
||||
var col = this.getColumnById(k);
|
||||
if (col)
|
||||
{
|
||||
col.set_visibility(_set[k].visible ? EGW_COL_VISIBILITY_VISIBLE :
|
||||
EGW_COL_VISIBILITY_INVISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.visibilityChanged)
|
||||
{
|
||||
this._calculateWidths();
|
||||
}
|
||||
|
||||
this._endUpdate();
|
||||
}
|
||||
|
||||
egwGridColumns.prototype.getColumnData = function()
|
||||
{
|
||||
var result = [];
|
||||
|
||||
for (var i = 0; i < this.columns.length; i++)
|
||||
{
|
||||
result.push(
|
||||
{
|
||||
"id": this.columns[i].id,
|
||||
"caption": this.columns[i].caption,
|
||||
"sortable": this.columns[i].sortable,
|
||||
"sortmode": this.columns[i].sortmode,
|
||||
"default": this.columns[i]["default"],
|
||||
"width": this.columnWidths[i],
|
||||
"type": this.columns[i].type,
|
||||
"visible": this.columns[i].visibility != EGW_COL_VISIBILITY_INVISIBLE,
|
||||
"element": this.columns[i]
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
egwGridColumns.prototype.sortBy = function(_id, _mode)
|
||||
{
|
||||
// Fetch the column and set its sortmode. If the column supports sorting,
|
||||
// it will call the callback function.
|
||||
var col = this.getColumnById(_id);
|
||||
if (col)
|
||||
{
|
||||
col.set_sortmode(_mode);
|
||||
}
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,229 +0,0 @@
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
body, td, th {
|
||||
font-family: Verdana,Arial,Helvetica,sans-serif;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.egwGridView_grid {
|
||||
table-layout: fixed;
|
||||
border-spacing: 0;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.egwGridView_outer div.innerContainer.queued {
|
||||
background-image: url(imgs/ajax-loader.gif);
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
height: 19px;
|
||||
}
|
||||
|
||||
.egwGridView_grid tr.focused td {
|
||||
background-image: url(imgs/focused_hatching.png);
|
||||
background-repeat: repeat;
|
||||
}
|
||||
|
||||
.egwGridView_grid tr.selected td {
|
||||
background-color: #b7c3ff;
|
||||
}
|
||||
|
||||
.egwGridView_grid tr.draggedOver td {
|
||||
background-color: #ffd09c !important;
|
||||
}
|
||||
|
||||
/*.egwGridView_grid tr.selected.odd td {
|
||||
background-color: #9dadff;
|
||||
}*/
|
||||
|
||||
.egwGridView_scrollarea {
|
||||
width: 100%;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.egwGridView_spacer {
|
||||
background-image: url(imgs/non_loaded_bg.png);
|
||||
background-position: top left;
|
||||
}
|
||||
|
||||
.egwGridView_outer {
|
||||
table-layout: fixed;
|
||||
border-spacing: 0;
|
||||
border-collapse: collapse;
|
||||
padding: 0;
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
.egwGridView_outer td, .egwGridView_outer tr {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.egwGridView_grid td {
|
||||
border-right: 1px solid silver;
|
||||
border-bottom: 1px solid #e0e0e0;
|
||||
padding: 2px 3px 2px 4px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.egwGridView_outer th div.innerContainer,
|
||||
.egwGridView_grid td div.innerContainer {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.egwGridView_grid tr.fullRow {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.egwGridView_grid tr.row:hover {
|
||||
background-color: #f0f0ff;
|
||||
}
|
||||
|
||||
.egwGridView_grid tr {
|
||||
padding: 2px 3px 2px 4px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.egwGridView_grid tr.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/*.egwGridView_grid tr.odd {
|
||||
background-color: #F1F1F1;
|
||||
}*/
|
||||
|
||||
.egwGridView_grid span.indentation {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.egwGridView_grid span {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.egwGridView_grid img.icon {
|
||||
vertical-align: middle;
|
||||
margin: 2px 5px 2px 2px;
|
||||
-moz-user-select: none;
|
||||
-khtml-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.egwGridView_grid span.arrow {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
background-repeat: no-repeat;
|
||||
margin-right: 2px;
|
||||
-moz-user-select: none;
|
||||
-khtml-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.egwGridView_grid span.arrow.opened {
|
||||
cursor: pointer;
|
||||
background-image: url(imgs/arrows.png);
|
||||
background-position: -8px 0;
|
||||
}
|
||||
|
||||
.egwGridView_grid span.arrow.closed {
|
||||
cursor: pointer;
|
||||
background-image: url(imgs/arrows.png);
|
||||
background-position: 0 0;
|
||||
}
|
||||
|
||||
.egwGridView_grid span.arrow.loading {
|
||||
cursor: pointer;
|
||||
background-image: url(imgs/ajax-loader.gif);
|
||||
background-position: 0 0;
|
||||
}
|
||||
|
||||
.egwGridView_grid span.iconContainer {
|
||||
display: inline-block;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.egwGridView_grid span.caption {
|
||||
cursor: default;
|
||||
-moz-user-select: none;
|
||||
-khtml-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.egwGridView_outer thead th {
|
||||
background-color: #E0E0E0;
|
||||
font-weight: normal;
|
||||
padding: 5px;
|
||||
text-align: left;
|
||||
border-left: 1px solid silver;
|
||||
border-top: 1px solid silver;
|
||||
border-right: 1px solid gray;
|
||||
border-bottom: 1px solid gray;
|
||||
background-image: url(imgs/header_overlay.png);
|
||||
background-position: center;
|
||||
background-repeat: repeat-x;
|
||||
}
|
||||
|
||||
.egwGridView_outer thead th:hover {
|
||||
background-color: #F0F0F0;
|
||||
}
|
||||
|
||||
.egwGridView_outer thead th:active {
|
||||
background-color: #D0D0D0;
|
||||
border-left: 1px solid gray;
|
||||
border-top: 1px solid gray;
|
||||
border-right: 1px solid silver;
|
||||
border-bottom: 1px solid silver;
|
||||
}
|
||||
|
||||
|
||||
.egwGridView_outer thead th.optcol {
|
||||
padding: 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.selectcols {
|
||||
display: inline-block;
|
||||
width: 10px;
|
||||
height: 9px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
vertical-align: middle;
|
||||
background-image: url(imgs/selectcols.png);
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
.egwGridView_grid td.frame,
|
||||
.egwGridView_outer td.frame,
|
||||
.egwGridView_grid td.egwGridView_spacer {
|
||||
padding: 0 !important;
|
||||
border-right: 0 none silver !important;
|
||||
border-bottom: 0 none silver !important;
|
||||
}
|
||||
|
||||
.egwGridView_outer span.sort {
|
||||
display: inline-block;
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
margin: 2px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.egwGridView_outer span.sort.asc {
|
||||
background-image: url(imgs/up.png);
|
||||
}
|
||||
|
||||
.egwGridView_outer span.sort.desc {
|
||||
background-image: url(imgs/down.png);
|
||||
}
|
||||
|
@ -1,199 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Grid Test</title>
|
||||
|
||||
<!-- Basic action stuff -->
|
||||
<script src="../egw_action.js"></script>
|
||||
<script src="../egw_action_common.js"></script>
|
||||
|
||||
<!-- Grid stuff -->
|
||||
<script src="../egw_grid.js"></script>
|
||||
<script src="js/jquery.js"></script>
|
||||
<link rel="stylesheet" href="grid.css"/>
|
||||
|
||||
<!-- Popup stuff -->
|
||||
<link rel="stylesheet" type="text/css" href="skins/dhtmlxmenu_egw.css">
|
||||
<script src="js/dhtmlxcommon.js"></script>
|
||||
<script src="js/dhtmlxmenu.js"></script>
|
||||
<script src="js/dhtmlxmenu_ext.js"></script>
|
||||
<script src="../egw_action_popup.js"></script>
|
||||
<script src="../egw_menu.js"></script>
|
||||
<script src="../egw_menu_dhtmlx.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div id="container" style="height: 300px"></div>
|
||||
<script>
|
||||
var grid = null;
|
||||
var actionManager = null;
|
||||
var objectManager = null;
|
||||
|
||||
function alertClicked(_action, _senders)
|
||||
{
|
||||
var ids = "";
|
||||
for (var i = 0; i < _senders.length; i++)
|
||||
ids += _senders[i].id + ((i < _senders.length - 1) ? ", " : "");
|
||||
|
||||
alert("Action '" + _action.caption + "' executed on elements '"
|
||||
+ ids + "'");
|
||||
}
|
||||
|
||||
$j(document).ready(function() {
|
||||
actionManager = new egwActionManager();
|
||||
actionManager.updateActions(
|
||||
[
|
||||
{
|
||||
"id": "folder_open",
|
||||
"iconUrl": "imgs/folder.png",
|
||||
"caption": "Open folder",
|
||||
"onExecute": alertClicked,
|
||||
"allowOnMultiple": false,
|
||||
"type": "popup",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"id": "file_view",
|
||||
"iconUrl": "imgs/view.png",
|
||||
"caption": "View",
|
||||
"onExecute": alertClicked,
|
||||
"allowOnMultiple": false,
|
||||
"type": "popup",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"id": "file_preview",
|
||||
"iconUrl": "imgs/preview.png",
|
||||
"caption": "Preview",
|
||||
"onExecute": alertClicked,
|
||||
"allowOnMultiple": false,
|
||||
"type": "popup",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"id": "file_delete",
|
||||
"iconUrl": "imgs/delete.png",
|
||||
"caption": "Delete",
|
||||
"onExecute": alertClicked,
|
||||
"type": "popup",
|
||||
"group": 2
|
||||
},
|
||||
{
|
||||
"id": "file_edit",
|
||||
"iconUrl": "imgs/edit.png",
|
||||
"caption": "Edit file",
|
||||
"onExecute": alertClicked,
|
||||
"allowOnMultiple": false,
|
||||
"type": "popup"
|
||||
},
|
||||
{
|
||||
"id": "file_compress",
|
||||
"iconUrl": "imgs/compress.png",
|
||||
"caption": "Create ZIP archive",
|
||||
"onExecute": alertClicked,
|
||||
"type": "popup",
|
||||
"group": 1,
|
||||
"order": 1
|
||||
},
|
||||
{
|
||||
"id": "file_email",
|
||||
"iconUrl": "imgs/email.png",
|
||||
"caption": "E-Mail",
|
||||
"onExecute": alertClicked,
|
||||
"allowOnMultiple": false,
|
||||
"type": "popup",
|
||||
"group": 1,
|
||||
"order": 0
|
||||
},
|
||||
{
|
||||
"id": "file_compress_email",
|
||||
"caption": "Create ZIP and E-Mail",
|
||||
"onExecute": alertClicked,
|
||||
"type": "popup",
|
||||
"group": 1,
|
||||
"order": 2
|
||||
}
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
objectManager = new egwActionObjectManager("", actionManager);
|
||||
|
||||
grid = new egwGrid(document.getElementById("container"),
|
||||
[
|
||||
{
|
||||
"caption": "Name",
|
||||
"width": "50%"
|
||||
},
|
||||
{
|
||||
"id": "size",
|
||||
"caption": "Size"
|
||||
},
|
||||
{
|
||||
"id": "rights",
|
||||
"caption": "<a href=\"http://www.google.de/\">UNIX Filerights</a>",
|
||||
"default": "---------"
|
||||
},
|
||||
{
|
||||
"id": "mime",
|
||||
"caption": "File-Type/MIME with very long column header caption"
|
||||
},
|
||||
{
|
||||
"id": "atime",
|
||||
"caption": "atime",
|
||||
"width": "40px"
|
||||
},
|
||||
{
|
||||
"id": "ctime",
|
||||
"caption": "ctime",
|
||||
"width": "40px"
|
||||
},
|
||||
{
|
||||
"id": "mtime",
|
||||
"caption": "mtime",
|
||||
"width": "40px"
|
||||
},
|
||||
{
|
||||
"id": "owner",
|
||||
"caption": "owner",
|
||||
"width": "40px"
|
||||
},
|
||||
{
|
||||
"id": "group",
|
||||
"caption": "group",
|
||||
"width": "40px"
|
||||
}
|
||||
]
|
||||
);
|
||||
|
||||
var listboxFolderLinks = [
|
||||
{"actionId": "folder_open", "enabled": true},
|
||||
{"actionId": "file_compress_email", "enabled": true},
|
||||
{"actionId": "file_compress", "enabled": true},
|
||||
{"actionId": "file_delete", "enabled": true}
|
||||
];
|
||||
|
||||
var info =
|
||||
{
|
||||
"size": "16KiB",
|
||||
"mime": "Directory"
|
||||
}
|
||||
|
||||
grid.beginUpdate();
|
||||
function recurse_add(item, obj, depth)
|
||||
{
|
||||
for (var i = 1; i <= 20; i++)
|
||||
{
|
||||
var id = "file" + i;
|
||||
var it = item.addItem(id, "Test" + i, "imgs/mime16_directory.png", info);
|
||||
var _obj = obj.addObject(id, it.getAOI());
|
||||
_obj.updateActionLinks(listboxFolderLinks);
|
||||
if (depth < 0)
|
||||
recurse_add(it, _obj, depth + 1);
|
||||
}
|
||||
}
|
||||
recurse_add(grid, objectManager, 0);
|
||||
grid.endUpdate();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,322 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>Grid Test</title>
|
||||
|
||||
<!-- Basic action stuff -->
|
||||
<script src="js/jquery.js"></script>
|
||||
|
||||
<script src="../egw_action.js"></script>
|
||||
<script src="../egw_action_common.js"></script>
|
||||
|
||||
<!-- Popup stuff -->
|
||||
<script src="../egw_action_popup.js"></script>
|
||||
<script src="../egw_menu.js"></script>
|
||||
<script src="../egw_menu_dhtmlx.js"></script>
|
||||
<script src="js/dhtmlxcommon.js"></script>
|
||||
<script src="js/dhtmlxmenu.js"></script>
|
||||
<script src="js/dhtmlxmenu_ext.js"></script>
|
||||
|
||||
<!-- Grid stuff -->
|
||||
<script src="../egw_grid_view.js"></script>
|
||||
<script src="../egw_grid_columns.js"></script>
|
||||
<script src="../egw_grid_data.js"></script>
|
||||
<script src="../egw_grid.js"></script>
|
||||
<script src="../egw_stylesheet.js"></script>
|
||||
|
||||
<link rel="stylesheet" href="grid.css"/>
|
||||
<link rel="stylesheet" href="skins/dhtmlxmenu_egw.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Test for dynamically displaying and loading grid lines</h1>
|
||||
<b>Simulates network trafic by using window.setTimeout(), 100ms network latency</b>
|
||||
<button onclick="buildGrid();">Leak</button>
|
||||
<button onclick="clean();">Clean</button>
|
||||
<div id="container"></div>
|
||||
<script>
|
||||
var grid = null;
|
||||
var actionManager = null;
|
||||
var objectManager = null;
|
||||
|
||||
var columns =
|
||||
[
|
||||
{
|
||||
"id": "check",
|
||||
"type": EGW_COL_TYPE_CHECKBOX
|
||||
},
|
||||
{
|
||||
"id": "name",
|
||||
"caption": "Name",
|
||||
"type": EGW_COL_TYPE_NAME_ICON_FIXED,
|
||||
"sortable": EGW_COL_SORTABLE_EXTERNAL,
|
||||
"sortmode": EGW_COL_SORTMODE_ASC
|
||||
},
|
||||
{
|
||||
"id": "size",
|
||||
"maxWidth": 100,
|
||||
"caption": "Size"
|
||||
},
|
||||
{
|
||||
"id": "rights",
|
||||
"caption": "UNIX Filerights",
|
||||
"maxWidth": 150,
|
||||
"visibility": EGW_COL_VISIBILITY_INVISIBLE
|
||||
},
|
||||
{
|
||||
"id": "mime",
|
||||
"caption": "File-Type/MIME",
|
||||
"maxWidth": 150,
|
||||
"visibility": EGW_COL_VISIBILITY_INVISIBLE
|
||||
},
|
||||
{
|
||||
"id": "atime",
|
||||
"caption": "atime",
|
||||
"width": "15%",
|
||||
"visibility": EGW_COL_VISIBILITY_INVISIBLE
|
||||
},
|
||||
{
|
||||
"id": "ctime",
|
||||
"caption": "ctime",
|
||||
"width": "15%",
|
||||
"visibility": EGW_COL_VISIBILITY_INVISIBLE
|
||||
},
|
||||
{
|
||||
"id": "mtime",
|
||||
"caption": "mtime",
|
||||
"width": "15%",
|
||||
"visibility": EGW_COL_VISIBILITY_INVISIBLE
|
||||
},
|
||||
{
|
||||
"id": "owner",
|
||||
"caption": "owner",
|
||||
"width": "10%",
|
||||
"visibility": EGW_COL_VISIBILITY_INVISIBLE
|
||||
},
|
||||
{
|
||||
"id": "group",
|
||||
"caption": "group",
|
||||
"width": "10%",
|
||||
"visibility": EGW_COL_VISIBILITY_INVISIBLE
|
||||
}
|
||||
];
|
||||
|
||||
var actions =
|
||||
[
|
||||
{
|
||||
"id": "folder_open",
|
||||
"iconUrl": "imgs/folder.png",
|
||||
"caption": "Open folder",
|
||||
"onExecute": alertClicked,
|
||||
"allowOnMultiple": false,
|
||||
"type": "popup",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"id": "file_view",
|
||||
"iconUrl": "imgs/view.png",
|
||||
"caption": "View",
|
||||
"onExecute": alertClicked,
|
||||
"allowOnMultiple": false,
|
||||
"type": "popup",
|
||||
},
|
||||
{
|
||||
"id": "file_preview",
|
||||
"iconUrl": "imgs/preview.png",
|
||||
"caption": "Preview",
|
||||
"onExecute": alertClicked,
|
||||
"allowOnMultiple": false,
|
||||
"type": "popup",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"id": "file_delete",
|
||||
"iconUrl": "imgs/delete.png",
|
||||
"caption": "Delete",
|
||||
"onExecute": alertClicked,
|
||||
"type": "popup",
|
||||
"group": 2
|
||||
},
|
||||
{
|
||||
"id": "file_edit",
|
||||
"iconUrl": "imgs/edit.png",
|
||||
"caption": "Edit file",
|
||||
"onExecute": alertClicked,
|
||||
"allowOnMultiple": false,
|
||||
"type": "popup"
|
||||
},
|
||||
{
|
||||
"id": "file_compress",
|
||||
"iconUrl": "imgs/compress.png",
|
||||
"caption": "Create ZIP archive",
|
||||
"onExecute": alertClicked,
|
||||
"type": "popup",
|
||||
"group": 1,
|
||||
"order": 1
|
||||
},
|
||||
{
|
||||
"id": "file_email",
|
||||
"iconUrl": "imgs/email.png",
|
||||
"caption": "E-Mail",
|
||||
"onExecute": alertClicked,
|
||||
"allowOnMultiple": false,
|
||||
"type": "popup",
|
||||
"group": 1,
|
||||
"order": 0
|
||||
},
|
||||
{
|
||||
"id": "file_compress_email",
|
||||
"caption": "Create ZIP and E-Mail",
|
||||
"onExecute": alertClicked,
|
||||
"type": "popup",
|
||||
"group": 1,
|
||||
"order": 2
|
||||
}
|
||||
];
|
||||
|
||||
var listboxFolderLinks = [
|
||||
{"actionId": "folder_open", "enabled": true},
|
||||
{"actionId": "file_compress_email", "enabled": true},
|
||||
{"actionId": "file_compress", "enabled": true},
|
||||
{"actionId": "file_delete", "enabled": true}
|
||||
];
|
||||
|
||||
function fetchDataProc(_elems, _columns, _callback, _context)
|
||||
{
|
||||
// Delay the result a bit to simulate real network traffic
|
||||
window.setTimeout(function() {
|
||||
var result = [];
|
||||
for (var i = 0; i < _elems.length; i++)
|
||||
{
|
||||
// console.log(_elems[i]);
|
||||
if (_elems[i].substr(0, "[CHILDREN]".length) == "[CHILDREN]")
|
||||
{
|
||||
var id = _elems[i].substr("[CHILDREN]".length);
|
||||
var children = [
|
||||
{
|
||||
"entryType": EGW_DATA_TYPE_RANGE,
|
||||
"prefix": id + "_child_",
|
||||
"canHaveChildren": true,
|
||||
"count": 20
|
||||
}
|
||||
];
|
||||
|
||||
result.push({
|
||||
"id": id,
|
||||
"children": children,
|
||||
"opened": true
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var data = {};
|
||||
|
||||
data["size"] = Math.floor(Math.random() * 1024) + "KiB";
|
||||
data["rights"] = "rwxr-xr--";
|
||||
data["mime"] = "image/png";
|
||||
data["atime"] = (new Date).toUTCString();
|
||||
data["mtime"] = (new Date).toUTCString();
|
||||
data["ctime"] = (new Date).toUTCString();
|
||||
data["owner"] = "as";
|
||||
data["group"] = "stylitedevs";
|
||||
|
||||
result.push({
|
||||
"id": _elems[i],
|
||||
"data": data,
|
||||
"caption": _elems[i],
|
||||
"iconUrl": "imgs/folder.png",
|
||||
"group": "folder"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
_callback.call(_context, result);
|
||||
}, 100);
|
||||
}
|
||||
|
||||
function clean() {
|
||||
$j("#container").children().remove();
|
||||
actionManager = null;
|
||||
objectManager = null;
|
||||
grid = null;
|
||||
}
|
||||
|
||||
function buildGrid() {
|
||||
clean();
|
||||
|
||||
var cnt = $j(document.createElement("div"));
|
||||
$j("#container").append(cnt);
|
||||
|
||||
actionManager = new egwActionManager();
|
||||
actionManager.updateActions(actions);
|
||||
|
||||
objectManager = new egwActionObjectManager("", actionManager);
|
||||
|
||||
grid = new egwGrid(cnt, columns, objectManager, fetchDataProc,
|
||||
null, window);
|
||||
grid.setActionLinkGroup("folder", listboxFolderLinks);
|
||||
grid.dataRoot.loadData(
|
||||
[
|
||||
{
|
||||
"entryType": EGW_DATA_TYPE_RANGE,
|
||||
"prefix": "root_elem_",
|
||||
"canHaveChildren": true,
|
||||
"count": 1000
|
||||
}
|
||||
]
|
||||
);
|
||||
grid.resize(1000, 500);
|
||||
grid.reload();
|
||||
}
|
||||
|
||||
$j(document).ready(function() {
|
||||
buildGrid();
|
||||
});
|
||||
|
||||
function check_positions(_grid, _delta)
|
||||
{
|
||||
var outer = grid.gridOuter.grid;
|
||||
|
||||
if (typeof _grid == "undefined")
|
||||
{
|
||||
_grid = outer;
|
||||
}
|
||||
|
||||
if (typeof _delta == "undefined")
|
||||
{
|
||||
_delta = 0;
|
||||
}
|
||||
|
||||
|
||||
var g = _grid;
|
||||
var delta = outer.scrollarea.scrollTop() - outer.scrollarea.offset().top;
|
||||
for (var i = 0; i < g.children.length; i++)
|
||||
{
|
||||
var rtop = g.children[i].parentNode.offset().top + delta;
|
||||
var itop = g.children[i].position + _delta;
|
||||
|
||||
var rheight = g.children[i].parentNode.outerHeight();
|
||||
var iheight = g.children[i].getHeight();
|
||||
|
||||
console.log(Math.round(itop - rtop), Math.round(iheight - rheight), g.children[i].visible);
|
||||
|
||||
if (g.children[i].containerClass == "grid" && g.children[i].visible)
|
||||
{
|
||||
console.log("-->");
|
||||
check_positions(g.children[i], itop);
|
||||
console.log("<--");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function alertClicked(_action, _senders)
|
||||
{
|
||||
var ids = "";
|
||||
for (var i = 0; i < _senders.length; i++)
|
||||
ids += _senders[i].id + ((i < _senders.length - 1) ? ", " : "");
|
||||
|
||||
alert("Action '" + _action.caption + "' executed on elements '"
|
||||
+ ids + "'");
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user