mirror of
https://github.com/DarrenOfficial/dpaste.git
synced 2024-11-15 16:12:51 +11:00
First iteration of JS vanilla'ization
This commit is contained in:
parent
470b8dd2b3
commit
201f78e81b
5 changed files with 28 additions and 40 deletions
7
dpaste/static/dpaste/clipboardjs.min.js
vendored
7
dpaste/static/dpaste/clipboardjs.min.js
vendored
File diff suppressed because one or more lines are too long
7
dpaste/static/dpaste/typeahead.min.js
vendored
7
dpaste/static/dpaste/typeahead.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -27,29 +27,5 @@
|
||||||
PAGE MISSING
|
PAGE MISSING
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% block script_footer %}
|
|
||||||
<script src="{{ jquery_url }}"></script>
|
|
||||||
<script src="{% static "dpaste/clipboardjs.min.js" %}"></script>
|
|
||||||
<script>
|
|
||||||
jQuery(function($) {
|
|
||||||
new Clipboard('.clip-button');
|
|
||||||
$('.autofocus textarea:first').focus();
|
|
||||||
$('.superenter textarea').on('keydown', function(e){
|
|
||||||
var metaKey;
|
|
||||||
if (navigator.appVersion.indexOf("Win")!=-1) {
|
|
||||||
metaKey = e.ctrlKey;
|
|
||||||
} else {
|
|
||||||
metaKey = event.metaKey;
|
|
||||||
}
|
|
||||||
if (e.keyCode == 13 && metaKey) {
|
|
||||||
$(this).closest('form').submit();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -87,7 +87,8 @@
|
||||||
{% block script_footer %}
|
{% block script_footer %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
<script>
|
<script>
|
||||||
jQuery(function($) {
|
|
||||||
|
<!--
|
||||||
$('.snippet-reply-hidden').click(function(e) {
|
$('.snippet-reply-hidden').click(function(e) {
|
||||||
$(this).removeClass('snippet-reply-hidden');
|
$(this).removeClass('snippet-reply-hidden');
|
||||||
});
|
});
|
||||||
|
@ -166,5 +167,6 @@ jQuery(function($) {
|
||||||
$('.code').toggleClass('wordwrap');
|
$('.code').toggleClass('wordwrap');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
-->
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
<form method="post" action="" class="form-horizontal">
|
<form method="post" action="" class="form-horizontal snippet-form">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ form.non_field_errors }}
|
{{ form.non_field_errors }}
|
||||||
<div style="display: none;">{{ form.title }}</div>
|
<div style="display: none;">{{ form.title }}</div>
|
||||||
|
@ -38,3 +38,27 @@
|
||||||
<span class="shortcut">⌘+⏎ {% trans "or" %} Ctrl+⏎</span>
|
<span class="shortcut">⌘+⏎ {% trans "or" %} Ctrl+⏎</span>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
{% block script_footer %}
|
||||||
|
<script>
|
||||||
|
var af = document.querySelector(".autofocus textarea");
|
||||||
|
if (af !== null)
|
||||||
|
af.focus();
|
||||||
|
|
||||||
|
var se = document.querySelector(".superenter textarea");
|
||||||
|
if (se !== null) {
|
||||||
|
se.onkeydown = function(e) {
|
||||||
|
var metaKey;
|
||||||
|
if (navigator.appVersion.indexOf("Win") !== -1) {
|
||||||
|
metaKey = e.ctrlKey;
|
||||||
|
} else {
|
||||||
|
metaKey = event.metaKey;
|
||||||
|
}
|
||||||
|
if (e.keyCode == 13 && metaKey) {
|
||||||
|
document.querySelector(".snippet-form").submit();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in a new issue