2014-01-14 23:22:29 +01:00
|
|
|
/*
|
|
|
|
* JavaScript functions for assignment.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2011-09-03 11:42:44 +02:00
|
|
|
$(function() {
|
2011-09-05 23:13:18 +02:00
|
|
|
$('a.elected').parent().parent().children('td').addClass('elected');
|
2011-09-03 11:42:44 +02:00
|
|
|
|
|
|
|
$('.election_link').click(function(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
line = $(this);
|
|
|
|
$.ajax({
|
|
|
|
type: 'GET',
|
|
|
|
url: line.attr('href'),
|
|
|
|
dataType: 'json',
|
|
|
|
success: function(data) {
|
2011-09-05 23:13:18 +02:00
|
|
|
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')
|
2011-09-03 11:42:44 +02:00
|
|
|
}
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2013-02-05 20:40:55 +01:00
|
|
|
// change publish status of ballot
|
2012-05-19 16:25:55 +02:00
|
|
|
$('.publish_link').click(function(event) {
|
|
|
|
event.preventDefault();
|
2013-02-05 20:40:55 +01:00
|
|
|
var link = $(this);
|
2012-05-19 16:25:55 +02:00
|
|
|
$.ajax({
|
|
|
|
type: 'GET',
|
2013-02-05 20:40:55 +01:00
|
|
|
url: $(this).attr('href'),
|
2012-05-19 16:25:55 +02:00
|
|
|
dataType: 'json',
|
|
|
|
success: function(data) {
|
|
|
|
if (data.published) {
|
2013-02-05 20:40:55 +01:00
|
|
|
newclass = 'icon-checked-new_white';
|
|
|
|
link.addClass('btn-primary');
|
2012-05-19 16:25:55 +02:00
|
|
|
} else {
|
2013-02-05 20:40:55 +01:00
|
|
|
newclass = 'icon-unchecked-new';
|
|
|
|
link.removeClass('btn-primary');
|
2012-05-19 16:25:55 +02:00
|
|
|
}
|
2013-02-05 20:40:55 +01:00
|
|
|
link.children('i').removeClass('icon-checked-new_white icon-unchecked-new').addClass(newclass);
|
|
|
|
link.attr('href', data.link);
|
2012-05-19 16:25:55 +02:00
|
|
|
}
|
|
|
|
});
|
2014-01-14 23:22:29 +01:00
|
|
|
});
|
|
|
|
});
|