Share url view
* adds modal for rendering the share url * adds new custom_widget text-to-clipboard-input.html * provides a copy button for writing the text input's value into the client's clipboard * adds translation
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
{% comment %}
|
||||
This is an empty template.
|
||||
It's used to dismiss a default widget for a django_filter filter and to use a predefined input directly in the
|
||||
template without losing the comfort of matching the filter methods declared in the filter
|
||||
{% endcomment %}
|
||||
@@ -0,0 +1,18 @@
|
||||
{% load i18n fontawesome_5 %}
|
||||
|
||||
<div class="input-group" title="{{ widget.value|stringformat:'s' }}">
|
||||
<input aria-describedby="copy-btn" type="{{ widget.type }}" name="{{ widget.name }}"{% if widget.value != None %} value="{{ widget.value|stringformat:'s' }}"{% endif %}{% include "django/forms/widgets/attrs.html" %}>
|
||||
<div class="input-group-append" onclick="copyClipboard()">
|
||||
<span id="copy-btn" class="btn btn-default" value="{% trans 'Copy to clipboard' %}" title="{% trans 'Copy to clipboard' %}">{% fa5_icon 'clipboard' 'far' %}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function copyClipboard() {
|
||||
var copyText = document.getElementById("id_{{ widget.name }}");
|
||||
copyText.select();
|
||||
copyText.setSelectionRange(0, 99999); /* For mobile devices */
|
||||
document.execCommand("copy");
|
||||
alert("{% trans 'Copied to clipboard' %}");
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user