mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-11 02:26:45 -05:00
51 lines
1.8 KiB
CoffeeScript
51 lines
1.8 KiB
CoffeeScript
|
define [
|
||
|
"base"
|
||
|
], (App) ->
|
||
|
App.controller "SettingsController", ["$scope", "settings", "ide", ($scope, settings, ide) ->
|
||
|
if $scope.settings.mode not in ["default", "vim", "emacs"]
|
||
|
$scope.settings.mode = "default"
|
||
|
|
||
|
$scope.$watch "settings.theme", (theme, oldTheme) =>
|
||
|
if theme != oldTheme
|
||
|
settings.saveSettings({theme: theme})
|
||
|
|
||
|
$scope.$watch "settings.fontSize", (fontSize, oldFontSize) =>
|
||
|
if fontSize != oldFontSize
|
||
|
settings.saveSettings({fontSize: parseInt(fontSize, 10)})
|
||
|
|
||
|
$scope.$watch "settings.mode", (mode, oldMode) =>
|
||
|
if mode != oldMode
|
||
|
settings.saveSettings({mode: mode})
|
||
|
|
||
|
$scope.$watch "settings.autoComplete", (autoComplete, oldAutoComplete) =>
|
||
|
if autoComplete != oldAutoComplete
|
||
|
settings.saveSettings({autoComplete: autoComplete})
|
||
|
|
||
|
$scope.$watch "settings.pdfViewer", (pdfViewer, oldPdfViewer) =>
|
||
|
if pdfViewer != oldPdfViewer
|
||
|
settings.saveSettings({pdfViewer: pdfViewer})
|
||
|
|
||
|
$scope.$watch "project.spellCheckLanguage", (language, oldLanguage) =>
|
||
|
return if @ignoreUpdates
|
||
|
if oldLanguage? and language != oldLanguage
|
||
|
settings.saveProjectSettings({spellCheckLanguage: language})
|
||
|
# Also set it as the default for the user
|
||
|
settings.saveSettings({spellCheckLanguage: language})
|
||
|
|
||
|
$scope.$watch "project.compiler", (compiler, oldCompiler) =>
|
||
|
return if @ignoreUpdates
|
||
|
if oldCompiler? and compiler != oldCompiler
|
||
|
settings.saveProjectSettings({compiler: compiler})
|
||
|
|
||
|
ide.socket.on "compilerUpdated", (compiler) =>
|
||
|
@ignoreUpdates = true
|
||
|
$scope.$apply () =>
|
||
|
$scope.project.compiler = compiler
|
||
|
delete @ignoreUpdates
|
||
|
|
||
|
ide.socket.on "spellCheckLanguageUpdated", (languageCode) =>
|
||
|
@ignoreUpdates = true
|
||
|
$scope.$apply () =>
|
||
|
$scope.project.spellCheckLanguage = languageCode
|
||
|
delete @ignoreUpdates
|
||
|
]
|