2011-08-16 14:31:18 +02:00
/ * *
2013-04-13 21:00:13 +02:00
* EGroupware eTemplate2 - JS widget class with value attribute and auto loading
2011-08-16 14:31:18 +02:00
*
* @ license http : //opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @ package etemplate
* @ subpackage api
* @ link http : //www.egroupware.org
* @ author Andreas Stöckel
* @ copyright Stylite 2011
* @ version $Id$
* /
2011-08-16 14:56:55 +02:00
"use strict" ;
2011-08-16 14:31:18 +02:00
/ * e g w : u s e s
jquery . jquery ;
2011-08-24 12:18:07 +02:00
et2 _core _baseWidget ;
2011-08-16 14:31:18 +02:00
* /
/ * *
* et2 _valueWidget is the base class for et2 _inputWidget - valueWidget introduces
* the "value" attribute and automatically loads it from the "content" array
* after loading from XML .
2013-04-13 21:00:13 +02:00
*
* @ augments et2 _baseWidget
2011-08-16 14:31:18 +02:00
* /
2013-04-13 21:00:13 +02:00
var et2 _valueWidget = et2 _baseWidget . extend (
{
2011-08-16 14:31:18 +02:00
attributes : {
2012-07-11 22:08:32 +02:00
"label" : {
"name" : "Label" ,
"default" : "" ,
"type" : "string" ,
"description" : "The label is displayed by default in front (for radiobuttons behind) each widget (if not empty). If you want to specify a different position, use a '%s' in the label, which gets replaced by the widget itself. Eg. '%s Name' to have the label Name behind a checkbox. The label can contain variables, as descript for name. If the label starts with a '@' it is replaced by the value of the content-array at this index (with the '@'-removed and after expanding the variables)." ,
"translate" : true
} ,
2011-08-16 14:31:18 +02:00
"value" : {
"name" : "Value" ,
"description" : "The value of the widget" ,
"type" : "string" ,
"default" : et2 _no _init
}
} ,
2013-04-13 21:00:13 +02:00
/ * *
*
*
* @ memberOf et2 _valueWidget
* @ param _attrs
* /
2011-08-21 17:22:00 +02:00
transformAttributes : function ( _attrs ) {
2011-08-23 17:27:34 +02:00
this . _super . apply ( this , arguments ) ;
2011-08-16 14:31:18 +02:00
2011-08-23 19:05:05 +02:00
if ( this . id )
2011-08-16 14:31:18 +02:00
{
// Set the value for this element
var contentMgr = this . getArrayMgr ( "content" ) ;
2011-08-19 18:00:44 +02:00
if ( contentMgr != null ) {
2011-09-08 20:36:09 +02:00
var val = contentMgr . getEntry ( this . id ) ;
2011-08-16 23:18:26 +02:00
if ( val !== null )
{
2011-08-19 18:00:44 +02:00
_attrs [ "value" ] = val ;
2011-08-16 23:18:26 +02:00
}
2011-08-16 14:31:18 +02:00
}
}
}
} ) ;