aboutsummaryrefslogtreecommitdiff
path: root/resources/assets/javascripts/bootstrap/raumzeit.js
blob: 3a6414ec25d0b1b93e96c52d719f730a4f4c403e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { $gettext } from '../lib/gettext';

STUDIP.Dialog.handlers.header['X-Raumzeit-Update-Times'] = function(json) {
    var info = $.parseJSON(json);
    $('.course-admin #course-' + info.course_id + ' .raumzeit').html(info.html);
};

$(document).on('change', '.datesBulkActions', function() {
    var $button = $(this).next('button');
    if ($(this).val() === 'delete') {
        $button.attr('data-confirm', $gettext('Wollen Sie die gewünschten Termine wirklich löschen?'));
    } else {
        if ($button.attr('data-confirm')) {
            $button.removeAttr('data-confirm');
        }
    }
});

$(document).on('change', '#edit-cycle', function() {
    var start = $('input[name=start_time]', this)[0],
        end = $('input[name=end_time]', this)[0],
        changed =
            start.defaultValue &&
            end.defaultValue &&
            (start.value !== start.defaultValue || end.value !== end.defaultValue);
    // check if new time exceeds the current one and add security question if necessary
    if (changed && (start.value < start.defaultValue || end.value > end.defaultValue)) {
        $(this).attr(
            'data-confirm',
            $gettext('Wenn Sie die regelmäßige Zeit ändern, verlieren Sie die Raumbuchungen für alle in der Zukunft liegenden Termine! Sind Sie sicher, dass Sie die regelmäßige Zeit ändern möchten?')
        );
    } else {
        // remove security question - not necessary (any more)
        $(this).attr('data-confirm', null);
    }
});