Add copy clipboard to base
This commit is contained in:
parent
e46775301c
commit
69d23fded4
3 changed files with 29 additions and 1 deletions
|
@ -359,6 +359,33 @@ function onWindowReady() {
|
||||||
$('#form-lang').submit();
|
$('#form-lang').submit();
|
||||||
})
|
})
|
||||||
$('#logout').on('click', () => $('#logout-form').submit());
|
$('#logout').on('click', () => $('#logout-form').submit());
|
||||||
|
|
||||||
|
var copyButton;
|
||||||
|
$('pre code').each(function () {
|
||||||
|
console.log($(this));
|
||||||
|
$(this).parent().before($('<div>', {'class': 'copy-clipboard'})
|
||||||
|
.append(copyButton = $('<span>', {
|
||||||
|
'class': 'btn-clipboard',
|
||||||
|
'data-clipboard-text': $(this).text(),
|
||||||
|
'title': 'Click to copy'
|
||||||
|
}).text('Copy')));
|
||||||
|
|
||||||
|
$(copyButton.get(0)).mouseleave(function () {
|
||||||
|
$(this).attr('class', 'btn-clipboard');
|
||||||
|
$(this).removeAttr('aria-label');
|
||||||
|
});
|
||||||
|
|
||||||
|
var curClipboard = new Clipboard(copyButton.get(0));
|
||||||
|
|
||||||
|
curClipboard.on('success', function (e) {
|
||||||
|
e.clearSelection();
|
||||||
|
showTooltip(e.trigger, 'Copied!');
|
||||||
|
});
|
||||||
|
|
||||||
|
curClipboard.on('error', function (e) {
|
||||||
|
showTooltip(e.trigger, fallbackMessage(e.action));
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
|
|
|
@ -89,6 +89,7 @@
|
||||||
<script src="{{ static('libs/jquery.unveil.js') }}"></script>
|
<script src="{{ static('libs/jquery.unveil.js') }}"></script>
|
||||||
<script src="{{ static('libs/moment.js') }}"></script>
|
<script src="{{ static('libs/moment.js') }}"></script>
|
||||||
<script src="{{ static('libs/select2/select2.js') }}"></script>
|
<script src="{{ static('libs/select2/select2.js') }}"></script>
|
||||||
|
<script src="{{ static('libs/clipboard/clipboard.js') }}"></script>
|
||||||
{% include "extra_js.html" %}
|
{% include "extra_js.html" %}
|
||||||
<script src="{{ static('common.js') }}"></script>
|
<script src="{{ static('common.js') }}"></script>
|
||||||
<script src="{{ static('libs/clipboard/tooltip.js') }}"></script>
|
<script src="{{ static('libs/clipboard/tooltip.js') }}"></script>
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
{% block js_media %}
|
{% block js_media %}
|
||||||
{% compress js %}
|
{% compress js %}
|
||||||
<script src="{{ static('libs/clipboard/clipboard.js') }}"></script>
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(function () {
|
$(function () {
|
||||||
var info_float = $('.info-float');
|
var info_float = $('.info-float');
|
||||||
|
@ -23,6 +22,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: remove this
|
||||||
var copyButton;
|
var copyButton;
|
||||||
$('pre code').each(function () {
|
$('pre code').each(function () {
|
||||||
$(this).parent().before($('<div>', {'class': 'copy-clipboard'})
|
$(this).parent().before($('<div>', {'class': 'copy-clipboard'})
|
||||||
|
|
Loading…
Reference in a new issue