Mercurial > public > sg101
changeset 135:13330e1836f3
Cutting forums over to the new common way to add markItUp, extra smileys, and markdown help.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Fri, 27 Nov 2009 03:30:15 +0000 |
parents | b8474ffe76d9 |
children | d203a4a986d2 |
files | gpp/forums/forms.py gpp/templates/forums/show_form.html media/js/forums.js |
diffstat | 3 files changed, 8 insertions(+), 63 deletions(-) [+] |
line wrap: on
line diff
--- a/gpp/forums/forms.py Fri Nov 27 00:39:50 2009 +0000 +++ b/gpp/forums/forms.py Fri Nov 27 03:30:15 2009 +0000 @@ -11,7 +11,8 @@ class NewPostForm(forms.Form): """Form for creating a new post.""" - body = forms.CharField(label='', widget=forms.Textarea) + body = forms.CharField(label='', + widget=forms.Textarea(attrs={'class': 'markItUp smileyTarget'})) topic_id = forms.IntegerField(widget=forms.HiddenInput) topic = None @@ -50,7 +51,8 @@ """ name = forms.CharField(label='Subject', max_length=255, widget=forms.TextInput(attrs={'size': 64})) - body = forms.CharField(label='', widget=forms.Textarea) + body = forms.CharField(label='', + widget=forms.Textarea(attrs={'class': 'markItUp smileyTarget'})) user = None forum = None has_mod_fields = False @@ -98,7 +100,8 @@ """ Form for editing an existing post or a new, non-quick post. """ - body = forms.CharField(label='', widget=forms.Textarea) + body = forms.CharField(label='', + widget=forms.Textarea(attrs={'class': 'markItUp smileyTarget'})) class Meta: model = Post
--- a/gpp/templates/forums/show_form.html Fri Nov 27 00:39:50 2009 +0000 +++ b/gpp/templates/forums/show_form.html Fri Nov 27 03:30:15 2009 +0000 @@ -1,17 +1,9 @@ +{% load core_tags %} <form action="." method="post"> <fieldset> <legend>{{ legend_text }}</legend> {{ form.as_p }} -<a href="#" id="more_smileys"> -<img src="{{ MEDIA_URL }}icons/emoticon_smile.png" alt="More smileys" title="More smileys" /></a> -<a href="#" id="markdown_help"> -<img src="{{ MEDIA_URL }}icons/help.png" alt="Help" title="Help" /></a> +{% comment_dialogs %} <input type="submit" value="{{ submit_value }}" {% if is_ajax %}id="forums-reply-post"{% endif %} /> </fieldset> </form> -<div id="smileys_dialog" title="More Smileys"> -<img src="{{ MEDIA_URL }}icons/ajax_busy.gif" alt="Loading" id="smiley_busy" /> -</div> -<div id="markdown_help_dialog" title="Markdown Help"> -<img src="{{ MEDIA_URL }}icons/ajax_busy.gif" alt="Loading" id="markdown_busy" /> -</div>
--- a/media/js/forums.js Fri Nov 27 00:39:50 2009 +0000 +++ b/media/js/forums.js Fri Nov 27 03:30:15 2009 +0000 @@ -82,54 +82,4 @@ return confirm('Are you sure you want to delete this topic?\n' + 'WARNING: all posts will be lost.'); }); - $('#id_body').markItUp(mySettings); - $('#smileys_dialog').dialog({autoOpen:false}); - var firstTime = true; - $('#more_smileys').click(function () { - $('#smileys_dialog').dialog('open'); - var postBox = $('#id_body')[0]; - if (firstTime) { - $.ajax({ - url: '/smiley/farm/extra/', - type: 'GET', - dataType: 'html', - success: function(data, textStatus) { - var img = $('#smiley_busy'); - img.hide(); - img.after(data); - $('#smileys_dialog .smiley_farm img').click(function() { - postBox.value += ' ' + this.alt + ' '; - postBox.focus(); - }); - firstTime = false; - }, - error: function (xhr, textStatus, ex) { - alert('Oops, an error occurred: ' + xhr.statusText + ' - ' + xhr.responseText); - } - }); - } - return false; - }); - $('#markdown_help_dialog').dialog({autoOpen: false, width: 720, height: 600}); - var firstTimeMd = true; - $('#markdown_help').click(function () { - $('#markdown_help_dialog').dialog('open'); - if (firstTimeMd) { - $.ajax({ - url: '/core/markdown_help/', - type: 'GET', - dataType: 'html', - success: function(data, textStatus) { - var img = $('#markdown_busy'); - img.hide(); - img.after(data); - firstTimeMd = false; - }, - error: function (xhr, textStatus, ex) { - alert('Oops, an error occurred: ' + xhr.statusText + ' - ' + xhr.responseText); - } - }); - } - return false; - }); });