2014-06-22 07:10:42 -04:00
|
|
|
define [
|
|
|
|
"base"
|
|
|
|
], (App) ->
|
|
|
|
App.controller "FileTreeController", ["$scope", "$modal", ($scope, $modal) ->
|
|
|
|
$scope.openNewDocModal = () ->
|
|
|
|
$modal.open(
|
|
|
|
templateUrl: "newDocModalTemplate"
|
2014-06-22 09:39:38 -04:00
|
|
|
controller: "NewDocModalController"
|
2014-06-22 07:10:42 -04:00
|
|
|
)
|
2014-06-22 09:39:38 -04:00
|
|
|
|
|
|
|
$scope.openNewFolderModal = () ->
|
|
|
|
$modal.open(
|
|
|
|
templateUrl: "newFolderModalTemplate"
|
|
|
|
controller: "NewFolderModalController"
|
|
|
|
)
|
|
|
|
|
2014-06-22 12:32:15 -04:00
|
|
|
$scope.openUploadFileModal = () ->
|
|
|
|
$modal.open(
|
|
|
|
templateUrl: "uploadFileModalTemplate"
|
|
|
|
controller: "UploadFileModalController"
|
|
|
|
scope: $scope
|
|
|
|
)
|
|
|
|
|
2014-06-22 09:39:38 -04:00
|
|
|
$scope.orderByFoldersFirst = (entity) ->
|
2014-06-23 05:57:31 -04:00
|
|
|
return '0' if entity.type == "folder"
|
|
|
|
return '1'
|
2014-06-22 15:08:56 -04:00
|
|
|
|
|
|
|
$scope.startRenamingSelected = () ->
|
|
|
|
$scope.$broadcast "rename:selected"
|
2014-06-22 15:49:58 -04:00
|
|
|
|
|
|
|
$scope.openDeleteModalForSelected = () ->
|
|
|
|
$scope.$broadcast "delete:selected"
|
2014-06-22 07:10:42 -04:00
|
|
|
]
|
|
|
|
|
|
|
|
App.controller "NewDocModalController", [
|
|
|
|
"$scope", "ide", "$modalInstance", "$timeout",
|
|
|
|
($scope, ide, $modalInstance, $timeout) ->
|
|
|
|
$scope.inputs =
|
|
|
|
name: "name.tex"
|
|
|
|
$scope.state =
|
|
|
|
inflight: false
|
|
|
|
|
|
|
|
$modalInstance.opened.then () ->
|
|
|
|
$timeout () ->
|
|
|
|
$scope.$broadcast "open"
|
|
|
|
, 700
|
|
|
|
|
|
|
|
$scope.create = () ->
|
|
|
|
$scope.state.inflight = true
|
|
|
|
ide.fileTreeManager.createDocInCurrentFolder $scope.inputs.name, (error, doc) ->
|
|
|
|
$scope.state.inflight = false
|
|
|
|
$modalInstance.close()
|
|
|
|
|
2014-06-22 09:39:38 -04:00
|
|
|
$scope.cancel = () ->
|
|
|
|
$modalInstance.dismiss('cancel')
|
|
|
|
]
|
|
|
|
|
|
|
|
App.controller "NewFolderModalController", [
|
|
|
|
"$scope", "ide", "$modalInstance", "$timeout",
|
|
|
|
($scope, ide, $modalInstance, $timeout) ->
|
|
|
|
$scope.inputs =
|
|
|
|
name: "name"
|
|
|
|
$scope.state =
|
|
|
|
inflight: false
|
|
|
|
|
|
|
|
$modalInstance.opened.then () ->
|
|
|
|
$timeout () ->
|
|
|
|
$scope.$broadcast "open"
|
|
|
|
, 700
|
|
|
|
|
|
|
|
$scope.create = () ->
|
|
|
|
$scope.state.inflight = true
|
|
|
|
ide.fileTreeManager.createFolderInCurrentFolder $scope.inputs.name, (error, doc) ->
|
|
|
|
$scope.state.inflight = false
|
|
|
|
$modalInstance.close()
|
|
|
|
|
2014-06-22 12:32:15 -04:00
|
|
|
$scope.cancel = () ->
|
|
|
|
$modalInstance.dismiss('cancel')
|
|
|
|
]
|
|
|
|
|
|
|
|
App.controller "UploadFileModalController", [
|
|
|
|
"$scope", "ide", "$modalInstance", "$timeout",
|
|
|
|
($scope, ide, $modalInstance, $timeout) ->
|
|
|
|
parent_folder = ide.fileTreeManager.getCurrentFolder()
|
|
|
|
$scope.parent_folder_id = parent_folder?.id
|
|
|
|
|
|
|
|
uploadCount = 0
|
|
|
|
$scope.onUpload = () ->
|
|
|
|
uploadCount++
|
|
|
|
|
|
|
|
$scope.onComplete = (error, name, response) ->
|
|
|
|
$timeout (() ->
|
|
|
|
uploadCount--
|
|
|
|
if uploadCount == 0 and response? and response.success
|
|
|
|
$modalInstance.close("done")
|
|
|
|
), 250
|
|
|
|
|
2014-06-22 07:10:42 -04:00
|
|
|
$scope.cancel = () ->
|
|
|
|
$modalInstance.dismiss('cancel')
|
|
|
|
]
|