2011-08-29 17:04:10 +02:00
|
|
|
/**
|
2013-04-13 21:00:13 +02:00
|
|
|
* EGroupware eTemplate2 - Class which contains a factory method for rows
|
2011-08-29 17:04:10 +02:00
|
|
|
*
|
|
|
|
* @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;
|
2011-09-05 16:35:28 +02:00
|
|
|
et2_core_interfaces;
|
|
|
|
et2_core_arrayMgr;
|
|
|
|
et2_core_widget;
|
2011-08-29 17:04:10 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2014-03-20 10:40:37 +01:00
|
|
|
* The row provider contains prototypes (full clonable dom-trees)
|
2011-08-29 17:04:10 +02:00
|
|
|
* for all registered row types.
|
2014-03-20 10:40:37 +01:00
|
|
|
*
|
2013-04-13 21:00:13 +02:00
|
|
|
* @augments Class
|
2011-08-29 17:04:10 +02:00
|
|
|
*/
|
2016-02-29 21:40:43 +01:00
|
|
|
var et2_dataview_rowProvider = (function(){ "use strict"; return Class.extend(
|
2013-04-13 21:00:13 +02:00
|
|
|
{
|
|
|
|
/**
|
2014-03-20 10:40:37 +01:00
|
|
|
*
|
2013-04-13 21:00:13 +02:00
|
|
|
* @param _outerId
|
|
|
|
* @param _columnIds
|
|
|
|
* @memberOf et2_dataview_rowProvider
|
|
|
|
*/
|
2011-08-31 17:39:24 +02:00
|
|
|
init: function(_outerId, _columnIds) {
|
2011-08-29 17:04:10 +02:00
|
|
|
// Copy the given parameters
|
2011-08-31 17:39:24 +02:00
|
|
|
this._outerId = _outerId;
|
2011-08-29 17:04:10 +02:00
|
|
|
this._columnIds = _columnIds;
|
|
|
|
this._prototypes = {};
|
|
|
|
|
2011-09-06 18:50:38 +02:00
|
|
|
this._template = null;
|
2011-09-05 16:35:28 +02:00
|
|
|
this._mgrs = null;
|
|
|
|
this._rootWidget = null;
|
|
|
|
|
2011-08-29 17:04:10 +02:00
|
|
|
// Create the default row "prototypes"
|
|
|
|
this._createFullRowPrototype();
|
|
|
|
this._createDefaultPrototype();
|
2011-08-31 17:39:24 +02:00
|
|
|
this._createEmptyPrototype();
|
2012-03-23 13:20:57 +01:00
|
|
|
this._createLoadingPrototype();
|
|
|
|
},
|
|
|
|
|
|
|
|
getColumnCount: function() {
|
|
|
|
return this._columnIds.length;
|
2011-08-29 17:04:10 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
2014-03-20 10:40:37 +01:00
|
|
|
*
|
|
|
|
* @param {string} _name
|
|
|
|
* @param {function} _generator
|
|
|
|
* @param {object} _context
|
2011-08-29 17:04:10 +02:00
|
|
|
*/
|
|
|
|
getPrototype: function(_name, _generator, _context) {
|
|
|
|
if (typeof this._prototypes[_name] == "undefined")
|
|
|
|
{
|
|
|
|
if (typeof _generator != "undefined")
|
|
|
|
{
|
2011-08-31 17:39:24 +02:00
|
|
|
this._prototypes[_name] = _generator.call(_context, this._outerId,
|
|
|
|
this._columnIds);
|
2011-08-29 17:04:10 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return this._prototypes[_name].clone();
|
|
|
|
},
|
|
|
|
|
2011-09-05 16:35:28 +02:00
|
|
|
|
2011-08-29 17:04:10 +02:00
|
|
|
/* ---- PRIVATE FUNCTIONS ---- */
|
|
|
|
|
2012-03-23 13:20:57 +01:00
|
|
|
|
2011-08-29 17:04:10 +02:00
|
|
|
_createFullRowPrototype: function() {
|
|
|
|
var tr = $j(document.createElement("tr"));
|
|
|
|
var td = $j(document.createElement("td"))
|
2012-03-23 13:20:57 +01:00
|
|
|
.addClass(this._outerId + "_td_fullRow")
|
|
|
|
.attr("colspan", this._columnIds.length)
|
2011-08-29 17:04:10 +02:00
|
|
|
.appendTo(tr);
|
|
|
|
var div = $j(document.createElement("div"))
|
2011-08-31 17:39:24 +02:00
|
|
|
.addClass(this._outerId + "_div_fullRow")
|
2011-08-29 17:04:10 +02:00
|
|
|
.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"))
|
2011-08-31 17:39:24 +02:00
|
|
|
.addClass(this._outerId + "_td_" + this._columnIds[i])
|
2011-08-29 17:04:10 +02:00
|
|
|
.appendTo(tr);
|
|
|
|
var div = $j(document.createElement("div"))
|
2011-08-31 17:39:24 +02:00
|
|
|
.addClass(this._outerId + "_div_" + this._columnIds[i])
|
2011-09-01 12:02:23 +02:00
|
|
|
.addClass("innerContainer")
|
2011-08-29 17:04:10 +02:00
|
|
|
.appendTo(td);
|
|
|
|
}
|
|
|
|
|
|
|
|
this._prototypes["default"] = tr;
|
2011-08-31 17:39:24 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
_createEmptyPrototype: function() {
|
|
|
|
this._prototypes["empty"] = $j(document.createElement("tr"));
|
2011-09-06 18:50:38 +02:00
|
|
|
},
|
2011-09-05 16:35:28 +02:00
|
|
|
|
2012-03-23 13:20:57 +01:00
|
|
|
_createLoadingPrototype: function() {
|
|
|
|
var fullRow = this.getPrototype("fullRow");
|
|
|
|
$j("div", fullRow).addClass("loading");
|
2011-09-06 18:50:38 +02:00
|
|
|
|
2012-03-23 13:20:57 +01:00
|
|
|
this._prototypes["loading"] = fullRow;
|
2011-09-05 16:35:28 +02:00
|
|
|
}
|
|
|
|
|
2016-02-29 21:40:43 +01:00
|
|
|
});}).call(this);
|
2011-09-05 16:35:28 +02:00
|
|
|
|