Skip to content

Commit 975ef1e

Browse files
authored
Merge pull request #686 from mosvov/osd-switch-all-elements
Enable/Disable all button for OSD screen
2 parents a976b88 + 79d5c1a commit 975ef1e

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

_locales/en/messages.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2312,6 +2312,9 @@
23122312
"osdSetupElementsTitle": {
23132313
"message": "Elements"
23142314
},
2315+
"osdSetupElementsSwitchAll": {
2316+
"message": "Switch all"
2317+
},
23152318
"osdSetupPreviewTitle": {
23162319
"message": "Preview (drag to change position)"
23172320
},

tabs/osd.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,10 @@
316316
background: rgba(255,255,255,0.4);
317317
}
318318

319+
.tab-osd .switch-all-elements {
320+
float: right;
321+
}
322+
319323
.tab-osd .preview .char[draggable="true"] {
320324
cursor: move;
321325
}

tabs/osd.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ <h1 class="tab_title">
1818
<div class="spacer_right">
1919
<div class="gui_box grey">
2020
<div class="gui_box_titlebar" style="margin-bottom: 0px;">
21-
<div class="spacer_box_title" i18n="osdSetupElementsTitle" />
21+
<div class="spacer_box_title">
22+
<span i18n="osdSetupElementsTitle" />
23+
<span class="switch-all-elements">
24+
<label for="switch-all"><span i18n="osdSetupElementsSwitchAll" />: </label>
25+
<input type="checkbox" checked id="switch-all" name="switch-all" class="togglesmall"></input>
26+
</span>
27+
</div>
2228
</div>
2329
<div class="spacer_box">
2430
<div id="element-fields" class="switchable-fields"></div>

tabs/osd.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,6 +1532,23 @@ TABS.osd.initialize = function (callback) {
15321532
}
15331533
});
15341534

1535+
//Switch all elements
1536+
$('input#switch-all').change(function () {
1537+
var new_state = $(this).is(':checked');
1538+
1539+
var updateList = [];
1540+
$('#element-fields input[type=checkbox]').each(function () {
1541+
var field = $(this).data('field');
1542+
field.isVisible = new_state;
1543+
1544+
updateList.push(MSP.promise(MSPCodes.MSP_SET_OSD_CONFIG, OSD.msp.encodeLayout(field)));
1545+
})
1546+
1547+
Promise.all(updateList).then(function () {
1548+
updateOsdView();
1549+
});
1550+
})
1551+
15351552
$(document).on('click', 'span.progressLabel a.save_font', function () {
15361553
chrome.fileSystem.chooseEntry({type: 'saveFile', suggestedName: 'baseflight', accepts: [{extensions: ['mcm']}]}, function (fileEntry) {
15371554
if (chrome.runtime.lastError) {

0 commit comments

Comments
 (0)