75 lines
2.6 KiB
JavaScript
75 lines
2.6 KiB
JavaScript
$(document).ready(function(){
|
|
$('.add-mn-btn').on('click', function () {
|
|
$('.card-reader').toggleClass('open');
|
|
});
|
|
|
|
|
|
$('.add-subject-btn').on('click', function () {
|
|
$('.add-subject').toggleClass('open');
|
|
if ($('.add-subject').first().hasClass('open')) {
|
|
$(this).addClass('btn-danger');
|
|
$(this).html('<i class="fa fa-times"></i> Anuluj');
|
|
$(this).attr('title', 'Anuluj');
|
|
} else {
|
|
$(this).removeClass('btn-danger');
|
|
$(this).html('<i class="fa fa-plus"></i> Dodaj nowy przedmiot');
|
|
$(this).attr('title', 'Dodaj nowy przedmiot');
|
|
}
|
|
});
|
|
|
|
$('.add-attendance-btn').on('click', function () {
|
|
$('.add-attendance').toggleClass('open');
|
|
if ($('.add-attendance').first().hasClass('open')) {
|
|
$(this).addClass('btn-danger');
|
|
$(this).html('<i class="fa fa-times"></i> Anuluj');
|
|
$(this).attr('title', 'Anuluj');
|
|
} else {
|
|
$(this).removeClass('btn-danger');
|
|
$(this).html('<i class="fa fa-plus"></i> Dodaj nowy wpis');
|
|
$(this).attr('title', 'Dodaj nowy wpis');
|
|
}
|
|
});
|
|
|
|
$(".modal").on("hidden.bs.modal", function(){
|
|
const originalText = $(this).find("#note_content_hidden").first().val();
|
|
$(this).find("#note_content").first().val(originalText);
|
|
});
|
|
|
|
$('#sort-select').on('change', function() {
|
|
$(location).attr('href', $(this).val())
|
|
});
|
|
|
|
$('#group-select').on('change', function() {
|
|
$(location).attr('href', $(this).val())
|
|
});
|
|
|
|
function setSelectedOptionSortAttendances() {
|
|
const orderBy = $('#orderBy-hidden').first().val();
|
|
const orderDirection = $('#orderDirection-hidden').first().val();
|
|
const pattern = `/${orderBy}/${orderDirection}`;
|
|
const options = $('#sort-select').find('option');
|
|
options.each(function() {
|
|
if($(this).val().search(pattern) !== -1) {
|
|
$('#sort-select').val($(this).val());
|
|
}
|
|
});
|
|
}
|
|
setSelectedOptionSortAttendances();
|
|
|
|
function setSelectedOptionGroup() {
|
|
const groupBy = $('#groupBy-hidden').first().val();
|
|
const pattern = `/${groupBy}`;
|
|
const options = $('#group-select').find('option');
|
|
options.each(function() {
|
|
if($(this).val().search(pattern) !== -1) {
|
|
$('#group-select').val($(this).val());
|
|
}
|
|
});
|
|
}
|
|
setSelectedOptionGroup();
|
|
|
|
$('input[type="checkbox"]').on('change', function() {
|
|
$('input[type="checkbox"]').not(this).prop('checked', false);
|
|
});
|
|
});
|