mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-31 21:21:03 -04:00
c05c5ac7c8
Solves a problem where sometimes the Jquery drag/drop plugin fails to remove the highlight class from drop target.
52 lines
1.5 KiB
CoffeeScript
52 lines
1.5 KiB
CoffeeScript
define [
|
|
"base"
|
|
], (App) ->
|
|
App.controller "FileTreeFolderController", ($scope, ide, $modal, localStorage) ->
|
|
$scope.expanded = localStorage("folder.#{$scope.entity.id}.expanded") or false
|
|
|
|
$scope.toggleExpanded = () ->
|
|
$scope.expanded = !$scope.expanded
|
|
localStorage("folder.#{$scope.entity.id}.expanded", $scope.expanded)
|
|
|
|
$scope.onDrop = (events, ui) ->
|
|
source = $(ui.draggable).scope().entity
|
|
return if !source?
|
|
# clear highlight explicitely
|
|
$('.file-tree-inner .droppable-hover').removeClass('droppable-hover')
|
|
ide.fileTreeManager.moveEntity(source, $scope.entity)
|
|
|
|
$scope.orderByFoldersFirst = (entity) ->
|
|
# We need this here as well as in FileTreeController
|
|
# since the file-entity diretive creates a new scope
|
|
# that doesn't inherit from previous scopes.
|
|
return '0' if entity?.type == "folder"
|
|
return '1'
|
|
|
|
$scope.openNewDocModal = () ->
|
|
$modal.open(
|
|
templateUrl: "newDocModalTemplate"
|
|
controller: "NewDocModalController"
|
|
resolve: {
|
|
parent_folder: () -> $scope.entity
|
|
}
|
|
)
|
|
|
|
$scope.openNewFolderModal = () ->
|
|
$modal.open(
|
|
templateUrl: "newFolderModalTemplate"
|
|
controller: "NewFolderModalController"
|
|
resolve: {
|
|
parent_folder: () -> $scope.entity
|
|
}
|
|
)
|
|
|
|
$scope.openUploadFileModal = () ->
|
|
$scope.project_id = ide.project_id
|
|
$modal.open(
|
|
templateUrl: "uploadFileModalTemplate"
|
|
controller: "UploadFileModalController"
|
|
scope: $scope
|
|
resolve: {
|
|
parent_folder: () -> $scope.entity
|
|
}
|
|
)
|