2020-02-06 16:47:08 +01:00
"use strict" ;
2011-08-16 15:12:39 +02:00
/ * *
2013-04-13 21:00:13 +02:00
* EGroupware eTemplate2 - JS widget class containing raw HTML
2011-08-16 15:12:39 +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
* /
2020-02-06 16:47:08 +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 } ) ;
2021-03-22 18:42:50 +01:00
exports . et2 _html = void 0 ;
2011-08-16 15:12:39 +02:00
/ * e g w : u s e s
2020-02-06 16:47:08 +01:00
jsapi . jsapi ; // Needed for egw_seperateJavaScript
/ 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 _baseWidget ;
2011-08-16 15:12:39 +02:00
* /
2020-02-06 16:47:08 +01:00
var et2 _core _valueWidget _1 = require ( "./et2_core_valueWidget" ) ;
var et2 _core _widget _1 = require ( "./et2_core_widget" ) ;
var et2 _core _inheritance _1 = require ( "./et2_core_inheritance" ) ;
2013-04-13 21:00:13 +02:00
/ * *
* @ augments et2 _valueWidget
* /
2020-02-06 16:47:08 +01:00
var et2 _html = /** @class */ ( function ( _super ) {
_ _extends ( et2 _html , _super ) ;
/ * *
* Constructor
*
* @ memberOf et2 _html
* /
function et2 _html ( _parent , _attrs , _child ) {
var _this =
// Call the inherited constructor
_super . call ( this , _parent , _attrs , et2 _core _inheritance _1 . ClassWithAttributes . extendAttributes ( et2 _html . _attributes , _child || { } ) ) || this ;
_this . htmlNode = null ;
// Allow no child widgets
_this . supportedWidgetClasses = [ ] ;
_this . htmlNode = jQuery ( document . createElement ( "span" ) ) ;
if ( _this . getType ( ) == 'htmlarea' ) {
_this . htmlNode . addClass ( 'et2_textbox_ro' ) ;
}
if ( _this . options . label ) {
_this . htmlNode . append ( '<span class="et2_label">' + _this . options . label + '</span>' ) ;
}
_this . setDOMNode ( _this . htmlNode [ 0 ] ) ;
return _this ;
}
et2 _html . prototype . loadContent = function ( _data ) {
// Create an object containg the given value and an empty js string
var html = { html : _data ? _data : '' , js : '' } ;
// Seperate the javascript from the given html. The js code will be
// written to the previously created empty js string
egw _seperateJavaScript ( html ) ;
// Append the html to the parent element
if ( this . options . label ) {
this . htmlNode . append ( '<span class="et2_label">' + this . options . label + '</span>' ) ;
}
this . htmlNode . append ( html . html ) ;
this . htmlNode . append ( html . js ) ;
} ;
et2 _html . prototype . set _value = function ( _value ) {
this . htmlNode . empty ( ) ;
this . loadContent ( _value ) ;
} ;
/ * *
* Code for implementing et2 _IDetachedDOM
*
* @ param { array } _attrs
* /
et2 _html . prototype . getDetachedAttributes = function ( _attrs ) {
_attrs . push ( "value" , "class" ) ;
} ;
et2 _html . prototype . getDetachedNodes = function ( ) {
return [ this . htmlNode [ 0 ] ] ;
} ;
et2 _html . prototype . setDetachedAttributes = function ( _nodes , _values ) {
this . htmlNode = jQuery ( _nodes [ 0 ] ) ;
if ( typeof _values [ 'value' ] !== 'undefined' ) {
this . set _value ( _values [ 'value' ] ) ;
}
} ;
et2 _html . _attributes = {
'label' : {
'default' : "" ,
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)." ,
ignore : false ,
name : "Label" ,
translate : true ,
type : "string"
} ,
"needed" : {
"ignore" : true
} ,
value : {
name : "Value" ,
description : "The value of the widget" ,
type : "html" ,
default : et2 _no _init
}
} ;
return et2 _html ;
} ( et2 _core _valueWidget _1 . et2 _valueWidget ) ) ;
2020-10-09 14:57:03 +02:00
exports . et2 _html = et2 _html ;
2020-02-06 16:47:08 +01:00
et2 _core _widget _1 . et2 _register _widget ( et2 _html , [ "html" , "htmlarea_ro" ] ) ;
//# sourceMappingURL=et2_widget_html.js.map