Add autocompile setting

This commit is contained in:
Alasdair Smith 2017-09-05 12:21:23 +01:00
parent 64f70942d0
commit cca7f55322
2 changed files with 16 additions and 1 deletions

View file

@ -26,6 +26,15 @@ div.full-size.pdf(ng-controller="PdfController")
)
span.caret
ul.dropdown-menu.dropdown-menu-left
// Only show on beta program?
li.dropdown-header Auto-compile
li
a(href, ng-click="autocompile_enabled = true")
i.fa.fa-fw(ng-class="{'fa-check': autocompile_enabled}")
|  On
a(href, ng-click="autocompile_enabled = false")
i.fa.fa-fw(ng-class="{'fa-check': !autocompile_enabled}")
|  Off
li.dropdown-header #{translate("compile_mode")}
li
a(href, ng-click="draft = false")

View file

@ -72,10 +72,16 @@ define [
$scope.pdf.view = 'errors'
$scope.pdf.renderingError = true
$scope.autocompile_enabled = localStorage("autocompile_enabled:#{$scope.project_id}") or false
$scope.$watch "autocompile_enabled", (newValue, oldValue) ->
if newValue? and oldValue != newValue
localStorage("autocompile_enabled:#{$scope.project_id}", newValue)
# TODO: toggle listener when setting changed?
ide.$scope.$on "ide:opAcknowledged", _.debounce(() ->
if (!ide.$scope.hasLintingError)
$scope.recompile()
, 3000) if window.user?.betaProgram
, 3000) if window.user?.betaProgram and $scope.autocompile_enabled
# abort compile if syntax checks fail
$scope.stop_on_validation_error = localStorage("stop_on_validation_error:#{$scope.project_id}")