Cmd+Enter form submit

This commit is contained in:
Martin Mahner 2013-11-30 13:22:59 +01:00
parent 7f7a53aa62
commit b362cd2ef6
3 changed files with 20 additions and 0 deletions

View file

@ -80,6 +80,13 @@ h1, h2, h3, h4 {
opacity: 1; opacity: 1;
} }
.shortcut {
color: #AAA;
font-size: 13px;
font-weight: 300;
margin-left: 15px;
}
/* ---------------------------------------------------------------------------- /* ----------------------------------------------------------------------------
Snippet Details Snippet Details
---------------------------------------------------------------------------- */ ---------------------------------------------------------------------------- */

View file

@ -29,6 +29,17 @@
{% block script_footer %} {% block script_footer %}
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script> <script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
<script>
jQuery(function($) {
$('.autofocus textarea:first').focus();
$('.superenter textarea').on('keydown', function(e){
if(e.keyCode == 13 && e.metaKey) {
$(this).closest('form').submit();
return false;
}
});
});
</script>
{% endblock %} {% endblock %}
</body> </body>

View file

@ -9,6 +9,7 @@
<div class=" <div class="
control-group control-group
form-content form-content
superenter
{% if is_new %}autofocus{% endif %} {% if is_new %}autofocus{% endif %}
{% if snippet_form.content.errors %}error{% endif %} {% if snippet_form.content.errors %}error{% endif %}
"> ">
@ -41,5 +42,6 @@
</div> </div>
{% endif %} {% endif %}
<input tabindex="0" type="submit"class="btn btn-primary" value="{% trans "Paste it" %}"> <input tabindex="0" type="submit"class="btn btn-primary" value="{% trans "Paste it" %}">
<span class="shortcut">&#8984; + &#9166;</span>
</div> </div>
</form> </form>