diff --git a/src/octoprint/static/js/app/viewmodels/settings.js b/src/octoprint/static/js/app/viewmodels/settings.js index 0e2a23d5..1557209d 100644 --- a/src/octoprint/static/js/app/viewmodels/settings.js +++ b/src/octoprint/static/js/app/viewmodels/settings.js @@ -363,9 +363,20 @@ $(function() { self.requestData(undefined, true); return false; }); + + // reset scroll position on tab change + $('ul.nav-list a[data-toggle="tab"]', self.settingsDialog).on("show", function() { + self._resetScrollPosition(); + }); }; - self.show = function() { + self.show = function(tab) { + // select first or specified tab + self.selectTab(tab); + + // reset scroll position + self._resetScrollPosition(); + // show settings, ensure centered position self.settingsDialog.modal({ minHeight: function() { return Math.max($.fn.modal.defaults.maxHeight() - 80, 250); } @@ -762,6 +773,21 @@ $(function() { self.requestData(); } }; + + self._resetScrollPosition = function() { + $('.scrollable', self.settingsDialog).scrollTop(0); + }; + + self.selectTab = function(tab) { + if (tab != undefined) { + if (!_.startsWith(tab, "#")) { + tab = "#" + tab; + } + $('ul.nav-list a[href="' + tab + '"]', self.settingsDialog).tab("show"); + } else { + $('ul.nav-list a:first', self.settingsDialog).tab("show"); + } + }; } OCTOPRINT_VIEWMODELS.push([ diff --git a/src/octoprint/templates/navbar/settings.jinja2 b/src/octoprint/templates/navbar/settings.jinja2 index fb0a6c31..27605710 100644 --- a/src/octoprint/templates/navbar/settings.jinja2 +++ b/src/octoprint/templates/navbar/settings.jinja2 @@ -1,3 +1,3 @@ - + {{ _('Settings') }}