d8d2ad002a
- rename static subdirs to css and js - move global static dir to core/static, changed - move global templates dir to core/templates - check comments and code style of all our own CSS and JS files - minor changes related to the changes of template and static files
68 lines
2.2 KiB
JavaScript
68 lines
2.2 KiB
JavaScript
/*
|
|
* JavaScript functions for assignment.
|
|
*
|
|
*/
|
|
|
|
$(function() {
|
|
$('a.elected').parent().parent().children('td').addClass('elected');
|
|
|
|
$('.election_link').click(function(event) {
|
|
event.preventDefault();
|
|
line = $(this);
|
|
$.ajax({
|
|
type: 'GET',
|
|
url: line.attr('href'),
|
|
dataType: 'json',
|
|
success: function(data) {
|
|
if (line.hasClass('elected') && !data.elected) {
|
|
line.removeClass('elected')
|
|
line.parent().parent().children('td').removeClass('elected')
|
|
} else if (!line.hasClass('elected') && data.elected) {
|
|
line.addClass('elected')
|
|
line.parent().parent().children('td').addClass('elected')
|
|
}
|
|
line.attr('href', data.link);
|
|
}
|
|
});
|
|
});
|
|
$('.close_link').click(function(event) {
|
|
event.preventDefault();
|
|
slide = $(this);
|
|
$.ajax({
|
|
type: 'GET',
|
|
url: slide.attr('href'),
|
|
dataType: 'json',
|
|
success: function(data) {
|
|
if (data.closed) {
|
|
newclass = 'closed';
|
|
} else {
|
|
newclass = 'open';
|
|
}
|
|
slide.removeClass('closed open').addClass(newclass);
|
|
slide.attr('href', data.link);
|
|
}
|
|
});
|
|
});
|
|
// change publish status of ballot
|
|
$('.publish_link').click(function(event) {
|
|
event.preventDefault();
|
|
var link = $(this);
|
|
$.ajax({
|
|
type: 'GET',
|
|
url: $(this).attr('href'),
|
|
dataType: 'json',
|
|
success: function(data) {
|
|
if (data.published) {
|
|
newclass = 'icon-checked-new_white';
|
|
link.addClass('btn-primary');
|
|
} else {
|
|
newclass = 'icon-unchecked-new';
|
|
link.removeClass('btn-primary');
|
|
}
|
|
link.children('i').removeClass('icon-checked-new_white icon-unchecked-new').addClass(newclass);
|
|
link.attr('href', data.link);
|
|
}
|
|
});
|
|
});
|
|
});
|