OpenSlides/openslides/projector/static/javascript/dashboard.js

143 lines
4.6 KiB
JavaScript
Raw Normal View History

/**
* OpenSlides projector functions
*
* :copyright: 2011, 2012 by OpenSlides team, see AUTHORS.
* :license: GNU GPL, see LICENSE for more details.
*/
// function that writes the widget list order to a cookie
2012-07-04 02:43:26 +02:00
function saveOrder() {
$(".column").each(function(index, value){
var colid = value.id;
var cookieName = "cookie-" + colid;
// Get the order for this column.
var order = $('#' + colid).sortable("toArray");
$.cookie(cookieName, order, { path: "/", expiry: new Date(2012, 1, 1)});
});
}
// function that restores the widget list order from a cookie
2012-07-04 02:43:26 +02:00
function restoreOrder() {
$(".column").each(function(index, value) {
var colid = value.id;
var cookieName = "cookie-" + colid;
2012-07-04 02:43:26 +02:00
var cookie = $.cookie(cookieName);
if ( cookie == null ) { return; }
var IDs = cookie.split(",");
for (var i = 0, n = IDs.length; i < n; i++ ) {
var widgetID = IDs[i];
var widget = $(".column")
.find('#' + widgetID)
2012-07-04 02:43:26 +02:00
.appendTo($('#' + colid));
}
});
}
$(function() {
2012-07-04 02:43:26 +02:00
$( ".column" ).sortable({
connectWith: ".column",
stop: function() { saveOrder(); }
});
// control the projector view
$('.projector_edit').click(function(event) {
event.preventDefault();
2012-04-20 22:41:57 +02:00
var link = $(this);
$.ajax({
type: 'GET',
url: link.attr('href'),
dataType: 'json',
success: function(data) {
$('#scale_level').html(data['scale_level']);
$('#scroll_level').html(data['scroll_level']);
if ( data['scroll_level'] == 0 )
$('#scroll_up_button').addClass('disabled');
else {
if ( $('#scroll_up_button').hasClass('disabled') )
$('#scroll_up_button').removeClass('disabled');
}
}
});
});
// control countdown
2012-07-04 02:43:26 +02:00
$('.countdown_control').click(function(event) {
event.preventDefault();
2012-04-20 22:41:57 +02:00
var link = $(this);
var requestData = {};
if (link.attr('id') == "countdown_set") {
requestData = { "countdown_time" : $( "#countdown_time" ).val() };
}
$.ajax({
type: 'GET',
url: link.attr('href'),
data: requestData,
dataType: 'json',
success: function(data) {
2012-07-04 02:43:26 +02:00
if (data['state'] == 'active') {
$('#countdown_play').hide();
$('#countdown_stop').show();
} else {
$('#countdown_play').show();
$('#countdown_stop').hide();
}
$('#countdown_time').val(data['countdown_time'])
}
});
});
// activate/deactivate overlay
$('.overlay_activate_link').click(function(event) {
event.preventDefault();
2012-04-20 22:41:57 +02:00
var link = $(this);
$.ajax({
type: 'GET',
url: link.attr('href'),
dataType: 'json',
success: function(data) {
if (data['active']) {
2013-04-15 10:40:47 +02:00
$('#' + data['name'] + '_active').show();
$('#' + data['name'] + '_inactive').hide();
} else {
2013-04-15 10:40:47 +02:00
$('#' + data['name'] + '_active').hide();
$('#' + data['name'] + '_inactive').show();
}
}
});
});
2012-07-04 02:43:26 +02:00
2012-07-04 03:21:03 +02:00
$('#overlay_message').ajaxForm({
dataType: 'json',
success: function(data) {
$('#overlay_message_text').val(data['overlay_message']);
}
2012-07-04 02:43:26 +02:00
});
$('.fixbutton button').click(function (event) {
event.preventDefault();
if($(this).hasClass('active')) {
$(this).closest('.widget').removeClass('affix');
$(this).closest('.widget').removeAttr('data-spy');
} else {
$(this).closest('.widget').addClass('affix');
$(this).closest('.widget').attr('data-spy', 'affix');
}
});
/* comment out this function because '$.browser' has been removed from jquery 1.9, see:
http://blog.jquery.com/2013/01/15/jquery-1-9-final-jquery-2-0-beta-migrate-final-released/
TODO: use jquery migrate to have $.browser support for IE8;
if ($.browser.msie) {
if ($.browser.version >= 8.0 && $.browser.version < 9.0)
{
// scaling bug in IE8.. iframe has to be 4 times bigger
$( "#iframe" ).css('width', 1024 * 4);
$( "#iframe" ).css('height', 768 * 4);
}
$( "#iframe" ).css('zoom', '0.25');
}
*/
restoreOrder();
});