Fix toggle buttons reverting to checkboxes after reboot.

This moves GUI specific code out of main and the individual tab js files
into gui.js, where it fits better.
10.3.x-maintenance
Dominic Clifton 2015-11-11 21:01:22 +00:00
parent a0acd86873
commit d73196ea11
21 changed files with 49 additions and 47 deletions

View File

@ -237,5 +237,35 @@ GUI_control.prototype.tab_switch_cleanup = function (callback) {
}
};
GUI_control.prototype.content_ready = function (callback) {
$('.togglesmall').each(function(index, html) {
var switchery = new Switchery(html,
{
size: 'small',
color: '#59aa29',
secondaryColor: '#c4c4c4'
});
$(html).removeClass('togglesmall');
});
$('.toggle').each(function(index, html) {
var switchery = new Switchery(html,
{
color: '#59aa29',
secondaryColor: '#c4c4c4'
});
$(html).removeClass('toggle');
});
// Build link to in-use CF version documentation
var documentationButton = $('div#content #button-documentation');
documentationButton.html("Documentation for "+CONFIG.flightControllerVersion);
documentationButton.attr("href","https://github.com/cleanflight/cleanflight/tree/v{0}/docs".format(CONFIG.flightControllerVersion));
if (callback) callback();
}
// initialize object into GUI variable
var GUI = new GUI_control();

26
main.js
View File

@ -101,32 +101,6 @@ $(document).ready(function () {
function content_ready() {
GUI.tab_switch_in_progress = false;
$('.togglesmall').each(function(index, html) {
var switchery = new Switchery(html,
{
size: 'small',
color: '#59aa29',
secondaryColor: '#c4c4c4'
});
$(html).removeClass('togglesmall');
});
$('.toggle').each(function(index, html) {
var switchery = new Switchery(html,
{
color: '#59aa29',
secondaryColor: '#c4c4c4'
});
$(html).removeClass('toggle');
});
// Build link to in-use CF version documentation
var documentationButton = $('div#content #button-documentation');
documentationButton.html("Documentation for "+CONFIG.flightControllerVersion);
documentationButton.attr("href","https://github.com/cleanflight/cleanflight/tree/v{0}/docs".format(CONFIG.flightControllerVersion));
}
switch (tab) {

View File

@ -277,7 +277,7 @@ TABS.adjustments.initialize = function (callback) {
MSP.send_message(MSP_codes.MSP_STATUS);
}, 250, true);
if (callback) callback();
GUI.content_ready(callback);
}
};

View File

@ -283,7 +283,7 @@ TABS.auxiliary.initialize = function (callback) {
MSP.send_message(MSP_codes.MSP_STATUS);
}, 250, true);
if (callback) callback();
GUI.content_ready(callback);
}
};

View File

@ -62,7 +62,7 @@ TABS.cli.initialize = function (callback) {
// give input element user focus
textarea.focus();
if (callback) callback();
GUI.content_ready(callback);
});
};

View File

@ -469,7 +469,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
MSP.send_message(MSP_codes.MSP_STATUS);
}, 250, true);
if (callback) callback();
GUI.content_ready(callback);
}
};

View File

@ -113,7 +113,7 @@ TABS.dataflash.initialize = function (callback) {
}
if (callback) callback();
GUI.content_ready(callback);
}
// IO related methods

View File

@ -516,7 +516,7 @@ TABS.firmware_flasher.initialize = function (callback) {
}
});
if (callback) callback();
GUI.content_ready(callback);
});
};

View File

@ -71,7 +71,7 @@ TABS.gps.initialize = function (callback) {
MSP.send_message(MSP_codes.MSP_STATUS);
}, 250, true);
if (callback) callback();
GUI.content_ready(callback);
}
};

View File

@ -12,7 +12,7 @@ TABS.help.initialize = function (callback) {
$('#content').load("./tabs/help.html", function () {
localize();
if (callback) callback();
GUI.content_ready(callback);
});
};

View File

@ -45,7 +45,7 @@ $("#changelog_button").on('click', function() {
if (callback) callback();
GUI.content_ready(callback);
});
};

View File

@ -288,7 +288,7 @@ TABS.led_strip.initialize = function (callback, scrollPosition) {
});
if (callback) callback();
GUI.content_ready(callback);
}
function findLed(x, y) {

View File

@ -110,7 +110,7 @@ TABS.logging.initialize = function (callback) {
}
});
if (callback) callback();
GUI.content_ready(callback);
}
function print_head() {

View File

@ -149,7 +149,7 @@ TABS.modes.initialize = function (callback) {
MSP.send_message(MSP_codes.MSP_STATUS);
}, 250, true);
if (callback) callback();
GUI.content_ready(callback);
}
};

View File

@ -450,7 +450,7 @@ TABS.motors.initialize = function (callback) {
// enable Status and Motor data pulling
GUI.interval_add('motor_and_status_pull', get_status, 50, true);
if (callback) callback();
GUI.content_ready(callback);
}
};

View File

@ -402,9 +402,7 @@ TABS.pid_tuning.initialize = function (callback) {
MSP.send_message(MSP_codes.MSP_STATUS);
}, 250, true);
if (callback) {
callback();
}
GUI.content_ready(callback);
}
};

View File

@ -208,7 +208,7 @@ TABS.ports.initialize = function (callback, scrollPosition) {
MSP.send_message(MSP_codes.MSP_STATUS);
}, 250, true);
if (callback) callback();
GUI.content_ready(callback);
}
function on_save_handler() {

View File

@ -458,7 +458,7 @@ TABS.receiver.initialize = function (callback) {
MSP.send_message(MSP_codes.MSP_STATUS);
}, 250, true);
if (callback) callback();
GUI.content_ready(callback);
}
};

View File

@ -448,7 +448,7 @@ TABS.sensors.initialize = function (callback) {
MSP.send_message(MSP_codes.MSP_STATUS);
}, 250, true);
if (callback) callback();
GUI.content_ready(callback);
});
};

View File

@ -192,7 +192,7 @@ TABS.servos.initialize = function (callback) {
MSP.send_message(MSP_codes.MSP_STATUS);
}, 250, true);
if (callback) callback();
GUI.content_ready(callback);
}
};

View File

@ -193,7 +193,7 @@ TABS.setup.initialize = function (callback) {
GUI.interval_add('setup_data_pull_fast', get_fast_data, 33, true); // 30 fps
GUI.interval_add('setup_data_pull_slow', get_slow_data, 250, true); // 4 fps
if (callback) callback();
GUI.content_ready(callback);
}
};