add left menu for syntax validator

This commit is contained in:
Brian Gough 2016-10-06 11:51:24 +01:00
parent 95a66bbf00
commit 9177544ed9
7 changed files with 25 additions and 0 deletions

View file

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

View file

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

View file

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

View file

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

View file

@ -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 }]" 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 .form-controls
label(for="theme") #{translate("theme")} label(for="theme") #{translate("theme")}
select( select(

View file

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

View file

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