mirror of
https://github.com/eosswedenorg/apt
synced 2026-06-17 04:40:03 +02:00
Adding npm and build script with uglifyjs
This commit is contained in:
parent
6c9bd003dd
commit
db291a87df
5 changed files with 83 additions and 53 deletions
50
_scripts/app.js
Normal file
50
_scripts/app.js
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
|
||||
anchors.add();
|
||||
|
||||
// adapted from https://stackoverflow.com/a/48078807/1217368
|
||||
$(document).ready(function() {
|
||||
$('.highlight > pre').each(function(i) {
|
||||
if (!$(this).parent().hasClass('no-select-button')) {
|
||||
|
||||
// create an id for the current code section
|
||||
var currentId = "codeblock" + (i + 1);
|
||||
|
||||
// find the code section and add the id to it
|
||||
var codeSection = $(this).find('code');
|
||||
codeSection.attr('id', currentId);
|
||||
|
||||
// now create the button, setting the clipboard target to the id
|
||||
var btn = document.createElement('a');
|
||||
btn.setAttribute('type', 'button');
|
||||
btn.setAttribute('class', 'btn btn-copy-code');
|
||||
btn.setAttribute('data-clipboard-target', '#' + currentId);
|
||||
btn.innerHTML = '<i class="far fa-file-code fa-2x"></i>';
|
||||
this.insertBefore(btn, this.firstChild);
|
||||
|
||||
// Create tooltip
|
||||
tippy(btn, {
|
||||
trigger: 'manual',
|
||||
content: "Copied!",
|
||||
placement: 'left',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
var clipboard = new ClipboardJS('.btn-copy-code');
|
||||
|
||||
// Attach callback to copy successful event.
|
||||
clipboard.on('success', function(event) {
|
||||
var tooltip = event.trigger._tippy;
|
||||
|
||||
// Clear text selection.
|
||||
event.clearSelection();
|
||||
|
||||
// Show tooltiop
|
||||
tooltip.show();
|
||||
|
||||
// After 1 second, hide it again.
|
||||
setTimeout(function() {
|
||||
tooltip.hide();
|
||||
}, 1000, tooltip);
|
||||
});
|
||||
});
|
||||
8
_scripts/build.sh
Executable file
8
_scripts/build.sh
Executable file
|
|
@ -0,0 +1,8 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
UGLIFYJS=node_modules/uglify-js/bin/uglifyjs
|
||||
|
||||
SRC=_scripts/app.js
|
||||
TARGET=assets/scripts.js
|
||||
|
||||
$UGLIFYJS $SRC -c -m > $TARGET
|
||||
Loading…
Add table
Add a link
Reference in a new issue