2019-01-02 17:32:44 +00:00
|
|
|
///////////////////////////// Make headers linkable /////////////////////////////
|
|
|
|
|
2019-01-21 15:57:35 +00:00
|
|
|
$(".article--content h2, \
|
|
|
|
.article--content h3, \
|
|
|
|
.article--content h4, \
|
|
|
|
.article--content h5, \
|
|
|
|
.article--content h6" ).each(function() {
|
2018-12-21 23:59:12 +00:00
|
|
|
var link = "<a href=\"#" + $(this).attr("id") + "\"></a>"
|
|
|
|
$(this).wrapInner( link );
|
|
|
|
})
|
|
|
|
|
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-01-22 19:04:11 +00:00
|
|
|
".truncate-toggle",
|
2019-02-05 18:39:00 +00:00
|
|
|
".children-links a",
|
2020-04-17 06:57:07 +00:00
|
|
|
".list-links a",
|
|
|
|
"a.url-trigger"
|
2019-01-04 15:44:53 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
$('.article a[href^="#"]:not(' + elementWhiteList + ')').click(function (e) {
|
2019-01-02 17:32:44 +00:00
|
|
|
e.preventDefault();
|
2018-12-21 23:59:12 +00:00
|
|
|
|
2019-01-02 17:32:44 +00:00
|
|
|
var target = this.hash;
|
|
|
|
var $target = $(target);
|
2018-12-21 23:59:12 +00:00
|
|
|
|
2019-01-02 17:32:44 +00:00
|
|
|
$('html, body').stop().animate({
|
|
|
|
'scrollTop': ($target.offset().top)
|
|
|
|
}, 400, 'swing', function () {
|
|
|
|
window.location.hash = target;
|
2018-12-21 23:59:12 +00:00
|
|
|
});
|
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-02 17:32:44 +00:00
|
|
|
//////////////////////////////// Tabbed Content ////////////////////////////////
|
|
|
|
|
2019-01-03 19:39:07 +00:00
|
|
|
function tabbedContent(container, tab, content) {
|
2019-01-02 17:32:44 +00:00
|
|
|
|
2019-10-08 21:38:49 +00:00
|
|
|
// Add the active class to the first tab in each tab group,
|
|
|
|
// in case it wasn't already set in the markup.
|
|
|
|
$(container).each(function () {
|
|
|
|
$(tab, this).removeClass('is-active');
|
|
|
|
$(tab + ':first', this).addClass('is-active');
|
|
|
|
});
|
|
|
|
|
|
|
|
$(tab).on('click', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
// Make sure the tab being clicked is marked as active, and make the rest inactive.
|
|
|
|
$(this).addClass('is-active').siblings().removeClass('is-active');
|
|
|
|
|
|
|
|
// Render the correct tab content based on the position of the tab being clicked.
|
|
|
|
const activeIndex = $(tab).index(this);
|
|
|
|
$(content).each(function(i) {
|
|
|
|
if (i === activeIndex) {
|
|
|
|
$(this).show();
|
|
|
|
$(this).siblings(content).hide();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2019-01-03 19:39:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tabbedContent('.code-tabs-wrapper', '.code-tabs p a', '.code-tab-content');
|
|
|
|
tabbedContent('.tabs-wrapper', '.tabs p a', '.tab-content');
|
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()
|
|
|
|
$(this).closest('.truncate').toggleClass('closed');
|
2019-01-04 15:44:53 +00:00
|
|
|
})
|
2019-01-23 04:43:47 +00:00
|
|
|
|
|
|
|
//////////////////// Replace Missing Images with Placeholder ///////////////////
|
|
|
|
|
|
|
|
$(".article--content img").on("error", function() {
|
|
|
|
$(this).attr("src", "/img/coming-soon.svg");
|
|
|
|
$(this).attr("style", "max-width:500px;");
|
|
|
|
});
|
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);
|
|
|
|
});
|