Adding a 'Clear ALL' button on the LED Strip tab. Updating 'Clear' so

that it also clears the wire order.

This makes it easier to change LED layouts without too much button
clicking.
10.3.x-maintenance
Dominic Clifton 2015-01-22 21:27:13 +01:00
parent 822af2352e
commit bb13699b48
2 changed files with 29 additions and 7 deletions

View File

@ -7,6 +7,7 @@
<div class="controls">
<div class="wires-remaining"><div></div>Remaining</div>
<button class="funcClear">Clear selected</button>
<button class="funcClearAll">Clear ALL</button>
<div class="section">LED Functions</div>
<div class="functions">

View File

@ -53,22 +53,43 @@ TABS.led_strip.initialize = function (callback, scrollPosition) {
$(this).select();
});
// Clear Button
// Clear button
$('.funcClear').click(function() {
$('.gPoint').each(function() {
if ($(this).is('.ui-selected')) {
$(this).removeClass(function(index, theClass) {
theClass = theClass.replace(/(^|\s)+gPoint\s+/, '');
return theClass;
});
$(this).addClass('ui-selected');
updateBulkCmd();
removeFunctionsAndDirections(this);
$(this).find('.wire').html('');
}
});
$('.controls button').removeClass('btnOn');
updateBulkCmd();
});
// Clear All button
$('.funcClearAll').click(function() {
$('.gPoint').each(function() {
removeFunctionsAndDirections(this);
});
$('.gPoint .wire').html('');
updateBulkCmd();
$('.controls button').removeClass('btnOn');
});
function removeFunctionsAndDirections(element) {
var classesToRemove = [];
TABS.led_strip.functions.forEach(function(letter) {
classesToRemove.push('function-' + letter);
});
TABS.led_strip.directions.forEach(function(letter) {
classesToRemove.push('dir-' + letter);
});
$(element).removeClass(classesToRemove.join(' '));
}
// Directional Buttons
$('.directions').on('click', 'button', function() {