Explorar o código

Wire up fontSize and mode settings

James Allen %!s(int64=12) %!d(string=hai) anos
pai
achega
f154f17704

+ 0 - 3
services/web/app/coffee/Features/User/UserPagesController.coffee

@@ -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

+ 21 - 0
services/web/app/views/project/editor.jade

@@ -47,6 +47,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",
@@ -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"

+ 7 - 1
services/web/public/coffee/app/ide/editor/directives/aceEditor.coffee

@@ -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)

+ 11 - 0
services/web/public/coffee/app/ide/settings/SettingsManager.coffee

@@ -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