mirror of
https://github.com/eosswedenorg/apt
synced 2026-06-16 04:34:56 +02:00
move source js files (that should be bundled) from _scripts/ to assets/js/
This commit is contained in:
parent
f097ea57d7
commit
76623dfd2e
4 changed files with 2 additions and 2 deletions
|
|
@ -1,74 +0,0 @@
|
|||
|
||||
import Alpine from 'alpinejs'
|
||||
import alpine_search from './js/alpine_search'
|
||||
|
||||
anchors.add();
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$('.collapse-trigger').click(function() {
|
||||
|
||||
var target_id = $(this).attr('data-target');
|
||||
|
||||
if (target_id) {
|
||||
var target = $(document).find('#' + target_id);
|
||||
|
||||
$(target).toggleClass('collapsed');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// adapted from https://stackoverflow.com/a/48078807/1217368
|
||||
$('.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);
|
||||
});
|
||||
});
|
||||
|
||||
// -------------------
|
||||
// Alpine
|
||||
// -------------------
|
||||
|
||||
Alpine.data('searchComponent', alpine_search)
|
||||
Alpine.start()
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
|
||||
import pkg_idx from './pkg_idx'
|
||||
|
||||
// Alpine search component
|
||||
export default () => ({
|
||||
show: false,
|
||||
query: "",
|
||||
getResults() {
|
||||
if (this.query.length < 1) {
|
||||
return [];
|
||||
}
|
||||
|
||||
var results = pkg_idx.search(this.query).slice(0, 10);
|
||||
|
||||
var list = results.map(function (item) {
|
||||
return package_data.filter(function (v, i, arr) {
|
||||
return v.id == item.ref;
|
||||
})[0];
|
||||
});
|
||||
|
||||
this.open();
|
||||
return list;
|
||||
},
|
||||
toggle() {
|
||||
this.show = ! this.show;
|
||||
},
|
||||
open() {
|
||||
this.show = true;
|
||||
},
|
||||
close() {
|
||||
this.show = false;
|
||||
},
|
||||
isOpen() {
|
||||
return this.show;
|
||||
}
|
||||
})
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
|
||||
import lunr from 'lunr'
|
||||
|
||||
// Package Search using Lunr
|
||||
export default lunr(function () {
|
||||
this.field('name');
|
||||
this.field('version');
|
||||
this.field('repo');
|
||||
this.field('component');
|
||||
|
||||
package_data.forEach(function (pkg) {
|
||||
this.add(pkg);
|
||||
}, this);
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue