From e9770293bbdd14ea014a41a7b59044c1f79719f5 Mon Sep 17 00:00:00 2001 From: Martin Mahner Date: Fri, 22 Mar 2013 19:40:31 +0100 Subject: [PATCH] Autofocus the textfield for a new snippet. --- dpaste/forms.py | 5 +++++ dpaste/templates/dpaste/base.html | 2 ++ dpaste/templates/dpaste/snippet_form.html | 4 ++-- dpaste/templates/dpaste/snippet_new.html | 4 +--- dpaste/views.py | 1 + 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/dpaste/forms.py b/dpaste/forms.py index 426a13b..04f9704 100644 --- a/dpaste/forms.py +++ b/dpaste/forms.py @@ -19,6 +19,11 @@ EXPIRE_DEFAULT = 3600 * 24 * 30 class SnippetForm(forms.ModelForm): + content = forms.CharField( + label=_('Content'), + widget=forms.Textarea(attrs={'placeholder': _('Awesome code goes here...')}), + ) + lexer = forms.ChoiceField( label=_(u'Lexer'), initial=LEXER_DEFAULT, diff --git a/dpaste/templates/dpaste/base.html b/dpaste/templates/dpaste/base.html index 0d8037a..c85fd74 100644 --- a/dpaste/templates/dpaste/base.html +++ b/dpaste/templates/dpaste/base.html @@ -44,6 +44,8 @@ $(document).ready(function(){ } }); }); + + $('.autofocus input:text, .autofocus textarea').first().focus(); }); {% endblock %} diff --git a/dpaste/templates/dpaste/snippet_form.html b/dpaste/templates/dpaste/snippet_form.html index 4702367..0670f26 100644 --- a/dpaste/templates/dpaste/snippet_form.html +++ b/dpaste/templates/dpaste/snippet_form.html @@ -5,7 +5,7 @@ {{ snippet_form.non_field_errors }}
{{ snippet_form.title }}
-
+
{{ snippet_form.content }}
@@ -26,7 +26,7 @@
- {% if follow_button %} + {% if is_new %}