2019-01-02 17:32:44 +00:00
|
|
|
///////////////////////////// Make headers linkable /////////////////////////////
|
|
|
|
|
2022-06-03 18:26:25 +00:00
|
|
|
var headingWhiteList = $("\
|
|
|
|
.article--content h2, \
|
|
|
|
.article--content h3, \
|
|
|
|
.article--content h4, \
|
|
|
|
.article--content h5, \
|
|
|
|
.article--content h6 \
|
|
|
|
");
|
|
|
|
|
|
|
|
var headingBlackList = ("\
|
|
|
|
.influxdbu-banner h4 \
|
|
|
|
");
|
|
|
|
|
|
|
|
headingElements = headingWhiteList.not(headingBlackList);
|
|
|
|
|
|
|
|
headingElements.each(function() {
|
2022-05-20 20:47:27 +00:00
|
|
|
function getLink(element) {
|
|
|
|
return ((element.attr('href') === undefined ) ? $(element).attr("id") : element.attr('href'))
|
|
|
|
}
|
|
|
|
var link = "<a href=\"#" + getLink($(this)) + "\"></a>"
|
|
|
|
$(this).wrapInner( link );
|
2018-12-21 23:59:12 +00:00
|
|
|
})
|
|
|
|
|
2019-01-02 17:32:44 +00:00
|
|
|
///////////////////////////////// Smooth Scroll /////////////////////////////////
|
|
|
|
|
2019-01-04 15:44:53 +00:00
|
|
|
var elementWhiteList = [
|
|
|
|
".tabs p a",
|
|
|
|
".code-tabs p a",
|
2019-02-05 18:39:00 +00:00
|
|
|
".children-links a",
|
2020-04-17 06:57:07 +00:00
|
|
|
".list-links a",
|
2022-02-28 20:56:17 +00:00
|
|
|
"a.url-trigger",
|
|
|
|
"a.fullscreen-close"
|
2019-01-04 15:44:53 +00:00
|
|
|
]
|
|
|
|
|
2021-02-27 01:31:19 +00:00
|
|
|
function scrollToAnchor(target) {
|
2019-01-02 17:32:44 +00:00
|
|
|
var $target = $(target);
|
2021-06-15 20:56:02 +00:00
|
|
|
if($target && $target.length > 0) {
|
|
|
|
$('html, body').stop().animate({
|
|
|
|
'scrollTop': ($target.offset().top)
|
|
|
|
}, 400, 'swing', function () {
|
|
|
|
window.location.hash = target;
|
|
|
|
});
|
2022-03-29 20:44:01 +00:00
|
|
|
|
|
|
|
// Unique accordion functionality
|
|
|
|
// If the target is an accordion element, open the accordion after scrolling
|
|
|
|
if ($target.hasClass('expand')) {
|
|
|
|
if ($(target + ' .expand-label .expand-toggle').hasClass('open')) {}
|
|
|
|
else {
|
|
|
|
$(target + '> .expand-label').trigger('click');
|
|
|
|
};
|
|
|
|
};
|
2021-06-15 20:56:02 +00:00
|
|
|
}
|
2021-02-27 01:31:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$('.article a[href^="#"]:not(' + elementWhiteList + ')').click(function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
scrollToAnchor(this.hash);
|
2019-01-02 17:32:44 +00:00
|
|
|
});
|
|
|
|
|
2019-01-03 00:18:01 +00:00
|
|
|
///////////////////////////// Left Nav Interactions /////////////////////////////
|
|
|
|
|
2019-01-03 18:23:17 +00:00
|
|
|
$(".children-toggle").click(function(e) {
|
2019-10-08 21:38:49 +00:00
|
|
|
e.preventDefault()
|
|
|
|
$(this).toggleClass('open');
|
|
|
|
$(this).siblings('.children').toggleClass('open');
|
2019-01-03 00:18:01 +00:00
|
|
|
})
|
|
|
|
|
2019-01-03 23:59:31 +00:00
|
|
|
//////////////////////////// Mobile Contents Toggle ////////////////////////////
|
|
|
|
|
|
|
|
$('#contents-toggle-btn').click(function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
$(this).toggleClass('open');
|
|
|
|
$('#nav-tree').toggleClass('open');
|
|
|
|
})
|
|
|
|
|
2019-01-04 15:44:53 +00:00
|
|
|
/////////////////////////////// Truncate Content ///////////////////////////////
|
|
|
|
|
|
|
|
$(".truncate-toggle").click(function(e) {
|
2019-10-08 21:38:49 +00:00
|
|
|
e.preventDefault()
|
2022-11-21 22:44:14 +00:00
|
|
|
var truncateParent = $(this).closest('.truncate')
|
|
|
|
var truncateParentID = $(this).closest('.truncate')[0].id
|
|
|
|
|
|
|
|
if (truncateParent.hasClass('closed')) {
|
|
|
|
$(this)[0].href = `#${truncateParentID}`
|
|
|
|
} else {
|
|
|
|
$(this)[0].href = "#"
|
|
|
|
}
|
|
|
|
|
|
|
|
truncateParent.toggleClass('closed')
|
|
|
|
truncateParent.find('.truncate-content').toggleClass('closed')
|
2019-01-04 15:44:53 +00:00
|
|
|
})
|
2019-01-23 04:43:47 +00:00
|
|
|
|
2022-03-29 20:44:01 +00:00
|
|
|
////////////////////////////// Expand Accordions ///////////////////////////////
|
2020-07-30 21:25:10 +00:00
|
|
|
|
2020-07-29 21:07:24 +00:00
|
|
|
$('.expand-label').click(function() {
|
|
|
|
$(this).children('.expand-toggle').toggleClass('open')
|
|
|
|
$(this).next('.expand-content').slideToggle(200)
|
|
|
|
})
|
|
|
|
|
2022-03-29 20:44:01 +00:00
|
|
|
// Expand accordions on load based on URL anchor
|
|
|
|
function openAccordionByHash() {
|
|
|
|
var anchor = window.location.hash;
|
|
|
|
|
|
|
|
function expandElement() {
|
|
|
|
if ($(anchor).parents('.expand').length > 0) {
|
|
|
|
return $(anchor).closest('.expand').children('.expand-label');
|
|
|
|
} else if ($(anchor).hasClass('expand')){
|
|
|
|
return $(anchor).children('.expand-label');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
if (expandElement() != null) {
|
|
|
|
if (expandElement().children('.expand-toggle').hasClass('open')) {}
|
|
|
|
else {
|
|
|
|
expandElement().children('.expand-toggle').trigger('click');
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
// Open accordions by hash on page load.
|
|
|
|
openAccordionByHash()
|
|
|
|
|
2019-10-02 21:53:48 +00:00
|
|
|
////////////////////////// Inject tooltips on load //////////////////////////////
|
2019-10-03 19:07:25 +00:00
|
|
|
|
2019-10-08 21:36:30 +00:00
|
|
|
$('.tooltip').each( function(){
|
2019-10-08 21:38:49 +00:00
|
|
|
$toolTipText = $('<div/>').addClass('tooltip-text').text($(this).attr('data-tooltip-text'));
|
|
|
|
$toolTipElement = $('<div/>').addClass('tooltip-container').append($toolTipText);
|
|
|
|
$(this).prepend($toolTipElement);
|
|
|
|
});
|
2021-11-19 22:41:06 +00:00
|
|
|
|
2022-09-23 20:42:19 +00:00
|
|
|
//////////////////// Style time cells in tables to not wrap ////////////////////
|
2021-11-19 22:41:06 +00:00
|
|
|
|
|
|
|
$('.article--content table').each(function() {
|
|
|
|
var table = $(this);
|
|
|
|
|
|
|
|
table.find('td').each(function() {
|
2022-09-23 20:42:19 +00:00
|
|
|
let cellContent = $(this)[0].innerText
|
|
|
|
|
2023-01-31 18:07:26 +00:00
|
|
|
if (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.*Z/.test(cellContent)) {
|
2022-09-23 20:42:19 +00:00
|
|
|
$(this).addClass('nowrap')
|
2021-11-19 22:41:06 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
2024-02-20 19:56:12 +00:00
|
|
|
|
|
|
|
/////////////////////// Open external links in a new tab ///////////////////////
|
|
|
|
|
|
|
|
$('.article--content a').each(function() {
|
|
|
|
var currentHost = location.host;
|
|
|
|
|
|
|
|
if (!($(this)[0].href).includes(currentHost)) {
|
|
|
|
$(this).attr('target', '_blank');
|
|
|
|
};
|
|
|
|
})
|