# HG changeset patch # User Brian Neal # Date 1259275637 0 # Node ID 5b69d6e01fd4e132e5dc493d21a24224e5fb04e0 # Parent a4635c094f246b35a9f08c345421378e095815df Creating a common way to display the smiley and markdown help dialogs for a markItUp textarea input form. Converted gcalendar over to it as a trial. diff -r a4635c094f24 -r 5b69d6e01fd4 gpp/core/templatetags/core_tags.py --- a/gpp/core/templatetags/core_tags.py Fri Nov 20 02:44:45 2009 +0000 +++ b/gpp/core/templatetags/core_tags.py Thu Nov 26 22:47:17 2009 +0000 @@ -17,3 +17,7 @@ return u"""%s""" % ( params[0], params[1], params[1]) + +@register.inclusion_tag('core/comment_dialogs.html') +def comment_dialogs(): + return {'MEDIA_URL': settings.MEDIA_URL} diff -r a4635c094f24 -r 5b69d6e01fd4 gpp/gcalendar/forms.py --- a/gpp/gcalendar/forms.py Fri Nov 20 02:44:45 2009 +0000 +++ b/gpp/gcalendar/forms.py Thu Nov 26 22:47:17 2009 +0000 @@ -69,6 +69,8 @@ end_time = forms.TimeField(required=False, widget=forms.Select(choices=TIME_CHOICES)) time_zone = forms.CharField(required=False, widget=forms.HiddenInput()) where = forms.CharField(required=False, widget=forms.TextInput(attrs={'size': 60})) + description = forms.CharField(required=False, + widget=forms.Textarea(attrs={'class': 'markItUp smileyTarget'})) TIME_FORMAT = '%H:%M' DEFAULT_START_TIME = '19:00' @@ -81,13 +83,13 @@ class Media: css = { - 'all': settings.GPP_THIRD_PARTY_CSS['markitup'] + \ - settings.GPP_THIRD_PARTY_CSS['jquery-ui'] + \ - ('css/gcalendar.css', ) + 'all': (settings.GPP_THIRD_PARTY_CSS['markitup'] + + settings.GPP_THIRD_PARTY_CSS['jquery-ui'] + + ('css/gcalendar.css', )) } - js = settings.GPP_THIRD_PARTY_JS['markitup'] + \ - settings.GPP_THIRD_PARTY_JS['jquery-ui'] + \ - ('js/timezone.js', 'js/gcalendar.js', ) + js = (settings.GPP_THIRD_PARTY_JS['markitup'] + + settings.GPP_THIRD_PARTY_JS['jquery-ui'] + + ('js/timezone.js', 'js/gcalendar.js', )) def __init__(self, *args, **kwargs): initial = kwargs.get('initial', {}) @@ -150,5 +152,3 @@ class PasswordForm(forms.Form): password = forms.CharField(widget=forms.PasswordInput()) - -# vim: ts=4 sw=4 diff -r a4635c094f24 -r 5b69d6e01fd4 gpp/templates/core/comment_dialogs.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gpp/templates/core/comment_dialogs.html Thu Nov 26 22:47:17 2009 +0000 @@ -0,0 +1,10 @@ + +More smileys + +Help +
+Loading +
+
+Loading +
diff -r a4635c094f24 -r 5b69d6e01fd4 gpp/templates/gcalendar/event.html --- a/gpp/templates/gcalendar/event.html Fri Nov 20 02:44:45 2009 +0000 +++ b/gpp/templates/gcalendar/event.html Thu Nov 26 22:47:17 2009 +0000 @@ -1,4 +1,5 @@ {% extends 'base.html' %} +{% load core_tags %} {% block title %}{{ title }}{% endblock %} {% block custom_js %} {{ form.media }} @@ -36,7 +37,7 @@ Where:{{ form.where.errors }}{{ form.where }} Details:{{ form.description.errors }}{{ form.description }} {# form.as_p #} -  + {% comment_dialogs %}

« Back to the Event Calendar

diff -r a4635c094f24 -r 5b69d6e01fd4 media/js/gcalendar.js --- a/media/js/gcalendar.js Fri Nov 20 02:44:45 2009 +0000 +++ b/media/js/gcalendar.js Thu Nov 26 22:47:17 2009 +0000 @@ -1,5 +1,4 @@ $(document).ready(function() { - $('#id_description').markItUp(mySettings); $('#id_start_date').datepicker({constrainInput: true, onClose: function () { var end = $('#id_end_date'); diff -r a4635c094f24 -r 5b69d6e01fd4 media/js/markitup/sets/markdown/set.js --- a/media/js/markitup/sets/markdown/set.js Fri Nov 20 02:44:45 2009 +0000 +++ b/media/js/markitup/sets/markdown/set.js Thu Nov 26 22:47:17 2009 +0000 @@ -78,3 +78,57 @@ return '\n'+heading; } } + +$(document).ready(function() { + $('.markItUp').markItUp(mySettings); + + $('#smileys_dialog_popup').dialog({autoOpen:false}); + var firstTimeSmiley = true; + $('#more_smileys_link').click(function () { + $('#smileys_dialog_popup').dialog('open'); + var smileyTarget = $('.smileyTarget')[0]; + if (firstTimeSmiley) { + $.ajax({ + url: '/smiley/farm/extra/', + type: 'GET', + dataType: 'html', + success: function(data, textStatus) { + var img = $('#smiley_busy'); + img.hide(); + img.after(data); + $('#smileys_dialog_popup .smiley_farm img').click(function() { + smileyTarget.value += ' ' + this.alt + ' '; + smileyTarget.focus(); + }); + firstTimeSmiley = false; + }, + error: function (xhr, textStatus, ex) { + alert('Oops, an error occurred: ' + xhr.statusText + ' - ' + xhr.responseText); + } + }); + } + return false; + }); + $('#markdown_help_dialog_popup').dialog({autoOpen: false, width: 720, height: 600}); + var firstTimeMdHelp = true; + $('#markdown_help_link').click(function () { + $('#markdown_help_dialog_popup').dialog('open'); + if (firstTimeMdHelp) { + $.ajax({ + url: '/core/markdown_help/', + type: 'GET', + dataType: 'html', + success: function(data, textStatus) { + var img = $('#markdown_busy'); + img.hide(); + img.after(data); + firstTimeMdHelp = false; + }, + error: function (xhr, textStatus, ex) { + alert('Oops, an error occurred: ' + xhr.statusText + ' - ' + xhr.responseText); + } + }); + } + return false; + }); +});