Keep active subtab selected on PID Tuning tab, change displayed… (#1610)

Keep active subtab selected on PID Tuning tab, change displayed data …
10.7.0-preview
Michael Keller 2019-09-04 01:08:24 +12:00 committed by GitHub
commit 4985e86ecc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 23 deletions

View File

@ -9,7 +9,8 @@ TABS.pid_tuning = {
currentRateProfile: null, currentRateProfile: null,
SETPOINT_WEIGHT_RANGE_LOW: 2.55, SETPOINT_WEIGHT_RANGE_LOW: 2.55,
SETPOINT_WEIGHT_RANGE_HIGH: 20, SETPOINT_WEIGHT_RANGE_HIGH: 20,
SETPOINT_WEIGHT_RANGE_LEGACY: 2.54 SETPOINT_WEIGHT_RANGE_LEGACY: 2.54,
activeSubtab: 'pid',
}; };
TABS.pid_tuning.initialize = function (callback) { TABS.pid_tuning.initialize = function (callback) {
@ -891,33 +892,28 @@ TABS.pid_tuning.initialize = function (callback) {
self.currentRates.rc_expo_pitch = self.currentRates.rc_expo; self.currentRates.rc_expo_pitch = self.currentRates.rc_expo;
} }
$('.tab-pid_tuning .tab_container .pid').on('click', function () { function activateSubtab(subtabName) {
$('.tab-pid_tuning .subtab-pid').show(); const names = ['pid', 'rates', 'filter'];
$('.tab-pid_tuning .subtab-rates').hide(); if (!names.includes(subtabName)) {
$('.tab-pid_tuning .subtab-filter').hide(); console.debug('Invalid subtab name: "' + subtabName + '"');
return;
}
for (name of names) {
const el = $('.tab-pid_tuning .subtab-' + name);
el[name == subtabName ? 'show' : 'hide']();
}
$('.tab-pid_tuning .tab_container td').removeClass('active'); $('.tab-pid_tuning .tab_container td').removeClass('active');
$(this).addClass('active'); $('.tab-pid_tuning .tab_container .' + subtabName).addClass('active');
}); self.activeSubtab = subtabName;
}
$('.tab-pid_tuning .tab_container .rates').on('click', function () { activateSubtab(self.activeSubtab);
$('.tab-pid_tuning .subtab-rates').show();
$('.tab-pid_tuning .subtab-pid').hide();
$('.tab-pid_tuning .subtab-filter').hide();
$('.tab-pid_tuning .tab_container td').removeClass('active'); $('.tab-pid_tuning .tab_container .pid').on('click', () => activateSubtab('pid'));
$(this).addClass('active');
});
$('.tab-pid_tuning .tab_container .filter').on('click', function () { $('.tab-pid_tuning .tab_container .rates').on('click', () => activateSubtab('rates'));
$('.tab-pid_tuning .subtab-filter').show();
$('.tab-pid_tuning .subtab-pid').hide();
$('.tab-pid_tuning .subtab-rates').hide();
$('.tab-pid_tuning .tab_container td').removeClass('active');
$(this).addClass('active');
});
$('.tab-pid_tuning .tab_container .filter').on('click', () => activateSubtab('filter'));
function loadProfilesList() { function loadProfilesList() {
var numberOfProfiles = 3; var numberOfProfiles = 3;