diff --git a/CHANGELOG b/CHANGELOG index 1f5312fc0..a20c85148 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -13,6 +13,8 @@ Agenda: - Added CSV import. Assignment: - Coupled assignment candidates with list of speakers. +Dashboard: +- Shortcuts for the countdown. Participants: - Disabled widgets by default. - Added form field for multiple creation of new participants. diff --git a/openslides/core/static/css/dashboard.css b/openslides/core/static/css/dashboard.css index 341d5cdf0..a13eb8d8a 100644 --- a/openslides/core/static/css/dashboard.css +++ b/openslides/core/static/css/dashboard.css @@ -137,3 +137,22 @@ -moz-margin-start: 4px !important; margin-left: -6px; } + + +/* + * style for countdown shortcuts + * + * TODO: move to projector app or merge projector with core + */ + +#countdown_shortcut_storage .countdown_shortcut_time { + margin-right: 2px; +} + +#countdown_shortcut_storage .countdown_shortcut_time span { + padding-right: 5px; +} + +#countdown_shortcut_dummy { + display: none; +} diff --git a/openslides/core/static/js/dashboard.js b/openslides/core/static/js/dashboard.js index a835af411..239c27cb5 100644 --- a/openslides/core/static/js/dashboard.js +++ b/openslides/core/static/js/dashboard.js @@ -86,6 +86,8 @@ $(function() { }); // control countdown + // TODO: Move Countdown-code into the projector app, or merge the projector + // app with the core app. $('.countdown_control').click(function(event) { event.preventDefault(); var link = $(this); @@ -111,6 +113,69 @@ $(function() { }); }); + $('#countdown_set').click(function(event) { + // Create a shortcut from the value in the form + event.preventDefault(); + var times = get_times(); + times.push($("#countdown_time" ).val()); + localStorage.setItem('countdown_shortcut', times.join()); + build_countdown_shortcuts(); + }); + + get_times = function() { + // Loads the time values from the local storages. Converts all values + // to integers and removes doubles. + // Returns an empty array if an error occurs + try { + return localStorage.getItem('countdown_shortcut').split(',') + .map(function(value) { + // converts times into int + return parseInt(value); + }).filter(function(value, index, self) { + // filters doubles + return self.indexOf(value) === index; + }); + } catch(err) { + return []; + } + }; + + $('.countdown_shortcut_time').click(function(event) { + // click on a shortcut. Set the form value and simulate a click event. + event.preventDefault(); + var time = $(this).children('span').html(); + $('#countdown_time').val(time); + $('#countdown_set').click(); + }); + + $('.countdown_shortcut_time .close').click(function(event) { + // Removes a shortcut. + event.preventDefault(); + var time = $(this).parent().parent().children('span').html(); + var times = get_times().filter( + function(value) { + return value !== parseInt(time); + } + ); + localStorage.setItem('countdown_shortcut', times); + build_countdown_shortcuts(); + }); + + build_countdown_shortcuts = function() { + // Recreates the countdown shortcuts + var times = get_times(); + $('#countdown_shortcut_storage').empty(); + $.each(times, function(index, time) { + var element = $('#countdown_shortcut_dummy').clone(withDataAndEvents=true); + element.attr('id', ''); + $('span', element).html(time); + element.appendTo('#countdown_shortcut_storage'); + }); + }; + + // build shortcuts at start time. + build_countdown_shortcuts(); + // activate/deactivate overlay $('.overlay_activate_link').click(function(event) { event.preventDefault(); diff --git a/openslides/projector/templates/projector/overlay_countdown_widget.html b/openslides/projector/templates/projector/overlay_countdown_widget.html index 09d1a92ed..eba2e2564 100644 --- a/openslides/projector/templates/projector/overlay_countdown_widget.html +++ b/openslides/projector/templates/projector/overlay_countdown_widget.html @@ -7,8 +7,8 @@ {% trans "s" context "seconds" %} + + + + + + + + +