Wire up fontSize and mode settings

This commit is contained in:
James Allen 2014-06-24 20:46:00 +01:00
parent 5cef41fdbd
commit f154f17704
4 changed files with 39 additions and 4 deletions

View file

@ -37,8 +37,5 @@ module.exports =
userHasDropboxFeature: user.features.dropbox
userIsRegisteredWithDropbox: userIsRegisteredWithDropbox
user: user,
themes: THEME_LIST,
editors: ['default','vim','emacs'],
fontSizes: ['10','11','12','13','14','16','20','24']
languages: Settings.languages,
accountSettingsTabActive: true

View file

@ -48,6 +48,25 @@ block content
each theme in themes
option(value=theme) #{theme}
.form-controls
label(for="mode") Keybindings
select.form-control(
name="mode"
ng-model="settings.mode"
)
option(value='default') None
option(value='vim') Vim
option(value='emacs') Emacs
.form-controls
label(for="fontSize") Font Size
select.form-control(
name="fontSize"
ng-model="settings.fontSize"
)
each size in ['10','11','12','13','14','16','20','24']
option(value=size) #{size}px
#left-menu-mask(
ng-show="ui.leftMenuShown",
ng-click="ui.leftMenuShown = false"
@ -87,6 +106,8 @@ block content
ace-editor,
ng-show="!!editor.sharejs_doc && !editor.opening"
theme="settings.theme",
keybindings="settings.mode",
font-size="settings.fontSize",
show-print-margin="false",
sharejs-doc="editor.sharejs_doc",
last-updated="editor.last_updated"

View file

@ -16,6 +16,7 @@ define [
theme: "="
showPrintMargin: "="
keybindings: "="
fontSize: "="
sharejsDoc: "="
lastUpdated: "="
}
@ -43,9 +44,14 @@ define [
scope.$watch "keybindings", (value) ->
Vim = require("ace/keyboard/vim").handler
Emacs = require("ace/keyboard/emacs").handler
keybindings = ace: null, vim: Vim, emacs: Emacs
keybindings = vim: Vim, emacs: Emacs
editor.setKeyboardHandler(keybindings[value])
scope.$watch "fontSize", (value) ->
element.find(".ace_editor, .ace_content").css({
"font-size": value + "px"
})
scope.$watch "sharejsDoc", (sharejs_doc, old_sharejs_doc) ->
if old_sharejs_doc?
detachFromAce(old_sharejs_doc)

View file

@ -3,10 +3,21 @@ define [], () ->
constructor: (@ide, @$scope) ->
@$scope.settings = window.userSettings
if @$scope.settings.mode not in ["default", "vim", "emacs"]
@$scope.settings.mode = "default"
@$scope.$watch "settings.theme", (theme, oldTheme) =>
if theme != oldTheme
@saveSettings({theme: theme})
@$scope.$watch "settings.fontSize", (fontSize, oldFontSize) =>
if fontSize != oldFontSize
@saveSettings({fontSize: parseInt(fontSize, 10)})
@$scope.$watch "settings.mode", (mode, oldMode) =>
if mode != oldMode
@saveSettings({mode: mode})
saveSettings: (data) ->
data._csrf = window.csrfToken
@ide.$http.post "/user/settings", data