added button state for files which no actions are available for

This commit is contained in:
Hauke Klement
2015-03-21 12:40:58 +01:00
parent 5ec0a82157
commit 49f5ab061a
6 changed files with 15 additions and 1 deletions

View File

@ -156,6 +156,10 @@ $(function() {
jqxhr.fail(ajaxError);
};
var fileActionsAvailable = function() {
return isActiveFileRenderable() || isActiveFileRunnable() || isActiveFileStoppable() || isActiveFileTestable();
};
var findOrCreateOutputElement = function(index) {
if ($('#output-' + index).isPresent()) {
return $('#output-' + index);
@ -644,6 +648,8 @@ $(function() {
$('#dropdown-run').toggleClass('disabled', !isActiveFileRunnable() || running);
$('#dropdown-stop').toggleClass('disabled', !isActiveFileStoppable());
$('#dropdown-test').toggleClass('disabled', !isActiveFileTestable());
$('#dummy').toggle(!fileActionsAvailable());
$('#editor-buttons .dropdown-toggle').toggle(fileActionsAvailable());
$('#render').toggle(isActiveFileRenderable());
$('#run').toggle(isActiveFileRunnable() && !running);
$('#stop').toggle(isActiveFileStoppable());

View File

@ -24,6 +24,11 @@ button i.fa-spin {
display: none;
}
#dummy {
display: none;
width: 100% !important;
}
#editor-buttons {
background-color: #008CBA;
margin-top: 1em;

View File

@ -7,6 +7,7 @@
= render('editor_button', data: {:'data-message-confirm' => t('exercises.editor.confirm_start_over'), :'data-url' => exercise_path(exercise)}, icon: 'fa fa-history', id: 'start-over', label: t('exercises.editor.start_over'))
= render('editor_button', data: {:'data-message-success' => t('submissions.create.success'), :'data-placement' => 'top', :'data-tooltip' => true}, icon: 'fa fa-save', id: 'save', label: t('exercises.editor.save'), title: t('.tooltips.save'))
.btn-group
= render('editor_button', disabled: true, icon: 'fa fa-ban', id: 'dummy', label: t('exercises.editor.dummy'))
= render('editor_button', icon: 'fa fa-desktop', id: 'render', label: t('exercises.editor.render'))
= render('editor_button', data: {:'data-message-failure' => t('exercises.editor.run_failure'), :'data-message-network' => t('exercises.editor.network'), :'data-message-success' => t('exercises.editor.run_success'), :'data-placement' => 'top', :'data-tooltip' => true}, icon: 'fa fa-play', id: 'run', label: t('exercises.editor.run'), title: t('shared.tooltips.shortcut', shortcut: 'ALT + r'))
= render('editor_button', data: {:'data-placement' => 'top', :'data-tooltip' => true}, icon: 'fa fa-stop', id: 'stop', label: t('exercises.editor.stop'), title: t('shared.tooltips.shortcut', shortcut: 'ALT + r'))

View File

@ -1,4 +1,4 @@
button.btn class=local_assigns.fetch(:classes, 'btn-primary') *local_assigns.fetch(:data, {}) id=id title=local_assigns[:title] type='button'
button.btn class=local_assigns.fetch(:classes, 'btn-primary') *local_assigns.fetch(:data, {}) disabled=local_assigns.fetch(:disabled, false) id=id title=local_assigns[:title] type='button'
i.fa.fa-circle-o-notch.fa-spin
i class=icon
= label