| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- 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"
-
- if $scope.settings.pdfViewer not in ["pdfjs", "native"]
- $scope.settings.pdfViewer = "pdfjs"
- $scope.fontSizeAsStr = (newVal) ->
- if newVal?
- $scope.settings.fontSize = newVal
- return $scope.settings.fontSize.toString()
- $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.autoPairDelimiters", (autoPairDelimiters, oldAutoPairDelimiters) =>
- if autoPairDelimiters != oldAutoPairDelimiters
- settings.saveSettings({autoPairDelimiters: autoPairDelimiters})
- $scope.$watch "settings.pdfViewer", (pdfViewer, oldPdfViewer) =>
- if pdfViewer != oldPdfViewer
- settings.saveSettings({pdfViewer: pdfViewer})
- $scope.$watch "settings.syntaxValidation", (syntaxValidation, oldSyntaxValidation) =>
- if syntaxValidation != oldSyntaxValidation
- settings.saveSettings({syntaxValidation: syntaxValidation})
- $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})
- $scope.$watch "project.rootDoc_id", (rootDoc_id, oldRootDoc_id) =>
- return if @ignoreUpdates
- # don't save on initialisation, Angular passes oldRootDoc_id as
- # undefined in this case.
- return if typeof oldRootDoc_id is "undefined"
- # otherwise only save changes, null values are allowed
- if (rootDoc_id != oldRootDoc_id)
- settings.saveProjectSettings({rootDocId: rootDoc_id})
- 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
- ]
|