Don't allow setting of forbidden overlays in case of multiple selection of leds with varying functions
parent
aaef07a01b
commit
98e04ee9f6
|
@ -425,8 +425,38 @@ TABS.led_strip.initialize = function (callback, scrollPosition) {
|
|||
{
|
||||
if ($(that).is(':checked')) {
|
||||
$('.ui-selected').find('.wire').each(function() {
|
||||
if ($(this).text() != "")
|
||||
$(this).parent().addClass('function-' + letter);
|
||||
if ($(this).text() != "") {
|
||||
|
||||
var p = $(this).parent();
|
||||
|
||||
TABS.led_strip.functions.forEach(function(f) {
|
||||
if (p.is('.function-' + f)) {
|
||||
|
||||
switch (letter) {
|
||||
case 't':
|
||||
case 'o':
|
||||
case 's':
|
||||
if (areModifiersActive('function-' + f))
|
||||
p.addClass('function-' + letter);
|
||||
break;
|
||||
case 'b':
|
||||
case 'n':
|
||||
if (areBlinkersActive('function-' + f))
|
||||
p.addClass('function-' + letter);
|
||||
break;
|
||||
case 'i':
|
||||
if (areOverlaysActive('function-' + f))
|
||||
p.addClass('function-' + letter);
|
||||
break;
|
||||
case 'w':
|
||||
if (areOverlaysActive('function-' + f))
|
||||
if (isWarningActive('function-' + f))
|
||||
p.addClass('function-' + letter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$('.ui-selected').removeClass('function-' + letter);
|
||||
|
@ -434,7 +464,7 @@ TABS.led_strip.initialize = function (callback, scrollPosition) {
|
|||
return $(that).is(':checked');
|
||||
}
|
||||
|
||||
// UI: checkbox toggle
|
||||
// UI: check-box toggle
|
||||
$('.checkbox').change(function(e) {
|
||||
if (e.originalEvent) {
|
||||
// user-triggered event
|
||||
|
@ -444,17 +474,20 @@ TABS.led_strip.initialize = function (callback, scrollPosition) {
|
|||
TABS.led_strip.overlays.forEach(function(letter) {
|
||||
if ($(that).is('.function-' + letter)) {
|
||||
var ret = toggleSwitch(that, letter);
|
||||
var cbn = $('.checkbox .function-n');
|
||||
var cbb = $('.checkbox .function-b');
|
||||
|
||||
if (ret && letter == 'b' && cbn.is(':checked')) {
|
||||
cbn.prop('checked', false);
|
||||
cbn.change();
|
||||
toggleSwitch(cbn, 'n');
|
||||
} else if (ret && letter == 'n' && cbb.is(':checked')) {
|
||||
cbb.prop('checked', false);
|
||||
cbb.change();
|
||||
toggleSwitch(cbb, 'b');
|
||||
var cbn = $('.checkbox .function-n'); // blink on landing
|
||||
var cbb = $('.checkbox .function-b'); // blink
|
||||
|
||||
if (ret) {
|
||||
if (letter == 'b' && cbn.is(':checked')) {
|
||||
cbn.prop('checked', false);
|
||||
cbn.change();
|
||||
toggleSwitch(cbn, 'n');
|
||||
} else if (letter == 'n' && cbb.is(':checked')) {
|
||||
cbb.prop('checked', false);
|
||||
cbb.change();
|
||||
toggleSwitch(cbb, 'b');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -475,7 +508,7 @@ TABS.led_strip.initialize = function (callback, scrollPosition) {
|
|||
$('.gPoint').each(function(){
|
||||
var gridNumber = ($(this).index() + 1);
|
||||
var row = Math.ceil(gridNumber / 16) - 1;
|
||||
var col = gridNumber/16 % 1 * 16 - 1;
|
||||
var col = gridNumber / 16 % 1 * 16 - 1;
|
||||
if (col < 0) {
|
||||
col = 15;
|
||||
}
|
||||
|
@ -666,6 +699,86 @@ TABS.led_strip.initialize = function (callback, scrollPosition) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
function areModifiersActive(activeFunction) {
|
||||
if (semver.lt(CONFIG.apiVersion, "1.20.0")) {
|
||||
switch (activeFunction) {
|
||||
case "function-c":
|
||||
case "function-a":
|
||||
case "function-f":
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (activeFunction) {
|
||||
case "function-c":
|
||||
case "function-a":
|
||||
case "function-f":
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function areOverlaysActive(activeFunction) {
|
||||
if (semver.lt(CONFIG.apiVersion, "1.20.0")) {
|
||||
switch (activeFunction) {
|
||||
case "function-c":
|
||||
case "function-a":
|
||||
case "function-f":
|
||||
case "function-g":
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (activeFunction) {
|
||||
case "":
|
||||
case "function-c":
|
||||
case "function-a":
|
||||
case "function-f":
|
||||
case "function-s":
|
||||
case "function-l":
|
||||
case "function-r":
|
||||
case "function-o":
|
||||
case "function-g":
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function areBlinkersActive(activeFunction) {
|
||||
if (semver.gte(CONFIG.apiVersion, "1.20.0")) {
|
||||
switch (activeFunction) {
|
||||
case "function-c":
|
||||
case "function-a":
|
||||
case "function-f":
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function isWarningActive(activeFunction) {
|
||||
switch (activeFunction) {
|
||||
case "function-l":
|
||||
case "function-s":
|
||||
case "function-g":
|
||||
return false;
|
||||
break;
|
||||
case "function-r":
|
||||
case "function-b":
|
||||
if (semver.lt(CONFIG.apiVersion, "1.20.0"))
|
||||
return false;
|
||||
break;
|
||||
default:
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function setOptionalGroupsVisibility() {
|
||||
|
||||
|
@ -690,71 +803,26 @@ TABS.led_strip.initialize = function (callback, scrollPosition) {
|
|||
}
|
||||
|
||||
|
||||
|
||||
// set color modifiers (checkboxes) visibility
|
||||
// set color modifiers (check-boxes) visibility
|
||||
$('.overlays').hide();
|
||||
$('.modifiers').hide();
|
||||
$('.blinkers').hide();
|
||||
$('.warningOverlay').hide();
|
||||
|
||||
if (areOverlaysActive(activeFunction))
|
||||
$('.overlays').show();
|
||||
|
||||
if (semver.lt(CONFIG.apiVersion, "1.20.0")) {
|
||||
switch (activeFunction) {
|
||||
case "function-c":
|
||||
case "function-a":
|
||||
case "function-f":
|
||||
$('.modifiers').show();
|
||||
$('.overlays').show();
|
||||
break;
|
||||
case "function-g":
|
||||
$('.overlays').show();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (activeFunction) {
|
||||
case "":
|
||||
$('.overlays').show();
|
||||
break;
|
||||
case "function-c":
|
||||
case "function-a":
|
||||
case "function-f":
|
||||
$('.modifiers').show();
|
||||
$('.overlays').show();
|
||||
$('.blinkers').show();
|
||||
break;
|
||||
case "function-s":
|
||||
case "function-l":
|
||||
case "function-r":
|
||||
case "function-o":
|
||||
case "function-g":
|
||||
$('.overlays').show();
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (areModifiersActive(activeFunction))
|
||||
$('.modifiers').show();
|
||||
|
||||
if (areBlinkersActive(activeFunction))
|
||||
$('.blinkers').show();
|
||||
|
||||
if (isWarningActive(activeFunction))
|
||||
$('.warningOverlay').show();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// set overlays (checkboxes) visibility
|
||||
switch (activeFunction) {
|
||||
case "function-l":
|
||||
case "function-s":
|
||||
case "function-g":
|
||||
$('.warningOverlay').hide();
|
||||
break;
|
||||
case "function-r":
|
||||
case "function-b":
|
||||
if (semver.lt(CONFIG.apiVersion, "1.20.0"))
|
||||
$('.warningOverlay').hide();
|
||||
break;
|
||||
default:
|
||||
$('.warningOverlay').show();
|
||||
break;
|
||||
}
|
||||
|
||||
// set overlays (checkboxes) visibility
|
||||
// set directions visibility
|
||||
if (semver.lt(CONFIG.apiVersion, "1.20.0")) {
|
||||
switch (activeFunction) {
|
||||
|
@ -768,6 +836,7 @@ TABS.led_strip.initialize = function (callback, scrollPosition) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$('.mode_colors').hide();
|
||||
if (semver.gte(CONFIG.apiVersion, "1.19.0")) {
|
||||
// set mode colors visibility
|
||||
|
|
Loading…
Reference in New Issue