@ -17,6 +17,7 @@ define([
var TOP _CLS = Bar . constants . top = 'cryptpad-toolbar-top' ;
var TOP _CLS = Bar . constants . top = 'cryptpad-toolbar-top' ;
var LEFTSIDE _CLS = Bar . constants . leftside = 'cryptpad-toolbar-leftside' ;
var LEFTSIDE _CLS = Bar . constants . leftside = 'cryptpad-toolbar-leftside' ;
var RIGHTSIDE _CLS = Bar . constants . rightside = 'cryptpad-toolbar-rightside' ;
var RIGHTSIDE _CLS = Bar . constants . rightside = 'cryptpad-toolbar-rightside' ;
var DRAWER _CLS = Bar . constants . drawer = 'drawer-content' ;
var HISTORY _CLS = Bar . constants . history = 'cryptpad-toolbar-history' ;
var HISTORY _CLS = Bar . constants . history = 'cryptpad-toolbar-history' ;
// Userlist
// Userlist
@ -81,7 +82,7 @@ define([
$ ( '<span>' , { 'class' : STATE _CLS } ) . hide ( ) . appendTo ( $userContainer ) ;
$ ( '<span>' , { 'class' : STATE _CLS } ) . hide ( ) . appendTo ( $userContainer ) ;
$ ( '<span>' , { 'class' : LAG _CLS } ) . hide ( ) . appendTo ( $userContainer ) ;
$ ( '<span>' , { 'class' : LAG _CLS } ) . hide ( ) . appendTo ( $userContainer ) ;
$ ( '<span>' , { 'class' : LIMIT _CLS } ) . hide ( ) . appendTo ( $userContainer ) ;
$ ( '<span>' , { 'class' : LIMIT _CLS } ) . hide ( ) . appendTo ( $userContainer ) ;
$ ( '<span>' , { 'class' : NEWPAD _CLS + ' dropdown-bar' } ) . hide ( ) . appendTo ( $userContainer ) ;
//$('<span>', {'class': NEWPAD_CLS + ' dropdown-bar'}).hide().appendTo($userContainer);
$ ( '<span>' , { 'class' : USERADMIN _CLS + ' dropdown-bar' } ) . hide ( ) . appendTo ( $userContainer ) ;
$ ( '<span>' , { 'class' : USERADMIN _CLS + ' dropdown-bar' } ) . hide ( ) . appendTo ( $userContainer ) ;
$toolbar . append ( $topContainer )
$toolbar . append ( $topContainer )
@ -89,6 +90,15 @@ define([
. append ( $ ( '<div>' , { 'class' : RIGHTSIDE _CLS } ) )
. append ( $ ( '<div>' , { 'class' : RIGHTSIDE _CLS } ) )
. append ( $ ( '<div>' , { 'class' : HISTORY _CLS } ) ) ;
. append ( $ ( '<div>' , { 'class' : HISTORY _CLS } ) ) ;
var $rightside = $toolbar . find ( '.' + RIGHTSIDE _CLS ) ;
if ( ! config . hideDrawer ) {
var $drawerContent = $ ( '<div>' , { 'class' : 'drawer-content' } ) . appendTo ( $rightside ) ;
var $drawer = Cryptpad . createButton ( 'more' , true ) . appendTo ( $rightside ) ;
$drawer . click ( function ( e ) {
$drawerContent . toggle ( ) ;
} ) ;
}
// The 'notitle' class removes the line added for the title with a small screen
// The 'notitle' class removes the line added for the title with a small screen
if ( ! config . title || typeof config . title !== "object" ) {
if ( ! config . title || typeof config . title !== "object" ) {
$toolbar . addClass ( 'notitle' ) ;
$toolbar . addClass ( 'notitle' ) ;
@ -216,9 +226,11 @@ define([
var fa _viewusers = '<span class="fa fa-eye"></span>' ;
var fa _viewusers = '<span class="fa fa-eye"></span>' ;
var viewersText = numberOfViewUsers !== 1 ? Messages . viewers : Messages . viewer ;
var viewersText = numberOfViewUsers !== 1 ? Messages . viewers : Messages . viewer ;
var editorsText = numberOfEditUsers !== 1 ? Messages . editors : Messages . editor ;
var editorsText = numberOfEditUsers !== 1 ? Messages . editors : Messages . editor ;
var $span = $ ( '<span>' , { 'class' : 'large' } ) . html ( fa _editusers + ' ' + numberOfEditUsers + ' ' + editorsText + ' ' + fa _viewusers + ' ' + numberOfViewUsers + ' ' + viewersText ) ;
//var $span = $('<span>', {'class': 'large'}).html(fa_editusers + ' ' + numberOfEditUsers + ' ' + editorsText + ' ' + fa_viewusers + ' ' + numberOfViewUsers + ' ' + viewersText);
var $spansmall = $ ( '<span>' , { 'class' : 'narrow' } ) . html ( fa _editusers + ' ' + numberOfEditUsers + ' ' + fa _viewusers + ' ' + numberOfViewUsers ) ;
//var $spansmall = $('<span>', {'class': 'narrow'}).html(fa_editusers + ' ' + numberOfEditUsers + ' ' + fa_viewusers + ' ' + numberOfViewUsers);
$userButtons . find ( '.buttonTitle' ) . html ( '' ) . append ( $span ) . append ( $spansmall ) ;
//$userButtons.find('.buttonTitle').html('').append($span).append($spansmall);
var $spansmall = $ ( '<span>' ) . html ( fa _editusers + ' ' + numberOfEditUsers + ' ' + fa _viewusers + ' ' + numberOfViewUsers ) ;
$userButtons . find ( '.buttonTitle' ) . html ( '' ) . append ( $spansmall ) ;
// Change username in useradmin dropdown
// Change username in useradmin dropdown
if ( config . displayed . indexOf ( 'useradmin' ) !== - 1 ) {
if ( config . displayed . indexOf ( 'useradmin' ) !== - 1 ) {
@ -269,6 +281,7 @@ define([
} ;
} ;
var $block = Cryptpad . createDropdown ( dropdownConfig ) ;
var $block = Cryptpad . createDropdown ( dropdownConfig ) ;
$block . attr ( 'id' , 'userButtons' ) ;
$block . attr ( 'id' , 'userButtons' ) ;
toolbar . $leftside . prepend ( $ ( '<span>' , { 'class' : 'separator' } ) ) ;
toolbar . $leftside . prepend ( $block ) ;
toolbar . $leftside . prepend ( $block ) ;
return $block ;
return $block ;
@ -282,7 +295,6 @@ define([
}
}
Cryptpad . getRecentPads ( function ( err , recent ) {
Cryptpad . getRecentPads ( function ( err , recent ) {
var $shareIcon = $ ( '<span>' , { 'class' : 'fa fa-share-alt' } ) ;
var $shareIcon = $ ( '<span>' , { 'class' : 'fa fa-share-alt' } ) ;
var $span = $ ( '<span>' , { 'class' : 'large' } ) . append ( ' ' + Messages . shareButton ) ;
var hashes = Cryptpad . getHashes ( channel , secret ) ;
var hashes = Cryptpad . getHashes ( channel , secret ) ;
var options = [ ] ;
var options = [ ] ;
@ -342,11 +354,11 @@ define([
} ) ;
} ) ;
}
}
var dropdownConfigShare = {
var dropdownConfigShare = {
text : $ ( '<div>' ) . append ( $shareIcon ) . append( $span ) . html( ) ,
text : $ ( '<div>' ) . append ( $shareIcon ) . html( ) ,
options : options
options : options
} ;
} ;
var $shareBlock = Cryptpad . createDropdown ( dropdownConfigShare ) ;
var $shareBlock = Cryptpad . createDropdown ( dropdownConfigShare ) ;
$shareBlock . find ( 'button' ) . attr ( 'id' , 'shareButton' ) ;
//$shareBlock.find('button').attr('id', 'shareButton');
$shareBlock . find ( '.dropdown-bar-content' ) . addClass ( SHARE _CLS ) . addClass ( EDITSHARE _CLS ) . addClass ( VIEWSHARE _CLS ) ;
$shareBlock . find ( '.dropdown-bar-content' ) . addClass ( SHARE _CLS ) . addClass ( EDITSHARE _CLS ) . addClass ( VIEWSHARE _CLS ) ;
if ( hashes . editHash ) {
if ( hashes . editHash ) {
@ -401,6 +413,8 @@ define([
'class' : TITLE _CLS
'class' : TITLE _CLS
} ) . appendTo ( toolbar . $top ) ;
} ) . appendTo ( toolbar . $top ) ;
var $hoverable = $ ( '<span>' , { 'class' : 'hoverable' } ) . appendTo ( $titleContainer ) ;
if ( typeof config . title !== "object" ) {
if ( typeof config . title !== "object" ) {
console . error ( "config.title" , config ) ;
console . error ( "config.title" , config ) ;
throw new Error ( "config.title is not an object" ) ;
throw new Error ( "config.title is not an object" ) ;
@ -412,7 +426,7 @@ define([
// Buttons
// Buttons
var $text = $ ( '<span>' , {
var $text = $ ( '<span>' , {
'class' : 'title'
'class' : 'title'
} ) . appendTo ( $ titleContainer ) ;
} ) . appendTo ( $ hoverable ) ;
var $pencilIcon = $ ( '<span>' , {
var $pencilIcon = $ ( '<span>' , {
'class' : 'pencilIcon' ,
'class' : 'pencilIcon' ,
'title' : Messages . clickToEdit
'title' : Messages . clickToEdit
@ -425,7 +439,7 @@ define([
var $input = $ ( '<input>' , {
var $input = $ ( '<input>' , {
type : 'text' ,
type : 'text' ,
placeholder : placeholder
placeholder : placeholder
} ) . appendTo ( $ titleContainer ) . hide ( ) ;
} ) . appendTo ( $ hoverable ) . hide ( ) ;
if ( config . readOnly !== 1 ) {
if ( config . readOnly !== 1 ) {
$text . attr ( "title" , Messages . clickToEdit ) ;
$text . attr ( "title" , Messages . clickToEdit ) ;
$text . addClass ( "editable" ) ;
$text . addClass ( "editable" ) ;
@ -433,12 +447,12 @@ define([
'class' : 'fa fa-pencil readonly' ,
'class' : 'fa fa-pencil readonly' ,
style : 'font-family: FontAwesome;'
style : 'font-family: FontAwesome;'
} ) ;
} ) ;
$pencilIcon . append ( $icon ) . appendTo ( $ titleContainer ) ;
$pencilIcon . append ( $icon ) . appendTo ( $ hoverable ) ;
var $icon2 = $ ( '<span>' , {
var $icon2 = $ ( '<span>' , {
'class' : 'fa fa-check readonly' ,
'class' : 'fa fa-check readonly' ,
style : 'font-family: FontAwesome;'
style : 'font-family: FontAwesome;'
} ) ;
} ) ;
$saveIcon . append ( $icon2 ) . appendTo ( $ titleContainer ) ;
$saveIcon . append ( $icon2 ) . appendTo ( $ hoverable ) ;
}
}
// Events
// Events
@ -454,15 +468,14 @@ define([
if ( name === "" ) {
if ( name === "" ) {
name = $input . attr ( 'placeholder' ) ;
name = $input . attr ( 'placeholder' ) ;
}
}
Cryptpad . renamePad ( name , function ( err , newtitle ) {
Cryptpad . renamePad ( name , null , function ( err , newtitle ) {
if ( err ) { return ; }
if ( err ) { return console . error ( err ) ; }
$text . text ( newtitle ) ;
$text . text ( newtitle ) ;
callback ( null , newtitle ) ;
callback ( null , newtitle ) ;
$input . hide ( ) ;
$input . hide ( ) ;
$text . show ( ) ;
$text . show ( ) ;
$pencilIcon . show ( ) ;
$pencilIcon . show ( ) ;
$saveIcon . hide ( ) ;
$saveIcon . hide ( ) ;
//$pencilIcon.css('display', '');
} ) ;
} ) ;
} ;
} ;
$input . on ( 'keyup' , function ( e ) {
$input . on ( 'keyup' , function ( e ) {
@ -498,20 +511,13 @@ define([
var $linkContainer = $ ( '<span>' , {
var $linkContainer = $ ( '<span>' , {
'class' : "cryptpad-link"
'class' : "cryptpad-link"
} ) . appendTo ( toolbar . $top ) ;
} ) . appendTo ( toolbar . $top ) ;
var $imgTag = $ ( '<img>' , {
src : "/customize/cryptofist_mini.png" ,
alt : "Cryptpad"
} ) ;
// We need to override the "a" tag action here because it is inside the iframe!
// We need to override the "a" tag action here because it is inside the iframe!
var $aTag Small = $ ( '<a>' , {
var $aTag = $ ( '<a>' , {
href : "/" ,
href : "/" ,
title : Messages . header _logoTitle ,
title : Messages . header _logoTitle ,
'class' : "cryptpad-logo"
'class' : "cryptpad-logo fa fa-hdd-o"
} ) . append ( $imgTag ) ;
} ) ;
//var $span = $('<span>').text('CryptDrive');
var $aTagBig = $aTagSmall . clone ( ) . addClass ( 'large' ) ; //.append($span);
$aTagSmall . addClass ( 'narrow' ) ;
var onClick = function ( e ) {
var onClick = function ( e ) {
e . preventDefault ( ) ;
e . preventDefault ( ) ;
if ( e . ctrlKey ) {
if ( e . ctrlKey ) {
@ -523,10 +529,9 @@ define([
var onContext = function ( e ) { e . stopPropagation ( ) ; } ;
var onContext = function ( e ) { e . stopPropagation ( ) ; } ;
$aTagBig . click ( onClick ) . contextmenu ( onContext ) ;
$aTag . click ( onClick ) . contextmenu ( onContext ) ;
$aTagSmall . click ( onClick ) . contextmenu ( onContext ) ;
$linkContainer . append ( $aTag Small) . append ( $aTagBig ) ;
$linkContainer . append ( $aTag ) ;
return $linkContainer ;
return $linkContainer ;
} ;
} ;
@ -539,9 +544,6 @@ define([
if ( typeof getLag === "function" ) {
if ( typeof getLag === "function" ) {
lag = getLag ( ) ;
lag = getLag ( ) ;
}
}
var lagLight = $ ( '<div>' , {
'class' : 'lag'
} ) ;
var title ;
var title ;
if ( lag && toolbar . connected ) {
if ( lag && toolbar . connected ) {
$lag . attr ( 'class' , LAG _CLS ) ;
$lag . attr ( 'class' , LAG _CLS ) ;
@ -566,9 +568,10 @@ define([
}
}
else if ( ! toolbar . firstConnection ) {
else if ( ! toolbar . firstConnection ) {
$lag . attr ( 'class' , LAG _CLS ) ;
$lag . attr ( 'class' , LAG _CLS ) ;
// Display the red light at the 2nd failed attemp to get the lag
$lag . addClass ( 'dc' ) ;
lagLight . addClass ( 'lag-red' ) ;
title = Messages . redLight ;
title = Messages . redLight ;
} else {
$lag . addClass ( 'lag4' ) ;
}
}
if ( title ) {
if ( title ) {
$lag . attr ( 'title' , title ) ;
$lag . attr ( 'title' , title ) ;
@ -576,10 +579,12 @@ define([
} ;
} ;
var createLag = function ( toolbar , config ) {
var createLag = function ( toolbar , config ) {
var $a = toolbar . $userAdmin . find ( '.' + LAG _CLS ) . show ( ) ;
var $a = toolbar . $userAdmin . find ( '.' + LAG _CLS ) . show ( ) ;
$ ( '<span>' , { 'class' : 'bar1' } ) . appendTo ( $a ) ;
var $container = $ ( '<span>' , { 'class' : 'bars' } ) . appendTo ( $a ) ;
$ ( '<span>' , { 'class' : 'bar2' } ) . appendTo ( $a ) ;
$ ( '<span>' , { 'class' : 'bar1' } ) . appendTo ( $container ) ;
$ ( '<span>' , { 'class' : 'bar3' } ) . appendTo ( $a ) ;
$ ( '<span>' , { 'class' : 'bar2' } ) . appendTo ( $container ) ;
$ ( '<span>' , { 'class' : 'bar4' } ) . appendTo ( $a ) ;
$ ( '<span>' , { 'class' : 'bar3' } ) . appendTo ( $container ) ;
$ ( '<span>' , { 'class' : 'bar4' } ) . appendTo ( $container ) ;
$ ( '<span>' , { 'class' : 'disconnected fa fa-exclamation-circle' } ) . appendTo ( $a ) ;
if ( config . realtime ) {
if ( config . realtime ) {
checkLag ( toolbar , config , $a ) ;
checkLag ( toolbar , config , $a ) ;
setInterval ( function ( ) {
setInterval ( function ( ) {
@ -664,7 +669,9 @@ define([
} ;
} ;
var createNewPad = function ( toolbar ) {
var createNewPad = function ( toolbar ) {
var $newPad = toolbar . $userAdmin . find ( '.' + NEWPAD _CLS ) . show ( ) ;
var $newPad = $ ( '<span>' , {
'class' : "cryptpad-new dropdown-bar"
} ) . appendTo ( toolbar . $top ) ;
var pads _options = [ ] ;
var pads _options = [ ] ;
Config . availablePadTypes . forEach ( function ( p ) {
Config . availablePadTypes . forEach ( function ( p ) {
@ -680,18 +687,14 @@ define([
content : Messages . type [ p ]
content : Messages . type [ p ]
} ) ;
} ) ;
} ) ;
} ) ;
var $plusIcon = $ ( '<span>' , { 'class' : 'fa fa-plus' } ) ;
var $newbig = $ ( '<span>' , { 'class' : 'big' } ) . append ( ' ' + Messages . newButton ) ;
var $newButton = $ ( '<div>' ) . append ( $plusIcon ) . append ( $newbig ) ;
var dropdownConfig = {
var dropdownConfig = {
text : $newButton . html ( ) , // Button initial text
text : '' , // Button initial text
options : pads _options , // Entries displayed in the menu
options : pads _options , // Entries displayed in the menu
left : true , // Open to the left of the button,
container : $newPad
container : $newPad
} ;
} ;
var $newPadBlock = Cryptpad . createDropdown ( dropdownConfig ) ;
var $newPadBlock = Cryptpad . createDropdown ( dropdownConfig ) ;
$newPadBlock . find ( 'button' ) . attr ( 'title' , Messages . newButtonTitle ) ;
$newPadBlock . find ( 'button' ) . attr ( 'title' , Messages . newButtonTitle ) ;
$newPadBlock . find ( 'button' ) . a ttr( 'id' , 'newdoc ') ;
$newPadBlock . find ( 'button' ) . a ddClass( 'fa fa-plus ') ;
return $newPadBlock ;
return $newPadBlock ;
} ;
} ;
@ -901,6 +904,7 @@ define([
var $toolbar = toolbar . $toolbar = createRealtimeToolbar ( config ) ;
var $toolbar = toolbar . $toolbar = createRealtimeToolbar ( config ) ;
toolbar . $leftside = $toolbar . find ( '.' + Bar . constants . leftside ) ;
toolbar . $leftside = $toolbar . find ( '.' + Bar . constants . leftside ) ;
toolbar . $rightside = $toolbar . find ( '.' + Bar . constants . rightside ) ;
toolbar . $rightside = $toolbar . find ( '.' + Bar . constants . rightside ) ;
toolbar . $drawer = $toolbar . find ( '.' + Bar . constants . drawer ) ;
toolbar . $top = $toolbar . find ( '.' + Bar . constants . top ) ;
toolbar . $top = $toolbar . find ( '.' + Bar . constants . top ) ;
toolbar . $history = $toolbar . find ( '.' + Bar . constants . history ) ;
toolbar . $history = $toolbar . find ( '.' + Bar . constants . history ) ;