mirror of
https://github.com/rancher/rancher-docs.git
synced 2026-09-29 22:49:17 +00:00
Upgrade hugo
This commit is contained in:
@@ -0,0 +1,125 @@
|
||||
// This is for any custom JS that may need to be added to individual apps.
|
||||
// Main JS is located in Rancher Website Theme
|
||||
const bootstrapDocsSearch = function() {
|
||||
|
||||
var firstSearchRender = true;
|
||||
|
||||
const search = instantsearch({
|
||||
appId: '30NEY6C9UY',
|
||||
apiKey: 'b7f43c16886fec97b87981e9e62ef1a5',
|
||||
indexName: window.location.host === 'rancher.com' ? 'prod_docs' : 'dev_docs',
|
||||
routing: true,
|
||||
searchFunction: (helper) => {
|
||||
|
||||
if (helper.state.query === "" && firstSearchRender) {
|
||||
|
||||
firstSearchRender = false;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
helper.search();
|
||||
}
|
||||
});
|
||||
|
||||
search.addWidget(
|
||||
instantsearch.widgets.searchBox({
|
||||
autofocus: true,
|
||||
loadingIndicator: true,
|
||||
container: '#search-box',
|
||||
placeholder: 'Search Blog, Events, etc...',
|
||||
magnifier: false,
|
||||
reset: true,
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
search.addWidget(
|
||||
instantsearch.widgets.infiniteHits({
|
||||
container: '#hits',
|
||||
templates: {
|
||||
empty: '<h3>No results</h3>',
|
||||
item: `<h3><a href="{{permalink}}">{{{_highlightResult.title.value}}}</a></h3><div class="body">{{{_snippetResult.content.value}}}</div>`
|
||||
},
|
||||
escapeHits: true,
|
||||
})
|
||||
);
|
||||
|
||||
search.start();
|
||||
|
||||
$(document).on('click', '.search-open', (e) => {
|
||||
let wrapperId = $(e.currentTarget).data('launch-id');
|
||||
let wrapper = $(`#${wrapperId}`);
|
||||
|
||||
let content = wrapper.find('div.content');
|
||||
|
||||
const modal = new tingle.modal({
|
||||
closeMethods: ['overlay', 'button', 'escape'],
|
||||
closeLabel: "Close",
|
||||
|
||||
onOpen: () => {
|
||||
console.log('Search opened');
|
||||
},
|
||||
|
||||
onClose: () => {
|
||||
console.log('Search closed');
|
||||
},
|
||||
|
||||
beforeClose: () => {
|
||||
content.detach()
|
||||
wrapper.append(content);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
// set content
|
||||
content.detach();
|
||||
modal.setContent(content[0]);
|
||||
|
||||
// add a button
|
||||
let label = wrapper.find('.footer-button-label').data('footer-label');
|
||||
if ( label ) {
|
||||
modal.addFooterBtn(label, 'tingle-btn tingle-btn--primary', function() {
|
||||
// here goes some logic
|
||||
modal.close();
|
||||
});
|
||||
}
|
||||
|
||||
modal.open();
|
||||
setTimeout(function() {
|
||||
$('#search-box').focus();
|
||||
}, 50);
|
||||
});
|
||||
|
||||
//mobile nav toggle
|
||||
$(document).ready(function() {
|
||||
$("body").addClass("js");
|
||||
var $menu = $("#menu"),
|
||||
$menulink = $(".menu-link");
|
||||
|
||||
$menulink.click(function() {
|
||||
$menulink.toggleClass("active");
|
||||
$menu.toggleClass("active");
|
||||
return false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const bootstrapIdLinks = function() {
|
||||
const container = '.wrapper ARTICLE';
|
||||
const selector = 'h2[id], h3[id], h4[id], h5[id], h6[id]';
|
||||
$(container).on('mouseenter', selector, function(e) {
|
||||
$(e.target).append($('<a />').addClass('header-anchor').attr('href', '#' + e.target.id).html('<i class="material-icons p-l-xs" aria-hidden="true">link</i>'));
|
||||
});
|
||||
|
||||
$(container).on('mouseleave', selector, function(e) {
|
||||
$(e.target).parent().find('.header-anchor').remove();
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(() => {
|
||||
bootstrapDocsSearch();
|
||||
bootstrapIdLinks();
|
||||
});
|
||||
|
||||
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../node_modules/rancher-website-theme/assets/js/base.js
|
||||
@@ -0,0 +1,3 @@
|
||||
/*-----*/
|
||||
;
|
||||
/*-----*/
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../node_modules/instantsearch.js/dist/instantsearch.js
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../node_modules/jquery/dist/jquery.js
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../node_modules/lory.js/dist/jquery.lory.js
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../node_modules/ml-stack-nav/dist/ml-stack-nav.js
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../node_modules/moment/moment.js
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../node_modules/tingle.js/dist/tingle.js
|
||||
Reference in New Issue
Block a user