@ -124,6 +124,7 @@ define([
var $tagsIcon = $ ( '<span>' , { "class" : "fa " + faTags } ) ;
var $tagsIcon = $ ( '<span>' , { "class" : "fa " + faTags } ) ;
var $passwordIcon = $ ( '<span>' , { "class" : "fa fa-lock" } ) ;
var $passwordIcon = $ ( '<span>' , { "class" : "fa fa-lock" } ) ;
var $expirableIcon = $ ( '<span>' , { "class" : "fa fa-clock-o" } ) ;
var $expirableIcon = $ ( '<span>' , { "class" : "fa fa-clock-o" } ) ;
var $separator = $ ( '<div>' , { "class" : "dropdown-divider" } ) ;
var LS _LAST = "app-drive-lastOpened" ;
var LS _LAST = "app-drive-lastOpened" ;
var LS _OPENED = "app-drive-openedFolders" ;
var LS _OPENED = "app-drive-openedFolders" ;
@ -303,6 +304,7 @@ define([
'aria-labelledby' : 'dropdownMenu' ,
'aria-labelledby' : 'dropdownMenu' ,
'style' : 'display:block;position:static;margin-bottom:5px;'
'style' : 'display:block;position:static;margin-bottom:5px;'
} , [
} , [
h ( 'span.cp-app-drive-context-noAction.dropdown-item.disabled' , Messages . fc _noAction || "No action possible" ) ,
h ( 'li' , h ( 'a.cp-app-drive-context-open.dropdown-item' , {
h ( 'li' , h ( 'a.cp-app-drive-context-open.dropdown-item' , {
'tabindex' : '-1' ,
'tabindex' : '-1' ,
'data-icon' : faFolderOpen ,
'data-icon' : faFolderOpen ,
@ -311,6 +313,7 @@ define([
'tabindex' : '-1' ,
'tabindex' : '-1' ,
'data-icon' : faReadOnly ,
'data-icon' : faReadOnly ,
} , Messages . fc _open _ro ) ) ,
} , Messages . fc _open _ro ) ) ,
$separator . clone ( ) [ 0 ] ,
h ( 'li' , h ( 'a.cp-app-drive-context-expandall.dropdown-item' , {
h ( 'li' , h ( 'a.cp-app-drive-context-expandall.dropdown-item' , {
'tabindex' : '-1' ,
'tabindex' : '-1' ,
'data-icon' : "expandAll" ,
'data-icon' : "expandAll" ,
@ -319,6 +322,7 @@ define([
'tabindex' : '-1' ,
'tabindex' : '-1' ,
'data-icon' : "collapseAll" ,
'data-icon' : "collapseAll" ,
} , Messages . fc _collapseAll ) ) ,
} , Messages . fc _collapseAll ) ) ,
$separator . clone ( ) [ 0 ] ,
h ( 'li' , h ( 'a.cp-app-drive-context-color.dropdown-item.cp-app-drive-context-editable' , {
h ( 'li' , h ( 'a.cp-app-drive-context-color.dropdown-item.cp-app-drive-context-editable' , {
'tabindex' : '-1' ,
'tabindex' : '-1' ,
'data-icon' : faColor ,
'data-icon' : faColor ,
@ -347,6 +351,7 @@ define([
'tabindex' : '-1' ,
'tabindex' : '-1' ,
'data-icon' : faTags ,
'data-icon' : faTags ,
} , Messages . fc _hashtag ) ) ,
} , Messages . fc _hashtag ) ) ,
$separator . clone ( ) [ 0 ] ,
h ( 'li' , h ( 'a.cp-app-drive-context-newdoc.dropdown-item.cp-app-drive-context-editable' , {
h ( 'li' , h ( 'a.cp-app-drive-context-newdoc.dropdown-item.cp-app-drive-context-editable' , {
'tabindex' : '-1' ,
'tabindex' : '-1' ,
'data-icon' : AppConfig . applicationsIcon . pad ,
'data-icon' : AppConfig . applicationsIcon . pad ,
@ -372,6 +377,7 @@ define([
'data-icon' : AppConfig . applicationsIcon . whiteboard ,
'data-icon' : AppConfig . applicationsIcon . whiteboard ,
'data-type' : 'whiteboard'
'data-type' : 'whiteboard'
} , Messages . button _newwhiteboard ) ) ,
} , Messages . button _newwhiteboard ) ) ,
$separator . clone ( ) [ 0 ] ,
h ( 'li' , h ( 'a.cp-app-drive-context-empty.dropdown-item.cp-app-drive-context-editable' , {
h ( 'li' , h ( 'a.cp-app-drive-context-empty.dropdown-item.cp-app-drive-context-editable' , {
'tabindex' : '-1' ,
'tabindex' : '-1' ,
'data-icon' : faEmpty ,
'data-icon' : faEmpty ,
@ -380,6 +386,7 @@ define([
'tabindex' : '-1' ,
'tabindex' : '-1' ,
'data-icon' : faRestore ,
'data-icon' : faRestore ,
} , Messages . fc _restore ) ) ,
} , Messages . fc _restore ) ) ,
$separator . clone ( ) [ 0 ] ,
h ( 'li' , h ( 'a.cp-app-drive-context-rename.dropdown-item.cp-app-drive-context-editable' , {
h ( 'li' , h ( 'a.cp-app-drive-context-rename.dropdown-item.cp-app-drive-context-editable' , {
'tabindex' : '-1' ,
'tabindex' : '-1' ,
'data-icon' : faRename ,
'data-icon' : faRename ,
@ -406,6 +413,16 @@ define([
} , Messages . fc _prop ) ) ,
} , Messages . fc _prop ) ) ,
] )
] )
] ) ;
] ) ;
$ ( menu ) . find ( "li a.dropdown-item" ) . each ( function ( i , el ) {
var $icon = $ ( "<span>" ) ;
if ( $ ( el ) . attr ( 'data-icon' ) ) {
var font = $ ( el ) . attr ( 'data-icon' ) . indexOf ( 'cptools' ) === 0 ? 'cptools' : 'fa' ;
$icon . addClass ( font ) . addClass ( $ ( el ) . attr ( 'data-icon' ) ) ;
} else {
$icon . text ( $ ( el ) . text ( ) ) ;
}
$ ( el ) . prepend ( $icon ) ;
} ) ;
return $ ( menu ) ;
return $ ( menu ) ;
} ;
} ;
@ -1053,8 +1070,7 @@ define([
show = [ 'newfolder' , 'newsharedfolder' , 'newdoc' ] ;
show = [ 'newfolder' , 'newsharedfolder' , 'newdoc' ] ;
break ;
break ;
case 'tree' :
case 'tree' :
show = [ 'open' , 'openro' , 'expandall' , 'collapseall' , 'color' , 'download' , 'share' , 'rename' , 'delete' , 'deleteowned' , 'removesf' ,
show = [ 'open' , 'openro' , 'expandall' , 'collapseall' , 'color' , 'download' , 'share' , 'rename' , 'delete' , 'deleteowned' , 'removesf' , 'properties' , 'hashtag' ] ;
'newfolder' , 'properties' , 'hashtag' ] ;
break ;
break ;
case 'default' :
case 'default' :
show = [ 'open' , 'openro' , 'share' , 'openparent' , 'delete' , 'deleteowned' , 'properties' , 'hashtag' ] ;
show = [ 'open' , 'openro' , 'share' , 'openparent' , 'delete' , 'deleteowned' , 'properties' , 'hashtag' ] ;
@ -1238,6 +1254,20 @@ define([
var displayMenu = function ( e ) {
var displayMenu = function ( e ) {
var $menu = $contextMenu ;
var $menu = $contextMenu ;
var showSep = false ;
var $lastVisibleSep = null ;
$menu . find ( ".dropdown-menu" ) . children ( ) . each ( function ( i , el ) {
var $el = $ ( el ) ;
if ( $el . is ( ".dropdown-divider" ) ) {
$el . css ( "display" , showSep ? "list-item" : "none" ) ;
if ( showSep ) { $lastVisibleSep = $el ; }
showSep = false ;
}
else if ( $el . is ( "li" ) && $el . css ( "display" ) !== "none" ) {
showSep = true ;
}
} ) ;
if ( ! showSep && $lastVisibleSep ) { $lastVisibleSep . css ( "display" , "none" ) ; } // remove last divider if no options after
$menu . css ( { display : "block" } ) ;
$menu . css ( { display : "block" } ) ;
if ( APP . mobile ( ) ) { return ; }
if ( APP . mobile ( ) ) { return ; }
var h = $menu . outerHeight ( ) ;
var h = $menu . outerHeight ( ) ;
@ -1313,11 +1343,7 @@ define([
displayMenu ( e ) ;
displayMenu ( e ) ;
if ( $contextMenu . find ( 'li:visible' ) . length === 0 ) {
$ ( ".cp-app-drive-context-noAction" ) . toggle ( $contextMenu . find ( 'li:visible' ) . length === 0 ) ;
debug ( "No visible element in the context menu. Abort." ) ;
$contextMenu . hide ( ) ;
return true ;
}
$contextMenu . data ( 'paths' , paths ) ;
$contextMenu . data ( 'paths' , paths ) ;
return false ;
return false ;
@ -1345,6 +1371,7 @@ define([
} ) ;
} ) ;
cb ( ) ;
cb ( ) ;
} ;
} ;
if ( paths . some ( function ( p ) { return manager . comparePath ( newPath , p ) ; } ) ) { return void cb ( ) ; }
manager . move ( paths , newPath , newCb , copy ) ;
manager . move ( paths , newPath , newCb , copy ) ;
} ;
} ;
// Delete paths from the drive and/or shared folders (without moving them to the trash)
// Delete paths from the drive and/or shared folders (without moving them to the trash)
@ -2601,32 +2628,17 @@ define([
var displaySearch = function ( $list , value ) {
var displaySearch = function ( $list , value ) {
var filesList = manager . search ( value ) ;
var filesList = manager . search ( value ) ;
filesList . forEach ( function ( r ) {
filesList . forEach ( function ( r ) {
// if r.id === null, then it's a folder, not a file
r . paths . forEach ( function ( path ) {
r . paths . forEach ( function ( path ) {
if ( ! r . inSharedFolder &&
if ( ! r . inSharedFolder &&
APP . hideDuplicateOwned && manager . isDuplicateOwned ( path ) ) { return ; }
APP . hideDuplicateOwned && manager . isDuplicateOwned ( path ) ) { return ; }
var href = r . data . href ;
var href = r . data . href ;
var parsed = Hash . parsePadUrl ( href ) ;
var parsed = Hash . parsePadUrl ( href ) ;
var $table = $ ( '<table>' ) ;
var $table = $ ( '<table>' ) ;
var $icon = $ ( '<td>' , { 'rowspan' : '3' , 'class' : 'cp-app-drive-search-icon' } )
var $icon = $ ( '<td>' , { 'rowspan' : '3' , 'class' : 'cp-app-drive-search-icon' } ) ;
. append ( getFileIcon ( r . id ) ) ;
var $title = $ ( '<td>' , {
var $title = $ ( '<td>' , {
'class' : 'cp-app-drive-search-col1 cp-app-drive-search-title'
'class' : 'cp-app-drive-search-col1 cp-app-drive-search-title'
} ) . text ( r . data . title )
} ) . text ( r . data . title ) ;
. click ( function ( ) {
openFile ( null , r . data . href ) ;
} ) ;
var $typeName = $ ( '<td>' , { 'class' : 'cp-app-drive-search-label2' } )
. text ( Messages . fm _type ) ;
var $type = $ ( '<td>' , { 'class' : 'cp-app-drive-search-col2' } )
. text ( Messages . type [ parsed . type ] || parsed . type ) ;
var $atimeName = $ ( '<td>' , { 'class' : 'cp-app-drive-search-label2' } )
. text ( Messages . fm _lastAccess ) ;
var $atime = $ ( '<td>' , { 'class' : 'cp-app-drive-search-col2' } )
. text ( new Date ( r . data . atime ) . toLocaleString ( ) ) ;
var $ctimeName = $ ( '<td>' , { 'class' : 'cp-app-drive-search-label2' } )
. text ( Messages . fm _creation ) ;
var $ctime = $ ( '<td>' , { 'class' : 'cp-app-drive-search-col2' } )
. text ( new Date ( r . data . ctime ) . toLocaleString ( ) ) ;
if ( manager . isPathIn ( path , [ 'hrefArray' ] ) ) {
if ( manager . isPathIn ( path , [ 'hrefArray' ] ) ) {
path . pop ( ) ;
path . pop ( ) ;
path . push ( r . data . title ) ;
path . push ( r . data . title ) ;
@ -2635,25 +2647,48 @@ define([
'class' : 'cp-app-drive-search-col1 cp-app-drive-search-path'
'class' : 'cp-app-drive-search-col1 cp-app-drive-search-path'
} ) ;
} ) ;
createTitle ( $path , path , true ) ;
createTitle ( $path , path , true ) ;
var parentPath = path . slice ( ) ;
var $typeName = $ ( '<td>' , { 'class' : 'cp-app-drive-search-label2' } ) . text ( Messages . fm _type ) ;
var $a ;
var $type = $ ( '<td>' , { 'class' : 'cp-app-drive-search-col2' } ) ;
if ( parentPath ) {
var $atimeName = $ ( '<td>' , { 'class' : 'cp-app-drive-search-label2' } ) ;
$a = $ ( '<a>' ) . text ( Messages . fm _openParent ) . click ( function ( e ) {
var $atime = $ ( '<td>' , { 'class' : 'cp-app-drive-search-col2' } ) ;
e . preventDefault ( ) ;
var $ctimeName = $ ( '<td>' , { 'class' : 'cp-app-drive-search-label2' } ) ;
if ( manager . isInTrashRoot ( parentPath ) ) { parentPath = [ TRASH ] ; }
var $ctime = $ ( '<td>' , { 'class' : 'cp-app-drive-search-col2' } ) ;
else { parentPath . pop ( ) ; }
var $openDir = $ ( '<td>' , { 'class' : 'cp-app-drive-search-opendir' } ) ;
APP . selectedFiles = [ r . id ] ;
if ( r . id ) {
APP . displayDirectory ( parentPath ) ;
$icon . append ( getFileIcon ( r . id ) ) ;
$type . text ( Messages . type [ parsed . type ] || parsed . type ) ;
$title . click ( function ( ) {
openFile ( null , r . data . href ) ;
} ) ;
} ) ;
$atimeName . text ( Messages . fm _lastAccess ) ;
$atime . text ( new Date ( r . data . atime ) . toLocaleString ( ) ) ;
$ctimeName . text ( Messages . fm _creation ) ;
$ctime . text ( new Date ( r . data . ctime ) . toLocaleString ( ) ) ;
var parentPath = path . slice ( ) ;
if ( parentPath ) {
$ ( '<a>' ) . text ( Messages . fm _openParent ) . click ( function ( e ) {
e . preventDefault ( ) ;
if ( manager . isInTrashRoot ( parentPath ) ) { parentPath = [ TRASH ] ; }
else { parentPath . pop ( ) ; }
APP . selectedFiles = [ r . id ] ;
APP . displayDirectory ( parentPath ) ;
} ) . appendTo ( $openDir ) ;
}
$ ( '<a>' ) . text ( Messages . fc _prop ) . click ( function ( ) {
APP . getProperties ( r . id , function ( e , $prop ) {
if ( e ) { return void logError ( e ) ; }
UI . alert ( $prop [ 0 ] , undefined , true ) ;
} ) ;
} ) . appendTo ( $openDir ) ;
}
else {
$icon . append ( $folderIcon . clone ( ) ) ;
$type . text ( Messages . fm _folder ) ;
$ ( '<a>' ) . text ( Messages . fc _open ) . click ( function ( e ) {
e . preventDefault ( ) ;
APP . displayDirectory ( path ) ;
} ) . appendTo ( $openDir ) ;
}
}
var $openDir = $ ( '<td>' , { 'class' : 'cp-app-drive-search-opendir' } ) . append ( $a ) ;
$ ( '<a>' ) . text ( Messages . fc _prop ) . click ( function ( ) {
APP . getProperties ( r . id , function ( e , $prop ) {
if ( e ) { return void logError ( e ) ; }
UI . alert ( $prop [ 0 ] , undefined , true ) ;
} ) ;
} ) . appendTo ( $openDir ) ;
// rows 1-3
// rows 1-3
$ ( '<tr>' ) . append ( $icon ) . append ( $title ) . append ( $typeName ) . append ( $type ) . appendTo ( $table ) ;
$ ( '<tr>' ) . append ( $icon ) . append ( $title ) . append ( $typeName ) . append ( $type ) . appendTo ( $table ) ;
@ -3199,7 +3234,7 @@ define([
placeholder : Messages . fm _searchPlaceholder
placeholder : Messages . fm _searchPlaceholder
} ) . keyup ( function ( e ) {
} ) . keyup ( function ( e ) {
if ( search . to ) { window . clearTimeout ( search . to ) ; }
if ( search . to ) { window . clearTimeout ( search . to ) ; }
if ( [ 3 8, 39 , 40 , 41 ] . indexOf ( e . which ) !== - 1 ) {
if ( [ 3 7, 3 8, 39 , 40 ] . indexOf ( e . which ) !== - 1 ) {
if ( ! $input . val ( ) ) {
if ( ! $input . val ( ) ) {
$input . blur ( ) ;
$input . blur ( ) ;
$content . focus ( ) ;
$content . focus ( ) ;
@ -3647,6 +3682,14 @@ define([
APP . hideMenu ( ) ;
APP . hideMenu ( ) ;
} ) ;
} ) ;
$content . on ( "keydown" , function ( e ) {
if ( e . which === 113 ) {
var paths = $contextMenu . data ( 'paths' ) ;
if ( paths . length !== 1 ) { return ; }
displayRenameInput ( paths [ 0 ] . element , paths [ 0 ] . path ) ;
}
} ) ;
// Chrome considers the double-click means "select all" in the window
// Chrome considers the double-click means "select all" in the window
$content . on ( 'mousedown' , function ( e ) {
$content . on ( 'mousedown' , function ( e ) {
$content . focus ( ) ;
$content . focus ( ) ;