Răsfoiți Sursa

add left menu for syntax validator

Brian Gough 10 ani în urmă
părinte
comite
9177544ed9

+ 2 - 0
services/web/app/coffee/Features/Project/ProjectController.coffee

@@ -262,6 +262,7 @@ module.exports = ProjectController =
 						fontSize : user.ace.fontSize
 						autoComplete: user.ace.autoComplete
 						pdfViewer : user.ace.pdfViewer
+						syntaxValidation: user.ace.syntaxValidation
 					}
 					privilegeLevel: privilegeLevel
 					chatUrl: Settings.apis.chat.url
@@ -323,6 +324,7 @@ defaultSettingsForAnonymousUser = (user_id)->
 		autoComplete: true
 		spellCheckLanguage: ""
 		pdfViewer: ""
+		syntaxValidation: true
 	subscription:
 		freeTrial:
 			allowed: true

+ 2 - 0
services/web/app/coffee/Features/User/UserController.coffee

@@ -56,6 +56,8 @@ module.exports = UserController =
 				user.ace.spellCheckLanguage = req.body.spellCheckLanguage
 			if req.body.pdfViewer?
 				user.ace.pdfViewer = req.body.pdfViewer
+			if req.body.syntaxValidation?
+				user.ace.syntaxValidation = req.body.syntaxValidation
 			user.save (err)->
 				newEmail = req.body.email?.trim().toLowerCase()
 				if !newEmail? or newEmail == user.email

+ 1 - 0
services/web/app/coffee/models/User.coffee

@@ -26,6 +26,7 @@ UserSchema = new Schema
 							autoComplete:   {type : Boolean, default: true}
 							spellCheckLanguage :   {type : String, default: "en"}
 							pdfViewer   :   {type : String, default: "pdfjs"}
+							syntaxValidation   :   {type : Boolean, default: true}
 						}
 	features		  : {
 							collaborators: { type:Number,  default: Settings.defaultFeatures.collaborators }

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

@@ -36,6 +36,7 @@ div.full-size(
 			annotations="pdf.logEntryAnnotations[editor.open_doc_id]",
 			read-only="!permissions.write",
 			on-ctrl-enter="recompileViaKey"
+			syntax-validation="settings.syntaxValidation"
 		)
 
 	.ui-layout-east

+ 9 - 0
services/web/app/views/project/editor/left-menu.jade

@@ -105,6 +105,15 @@ aside#left-menu.full-size(
 					ng-options="o.v as o.n for o in [{ n: 'On', v: true }, { n: 'Off', v: false }]"
 				)
 
+			if (user.betaProgram)
+				.form-controls
+					label(for="syntaxValidation") #{translate("syntax_validation")}
+					select(
+						name="syntaxValidation"
+						ng-model="settings.syntaxValidation"
+						ng-options="o.v as o.n for o in [{ n: 'On', v: true }, { n: 'Off', v: false }]"
+					)
+
 			.form-controls
 				label(for="theme") #{translate("theme")}
 				select(

+ 6 - 0
services/web/public/coffee/ide/editor/directives/aceEditor.coffee

@@ -43,6 +43,7 @@ define [
 				annotations: "="
 				navigateHighlights: "=",
 				onCtrlEnter: "="
+				syntaxValidation: "="
 			}
 			link: (scope, element, attrs) ->
 				# Don't freak out if we're already in an apply callback
@@ -188,6 +189,11 @@ define [
 				scope.$watch "readOnly", (value) ->
 					editor.setReadOnly !!value
 
+				scope.$watch "syntaxValidation", (value) ->
+					console.log "change syntaxValidation to ", value
+					session = editor.getSession()
+					session.setOption("useWorker", value);
+
 				editor.setOption("scrollPastEnd", true)
 
 				resetSession = () ->

+ 4 - 0
services/web/public/coffee/ide/settings/controllers/SettingsController.coffee

@@ -28,6 +28,10 @@ define [
 			if pdfViewer != oldPdfViewer
 				settings.saveSettings({pdfViewer: pdfViewer})
 
+		$scope.$watch "settings.syntaxValidation", (syntaxValidation, oldSyntaxValidation) =>
+			if syntaxValidation != oldSyntaxValidation
+				settings.saveProjectSettings({syntaxValidation: syntaxValidation})
+
 		$scope.$watch "project.spellCheckLanguage", (language, oldLanguage) =>
 			return if @ignoreUpdates
 			if oldLanguage? and language != oldLanguage