2020-02-10 15:00:48 +01:00
"use strict" ;
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
* /
2020-02-10 15:00:48 +01:00
var _ _extends = ( this && this . _ _extends ) || ( function ( ) {
var extendStatics = function ( d , b ) {
extendStatics = Object . setPrototypeOf ||
( { _ _proto _ _ : [ ] } instanceof Array && function ( d , b ) { d . _ _proto _ _ = b ; } ) ||
function ( d , b ) { for ( var p in b ) if ( b . hasOwnProperty ( p ) ) d [ p ] = b [ p ] ; } ;
return extendStatics ( d , b ) ;
} ;
return function ( d , b ) {
extendStatics ( d , b ) ;
function _ _ ( ) { this . constructor = d ; }
d . prototype = b === null ? Object . create ( b ) : ( _ _ . prototype = b . prototype , new _ _ ( ) ) ;
} ;
} ) ( ) ;
Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
2011-09-09 10:29:31 +02:00
/ * e g w : u s e s
2020-02-10 15:00:48 +01:00
/ v e n d o r / b o w e r - a s s e t / j q u e r y / d i s t / j q u e r y . j s ;
et2 _core _interfaces ;
et2 _core _valueWidget ;
2011-09-09 10:29:31 +02:00
* /
2020-02-10 15:00:48 +01:00
var et2 _core _widget _1 = require ( "./et2_core_widget" ) ;
var et2 _core _valueWidget _1 = require ( "./et2_core_valueWidget" ) ;
var et2 _core _inheritance _1 = require ( "./et2_core_inheritance" ) ;
2011-09-09 10:29:31 +02:00
/ * *
2013-04-13 21:00:13 +02:00
* Class which implements the "progress" XET - Tag
2014-02-03 10:54:45 +01:00
*
2013-04-13 21:00:13 +02:00
* @ augments et2 _valueWidget
2014-02-03 10:54:45 +01:00
* /
2020-02-10 15:00:48 +01:00
var et2 _progress = /** @class */ ( function ( _super ) {
_ _extends ( et2 _progress , _super ) ;
/ * *
* Constructor
*
* @ memberOf et2 _progress
* /
function et2 _progress ( _parent , _attrs , _child ) {
var _this =
// Call the inherited constructor
_super . call ( this , _parent , _attrs , et2 _core _inheritance _1 . ClassWithAttributes . extendAttributes ( et2 _progress . _attributes , _child || { } ) ) || this ;
_this . progress = null ;
var outer = document . createElement ( "div" ) ;
outer . className = "et2_progress" ;
_this . progress = document . createElement ( "div" ) ;
_this . progress . style . width = "0" ;
outer . appendChild ( _this . progress ) ;
if ( _this . options . href ) {
outer . className += ' et2_clickable' ;
}
if ( _this . options [ "class" ] ) {
outer . className += ' ' + _this . options [ "class" ] ;
}
_this . setDOMNode ( outer ) ; // set's this.node = outer
return _this ;
}
et2 _progress . prototype . click = function ( e ) {
_super . prototype . click . call ( this , e ) ;
if ( this . options . href ) {
this . egw ( ) . open _link ( this . options . href , this . options . extra _link _target , this . options . extra _link _popup ) ;
}
} ;
// setting the value as width of the progress-bar
et2 _progress . prototype . set _value = function ( _value ) {
2021-05-19 21:54:56 +02:00
_super . prototype . set _value . call ( this , _value ) ;
2020-02-10 15:00:48 +01:00
_value = parseInt ( _value ) + "%" ; // make sure we have percent attached
this . progress . style . width = _value ;
if ( ! this . options . label )
this . set _label ( _value ) ;
} ;
// set's label as title of this.node
et2 _progress . prototype . set _label = function ( _value ) {
this . node . title = _value ;
} ;
// set's class of this.node; preserve baseclasses et2_progress and if this.options.href is set et2_clickable
et2 _progress . prototype . set _class = function ( _value ) {
var baseClass = "et2_progress" ;
if ( this . options . href ) {
baseClass += ' et2_clickable' ;
}
this . node . setAttribute ( 'class' , baseClass + ' ' + _value ) ;
} ;
et2 _progress . prototype . set _href = function ( _value ) {
if ( ! this . isInTree ( ) ) {
return false ;
}
this . options . href = _value ;
if ( _value ) {
jQuery ( this . node ) . addClass ( 'et2_clickable' )
. wrapAll ( '<a href="' + _value + '"></a>"' ) ;
var href _1 = this . options . href ;
var popup _1 = this . options . extra _link _popup ;
var target _1 = this . options . extra _link _target ;
jQuery ( this . node ) . parent ( ) . click ( function ( e ) {
egw . open _link ( href _1 , target _1 , popup _1 ) ;
e . preventDefault ( ) ;
return false ;
} ) ;
}
else if ( jQuery ( this . node ) . parent ( 'a' ) . length ) {
jQuery ( this . node ) . removeClass ( 'et2_clickable' )
. unwrap ( ) ;
}
return true ;
} ;
/ * *
* Implementation of "et2_IDetachedDOM" for fast viewing in gridview
*
* * @ param { array } _attrs array to add further attributes to
* /
et2 _progress . prototype . getDetachedAttributes = function ( _attrs ) {
_attrs . push ( "value" , "label" , "href" ) ;
} ;
et2 _progress . prototype . getDetachedNodes = function ( ) {
return [ this . node , this . progress ] ;
} ;
et2 _progress . prototype . setDetachedAttributes = function ( _nodes , _values ) {
// Set the given DOM-Nodes
this . node = _nodes [ 0 ] ;
this . progress = _nodes [ 1 ] ;
// Set the attributes
if ( _values [ "label" ] ) {
this . set _label ( _values [ "label" ] ) ;
}
if ( _values [ "value" ] ) {
this . set _value ( _values [ "value" ] ) ;
}
else if ( _values [ "label" ] ) {
this . set _value ( _values [ "label" ] ) ;
}
if ( _values [ "href" ] ) {
jQuery ( this . node ) . addClass ( 'et2_clickable' ) ;
this . set _href ( _values [ "href" ] ) ;
}
} ;
et2 _progress . _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" : {
"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
}
} ;
2020-03-30 18:28:48 +02:00
et2 _progress . legacyOptions = [ "href" , "extra_link_target" , "imagemap" , "extra_link_popup" , "id" ] ;
2020-02-10 15:00:48 +01:00
return et2 _progress ;
} ( et2 _core _valueWidget _1 . et2 _valueWidget ) ) ;
et2 _core _widget _1 . et2 _register _widget ( et2 _progress , [ "progress" ] ) ;
//# sourceMappingURL=et2_widget_progress.js.map