From ccafc51ade9536046aeb096b04b069f17874fab4 Mon Sep 17 00:00:00 2001 From: Aurélien Bompard Date: Tue, 12 Feb 2013 13:29:32 +0100 Subject: Add a "Create new thread" button --- hyperkitty/static/css/hyperkitty.css | 34 ++++++++++++++++ hyperkitty/static/js/hyperkitty.js | 14 +++++-- hyperkitty/templates/message_new.html | 42 ++++++++++++++++++++ hyperkitty/templates/thread_list.html | 9 +++++ hyperkitty/urls.py | 2 + hyperkitty/views/forms.py | 4 ++ hyperkitty/views/list.py | 9 +++++ hyperkitty/views/message.py | 75 ++++++++++++++++++++++++++++------- hyperkitty/views/thread.py | 10 ++--- requirements.txt | 1 + 10 files changed, 176 insertions(+), 24 deletions(-) create mode 100644 hyperkitty/templates/message_new.html diff --git a/hyperkitty/static/css/hyperkitty.css b/hyperkitty/static/css/hyperkitty.css index 5381e86..f08baaa 100644 --- a/hyperkitty/static/css/hyperkitty.css +++ b/hyperkitty/static/css/hyperkitty.css @@ -134,6 +134,16 @@ table.user-data { list-style-type: none; } +.flashmsg { + position: absolute; + left: 0; + width: 100%; + text-align: center; +} +.flashmsg .alert { + display: inline-block; +} + /* Add icons to some text */ .participant, .discussion, .saved, .notsaved { @@ -394,6 +404,15 @@ form.likeform { margin-right: 4em; } +#thread-list .thread-list-header .thread-new { + float: right; +} +#thread-list .thread-list-header .thread-new strong { + font-size: 150%; + font-weight: bold; + margin-right: 0.2em; +} + /* Thread view */ @@ -902,3 +921,18 @@ a.reply.disabled { white-space: pre; text-align: left; } + + +/* + * New thread form + */ +.new-thread-form { + margin-left: 2em; +} +.new-thread-form #id_subject, +.new-thread-form textarea { + width: 90%; +} +.new-thread-form .buttons .submit { + margin-right: 2em; +} diff --git a/hyperkitty/static/js/hyperkitty.js b/hyperkitty/static/js/hyperkitty.js index 87d6987..5371657 100644 --- a/hyperkitty/static/js/hyperkitty.js +++ b/hyperkitty/static/js/hyperkitty.js @@ -61,7 +61,6 @@ function vote(elem, value) { function setup_vote() { - $("a.youlike.disabled").add("a.youdislike.disabled").tooltip(); $("a.youlike").click(function(e) { e.preventDefault(); vote(this, 1); }); $("a.youdislike").click(function(e) { e.preventDefault(); vote(this, -1); }); } @@ -107,7 +106,6 @@ function setup_favorites() { form.find("a.saved").show(); } }).trigger("change"); - $(".favorite a.disabled").tooltip(); $(".favorite a").bind("click", function(e) { e.preventDefault(); if ($(elem).hasClass("disabled")) { @@ -145,7 +143,6 @@ function setup_favorites() { */ function setup_replies() { - $("a.reply.disabled").tooltip(); $("a.reply").click(function(e) { e.preventDefault(); if (!$(this).hasClass("disabled")) { @@ -301,6 +298,15 @@ function setup_months_list() { $("#months-list").accordion({ collapsible: true, active: current }); } +function setup_disabled_tooltips() { + $("a.disabled").tooltip().click(function (e) { + e.preventDefault(); + }); +} + +function setup_flash_messages() { + $('.flashmsg').delay(3000).fadeOut('slow'); +} /* @@ -315,4 +321,6 @@ $(document).ready(function() { setup_months_list(); setup_favorites(); setup_replies(); + setup_disabled_tooltips(); + setup_flash_messages(); }); diff --git a/hyperkitty/templates/message_new.html b/hyperkitty/templates/message_new.html new file mode 100644 index 0000000..c764c1a --- /dev/null +++ b/hyperkitty/templates/message_new.html @@ -0,0 +1,42 @@ +{% extends "base.html" %} +{% load gravatar %} +{% load hk_generic %} +{% load storm %} +{% load crispy_forms_tags %} + + +{% block title %} +Create a new thread - {{ mlist.display_name|default:mlist.name|escapeemail }} - {{ app_name|title }} +{% endblock %} + +{% block content %} + +
+ +{% include 'threads/month_list.html' %} + +
+ +
+

Create a new thread

+
+ +
+
+ {% csrf_token %} + {{ post_form|crispy }} +

+ + or cancel +

+
+
+ +
+ +
+ +{% endblock %} + +{# vim: set noet: #} diff --git a/hyperkitty/templates/thread_list.html b/hyperkitty/templates/thread_list.html index cb95daa..2b61792 100644 --- a/hyperkitty/templates/thread_list.html +++ b/hyperkitty/templates/thread_list.html @@ -15,7 +15,16 @@
+ {% if flash_msg %} +
+
{{ flash_msg }}
+
+ {% endif %} +