From: Frédéric Péters Date: Thu, 21 Apr 2016 14:07:52 +0000 (+0200) Subject: display chatrooms when open X-Git-Tag: v2021~363 X-Git-Url: https://git.0d.be/?p=panikweb.git;a=commitdiff_plain;h=2f7722ead4313f3e7bb2979dbb99e76f0f909644 display chatrooms when open --- diff --git a/panikweb/views.py b/panikweb/views.py index c8ed62e..d22662e 100644 --- a/panikweb/views.py +++ b/panikweb/views.py @@ -5,9 +5,9 @@ import os import stat import time +from django.core.urlresolvers import reverse from django.conf import settings from django.http import Http404 - from django.views.decorators.cache import cache_control from django.views.generic.base import TemplateView from django.views.generic.detail import DetailView @@ -627,9 +627,13 @@ def onair(request): 'url': d['episode'].get_absolute_url() } if d.get('emission'): + chat_url = None + if d['emission'].chat_open: + chat_url = reverse('emission-chat', kwargs={'slug': d['emission'].slug}) d['emission'] = { 'title': d['emission'].title, - 'url': d['emission'].get_absolute_url() + 'url': d['emission'].get_absolute_url(), + 'chat': chat_url, } if d.get('nonstop'): d['nonstop'] = { diff --git a/panikweb_templates/static/css/specifics.css b/panikweb_templates/static/css/specifics.css index b09b83d..c527005 100644 --- a/panikweb_templates/static/css/specifics.css +++ b/panikweb_templates/static/css/specifics.css @@ -1951,3 +1951,18 @@ div.top-logo img { max-width: none; } } + +div#CurrentlyChatting { + margin-top: 1em; +} + +div#CurrentlyChatting a { + border-radius: 5px; + padding: 1ex 0 0.5ex 0; + display: block; + box-sizing: border-box; + text-align: center; + width: 100%; + background: #FF6633; + color: white !important; +} diff --git a/panikweb_templates/static/js/specifics.js b/panikweb_templates/static/js/specifics.js index cb7eadd..e7beb49 100644 --- a/panikweb_templates/static/js/specifics.js +++ b/panikweb_templates/static/js/specifics.js @@ -220,6 +220,12 @@ $(function() { else { onairContainer = $('Unknown (Probably Non-Stop)'); } + if (onair.data.emission.chat) { + $('#CurrentlyChatting a').attr('href', onair.data.emission.chat); + $('#CurrentlyChatting').show(); + } else { + $('#CurrentlyChatting').hide(); + } var current_html = WhatsOnAir.html(); var new_html = '' + onairContainer.html() + ''; if (new_html !== current_html) { @@ -545,8 +551,7 @@ $(function() { }); /* CHAT */ - var $chat = $('#chat'); - if ($chat.length) { + if ($('#chat').length) { var $msg = $('input#msg'); var $send = $('button#send'); var chat_roster = Object(); @@ -600,7 +605,7 @@ $(function() { } else { klass = 'msg-in'; } - var new_msg = $('
' + from + ' ' + msg.textContent + '
').prependTo($chat); + var new_msg = $('
' + from + ' ' + msg.textContent + '
').prependTo($('#chat')); new_msg[0].offsetHeight; /* trigger reflow */ new_msg.removeClass('new'); $('div#chat div:nth-child(20)').remove() @@ -619,7 +624,7 @@ $(function() { if (chat_roster[nick] == true) { for (contact in roster) { if (chat_roster[contact] !== true) { - var new_msg = $('
' + contact + ' est dans la place.
').prependTo($chat); + var new_msg = $('
' + contact + ' est dans la place.
').prependTo($('#chat')); new_msg[0].offsetHeight; /* trigger reflow */ new_msg.removeClass('new'); } diff --git a/panikweb_templates/templates/chat.html b/panikweb_templates/templates/chat.html index 6781847..486eea0 100644 --- a/panikweb_templates/templates/chat.html +++ b/panikweb_templates/templates/chat.html @@ -26,6 +26,8 @@ diff --git a/panikweb_templates/templates/includes/player.html b/panikweb_templates/templates/includes/player.html index 98c3ae4..8117d3c 100644 --- a/panikweb_templates/templates/includes/player.html +++ b/panikweb_templates/templates/includes/player.html @@ -17,6 +17,9 @@ +