mirror of
https://github.com/DarrenOfficial/dpaste.git
synced 2024-12-23 23:23:06 +11:00
Autofocus the textfield for a new snippet.
This commit is contained in:
parent
368c8101ce
commit
a1e44486d2
5 changed files with 11 additions and 5 deletions
|
@ -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,
|
||||
|
|
|
@ -44,6 +44,8 @@ $(document).ready(function(){
|
|||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('.autofocus input:text, .autofocus textarea').first().focus();
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
{{ snippet_form.non_field_errors }}
|
||||
<div style="display: none;">{{ snippet_form.title }}</div>
|
||||
|
||||
<div class="control-group form-content">
|
||||
<div class="control-group form-content {% if is_new %}autofocus{% endif %}">
|
||||
{{ snippet_form.content }}
|
||||
</div>
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="form-actions">
|
||||
{% if follow_button %}
|
||||
{% if is_new %}
|
||||
<div class="twitter-follow-button-container">
|
||||
<a href="https://twitter.com/bartTC" class="twitter-follow-button" data-show-count="false" data-size="large" data-dnt="true">Follow @bartTC</a>
|
||||
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
|
||||
|
|
|
@ -6,7 +6,5 @@
|
|||
{% block dpaste_nav_new %}active{% endblock %}
|
||||
|
||||
{% block page %}
|
||||
{% with 1 as follow_button %}
|
||||
{% include "dpaste/snippet_form.html" %}
|
||||
{% endwith %}
|
||||
{% include "dpaste/snippet_form.html" %}
|
||||
{% endblock %}
|
|
@ -44,6 +44,7 @@ def snippet_new(request, template_name='dpaste/snippet_new.html'):
|
|||
|
||||
template_context = {
|
||||
'snippet_form': snippet_form,
|
||||
'is_new': True,
|
||||
}
|
||||
|
||||
return render_to_response(
|
||||
|
|
Loading…
Reference in a new issue