js: Use a fixed with for form buttons once a form submit is ongoing

...and a progress label is set.

refs #8369
This commit is contained in:
Johannes Meyer 2015-08-20 15:32:31 +02:00
parent a77dc3665c
commit 3f4221b249
1 changed files with 13 additions and 6 deletions

View File

@ -340,18 +340,25 @@
if ($button.attr('data-progress-label')) { if ($button.attr('data-progress-label')) {
var isInput = $button.is('input'); var isInput = $button.is('input');
if (isInput) { if (isInput) {
$button.prop('value', $button.attr('data-progress-label')); $button.prop('value', $button.attr('data-progress-label') + '...');
} else { } else {
$button.html($button.attr('data-progress-label')); $button.html($button.attr('data-progress-label') + '...');
} }
// Use a fixed width to prevent the button from wobbling
$button.css('width', $button.css('width'));
progressTimer = icinga.timer.register(function () { progressTimer = icinga.timer.register(function () {
var label = isInput ? $button.prop('value') : $button.html(); var label = isInput ? $button.prop('value') : $button.html();
var dots = label.substr(-3);
if (label.substr(-3) === '...') { // Using empty spaces here to prevent centered labels from wobbling
label = label.slice(0, -2); if (dots === '...') {
} else { label = label.slice(0, -2) + ' ';
label += '.'; } else if (dots === '.. ') {
label = label.slice(0, -1) + '.';
} else if (dots === '. ') {
label = label.slice(0, -2) + '. ';
} }
if (isInput) { if (isInput) {