overleaf/services/web/public/coffee/ide/settings/controllers/ProjectNameController.coffee

30 lines
879 B
CoffeeScript
Raw Normal View History

2014-07-08 07:02:26 -04:00
define [
"base"
], (App) ->
2016-02-23 10:00:04 -05:00
MAX_PROJECT_NAME_LENGTH = 150
2014-07-08 07:02:26 -04:00
App.controller "ProjectNameController", ["$scope", "settings", "ide", ($scope, settings, ide) ->
$scope.state =
renaming: false
$scope.inputs = {}
$scope.startRenaming = () ->
$scope.inputs.name = $scope.project.name
$scope.state.renaming = true
$scope.$emit "project:rename:start"
$scope.finishRenaming = () ->
2016-02-23 10:00:04 -05:00
$scope.state.renaming = false
newName = $scope.inputs.name
2016-02-23 10:00:04 -05:00
if !newName? or newName.length == 0 or newName.length > MAX_PROJECT_NAME_LENGTH
return
$scope.project.name = newName
settings.saveProjectSettings({name: $scope.project.name})
2014-07-08 07:02:26 -04:00
ide.socket.on "projectNameUpdated", (name) ->
$scope.$apply () ->
$scope.project.name = name
$scope.$watch "project.name", (name) ->
if name?
window.document.title = name + " - Online LaTeX Editor ShareLaTeX"
]