2011-09-09 10:29:31 +02:00
/ * *
* EGroupware eTemplate2 - JS Progrss object
*
* @ license http : //opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @ package etemplate
* @ subpackage api
* @ link http : //www.egroupware.org
* @ author Ralf Becker
* @ version $Id$
* /
"use strict" ;
/ * e g w : u s e s
jquery . jquery ;
et2 _core _interfaces ;
2011-09-09 14:17:16 +02:00
et2 _core _valueWidget ;
2011-09-09 10:29:31 +02:00
* /
/ * *
* Class which implements the "image" XET - Tag
* /
2011-09-09 14:17:16 +02:00
var et2 _progress = et2 _valueWidget . extend ( et2 _IDetachedDOM ,
{
2011-09-09 10:29:31 +02:00
attributes : {
"href" : {
"name" : "Link Target" ,
"type" : "string" ,
"description" : "Link URL, empty if you don't wan't to display a link."
} ,
"extra_link_target" : {
"name" : "Link target" ,
"type" : "string" ,
"default" : "_self" ,
"description" : "Link target descriptor"
} ,
"extra_link_popup" : {
"name" : "Popup" ,
"type" : "string" ,
"description" : "widthxheight, if popup should be used, eg. 640x480"
} ,
"label" : {
2011-09-28 01:44:07 +02:00
"name" : "Label" ,
"default" : "" ,
"type" : "string" ,
"description" : "The label is displayed as the title. 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
} ,
"onchange" : {
"name" : "onchange" ,
"type" : "js" ,
"description" : "JS code which is executed when the value changes."
2011-09-09 10:29:31 +02:00
}
} ,
legacyOptions : [ "href" , "extra_link_target" , "imagemap" , "extra_link_popup" , "id" ] ,
init : function ( )
{
this . _super . apply ( this , arguments ) ;
2011-09-09 14:17:16 +02:00
var outer = document . createElement ( "div" ) ;
outer . className = "et2_progress" ;
this . progress = document . createElement ( "div" ) ;
this . progress . style . width = "0" ;
outer . appendChild ( this . progress ) ;
2011-09-09 10:29:31 +02:00
if ( this . options . href )
{
2011-09-09 14:17:16 +02:00
outer . className += ' et2_clickable' ;
2011-09-09 10:29:31 +02:00
}
if ( this . options [ "class" ] )
{
2011-09-09 14:17:16 +02:00
outer . className += ' ' + this . options [ "class" ] ;
2011-09-09 10:29:31 +02:00
}
2011-09-09 14:17:16 +02:00
this . setDOMNode ( outer ) ; // set's this.node = outer
2011-09-09 10:29:31 +02:00
} ,
click : function ( )
{
2011-09-09 14:17:16 +02:00
this . _super . apply ( this , arguments ) ;
2011-09-09 10:29:31 +02:00
if ( this . options . href )
{
egw . call _link ( this . options . href , this . options . extra _link _target , this . options . extra _link _popup ) ;
2011-09-09 14:17:16 +02:00
}
2011-09-09 10:29:31 +02:00
} ,
2011-09-09 14:17:16 +02:00
// setting the value as width of the progress-bar
2011-09-09 10:29:31 +02:00
set _value : function ( _value )
{
2011-09-09 14:17:16 +02:00
_value = parseInt ( _value ) + "%" ; // make sure we have percent attached
this . progress . style . width = _value ;
2011-09-09 10:29:31 +02:00
if ( ! this . options . label ) this . set _label ( _value ) ;
} ,
// set's label as title of this.node
set _label : function ( _value )
{
2011-09-09 14:17:16 +02:00
this . node . title = _value ;
} ,
2011-09-09 10:29:31 +02:00
/ * *
* Implementation of "et2_IDetachedDOM" for fast viewing in gridview
* /
2011-09-09 14:17:16 +02:00
2011-09-09 10:29:31 +02:00
getDetachedAttributes : function ( _attrs ) {
2011-09-09 14:17:16 +02:00
_attrs . push ( "value" , "label" ) ;
2011-09-09 10:29:31 +02:00
} ,
getDetachedNodes : function ( ) {
2011-10-24 19:37:53 +02:00
return [ this . node ] ;
2011-09-09 10:29:31 +02:00
} ,
setDetachedAttributes : function ( _nodes , _values ) {
// Set the given DOM-Nodes
2011-09-09 14:17:16 +02:00
this . node = _nodes [ 0 ] ;
2011-09-09 10:29:31 +02:00
// Set the attributes
if ( _values [ "label" ] )
{
this . set _label ( _values [ "label" ] ) ;
}
2011-09-09 14:17:16 +02:00
if ( _values [ "value" ] )
{
this . set _value ( _values [ "value" ] ) ;
}
}
2011-09-09 10:29:31 +02:00
} ) ;
et2 _register _widget ( et2 _progress , [ "progress" ] ) ;