2014-09-04 17:52:18 +02:00
|
|
|
$(document).ready(function() {
|
2014-10-21 01:31:26 +02:00
|
|
|
|
2015-03-05 14:53:42 +01:00
|
|
|
window.lang = $('html').attr('lang');
|
2014-10-21 01:31:26 +02:00
|
|
|
|
2014-09-04 17:52:18 +02:00
|
|
|
/**
|
|
|
|
* adminstuds.php
|
|
|
|
**/
|
|
|
|
|
|
|
|
$('#title-form .btn-edit').on('click', function() {
|
2014-11-06 15:51:39 +01:00
|
|
|
$('#title-form h3').hide();
|
2015-06-25 07:58:05 +02:00
|
|
|
$('.js-title').removeClass('hidden');
|
2014-09-04 17:52:18 +02:00
|
|
|
$('.js-title input').focus();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#title-form .btn-cancel').on('click', function() {
|
2014-11-06 15:51:39 +01:00
|
|
|
$('#title-form h3').show();
|
2015-06-25 07:58:05 +02:00
|
|
|
$('#title-form .js-title').addClass('hidden');
|
2014-09-04 17:52:18 +02:00
|
|
|
$('#title-form .btn-edit').focus();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2015-01-08 22:03:44 +01:00
|
|
|
$('#name-form .btn-edit').on('click', function() {
|
|
|
|
$('#name-form p').hide();
|
2015-06-25 07:58:05 +02:00
|
|
|
$('.js-name').removeClass('hidden');
|
2015-01-08 22:03:44 +01:00
|
|
|
$('.js-name input').focus();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#name-form .btn-cancel').on('click', function() {
|
|
|
|
$('#name-form p').show();
|
2015-06-25 07:58:05 +02:00
|
|
|
$('#name-form .js-name').addClass('hidden');
|
2015-01-08 22:03:44 +01:00
|
|
|
$('#name-form .btn-edit').focus();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2014-09-04 17:52:18 +02:00
|
|
|
$('#email-form .btn-edit').on('click', function() {
|
|
|
|
$('#email-form p').hide();
|
2015-06-25 07:58:05 +02:00
|
|
|
$('#email-form .js-email').removeClass('hidden');
|
2014-09-04 17:52:18 +02:00
|
|
|
$('.js-email input').focus();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#email-form .btn-cancel').on('click', function() {
|
|
|
|
$('#email-form p').show();
|
2015-06-25 07:58:05 +02:00
|
|
|
$('#email-form .js-email').addClass('hidden');
|
2014-09-04 17:52:18 +02:00
|
|
|
$('#email-form .btn-edit').focus();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#description-form .btn-edit').on('click', function() {
|
|
|
|
$('#description-form .well').hide();
|
2015-06-25 07:58:05 +02:00
|
|
|
$('#description-form .js-desc').removeClass('hidden');
|
2014-09-04 17:52:18 +02:00
|
|
|
$('.js-desc textarea').focus();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#description-form .btn-cancel').on('click', function() {
|
|
|
|
$('#description-form .well').show();
|
2015-06-25 07:58:05 +02:00
|
|
|
$('#description-form .js-desc').addClass('hidden');
|
2014-09-04 17:52:18 +02:00
|
|
|
$('.js-desc .btn-edit').focus();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2014-10-21 01:31:26 +02:00
|
|
|
$('#poll-rules-form .btn-edit').on('click', function() {
|
|
|
|
$('#poll-rules-form p').hide();
|
2015-06-25 07:58:05 +02:00
|
|
|
$('#poll-rules-form .js-poll-rules').removeClass('hidden');
|
2014-10-21 01:31:26 +02:00
|
|
|
$('.js-poll-rules select').focus();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#poll-rules-form .btn-cancel').on('click', function() {
|
|
|
|
$('#poll-rules-form p').show();
|
2015-06-25 07:58:05 +02:00
|
|
|
$('#poll-rules-form .js-poll-rules').addClass('hidden');
|
2014-10-21 01:31:26 +02:00
|
|
|
$('.js-poll-rules .btn-edit').focus();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2015-04-06 12:39:58 +02:00
|
|
|
$('#poll-hidden-form .btn-edit').on('click', function() {
|
|
|
|
$('#poll-hidden-form p').hide();
|
2015-06-25 07:58:05 +02:00
|
|
|
$('#poll-hidden-form .js-poll-hidden').removeClass('hidden');
|
2015-04-06 12:39:58 +02:00
|
|
|
$('.js-poll-hidden input[type=checkbox]').focus();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#poll-hidden-form .btn-cancel').on('click', function() {
|
|
|
|
$('#poll-hidden-form p').show();
|
2015-06-25 07:58:05 +02:00
|
|
|
$('#poll-hidden-form .js-poll-hidden').addClass('hidden');
|
2015-04-06 12:39:58 +02:00
|
|
|
$('.js-poll-hidden .btn-edit').focus();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2015-01-08 00:27:40 +01:00
|
|
|
$('#expiration-form .btn-edit').on('click', function() {
|
|
|
|
$('#expiration-form p').hide();
|
2015-06-25 07:58:05 +02:00
|
|
|
$('.js-expiration').removeClass('hidden');
|
2015-01-08 00:27:40 +01:00
|
|
|
$('.js-expiration input').focus();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#expiration-form .btn-cancel').on('click', function() {
|
|
|
|
$('#expiration-form p').show();
|
2015-06-25 07:58:05 +02:00
|
|
|
$('#expiration-form .js-expiration').addClass('hidden');
|
2015-01-08 00:27:40 +01:00
|
|
|
$('#expiration-form .btn-edit').focus();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2014-10-21 01:31:26 +02:00
|
|
|
// Horizontal scroll buttons
|
|
|
|
if($('.results').width() > $('.container').width()) {
|
|
|
|
$('.scroll-buttons').removeClass('hidden');
|
|
|
|
}
|
|
|
|
|
|
|
|
var $scroll_page = 1;
|
|
|
|
var $scroll_scale = $('#tableContainer').width()*2/3;
|
|
|
|
|
|
|
|
$('.scroll-left').addClass('disabled');
|
|
|
|
|
|
|
|
$('.scroll-left').click(function(){
|
2015-06-25 07:58:05 +02:00
|
|
|
var next = Math.floor($scroll_page);
|
|
|
|
if(next == $scroll_page) {
|
|
|
|
next--;
|
|
|
|
}
|
|
|
|
|
2014-10-21 01:31:26 +02:00
|
|
|
$('.scroll-right').removeClass('disabled');
|
2015-06-25 07:58:05 +02:00
|
|
|
$('#tableContainer').animate({
|
|
|
|
scrollLeft: $scroll_scale*(next - 1)
|
2014-10-21 01:31:26 +02:00
|
|
|
}, 1000);
|
|
|
|
if($scroll_page == 1) {
|
|
|
|
$(this).addClass('disabled');
|
|
|
|
} else {
|
2015-06-25 07:58:05 +02:00
|
|
|
$scroll_page = next;
|
2014-10-21 01:31:26 +02:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
$('.scroll-right').click(function(){
|
2015-06-25 07:58:05 +02:00
|
|
|
var next = Math.ceil($scroll_page);
|
|
|
|
if(next == $scroll_page)
|
|
|
|
next++;
|
2014-10-21 01:31:26 +02:00
|
|
|
$('.scroll-left').removeClass('disabled');
|
2015-06-25 07:58:05 +02:00
|
|
|
$('#tableContainer').animate({
|
|
|
|
scrollLeft: $scroll_scale*(next - 1)
|
2014-10-21 01:31:26 +02:00
|
|
|
}, 1000);
|
|
|
|
|
2015-06-25 07:58:05 +02:00
|
|
|
if($scroll_scale*($scroll_page+1) > $('.results').width()) {
|
2014-10-21 01:31:26 +02:00
|
|
|
$(this).addClass('disabled');
|
|
|
|
} else {
|
2015-06-25 07:58:05 +02:00
|
|
|
$scroll_page = next;
|
2014-10-21 01:31:26 +02:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2015-06-25 07:58:05 +02:00
|
|
|
$('#tableContainer').scroll(function() {
|
|
|
|
var position = $(this).scrollLeft();
|
|
|
|
$scroll_page = position / $scroll_scale + 1;
|
|
|
|
if(position == 0) {
|
|
|
|
$('.scroll-left').addClass('disabled');
|
|
|
|
} else {
|
|
|
|
$('.scroll-left').removeClass('disabled');
|
|
|
|
}
|
|
|
|
|
|
|
|
if(position >= $('.results').width() - $('#tableContainer').width()) {
|
|
|
|
$('.scroll-right').addClass('disabled');
|
|
|
|
} else {
|
|
|
|
$('.scroll-right').removeClass('disabled');
|
|
|
|
}
|
|
|
|
});
|
2014-10-21 01:31:26 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
// Vote form moving to the top or to the bottom
|
|
|
|
$(window).scroll(function() {
|
|
|
|
var $table_offset = $('.results thead').offset();
|
2014-11-18 18:38:00 +01:00
|
|
|
if(($table_offset == undefined || $(window).scrollTop() > $table_offset.top+150) && ($('table.results').height()-150 > $(window).height())) {
|
2014-10-21 01:31:26 +02:00
|
|
|
$('#addition').before($('#vote-form'));
|
|
|
|
$('#tableContainer').after($('.scroll-buttons'));
|
2014-11-14 17:35:22 +01:00
|
|
|
} else {
|
|
|
|
$('.results tbody').prepend($('#vote-form'));
|
|
|
|
$('#tableContainer').before($('.scroll-buttons'));
|
2014-10-21 01:31:26 +02:00
|
|
|
}
|
2014-09-04 17:52:18 +02:00
|
|
|
});
|