From f31a64317aad4b5b8cfc9eb087634b1918a34f21 Mon Sep 17 00:00:00 2001 From: mikeller Date: Sun, 12 Feb 2017 00:35:59 +1300 Subject: [PATCH] Added auto-hiding for settings in configuration tab if the corresponding feature isn't enabled. --- js/Features.js | 2 +- tabs/configuration.html | 110 +++++++++++++++++++++++----------------- tabs/configuration.js | 81 ++++++++++++++++++++--------- 3 files changed, 123 insertions(+), 70 deletions(-) diff --git a/js/Features.js b/js/Features.js index aaa48609..ec7ced9c 100644 --- a/js/Features.js +++ b/js/Features.js @@ -15,7 +15,7 @@ var Features = function (config) { {bit: 9, group: 'other', name: 'SONAR'}, {bit: 10, group: 'other', name: 'TELEMETRY'}, {bit: 11, group: 'batteryCurrent', name: 'CURRENT_METER'}, - {bit: 12, group: 'other', name: '3D'}, + {bit: 12, group: '3D', name: '3D'}, {bit: 13, group: 'rxMode', mode: 'select', name: 'RX_PARALLEL_PWM'}, {bit: 14, group: 'rxMode', mode: 'select', name: 'RX_MSP'}, {bit: 15, group: 'rssi', name: 'RSSI_ADC'}, diff --git a/tabs/configuration.html b/tabs/configuration.html index ec23540e..6d0a0f54 100644 --- a/tabs/configuration.html +++ b/tabs/configuration.html @@ -435,11 +435,6 @@
-
-
-

-
-
@@ -452,28 +447,37 @@
-
- - -
-
- - -
-
- - -
-
- +
+
+
+
+

+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ +
@@ -482,25 +486,39 @@
-
- -
-
- -
-
- -
-
- + + + + + + + + + + + +
+
+
+ +
+
+ +
+
+ +
+
+ +
diff --git a/tabs/configuration.js b/tabs/configuration.js index 0d33c941..91815852 100644 --- a/tabs/configuration.js +++ b/tabs/configuration.js @@ -562,19 +562,6 @@ TABS.configuration.initialize = function (callback, scrollPosition) { } } - $('input.feature', features_e).change(function () { - var element = $(this); - - BF_CONFIG.features.updateData(element); - updateTabList(BF_CONFIG.features); - - if (element.attr('name') === 'MOTOR_STOP') { - checkShowDisarmDelay(); - } - }); - - checkShowDisarmDelay(); - function checkShowSerialRxBox() { if (BF_CONFIG.features.isEnabled('RX_SERIAL')) { $('div.serialRXBox').show(); @@ -623,28 +610,76 @@ TABS.configuration.initialize = function (callback, scrollPosition) { } } + function checkUpdateGpsControls() { + if (BF_CONFIG.features.isEnabled('GPS')) { + $('.gpsSettings').show(); + } else { + $('.gpsSettings').hide(); + } + } + + function checkUpdate3dControls() { + if (BF_CONFIG.features.isEnabled('3D')) { + $('._3dSettings').show(); + } else { + $('._3dSettings').hide(); + } + } + + $('input.feature', features_e).change(function () { + var element = $(this); + + BF_CONFIG.features.updateData(element); + updateTabList(BF_CONFIG.features); + + switch (element.attr('name')) { + case 'MOTOR_STOP': + checkShowDisarmDelay(); + + break; + case 'VBAT': + checkUpdateVbatControls(); + + break; + case 'CURRENT_METER': + checkUpdateCurrentControls(); + + break; + case 'GPS': + checkUpdateGpsControls(); + + break; + case '3D': + checkUpdate3dControls(); + + break; + default: + break; + } + }); + $(features_e).filter('select').change(function () { var element = $(this); BF_CONFIG.features.updateData(element); updateTabList(BF_CONFIG.features); - if (element.attr('name') === 'rxMode') { - checkShowSerialRxBox(); + switch (element.attr('name')) { + case 'rxMode': + checkShowSerialRxBox(); + + break; + default: + break; } }); - $(features_e).filter('tbody.features.batteryVoltage').change(function() { - checkUpdateVbatControls(); - }); - - $(features_e).filter('tbody.features.batteryCurrent').change(function() { - checkUpdateCurrentControls(); - }); - + checkShowDisarmDelay(); checkShowSerialRxBox(); checkUpdateVbatControls(); checkUpdateCurrentControls(); + checkUpdateGpsControls(); + checkUpdate3dControls(); $("input[id='unsyncedPWMSwitch']").change(function() { if ($(this).is(':checked')) {