@ -482,13 +482,44 @@ define([
'class' : 'fa fa-upload cp-toolbar-icon-import' ,
'class' : 'fa fa-upload cp-toolbar-icon-import' ,
title : Messages . importButtonTitle ,
title : Messages . importButtonTitle ,
} ) . append ( $ ( '<span>' , { 'class' : 'cp-toolbar-drawer-element' } ) . text ( Messages . importButton ) ) ;
} ) . append ( $ ( '<span>' , { 'class' : 'cp-toolbar-drawer-element' } ) . text ( Messages . importButton ) ) ;
if ( callback ) {
/ * i f ( d a t a . t y p e s ) {
// New import button in the toolbar
var importFunction = {
template : function ( ) {
UIElements . openTemplatePicker ( common , true ) ;
} ,
file : function ( cb ) {
importContent ( 'text/plain' , function ( content , file ) {
cb ( content , file ) ;
} , { accept : data ? data . accept : undefined } )
}
} ;
var toImport = [ ] ;
Object . keys ( data . types ) . forEach ( function ( importType ) {
if ( ! importFunction [ importType ] || ! data . types [ importType ] ) { return ; }
var option = h ( 'button' , importType ) ;
$ ( option ) . click ( function ( ) {
importFunction [ importType ] ( data . types [ importType ] ) ;
} ) ;
toImport . push ( options ) ;
} ) ;
button . click ( common . prepareFeedback ( type ) ) ;
if ( toImport . length === 1 ) {
button . click ( function ( ) { $ ( toImport [ 0 ] ) . click ( ) ; } ) ;
} else {
Cryptpad . alert ( h ( 'p.cp-import-container' , toImport ) ) ;
}
}
else if ( callback ) { * /
// Old import button, used in settings
button
button
. click ( common . prepareFeedback ( type ) )
. click ( common . prepareFeedback ( type ) )
. click ( importContent ( 'text/plain' , function ( content , file ) {
. click ( importContent ( 'text/plain' , function ( content , file ) {
callback ( content , file ) ;
callback ( content , file ) ;
} , { accept : data ? data . accept : undefined } ) ) ;
} , { accept : data ? data . accept : undefined } ) ) ;
}
//}
break ;
break ;
case 'upload' :
case 'upload' :
button = $ ( '<button>' , {
button = $ ( '<button>' , {
@ -520,6 +551,17 @@ define([
if ( data . accept ) { $input . attr ( 'accept' , data . accept ) ; }
if ( data . accept ) { $input . attr ( 'accept' , data . accept ) ; }
button . click ( function ( ) { $input . click ( ) ; } ) ;
button . click ( function ( ) { $input . click ( ) ; } ) ;
break ;
break ;
case 'importtemplate' :
button = $ ( '<button>' , {
'class' : 'fa fa-upload cp-toolbar-icon-import' ,
title : Messages . template _import ,
} ) . append ( $ ( '<span>' , { 'class' : 'cp-toolbar-drawer-element' } ) . text ( Messages . template _import ) ) ;
button
. click ( common . prepareFeedback ( type ) )
. click ( function ( ) {
UIElements . openTemplatePicker ( common , true ) ;
} ) ;
break ;
case 'template' :
case 'template' :
if ( ! AppConfig . enableTemplates ) { return ; }
if ( ! AppConfig . enableTemplates ) { return ; }
if ( ! common . isLoggedIn ( ) ) { return ; }
if ( ! common . isLoggedIn ( ) ) { return ; }
@ -584,7 +626,8 @@ define([
sframeChan . query ( 'Q_MOVE_TO_TRASH' , null , function ( err ) {
sframeChan . query ( 'Q_MOVE_TO_TRASH' , null , function ( err ) {
if ( err ) { return void callback ( err ) ; }
if ( err ) { return void callback ( err ) ; }
var cMsg = common . isLoggedIn ( ) ? Messages . movedToTrash : Messages . deleted ;
var cMsg = common . isLoggedIn ( ) ? Messages . movedToTrash : Messages . deleted ;
UI . alert ( cMsg , undefined , true ) ;
var msg = common . fixLinks ( $ ( '<div>' ) . html ( cMsg ) ) ;
UI . alert ( msg ) ;
callback ( ) ;
callback ( ) ;
return ;
return ;
} ) ;
} ) ;
@ -920,18 +963,7 @@ define([
h ( 'ul' , elements )
h ( 'ul' , elements )
] ) ;
] ) ;
var origin = common . getMetadataMgr ( ) . getPrivateData ( ) . origin || '' ;
common . fixLinks ( text ) ;
$ ( text ) . find ( 'a' ) . click ( function ( e ) {
e . preventDefault ( ) ;
e . stopPropagation ( ) ;
var href = $ ( this ) . attr ( 'href' ) ;
var absolute = /^https?:\/\//i ;
if ( ! absolute . test ( href ) ) {
if ( href . slice ( 0 , 1 ) !== '/' ) { href = '/' + href ; }
href = origin + href ;
}
common . openUnsafeURL ( href ) ;
} ) ;
var closeButton = h ( 'span.cp-help-close.fa.fa-window-close' ) ;
var closeButton = h ( 'span.cp-help-close.fa.fa-window-close' ) ;
var $toolbarButton = common . createButton ( '' , true , {
var $toolbarButton = common . createButton ( '' , true , {
@ -1422,50 +1454,51 @@ define([
tag : 'a' ,
tag : 'a' ,
attributes : {
attributes : {
'target' : '_blank' ,
'target' : '_blank' ,
'href' : origin + '/drive/'
'href' : origin + '/drive/' ,
'class' : 'fa fa-hdd-o'
} ,
} ,
content : Messages. login _accessDrive
content : h( 'span' , Messages. login _accessDrive )
} ) ;
} ) ;
}
}
// Add the change display name button if not in read only mode
// Add the change display name button if not in read only mode
if ( config . changeNameButtonCls && config . displayChangeName && ! AppConfig . disableProfile ) {
if ( config . changeNameButtonCls && config . displayChangeName && ! AppConfig . disableProfile ) {
options . push ( {
options . push ( {
tag : 'a' ,
tag : 'a' ,
attributes : { 'class' : config . changeNameButtonCls } ,
attributes : { 'class' : config . changeNameButtonCls + ' fa fa-user' } ,
content : Messages. user _rename
content : h( 'span' , Messages. user _rename )
} ) ;
} ) ;
}
}
if ( accountName && ! AppConfig . disableProfile ) {
if ( accountName && ! AppConfig . disableProfile ) {
options . push ( {
options . push ( {
tag : 'a' ,
tag : 'a' ,
attributes : { 'class' : 'cp-toolbar-menu-profile '} ,
attributes : { 'class' : 'cp-toolbar-menu-profile fa fa-user-circle '} ,
content : Messages. profileButton
content : h( 'span' , Messages. profileButton )
} ) ;
} ) ;
}
}
if ( padType !== 'settings' ) {
if ( padType !== 'settings' ) {
options . push ( {
options . push ( {
tag : 'a' ,
tag : 'a' ,
attributes : { 'class' : 'cp-toolbar-menu-settings '} ,
attributes : { 'class' : 'cp-toolbar-menu-settings fa fa-cog '} ,
content : Messages. settingsButton
content : h( 'span' , Messages. settingsButton )
} ) ;
} ) ;
}
}
// Add login or logout button depending on the current status
// Add login or logout button depending on the current status
if ( accountName ) {
if ( accountName ) {
options . push ( {
options . push ( {
tag : 'a' ,
tag : 'a' ,
attributes : { 'class' : 'cp-toolbar-menu-logout '} ,
attributes : { 'class' : 'cp-toolbar-menu-logout fa fa-sign-out '} ,
content : Messages. logoutButton
content : h( 'span' , Messages. logoutButton )
} ) ;
} ) ;
} else {
} else {
options . push ( {
options . push ( {
tag : 'a' ,
tag : 'a' ,
attributes : { 'class' : 'cp-toolbar-menu-login '} ,
attributes : { 'class' : 'cp-toolbar-menu-login fa fa-sign-in '} ,
content : Messages. login _login
content : h( 'span' , Messages. login _login )
} ) ;
} ) ;
options . push ( {
options . push ( {
tag : 'a' ,
tag : 'a' ,
attributes : { 'class' : 'cp-toolbar-menu-register '} ,
attributes : { 'class' : 'cp-toolbar-menu-register fa fa-user-plus '} ,
content : Messages. login _register
content : h( 'span' , Messages. login _register )
} ) ;
} ) ;
}
}
var $icon = $ ( '<span>' , { 'class' : 'fa fa-user-secret' } ) ;
var $icon = $ ( '<span>' , { 'class' : 'fa fa-user-secret' } ) ;
@ -1521,9 +1554,8 @@ define([
UIElements . displayAvatar ( Common , $avatar , url ,
UIElements . displayAvatar ( Common , $avatar , url ,
newName || Messages . anonymous , function ( $img ) {
newName || Messages . anonymous , function ( $img ) {
oldUrl = url ;
oldUrl = url ;
if ( $img ) {
$userAdmin . find ( '> button' ) . removeClass ( 'cp-avatar' ) ;
$userAdmin . find ( '> button' ) . addClass ( 'cp-avatar' ) ;
if ( $img ) { $userAdmin . find ( '> button' ) . addClass ( 'cp-avatar' ) ; }
}
loadingAvatar = false ;
loadingAvatar = false ;
} ) ;
} ) ;
return ;
return ;
@ -1742,7 +1774,7 @@ define([
sframeChan . event ( "EV_FILE_PICKER_OPEN" , types ) ;
sframeChan . event ( "EV_FILE_PICKER_OPEN" , types ) ;
} ;
} ;
UIElements . openTemplatePicker = function ( common ) {
UIElements . openTemplatePicker = function ( common , force ) {
var metadataMgr = common . getMetadataMgr ( ) ;
var metadataMgr = common . getMetadataMgr ( ) ;
var type = metadataMgr . getMetadataLazy ( ) . type ;
var type = metadataMgr . getMetadataLazy ( ) . type ;
var sframeChan = common . getSframeChannel ( ) ;
var sframeChan = common . getSframeChannel ( ) ;
@ -1782,10 +1814,13 @@ define([
if ( data ) {
if ( data ) {
common . openFilePicker ( pickerCfg ) ;
common . openFilePicker ( pickerCfg ) ;
focus = document . activeElement ;
focus = document . activeElement ;
if ( force ) { return void onConfirm ( true ) ; }
UI . confirm ( Messages . useTemplate , onConfirm , {
UI . confirm ( Messages . useTemplate , onConfirm , {
ok : Messages . useTemplateOK ,
ok : Messages . useTemplateOK ,
cancel : Messages . useTemplateCancel ,
cancel : Messages . useTemplateCancel ,
} ) ;
} ) ;
} else if ( force ) {
UI . alert ( Messages . template _empty ) ;
}
}
} ) ;
} ) ;
} ;
} ;