2020-02-07 17:41:51 +01:00
"use strict" ;
2012-03-26 21:46:51 +02:00
/ * *
2013-04-13 21:00:13 +02:00
* EGroupware eTemplate2 - JS VFS widgets
2012-03-26 21:46:51 +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 Nathan Gray
* @ copyright Nathan Gray 2012
2019-03-21 12:36:07 +01:00
* /
2020-02-07 17:41:51 +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 } ) ;
2012-03-26 21:46:51 +02:00
/ * e g w : u s e s
2020-02-07 17:41:51 +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 ;
vfsSelectUI ;
et2 _core _inputWidget ;
et2 _core _valueWidget ;
et2 _widget _description ;
et2 _widget _file ;
expose ;
2012-03-26 21:46:51 +02:00
* /
2020-02-07 17:41:51 +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" ) ;
var egw _action _js _1 = require ( "../egw_action/egw_action.js" ) ;
var egw _keymanager _js _1 = require ( "../egw_action/egw_keymanager.js" ) ;
var et2 _widget _textbox _1 = require ( "./et2_widget_textbox" ) ;
var et2 _widget _description _1 = require ( "./et2_widget_description" ) ;
var et2 _widget _selectAccount _1 = require ( "./et2_widget_selectAccount" ) ;
var et2 _widget _file _1 = require ( "./et2_widget_file" ) ;
var et2 _widget _dialog _1 = require ( "./et2_widget_dialog" ) ;
var et2 _core _inputWidget _1 = require ( "./et2_core_inputWidget" ) ;
2012-03-26 21:46:51 +02:00
/ * *
* Class which implements the "vfs" XET - Tag
2014-02-10 19:25:02 +01:00
*
2013-04-13 21:00:13 +02:00
* @ augments et2 _valueWidget
2012-03-26 21:46:51 +02:00
* /
2020-02-07 17:41:51 +01:00
var et2 _vfs = /** @class */ ( function ( _super ) {
_ _extends ( et2 _vfs , _super ) ;
/ * *
* Constructor
*
* @ memberOf et2 _vfs
* /
function et2 _vfs ( _parent , _attrs , _child ) {
var _this =
// Call the inherited constructor
_super . call ( this , _parent , _attrs , et2 _core _inheritance _1 . ClassWithAttributes . extendAttributes ( et2 _vfs . _attributes , _child || { } ) ) || this ;
_this . span = null ;
_this . value = "" ;
_this . span = jQuery ( document . createElement ( "ul" ) )
. addClass ( 'et2_vfs' ) ;
_this . setDOMNode ( _this . span [ 0 ] ) ;
return _this ;
}
et2 _vfs . prototype . getValue = function ( ) {
return this . value ;
} ;
et2 _vfs . prototype . set _value = function ( _value ) {
if ( typeof _value !== 'object' ) {
// Only warn if it's an actual value, just blank for falsy values
if ( _value ) {
this . egw ( ) . debug ( "warn" , "%s only has path, needs full array" , this . id , _value ) ;
}
this . span . empty ( ) . text ( _value ) ;
return ;
}
this . span . empty ( ) ;
this . value = _value ;
var path = _value . path ? _value . path : '/' ;
// calculate path as parent of name, which can contain slashes
// eg. _value.path=/home/ralf/sub/file, _value.name=sub/file --> path=/home/ralf
// --> generate clickable fields for sub/ + file
var sub _path = path . substring ( 0 , _value . path . length - _value . name . length - 1 ) ;
var path _offset , path _parts ;
if ( _value . path . indexOf ( _value . name ) >= 0 && sub _path [ sub _path . length - 1 ] === '/' ) {
path = sub _path ;
path _offset = path . split ( '/' ) . length ;
path _parts = _value . path . split ( '/' ) ;
}
else {
if ( _value . path . indexOf ( _value . name ) >= 0 ) {
// Remove name from end, so we can add it again later
path = sub _path ;
}
path _offset = 0 ;
path _parts = _value . name . split ( '/' ) ;
}
var text ;
var _loop _1 = function ( i ) {
path += ( path == '/' ? '' : '/' ) + path _parts [ i ] ;
text = egw . decodePath ( path _parts [ i ] ) ;
// Nice human-readable stuff for apps
if ( path _parts [ 1 ] == 'apps' ) {
switch ( path _parts . length ) {
case 2 :
if ( i == 1 ) {
text = this _1 . egw ( ) . lang ( 'applications' ) ;
}
break ;
case 3 :
if ( i == 2 ) {
text = this _1 . egw ( ) . lang ( path _parts [ 2 ] ) ;
}
break ;
case 4 :
if ( ! isNaN ( text ) ) {
var link _title = this _1 . egw ( ) . link _title ( path _parts [ 2 ] , path _parts [ 3 ] , function ( title ) {
if ( ! title || this . value . name == title )
return ;
jQuery ( 'li' , this . span ) . last ( ) . text ( title ) ;
} , this _1 ) ;
if ( link _title && typeof link _title !== 'undefined' )
text = link _title ;
}
break ;
}
}
var self _1 = this _1 ;
data = { path : path , type : i < path _parts . length - 1 ? et2 _vfs . DIR _MIME _TYPE : _value . mime } ;
node = jQuery ( document . createElement ( "li" ) )
. addClass ( "vfsFilename" )
. text ( text + ( i < path _parts . length - 1 ? '/' : '' ) )
//.attr('title', egw.decodePath(path))
. addClass ( "et2_clickable et2_link" )
. click ( { data : data , egw : this _1 . egw ( ) } , function ( e ) {
if ( ! self _1 . onclick ) {
e . data . egw . open ( e . data . data , "file" ) ;
}
else if ( self _1 . click ( e ) ) {
e . data . egw . open ( e . data . data , "file" ) ;
}
} )
. appendTo ( this _1 . span ) ;
} ;
var this _1 = this , data , node ;
for ( var i = path _offset ; i < path _parts . length ; i ++ ) {
_loop _1 ( i ) ;
}
// Last part of path do default action
this . _bind _default _action ( node , data ) ;
} ;
et2 _vfs . prototype . _bind _default _action = function ( node , data ) {
var links = [ ] ;
var widget = this ;
var defaultAction = null ;
var object = null ;
var app = this . getInstanceManager ( ) . app ;
while ( links . length === 0 && widget . getParent ( ) ) {
object = egw _action _js _1 . egw _getAppObjectManager ( app ) . getObjectById ( widget . id ) ;
if ( object && object . manager && object . manager . children ) {
links = object . manager . children ;
}
widget = widget . getParent ( ) ;
}
for ( var k in links ) {
if ( links [ k ] . default && links [ k ] . enabled . exec ( links [ k ] ) ) {
defaultAction = links [ k ] ;
break ;
}
}
if ( defaultAction && ! this . onclick ) {
node . off ( 'click' ) . click ( { data : data , egw : this . egw ( ) } , function ( e ) {
// Wait until object selection happens
window . setTimeout ( function ( ) {
// execute default action
egw _keymanager _js _1 . egw _keyHandler ( EGW _KEY _ENTER , false , false , false ) ;
} ) ;
// Select row
return true ;
} . bind ( { data : data , object : object } ) ) ;
}
} ;
/ * *
* Code for implementing et2 _IDetachedDOM ( data grid )
*
* @ param { array } _attrs array of attribute - names to push further names onto
* /
et2 _vfs . prototype . getDetachedAttributes = function ( _attrs ) {
_attrs . push ( "value" ) ;
} ;
et2 _vfs . prototype . getDetachedNodes = function ( ) {
return [ this . span [ 0 ] ] ;
} ;
et2 _vfs . prototype . setDetachedAttributes = function ( _nodes , _values ) {
this . span = jQuery ( _nodes [ 0 ] ) ;
if ( typeof _values [ "value" ] != 'undefined' ) {
this . set _value ( _values [ "value" ] ) ;
}
} ;
et2 _vfs . _attributes = {
"value" : {
"type" : "any" ,
"description" : "Array of (stat) information about the file"
}
} ;
/ * *
* Mime type of directories
* /
et2 _vfs . DIR _MIME _TYPE = 'httpd/unix-directory' ;
return et2 _vfs ;
} ( et2 _core _valueWidget _1 . et2 _valueWidget ) ) ;
et2 _core _widget _1 . et2 _register _widget ( et2 _vfs , [ "vfs" ] ) ;
2012-03-27 01:30:27 +02:00
/ * *
2020-02-07 17:41:51 +01:00
* vfs - name
* filename automatically urlencoded on return ( urldecoded on display to user )
*
* @ augments et2 _textbox
* /
var et2 _vfsName = /** @class */ ( function ( _super ) {
_ _extends ( et2 _vfsName , _super ) ;
/ * *
* Constructor
*
* @ memberOf et2 _vfsName
* /
function et2 _vfsName ( _parent , _attrs , _child ) {
var _this =
// Call the inherited constructor
_super . call ( this , _parent , _attrs , et2 _core _inheritance _1 . ClassWithAttributes . extendAttributes ( et2 _vfsName . _attributes , _child || { } ) ) || this ;
_this . input . addClass ( "et2_vfs" ) ;
return _this ;
}
et2 _vfsName . prototype . set _value = function ( _value ) {
if ( _value . path ) {
_value = _value . path ;
}
try {
_value = egw . decodePath ( _value ) ;
}
catch ( e ) {
_value = 'Error! ' + _value ;
}
_super . prototype . set _value . call ( this , _value ) ;
} ;
et2 _vfsName . prototype . getValue = function ( ) {
return egw . encodePath ( _super . prototype . getValue . call ( this ) || '' ) ;
} ;
return et2 _vfsName ;
} ( et2 _widget _textbox _1 . et2 _textbox ) ) ;
et2 _core _widget _1 . et2 _register _widget ( et2 _vfsName , [ "vfs-name" ] ) ;
2019-01-07 23:04:50 +01:00
/ * *
2020-02-07 17:41:51 +01:00
* vfs - name
* filename automatically urlencoded on return ( urldecoded on display to user )
*
* @ augments et2 _textbox
* /
var et2 _vfsPath = /** @class */ ( function ( _super ) {
_ _extends ( et2 _vfsPath , _super ) ;
/ * *
* Constructor
*
* @ memberOf et2 _vfsName
* /
function et2 _vfsPath ( _parent , _attrs , _child ) {
// Call the inherited constructor
return _super . call ( this , _parent , _attrs , et2 _core _inheritance _1 . ClassWithAttributes . extendAttributes ( et2 _vfsPath . _attributes , _child || { } ) ) || this ;
}
et2 _vfsPath . prototype . createInputWidget = function ( ) {
_super . prototype . createInputWidget . call ( this ) ;
this . div = jQuery ( document . createElement ( "div" ) )
. addClass ( 'et2_vfsPath' ) ;
this . span = jQuery ( document . createElement ( "ul" ) )
. appendTo ( this . div ) ;
this . div . prepend ( this . input ) ;
this . setDOMNode ( this . div [ 0 ] ) ;
this . span . on ( 'wheel' , function ( e ) {
var delta = e . originalEvent [ "deltaY" ] > 0 ? 30 : - 30 ;
this . scrollLeft = this . scrollLeft - delta ;
} ) ;
this . span . on ( 'mouseover' , function ( e ) {
if ( this . scrollWidth > this . clientWidth ) {
jQuery ( this ) . addClass ( 'scrollable' ) ;
}
else {
jQuery ( this ) . removeClass ( 'scrollable' ) ;
}
} ) ;
this . input . on ( 'focus' , function ( ) {
this . input . val ( this . options . value ) ;
this . span . hide ( ) ;
} . bind ( this ) )
. on ( 'focusout' , function ( ) {
// Can't use show() because it uses the wrong display
this . span . css ( 'display' , 'flex' ) ;
this . input . val ( '' ) ;
} . bind ( this ) ) ;
} ;
et2 _vfsPath . prototype . change = function ( _node ) {
if ( this . input . val ( ) ) {
this . set _value ( this . input . val ( ) ) ;
}
return _super . prototype . change . call ( this , _node ) ;
} ;
et2 _vfsPath . prototype . set _value = function ( _value ) {
if ( _value . path ) {
_value = _value . path ;
}
if ( _value === this . options . value && this . _oldValue !== et2 _no _init )
return ;
var path _parts = _value . split ( '/' ) ;
if ( _value === '/' )
path _parts = [ '' ] ;
var path = "/" ;
var text = '' ;
if ( this . span )
this . span . empty ( ) . css ( 'display' , 'flex' ) ;
this . input . val ( '' ) ;
var _loop _2 = function ( i ) {
path += ( path == '/' ? '' : '/' ) + path _parts [ i ] ;
text = egw . decodePath ( path _parts [ i ] ) ;
var image = path == '/' ? this _2 . egw ( ) . image ( 'navbar' , 'api' ) : this _2 . egw ( ) . image ( text ) ;
// Nice human-readable stuff for apps
if ( path _parts [ 1 ] == 'apps' ) {
if ( i === 1 ) {
text = this _2 . egw ( ) . lang ( 'applications' ) ;
}
else if ( i === 2 ) {
text = this _2 . egw ( ) . lang ( path _parts [ 2 ] ) ;
image = this _2 . egw ( ) . image ( 'navbar' , path _parts [ 2 ] . toLowerCase ( ) ) ;
}
else if ( ! isNaN ( text ) ) {
var link _title = this _2 . egw ( ) . link _title ( path _parts [ 2 ] , path _parts [ 3 ] , function ( title ) {
if ( ! title )
return ;
jQuery ( 'li' , this . span ) . first ( ) . text ( title ) ;
} , this _2 ) ;
if ( link _title && typeof link _title !== 'undefined' )
text = link _title ;
}
}
var self _2 = this _2 ;
var node = jQuery ( document . createElement ( "li" ) )
. addClass ( "vfsPath et2_clickable" )
. text ( text )
//.attr('title', egw.decodePath(path))
. click ( { data : path , egw : this _2 . egw ( ) } , function ( e ) {
return self _2 . set _value ( e . data . data ) ;
} )
. prependTo ( this _2 . span ) ;
if ( image && ! this _2 . options . noicon ) {
node . prepend ( this _2 . egw ( ) . image _element ( image ) ) ;
}
jQuery ( this _2 . getDOMNode ( ) ) . append ( this _2 . span ) ;
} ;
var this _2 = this ;
for ( var i = 0 ; i < path _parts . length ; i ++ ) {
_loop _2 ( i ) ;
}
if ( this . isAttached ( ) && this . options . value !== _value ) {
this . _oldValue = this . options . value ;
this . options . value = _value ;
this . change ( ) ;
}
} ;
et2 _vfsPath . prototype . getValue = function ( ) {
return this . options ? this . options . value : null ;
} ;
et2 _vfsPath . _attributes = {
noicon : {
type : "boolean" ,
description : "suppress folder icons" ,
default : true
}
} ;
return et2 _vfsPath ;
} ( et2 _vfsName ) ) ;
et2 _core _widget _1 . et2 _register _widget ( et2 _vfsPath , [ "vfs-path" ] ) ;
2013-04-12 11:39:37 +02:00
/ * *
2020-02-07 17:41:51 +01:00
* vfs - name
* filename automatically urlencoded on return ( urldecoded on display to user )
*
* @ augments et2 _textbox _ro
* /
var et2 _vfsName _ro = /** @class */ ( function ( _super ) {
_ _extends ( et2 _vfsName _ro , _super ) ;
/ * *
* Constructor
*
* @ memberOf et2 _vfsName _ro
* /
/ * *
* Constructor
* /
function et2 _vfsName _ro ( _parent , _attrs , _child ) {
// Call the inherited constructor
return _super . call ( this , _parent , _attrs , et2 _core _inheritance _1 . ClassWithAttributes . extendAttributes ( et2 _vfsName _ro . _attributes , _child || { } ) ) || this ;
}
et2 _vfsName _ro . prototype . set _value = function ( _value ) {
if ( _value . path ) {
_value = _value . path ;
}
try {
_value = egw . decodePath ( _value ) ;
}
catch ( e ) {
_value = 'Error! ' + _value ;
}
_super . prototype . set _value . call ( this , _value ) ;
} ;
et2 _vfsName _ro . prototype . getValue = function ( ) {
return egw . encodePath ( _super . prototype . getValue . call ( this ) || '' ) ;
} ;
return et2 _vfsName _ro ;
} ( et2 _widget _textbox _1 . et2 _textbox _ro ) ) ;
et2 _core _widget _1 . et2 _register _widget ( et2 _vfsName _ro , [ "vfs-name_ro" ] ) ;
2012-03-28 01:32:32 +02:00
/ * *
2020-02-07 17:41:51 +01:00
* vfs - mime : icon for mimetype of file , or thumbnail
* incl . optional link overlay icon , if file is a symlink
*
* Creates following structure
* < span class = "iconOverlayContainer" >
* < img class = "et2_vfs vfsMimeIcon" src = "..." / >
* < span class = "overlayContainer" >
* < img class = "overlay" src = "etemplate/templates/default/images/link.png" / >
* < / s p a n >
* < / s p a n >
*
* span . overlayContainer is optional and only generated for symlinks
* @ todo implement mixin Expose class
* @ augments et2 _valueWidget
* /
var et2 _vfsMime = /** @class */ ( function ( _super ) {
_ _extends ( et2 _vfsMime , _super ) ;
/ * *
* Constructor
*
* @ memberOf et2 _vfsMime
* /
function et2 _vfsMime ( _parent , _attrs , _child ) {
var _this =
// Call the inherited constructor
_super . call ( this , _parent , _attrs , et2 _core _inheritance _1 . ClassWithAttributes . extendAttributes ( et2 _vfsMime . _attributes , _child || { } ) ) || this ;
_this . legacyOptions = [ "size" ] ;
_this . iconOverlayContainer = null ;
_this . image = null ;
_this . iconOverlayContainer = jQuery ( document . createElement ( 'span' ) ) . addClass ( 'iconOverlayContainer' ) ;
_this . image = jQuery ( document . createElement ( "img" ) ) ;
_this . image . addClass ( "et2_vfs vfsMimeIcon" ) ;
_this . iconOverlayContainer . append ( _this . image ) ;
_this . setDOMNode ( _this . iconOverlayContainer [ 0 ] ) ;
return _this ;
}
/ * *
* Handler for expose slide action , from expose
* Returns data needed for the given index , or false to let expose handle it
*
* @ param { Gallery } gallery
* @ param { integer } index
* @ param { DOMNode } slide
* @ return { Array } array of objects consist of media contnet
* /
et2 _vfsMime . prototype . expose _onslide = function ( gallery , index , slide ) {
var content = false ;
if ( this . options . expose _callback && typeof this . options . expose _callback == 'function' ) {
//Call the callback to load more items
content = this . options . expose _callback . call ( this , [ gallery , index ] ) ;
if ( content )
this . add ( content ) ;
}
return content ;
} ;
/ * *
* Function to get media content to feed the expose
*
* @ param { type } _value
* @ returns { Array } return an array of object consists of media content
* /
et2 _vfsMime . prototype . getMedia = function ( _value ) {
var base _url = egw . webserverUrl . match ( /^\/ig/ ) ? egw ( window ) . window . location . origin + egw . webserverUrl : egw . webserverUrl ;
var mediaContent = [ {
title : _value . name ,
type : _value . mime ,
href : _value . download _url
} ] ;
// check if download_url is not already an url (some stream-wrappers allow to specify that!)
if ( _value . download _url && ( _value . download _url [ 0 ] == '/' || _value . download _url . substr ( 0 , 4 ) != 'http' ) ) {
mediaContent [ 0 ] . href = base _url + _value . download _url ;
if ( mediaContent [ 0 ] . href && mediaContent [ 0 ] . href . match ( /\/webdav.php/ , 'ig' ) ) {
mediaContent [ 0 ] [ "download_href" ] = mediaContent [ 0 ] . href + '?download' ;
}
}
if ( _value && _value . mime && _value . mime . match ( /video\// , 'ig' ) ) {
mediaContent [ 0 ] [ "thumbnail" ] = this . egw ( ) . mime _icon ( _value . mime , _value . path , undefined , _value . mtime ) ;
}
else {
mediaContent [ 0 ] [ "thumbnail" ] = _value . path && _value . mime ?
this . egw ( ) . mime _icon ( _value . mime , _value . path , undefined , _value . mtime ) :
this . image . attr ( 'src' ) + '&thheight=128' ;
}
return mediaContent ;
} ;
et2 _vfsMime . prototype . set _value = function ( _value ) {
if ( typeof _value !== 'object' ) {
this . egw ( ) . debug ( "warn" , "%s only has path, needs array with path & mime" , this . id , _value ) ;
// Keep going, will be 'unknown type'
}
var src = this . egw ( ) . mime _icon ( _value . mime , _value . path , undefined , _value . mtime ) ;
if ( src ) {
// Set size of thumbnail
if ( src . indexOf ( "thumbnail.php" ) > - 1 ) {
if ( this . options . size ) {
src += "&thsize=" + this . options . size ;
}
else if ( this . options . thumb _mime _size ) {
var mime _size = this . options . thumb _mime _size . split ( ',' ) ;
var mime _regex = RegExp ( _value . mime . split ( '/' ) [ 0 ] ) ;
if ( typeof mime _size != 'undefined' && jQuery . isArray ( mime _size )
&& ! isNaN ( mime _size [ mime _size . length - 1 ] ) && isNaN ( mime _size [ 0 ] ) && this . options . thumb _mime _size . match ( mime _regex [ 0 ] , 'ig' ) ) {
src += "&thsize=" + mime _size [ mime _size . length - 1 ] ;
}
}
this . image . css ( "max-width" , "100%" ) ;
}
this . image . attr ( "src" , src ) ;
// tooltip for mimetypes with available detailed thumbnail
if ( _value . mime && _value . mime . match ( /application\/vnd\.oasis\.opendocument\.(text|presentation|spreadsheet|chart)/ ) ) {
var tooltip _target = this . image . parent ( ) . parent ( ) . parent ( ) . length > 0 ?
// Nextmatch row
this . image . parent ( ) . parent ( ) . parent ( ) :
// Not in nextmatch
this . image . parent ( ) ;
tooltip _target . tooltip ( {
items : "img" ,
position : { my : "right top" , at : "left top" , collision : "flipfit" } ,
content : function ( ) {
return '<img src="' + this . src + '&thsize=512"/>' ;
}
} ) ;
}
}
// add/remove link icon, if file is (not) a symlink
if ( ( _value . mode & et2 _vfsMode . types . l ) == et2 _vfsMode . types . l ) {
if ( typeof this . overlayContainer == 'undefined' ) {
this . overlayContainer = jQuery ( document . createElement ( 'span' ) ) . addClass ( 'overlayContainer' ) ;
this . overlayContainer . append ( jQuery ( document . createElement ( 'img' ) )
. addClass ( 'overlay' ) . attr ( 'src' , this . egw ( ) . image ( 'link' , 'etemplate' ) ) ) ;
this . iconOverlayContainer . append ( this . overlayContainer ) ;
}
}
else if ( typeof this . overlayContainer != 'undefined' ) {
this . overlayContainer . remove ( ) ;
delete this . overlayContainer ;
}
} ;
/ * *
* Implementation of "et2_IDetachedDOM" for fast viewing in gridview
* Override to add needed attributes
*
* @ param { array } _attrs array of attribute - names to push further names onto
* /
et2 _vfsMime . prototype . getDetachedAttributes = function ( _attrs ) {
_attrs . push ( "value" , "class" ) ;
} ;
et2 _vfsMime . prototype . getDetachedNodes = function ( ) {
return [ this . node , this . iconOverlayContainer [ 0 ] , this . image [ 0 ] ] ;
} ;
et2 _vfsMime . prototype . setDetachedAttributes = function ( _nodes , _values ) {
this . iconOverlayContainer = jQuery ( _nodes [ 1 ] ) ;
this . image = jQuery ( _nodes [ 2 ] ) ;
this . node = _nodes [ 0 ] ;
this . overlayContainer = _nodes [ 0 ] . children [ 1 ] ;
if ( typeof _values [ 'class' ] != "undefined" ) {
this . image . addClass ( _values [ 'class' ] ) ;
}
if ( typeof _values [ 'value' ] != "undefined" ) {
this . set _value ( _values [ 'value' ] ) ;
}
} ;
et2 _vfsMime . _attributes = {
"value" : {
"type" : "any" ,
"description" : "Array of (stat) information about the file"
} ,
"size" : {
"name" : "Icon size" ,
"type" : "integer" ,
"description" : "Size of icon / thumbnail, in pixels" ,
"default" : et2 _no _init
} ,
"expose_callback" : {
"name" : "expose_callback" ,
"type" : "js" ,
"default" : et2 _no _init ,
"description" : "JS code which is executed when expose slides."
} ,
expose _view : {
name : "Expose view" ,
type : "boolean" ,
default : true ,
description : "Clicking on an image would popup an expose view"
} ,
thumb _mime _size : {
name : "Image thumbnail size" ,
type : "string" ,
default : "" ,
description : " Size of thumbnail in pixel for specified mime type with syntax of: mime_type(s),size (eg. image,video,128)"
}
} ;
return et2 _vfsMime ;
} ( et2 _core _valueWidget _1 . et2 _valueWidget ) ) ;
et2 _core _widget _1 . et2 _register _widget ( et2 _vfsMime , [ "vfs-mime" ] ) ;
2012-03-27 01:30:27 +02:00
/ * *
2020-02-07 17:41:51 +01:00
* vfs - size
* Human readable file sizes
*
* @ augments et2 _description
* /
var et2 _vfsSize = /** @class */ ( function ( _super ) {
_ _extends ( et2 _vfsSize , _super ) ;
/ * *
* Constructor
*
* @ memberOf et2 _vfsSize
* /
function et2 _vfsSize ( _parent , _attrs , _child ) {
var _this =
// Call the inherited constructor
_super . call ( this , _parent , _attrs , et2 _core _inheritance _1 . ClassWithAttributes . extendAttributes ( et2 _vfsSize . _attributes , _child || { } ) ) || this ;
_this . span . addClass ( "et2_vfs" ) ;
return _this ;
}
et2 _vfsSize . prototype . human _size = function ( size ) {
if ( typeof size !== "number" ) {
size = parseInt ( size ) ;
}
if ( ! size ) {
size = 0 ;
}
var units = [ 'B' , 'KB' , 'MB' , 'GB' , 'TB' , 'PB' , 'EB' , 'ZB' , 'YB' ] ;
var i = 0 ;
while ( size >= 1024 ) {
size /= 1024 ;
++ i ;
}
return size . toFixed ( i == 0 ? 0 : 1 ) + ' ' + units [ i ] ;
} ;
et2 _vfsSize . prototype . set _value = function ( _value ) {
if ( _value . size ) {
_value = _value . size ;
}
jQuery ( this . node ) . text ( this . human _size ( _value ) ) ;
} ;
et2 _vfsSize . prototype . setDetachedAttributes = function ( _nodes , _values ) {
if ( typeof _values [ "value" ] !== "undefined" ) {
this . node = _nodes [ 0 ] ;
this . set _value ( _values [ "value" ] ) ;
delete _values [ "value" ] ;
}
_super . prototype . setDetachedAttributes . call ( this , _nodes , _values ) ;
} ;
et2 _vfsSize . _attributes = {
"value" : {
"type" : "integer"
}
} ;
return et2 _vfsSize ;
} ( et2 _widget _description _1 . et2 _description ) ) ;
et2 _core _widget _1 . et2 _register _widget ( et2 _vfsSize , [ "vfs-size" ] ) ;
2012-03-27 01:30:27 +02:00
/ * *
2020-02-07 17:41:51 +01:00
* vfs - mode : textual representation of permissions + extra bits
*
* @ augments et2 _description
* /
var et2 _vfsMode = /** @class */ ( function ( _super ) {
_ _extends ( et2 _vfsMode , _super ) ;
/ * *
* Constructor
*
* @ memberOf et2 _vfsMode
* /
function et2 _vfsMode ( _parent , _attrs , _child ) {
var _this =
// Call the inherited constructor
_super . call ( this , _parent , _attrs , et2 _core _inheritance _1 . ClassWithAttributes . extendAttributes ( et2 _vfsMode . _attributes , _child || { } ) ) || this ;
_this . span . addClass ( "et2_vfs" ) ;
return _this ;
}
/ * *
* Get text for file stuff
* Result will be like - rwxr -- r -- . First char is type , then read , write , execute ( or other bits ) for
* user , group , world
*
* @ param { number } _value vfs mode
* /
et2 _vfsMode . prototype . text _mode = function ( _value ) {
var text = [ ] ;
if ( typeof _value != "number" ) {
_value = parseInt ( _value ) ;
}
if ( ! _value )
return "----------" ;
// Figure out type
var type = 'u' ; // unknown
for ( var flag in et2 _vfsMode . types ) {
if ( ( _value & et2 _vfsMode . types [ flag ] ) == et2 _vfsMode . types [ flag ] ) {
type = flag ;
break ;
}
}
// World, group, user - build string backwards
for ( var i = 0 ; i < 3 ; i ++ ) {
for ( var perm in et2 _vfsMode . perms ) {
if ( _value & et2 _vfsMode . perms [ perm ] ) {
text . unshift ( perm ) ;
}
else {
text . unshift ( "-" ) ;
}
}
_value = _value >> 3 ;
}
// Sticky / UID / GID
for ( var i = 0 ; i < et2 _vfsMode . sticky . length ; i ++ ) {
if ( et2 _vfsMode . sticky [ i ] . mask & _value ) {
var current = text [ et2 _vfsMode . sticky [ i ] . position ] ;
text [ et2 _vfsMode . sticky [ i ] . position ] = et2 _vfsMode . sticky [ i ] [ "char" ] ;
if ( current == 'x' )
text [ et2 _vfsMode . sticky [ i ] . position ] . toLowerCase ( ) ;
}
}
return type + text . join ( '' ) ;
} ;
et2 _vfsMode . prototype . set _value = function ( _value ) {
if ( _value . size ) {
_value = _value . size ;
}
var text = this . text _mode ( _value ) ;
jQuery ( this . node ) . text ( text ) ;
} ;
et2 _vfsMode . prototype . setDetachedAttributes = function ( _nodes , _values ) {
if ( typeof _values [ "value" ] !== "undefined" ) {
this . node = _nodes [ 0 ] ;
this . set _value ( _values [ "value" ] ) ;
delete _values [ "value" ] ;
}
_super . prototype . setDetachedAttributes . call ( this , _nodes , _values ) ;
} ;
// Masks for file types
et2 _vfsMode . types = {
'l' : 0xA000 ,
's' : 0xC000 ,
'p' : 0x1000 ,
'c' : 0x2000 ,
'd' : 0x4000 ,
'b' : 0x6000 ,
'-' : 0x8000 // Regular
} ;
// Sticky / UID / GID
et2 _vfsMode . sticky = [
{ mask : 0x200 , "char" : "T" , position : 9 } ,
{ mask : 0x400 , "char" : "S" , position : 6 } ,
{ mask : 0x800 , "char" : "S" , position : 3 } // SUID
] ;
et2 _vfsMode . perms = {
'x' : 0x1 ,
'w' : 0x2 ,
'r' : 0x4 // Read
} ;
return et2 _vfsMode ;
} ( et2 _widget _description _1 . et2 _description ) ) ;
et2 _core _widget _1 . et2 _register _widget ( et2 _vfsMode , [ "vfs-mode" ] ) ;
2012-03-27 01:30:27 +02:00
/ * *
2020-02-07 17:41:51 +01:00
* vfs - uid / vfs - gid : Displays the name for an ID .
* Same as read - only selectAccount , except if there ' s no user it shows "root"
*
* @ augments et2 _selectAccount _ro
* /
var et2 _vfsUid = /** @class */ ( function ( _super ) {
_ _extends ( et2 _vfsUid , _super ) ;
function et2 _vfsUid ( ) {
return _super !== null && _super . apply ( this , arguments ) || this ;
}
/ * *
* @ memberOf et2 _vfsUid
* @ param _node
* @ param _value
* /
et2 _vfsUid . prototype . set _title = function ( _node , _value ) {
if ( _value == "" ) {
arguments [ 1 ] = "root" ;
}
_super . prototype . set _title . call ( this , _node , _value ) ;
} ;
return et2 _vfsUid ;
} ( et2 _widget _selectAccount _1 . et2 _selectAccount _ro ) ) ;
et2 _core _widget _1 . et2 _register _widget ( et2 _vfsUid , [ "vfs-uid" , "vfs-gid" ] ) ;
2012-03-29 01:27:18 +02:00
/ * v f s - u p l o a d a k a V F S f i l e : d i s p l a y s e i t h e r d o w n l o a d a n d d e l e t e ( x ) l i n k s o r a f i l e u p l o a d
2020-02-07 17:41:51 +01:00
* + ID is either a vfs path or colon separated $app : $id : $relative _path , eg : infolog : 123 : special / offer
* + if empty ( $id ) / new entry , file is created in a hidden temporary directory in users home directory
* and calling app is responsible to move content of that dir to entry directory , after entry is saved
* + option : required mimetype or regular expression for mimetype to match , eg . '/^text\//i' for all text files
* + if path ends in a slash , multiple files can be uploaded , their original filename is kept then
*
* @ augments et2 _file
* /
var et2 _vfsUpload = /** @class */ ( function ( _super ) {
_ _extends ( et2 _vfsUpload , _super ) ;
/ * *
* Constructor
*
* @ param _parent
* @ param attrs
* @ memberof et2 _vfsUpload
* /
function et2 _vfsUpload ( _parent , _attrs , _child ) {
var _this =
// Call the inherited constructor
_super . call ( this , _parent , _attrs , et2 _core _inheritance _1 . ClassWithAttributes . extendAttributes ( et2 _vfsUpload . _attributes , _child || { } ) ) || this ;
_this . legacyOptions = [ "mime" ] ;
_this . asyncOptions = {
target : egw . ajaxUrl ( "EGroupware\\Api\\Etemplate\\Widget\\Vfs::ajax_upload" )
} ;
_this . list = null ;
jQuery ( _this . node ) . addClass ( "et2_vfs" ) ;
if ( ! _this . options . path ) {
_this . options . path = _this . options . id ;
}
// If the path is a directory, allow multiple uploads
if ( _this . options . path . substr ( - 1 ) == '/' ) {
_this . set _multiple ( true ) ;
}
_this . list = jQuery ( document . createElement ( 'table' ) ) . appendTo ( _this . node ) ;
return _this ;
}
/ * *
* If there is a file / files in the specified location , display them
* Value is the information for the file [ s ] in the specified location .
*
* @ param { Object [ ] } _value
* /
et2 _vfsUpload . prototype . set _value = function ( _value ) {
// Remove previous
while ( this . _children . length > 0 ) {
var node = this . _children [ this . _children . length - 1 ] ;
this . removeChild ( node ) ;
node . free ( ) ;
}
this . progress . empty ( ) ;
this . list . empty ( ) ;
// Set new
if ( typeof _value == 'object' && _value && _value . length ) {
for ( var i = 0 ; i < _value . length ; i ++ ) {
this . _addFile ( _value [ i ] ) ;
}
}
return true ;
} ;
et2 _vfsUpload . prototype . getDOMNode = function ( sender ) {
if ( sender !== this && sender . _type . indexOf ( 'vfs' ) >= 0 ) {
var value = sender . getValue && sender . getValue ( ) || sender . options . value || { } ;
var row = jQuery ( "[data-path='" + ( value . path . replace ( /'/g , '"' ) ) + "']" , this . list ) ;
if ( sender . _type === 'vfs-mime' ) {
return jQuery ( '.icon' , row ) . get ( 0 ) || null ;
}
else {
return jQuery ( '.title' , row ) . get ( 0 ) || null ;
}
}
else {
return _super . prototype . getDOMNode . call ( this , sender ) ;
}
} ;
/ * *
* Add in the request id
*
* @ param { type } form
* /
et2 _vfsUpload . prototype . beforeSend = function ( form ) {
var extra = _super . prototype . beforeSend . call ( this , form ) ;
extra [ "path" ] = this . options . path ;
return extra ;
} ;
/ * *
* A file upload is finished , update the UI
*
* @ param { object } file
* @ param { string | object } response
* /
et2 _vfsUpload . prototype . finishUpload = function ( file , response ) {
var result = _super . prototype . finishUpload . call ( this , file , response ) ;
if ( typeof response == 'string' )
response = jQuery . parseJSON ( response ) ;
if ( response . response [ 0 ] && typeof response . response [ 0 ] . data . length == 'undefined' ) {
for ( var key in response . response [ 0 ] . data ) {
var value = response . response [ 0 ] . data [ key ] ;
if ( value && value . path ) {
this . _addFile ( value ) ;
jQuery ( "[data-file='" + file . fileName . replace ( /'/g , '"' ) + "']" , this . progress ) . hide ( ) ;
}
}
}
return result ;
} ;
et2 _vfsUpload . prototype . _addFile = function ( file _data ) {
if ( jQuery ( "[data-path='" + file _data . path . replace ( /'/g , '"' ) + "']" ) . remove ( ) . length ) {
for ( var child _index = this . _children . length - 1 ; child _index >= 0 ; child _index -- ) {
var child = this . _children [ child _index ] ;
if ( child . options . value . path === file _data . path ) {
this . removeChild ( child ) ;
child . free ( ) ;
}
}
}
var row = jQuery ( document . createElement ( "tr" ) )
. attr ( "data-path" , file _data . path . replace ( /'/g , '"' ) )
. attr ( "draggable" , "true" )
. appendTo ( this . list ) ;
jQuery ( document . createElement ( "td" ) )
. addClass ( 'icon' )
. appendTo ( row ) ;
jQuery ( document . createElement ( "td" ) )
. addClass ( 'title' )
. appendTo ( row ) ;
var mime = et2 _core _widget _1 . et2 _createWidget ( 'vfs-mime' , { value : file _data } , this ) ;
var vfs = et2 _core _widget _1 . et2 _createWidget ( 'vfs' , { value : file _data } , this ) ;
// If already attached, need to do this explicitly
if ( this . isAttached ( ) ) {
mime . set _value ( file _data ) ;
vfs . set _value ( file _data ) ;
mime . doLoadingFinished ( ) ;
vfs . doLoadingFinished ( ) ;
}
// Add in delete button
if ( ! this . options . readonly ) {
var self _3 = this ;
var delete _button = jQuery ( document . createElement ( "td" ) )
. appendTo ( row ) ;
jQuery ( "<div />" )
. appendTo ( delete _button )
// We don't use ui-icon because it assigns a bg image
. addClass ( "delete icon" )
. bind ( 'click' , function ( ) {
et2 _core _widget _1 . et2 _createWidget ( "dialog" , {
callback : function ( button ) {
if ( button == et2 _widget _dialog _1 . et2 _dialog . YES _BUTTON ) {
egw . json ( "filemanager_ui::ajax_action" , [
'delete' ,
[ row . attr ( 'data-path' ) . replace ( /"/g , "'" ) ] ,
''
] , function ( data ) {
if ( data && data . errs == 0 ) {
row . slideUp ( null , row . remove ) ;
}
if ( data && data . msg ) {
self _3 . egw ( ) . message ( data . msg , data . errs == 0 ? 'success' : 'error' ) ;
}
} ) . sendRequest ( ) ;
}
} ,
message : self _3 . egw ( ) . lang ( 'Delete file' ) + '?' ,
title : self _3 . egw ( ) . lang ( 'Confirmation required' ) ,
buttons : et2 _widget _dialog _1 . et2 _dialog . BUTTONS _YES _NO ,
dialog _type : et2 _widget _dialog _1 . et2 _dialog . QUESTION _MESSAGE ,
width : 250
} , self _3 ) ;
} ) ;
}
} ;
et2 _vfsUpload . _attributes = {
"value" : {
"type" : "any" // Either nothing, or an object with file info
} ,
"path" : {
"name" : "Path" ,
"description" : "Upload files to the specified VFS path" ,
"type" : "string" ,
"default" : ''
}
} ;
return et2 _vfsUpload ;
} ( et2 _widget _file _1 . et2 _file ) ) ;
et2 _core _widget _1 . et2 _register _widget ( et2 _vfsUpload , [ "vfs-upload" ] ) ;
var et2 _vfsSelect = /** @class */ ( function ( _super ) {
_ _extends ( et2 _vfsSelect , _super ) ;
/ * *
* Constructor
*
* @ param _parent
* @ param _attrs
* @ memberOf et2 _vfsSelect
* /
function et2 _vfsSelect ( _parent , _attrs , _child ) {
var _this =
// Call the inherited constructor
_super . call ( this , _parent , _attrs , et2 _core _inheritance _1 . ClassWithAttributes . extendAttributes ( et2 _vfsSelect . _attributes , _child || { } ) ) || this ;
// Allowed mode options
_this . modes = [ 'open' , 'open-multiple' , 'saveas' , 'select-dir' ] ;
// Allow no child widgets
_this . supportedWidgetClasses = [ ] ;
_this . button = jQuery ( document . createElement ( "button" ) )
. attr ( "title" , _this . egw ( ) . lang ( "Select file(s) from VFS" ) )
. addClass ( "et2_button et2_vfs_btn" )
. css ( "background-image" , "url(" + _this . egw ( ) . image ( "filemanager/navbar" ) + ")" ) ;
if ( _this . options . readonly ) {
_this . button . hide ( ) ;
}
if ( _this . options . button _caption != "" ) {
_this . button . text ( _this . options . button _caption ) ;
}
_this . setDOMNode ( _this . button [ 0 ] ) ;
return _this ;
}
et2 _vfsSelect . prototype . _content = function ( _content , _callback ) {
egw ( window ) . loading _prompt ( 'vfs-select' , true , '' , 'body' ) ;
var self = this ;
if ( typeof app . vfsSelectUI != "undefined" ) {
if ( this . dialog && this . dialog . div )
this . dialog . div . dialog ( 'close' ) ;
delete app . vfsSelectUI ;
}
var attrs = {
mode : this . options . mode ,
label : this . options . button _label ,
path : this . options . path || null ,
mime : this . options . mime || null ,
name : this . options . name ,
method : this . options . method ,
recentPaths : et2 _vfsSelect . _getRecentPaths ( )
} ;
var callback = _callback || this . _buildDialog ;
egw ( window ) . json ( 'EGroupware\\Api\\Etemplate\\Widget\\Vfs::ajax_vfsSelect_content' , [ _content , attrs ] , function ( _content ) {
egw ( window ) . loading _prompt ( 'vfs-select' , false ) ;
callback . apply ( self , arguments ) ;
} ) . sendRequest ( true ) ;
} ;
/ * *
* Builds file navigator dialog
*
* @ param { object } _data content
* /
et2 _vfsSelect . prototype . _buildDialog = function ( _data ) {
if ( ! _data . content . mode . match ( /open|open-multiple|saveas|select-dir/ ) ) {
egw . debug ( 'warn' , 'Mode is not matched!' ) ;
return ;
}
var self = this ;
var buttons = [
{
text : egw . lang ( _data . content . label ) ,
id : "submit" ,
image : _data . content . mode . match ( /saveas|select-dir/ ) ? "save" : this . options . button _icon
}
] ;
var extra _buttons _action ;
if ( this . options . extra _buttons && this . options . method ) {
for ( var i = 0 ; i < this . options . extra _buttons . length ; i ++ ) {
delete ( this . options . extra _buttons [ i ] [ 'click' ] ) ;
buttons . push ( this . options . extra _buttons [ i ] ) ;
extra _buttons _action [ this . options . extra _buttons [ i ] [ 'id' ] ] = this . options . extra _buttons [ i ] [ 'id' ] ;
}
}
buttons . push ( { text : egw . lang ( "Close" ) , id : "close" , image : "cancel" } ) ;
var data = jQuery . extend ( _data , { 'currentapp' : egw ( window ) . app _name ( ) } ) ;
// define a mini app object for vfs select UI
app . vfsSelectUI = new app . classes . vfsSelectUI ;
// callback for dialog
this . submit _callback = function ( submit _button _id , submit _value , savemode ) {
if ( ( submit _button _id == 'submit' || ( extra _buttons _action && extra _buttons _action [ submit _button _id ] ) ) && submit _value ) {
var files = [ ] ;
switch ( _data . content . mode ) {
case 'open-multiple' :
if ( submit _value . dir && submit _value . dir . selected ) {
for ( var key in Object . keys ( submit _value . dir . selected ) ) {
if ( submit _value . dir . selected [ key ] != "" ) {
files . push ( submit _value . path + '/' + submit _value . dir . selected [ key ] ) ;
}
}
}
break ;
case 'select-dir' :
files = submit _value . path ;
break ;
default :
if ( self . options . method === 'download' )
submit _value . path = _data . content . download _baseUrl ;
files = submit _value . path + '/' + submit _value . name ;
if ( self . options . mode === 'saveas' && ! savemode ) {
for ( var p in _data . content . dir ) {
if ( _data . content . dir [ p ] [ 'name' ] == submit _value . name ) {
var saveModeDialogButtons = [
{ text : self . egw ( ) . lang ( "Yes" ) , id : "overwrite" , class : "ui-priority-primary" , "default" : true , image : 'check' } ,
{ text : self . egw ( ) . lang ( "Rename" ) , id : "rename" , image : 'edit' } ,
{ text : self . egw ( ) . lang ( "Cancel" ) , id : "cancel" }
] ;
return et2 _widget _dialog _1 . et2 _dialog . show _prompt ( function ( _button _id , _value ) {
switch ( _button _id ) {
case "overwrite" :
return self . submit _callback ( submit _button _id , submit _value , 'overwrite' ) ;
case "rename" :
submit _value . name = _value ;
return self . submit _callback ( submit _button _id , submit _value , 'rename' ) ;
}
} , self . egw ( ) . lang ( 'Do you want to overwrite existing file %1 in directory %2?' , submit _value . name , submit _value . path ) , self . egw ( ) . lang ( 'File %1 already exists' , submit _value . name ) , submit _value . name , saveModeDialogButtons , null ) ;
}
}
}
break ;
}
et2 _vfsSelect . _setRecentPaths ( submit _value . path ) ;
self . value = files ;
if ( self . options . method && self . options . method !== 'download' ) {
egw ( window ) . json ( self . options . method , [ self . options . method _id , files , submit _button _id , savemode ] , function ( ) {
jQuery ( self . node ) . change ( ) ;
} ) . sendRequest ( true ) ;
}
else {
jQuery ( self . node ) . change ( ) ;
}
delete app . vfsSelectUI ;
return true ;
}
} ;
this . dialog = et2 _core _widget _1 . et2 _createWidget ( "dialog" , {
callback : this . submit _callback ,
title : this . options . dialog _title ,
buttons : buttons ,
minWidth : 500 ,
minHeight : 400 ,
width : 400 ,
value : data ,
template : egw . webserverUrl + '/api/templates/default/vfsSelectUI.xet?1' ,
resizable : false
} , et2 _widget _dialog _1 . et2 _dialog . _create _parent ( 'api' ) ) ;
this . dialog . template . uniqueId = 'api.vfsSelectUI' ;
// Don't rely only on app_name to fetch et2 object as app_name may not
// always represent current app of the window, e.g.: mail admin account.
// Try to fetch et2 from its template name.
var etemplate = jQuery ( 'form' ) . data ( 'etemplate' ) ;
var et2 ;
if ( etemplate && etemplate . name && ! app [ egw ( window ) . app _name ( ) ] ) {
et2 = etemplate2 . getByTemplate ( etemplate . name ) [ 0 ] ;
}
else {
et2 = etemplate2 . getByApplication ( egw ( window ) . app _name ( ) ) [ 0 ] ;
}
// we need an etemplate_exec_id for better handling serverside parts of
// widgets and since we can not have a etemplate_exec_id specifically
// for dialog template our best shot is to inherit its parent etemplate_exec_id.
this . dialog . template . etemplate _exec _id = et2 . etemplate _exec _id ;
app . vfsSelectUI . et2 = this . dialog . template . widgetContainer ;
// Keep the dialog always at the top
this . dialog . div . parent ( ) . css ( { "z-index" : 100000 } ) ;
app . vfsSelectUI . vfsSelectWidget = this ;
this . dialog . div . on ( 'load' , function ( e ) {
app . vfsSelectUI . et2 _ready ( app . vfsSelectUI . et2 , 'api.vfsSelectUI' ) ;
} ) ;
} ;
/ * *
* Set recent path into sessionStorage
* @ param { string } _path
* /
et2 _vfsSelect . _setRecentPaths = function ( _path ) {
var recentPaths = egw . getSessionItem ( 'api' , 'vfsRecentPaths' ) ?
egw . getSessionItem ( 'api' , 'vfsRecentPaths' ) . split ( ',' ) : [ ] ;
if ( recentPaths . indexOf ( _path ) == - 1 )
recentPaths . push ( _path ) ;
egw . setSessionItem ( 'api' , 'vfsRecentPaths' , recentPaths ) ;
} ;
/ * *
* Get recent paths from sessionStorage
* @ returns { Array } returns an array of recent paths
* /
et2 _vfsSelect . _getRecentPaths = function ( ) {
return egw . getSessionItem ( 'api' , 'vfsRecentPaths' ) ?
egw . getSessionItem ( 'api' , 'vfsRecentPaths' ) . split ( ',' ) : [ ] ;
} ;
/ * *
* click handler
* @ param { event object } e
* /
et2 _vfsSelect . prototype . click = function ( e ) {
this . _content . call ( this , null ) ;
} ;
/ * *
* Set the dialog ' s mode .
* Valid options are in et2 _vfsSelect . modes
*
* @ param { string } mode 'open' , 'open-multiple' , 'saveas' or 'select-dir'
* /
et2 _vfsSelect . prototype . set _mode = function ( mode ) {
// Check mode
if ( jQuery . inArray ( mode , this . modes ) < 0 ) {
this . egw ( ) . debug ( "warn" , "Invalid mode for '%s': %s Valid options:" , this . id , mode , this . modes ) ;
return ;
}
this . options . mode = mode ;
} ;
/ * *
* Set the label on the dialog ' s OK button .
*
* @ param { string } label
* /
et2 _vfsSelect . prototype . set _button _label = function ( label ) {
this . options . button _label = label ;
} ;
/ * *
* Set the caption for vfs - select button
*
* @ param { string } caption string value as a caption
* /
et2 _vfsSelect . prototype . set _button _caption = function ( caption ) {
this . options . button _caption = caption ;
} ;
/ * *
* Set the ID passed to the server side callback
*
* @ param { string } id
* /
et2 _vfsSelect . prototype . set _method _id = function ( id ) {
this . options . method _id = id ;
} ;
et2 _vfsSelect . prototype . set _readonly = function ( readonly ) {
this . options . readonly = Boolean ( readonly ) ;
if ( this . options . readonly ) {
this . button . hide ( ) ;
}
else {
this . button . show ( ) ;
}
} ;
et2 _vfsSelect . prototype . set _value = function ( value ) {
this . value = value ;
} ;
et2 _vfsSelect . prototype . getValue = function ( ) {
return this . value ;
} ;
et2 _vfsSelect . _attributes = {
"mode" : {
name : "Dialog mode" ,
type : "string" ,
description : "One of {open|open-multiple|saveas|select-dir}" ,
default : "open-multiple"
} ,
"method" : {
name : "Server side callback" ,
type : "string" ,
description : " Server side callback to process selected value ( s ) in \ n \
app . class . method or class : : method format . The first parameter will \ n \
be Method ID , the second the file list . 'download' is reserved and it \ n \
means it should use download _baseUrl instead of path in value ( no method \ n \
will be actually executed ) . "
} ,
"method_id" : {
name : "Method ID" ,
type : "any" ,
description : " optional parameter passed to server side callback . \ n \
Can be a string or a function . " ,
default : ""
} ,
"path" : {
name : "Path" ,
type : "string" ,
description : "Start path in VFS. Leave unset to use the last used path."
} ,
"mime" : {
name : "Mime type" ,
type : "any" ,
description : "Limit display to the given mime-type"
} ,
"button_label" : {
name : "Button label" ,
description : "Set the label on the dialog's OK button." ,
default : "open"
} ,
"value" : {
type : "any" ,
description : "Array of paths (strings)"
} ,
"button_caption" : {
name : "button caption" ,
type : "string" ,
default : "Select files from Filemanager ..." ,
description : "Caption for vfs-select button." ,
translate : true
} ,
"button_icon" : {
name : "button icon" ,
type : "string" ,
default : "check" ,
description : "Custom icon to show on submit button."
} ,
"name" : {
name : "File name" ,
type : "any" ,
description : "file name" ,
default : ""
} ,
"dialog_title" : {
name : "dialog title" ,
type : "string" ,
default : "Save as" ,
description : "Title of dialog" ,
translate : true
} ,
"extra_buttons" : {
name : "extra action buttons" ,
type : "any" ,
description : "Extra buttons passed to dialog. It's co-related to method."
}
} ;
return et2 _vfsSelect ;
} ( et2 _core _inputWidget _1 . et2 _inputWidget ) ) ;
et2 _core _widget _1 . et2 _register _widget ( et2 _vfsSelect , [ "vfs-select" ] ) ;
//# sourceMappingURL=et2_widget_vfs.js.map