From 9926f906975f07d7ca10d888e09dfc9754b49282 Mon Sep 17 00:00:00 2001 From: Mo Bitar Date: Thu, 16 Aug 2018 09:48:48 -0500 Subject: [PATCH] Option to toggle editor margin resizers, disabled by default --- .../javascripts/app/controllers/editor.js | 17 ++++++++++------- app/assets/templates/editor.html.haml | 7 +++++-- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/app/controllers/editor.js b/app/assets/javascripts/app/controllers/editor.js index cffd903c7..d3f3947e2 100644 --- a/app/assets/javascripts/app/controllers/editor.js +++ b/app/assets/javascripts/app/controllers/editor.js @@ -479,6 +479,7 @@ angular.module('app') this.loadPreferences = function() { this.monospaceFont = authManager.getUserPrefValue("monospaceFont", "monospace"); this.spellcheck = authManager.getUserPrefValue("spellcheck", true); + this.marginResizersEnabled = authManager.getUserPrefValue("marginResizersEnabled", false); if(!document.getElementById("editor-content")) { // Elements have not yet loaded due to ng-if around wrapper @@ -487,14 +488,16 @@ angular.module('app') this.reloadFont(); - let width = authManager.getUserPrefValue("editorWidth", null); - if(width !== null) { - this.resizeControl.setWidth(width); - } + if(this.marginResizersEnabled) { + let width = authManager.getUserPrefValue("editorWidth", null); + if(width !== null) { + this.resizeControl.setWidth(width); + } - let left = authManager.getUserPrefValue("editorLeft", null); - if(left !== null) { - this.resizeControl.setLeft(left); + let left = authManager.getUserPrefValue("editorLeft", null); + if(left !== null) { + this.resizeControl.setLeft(left); + } } } diff --git a/app/assets/templates/editor.html.haml b/app/assets/templates/editor.html.haml index b52370789..5564a5c45 100644 --- a/app/assets/templates/editor.html.haml +++ b/app/assets/templates/editor.html.haml @@ -46,6 +46,9 @@ %menu-row{"label" => "'Spellcheck'", "circle" => "ctrl.spellcheck ? 'success' : 'default'", "action" => "ctrl.selectedMenuItem(true); ctrl.toggleKey('spellcheck')", "desc" => "'Toggles spellcheck for the default editor'", "subtitle" => "ctrl.selectedEditor ? 'Not available with editor extensions' : null", "disabled" => "ctrl.selectedEditor"} + %menu-row{"label" => "'Margin Resizers'", "circle" => "ctrl.marginResizersEnabled ? 'success' : 'default'", "action" => "ctrl.selectedMenuItem(true); ctrl.toggleKey('marginResizersEnabled')", + "desc" => "'Allows for editor left and right margins to be resized'", "faded" => "!ctrl.marginResizersEnabled"} + .item{"ng-click" => "ctrl.onEditorMenuClick()", "ng-class" => "{'selected' : ctrl.showEditorMenu}", "click-outside" => "ctrl.showEditorMenu = false;", "is-open" => "ctrl.showEditorMenu"} .label Editor %editor-menu{"ng-if" => "ctrl.showEditorMenu", "callback" => "ctrl.editorMenuOnSelect", "selected-editor" => "ctrl.selectedEditor", "current-item" => "ctrl.note"} @@ -60,7 +63,7 @@ .editor-content#editor-content{"ng-if" => "ctrl.noteReady && !ctrl.note.errorDecrypting"} - %panel-resizer.left{"panel-id" => "'editor-content'", "on-resize-finish" => "ctrl.onPanelResizeFinish","control" => "ctrl.resizeControl", "min-width" => 300, "property" => "'left'", "hoverable" => "true"} + %panel-resizer.left{"ng-if" => "ctrl.marginResizersEnabled", "panel-id" => "'editor-content'", "on-resize-finish" => "ctrl.onPanelResizeFinish","control" => "ctrl.resizeControl", "min-width" => 300, "property" => "'left'", "hoverable" => "true"} %component-view.component-view{"ng-if" => "ctrl.selectedEditor", "component" => "ctrl.selectedEditor", "ng-style" => "ctrl.note.locked && {'pointer-events' : 'none'}", "ng-class" => "{'locked' : ctrl.note.locked }"} @@ -69,7 +72,7 @@ "ng-focus" => "ctrl.onContentFocus()", "dir" => "auto", "ng-attr-spellcheck" => "{{ctrl.spellcheck}}", "ng-model-options"=>"{ debounce: 200 }"} {{ctrl.onSystemEditorLoad()}} - %panel-resizer{"panel-id" => "'editor-content'", "on-resize-finish" => "ctrl.onPanelResizeFinish","control" => "ctrl.resizeControl", "min-width" => 300, "hoverable" => "true", "property" => "'right'"} + %panel-resizer{"ng-if" => "ctrl.marginResizersEnabled", "panel-id" => "'editor-content'", "on-resize-finish" => "ctrl.onPanelResizeFinish","control" => "ctrl.resizeControl", "min-width" => 300, "hoverable" => "true", "property" => "'right'"} .section{"ng-if" => "ctrl.note.errorDecrypting"} %p.medium-padding{"style" => "padding-top: 0 !important;"} There was an error decrypting this item. Ensure you are running the latest version of this app, then sign out and sign back in to try again.