1
0
mirror of https://github.com/bitwarden/help synced 2025-12-10 21:33:18 +00:00
Files
help/js/bit.js
David Choi 80a0b17ac6 Staging (#294)
* jekyll redirect from

* Organizations rev (#262)

* Organizations revisions initial commit.

* API doc updates

* Fix absolute link causing build failure.

* Add import to org article, and downstream order changes.

* Bitwarden 101 videos: 1st steps toward proliferating these throughout /help.

* Added 'Create Your Account' article, which references B101 Videos.

* About SSO redirect & promote importing for orgs up the list

* Create Org FAQs & trim Feature FAQs accordingly.

* Image for Org FAQs

* Move 'About the Business Portal' to Orgs category, and re-order accordingly.

* Final edits.

* Dchoi/bootstrap upgrade (#264)

* bootstrap 4 upgrade and cleanup update gulp tasks

* bootstrap package updates

* renaming file convention

* general outline of help outline

* bitwarden help cleanup

* article cleanup

* article general styling complete

* bootstrap help page upgrades

* sidebar updates

* Dchoi/bootstrap upgrade (#267)

* bootstrap 4 upgrade and cleanup update gulp tasks

* bootstrap package updates

* renaming file convention

* general outline of help outline

* bitwarden help cleanup

* article cleanup

* article general styling complete

* bootstrap help page upgrades

* sidebar updates

* toc dynamic and more updates

* fix callout conditions

* sidebar collapse functionality added

* sidebar header toggle functionality

* sidebar article fixes

* Update sidebar.html

Fix sidebar Release Notes link.

* Update releasenotes.md

Remove unnecessary category tag.

* Delete release-notes.md

Remove unnecessary category.

* Update why-choose-bitwarden-for-your-team.md

Test table image differentiation

* Update why-choose-bitwarden-for-your-team.md

Second image differentiation test

* removed links from category breadcrumb and replaced with badges

Co-authored-by: fred_the_tech_writer <69817454+fschillingeriv@users.noreply.github.com>
2020-11-13 14:23:00 -08:00

100 lines
3.3 KiB
JavaScript

$(function () {
// lightbox listener
var lightboxOpen = false,
lightboxSelector = 'a[rel="lightbox"]';
$(lightboxSelector)
.on('openstart.fluidbox', function () {
lightboxOpen = true;
})
.on('closestart.fluidbox', function () {
lightboxOpen = false;
})
.fluidbox();
$(document).keydown(function (e) {
if (lightboxOpen && e.keyCode === 27) {
$(lightboxSelector).trigger('close.fluidbox');
}
});
$(window).scroll(function () {
if (lightboxOpen) {
$(lightboxSelector).trigger('close.fluidbox');
}
});
// generating article card headers
var $articleCardHeaders = $('.article-card .card-body > h2, .article-card .card-body > h3');
$articleCardHeaders.filter('[id]').each(function () {
var header = $(this),
headerID = header.attr('id');
if (headerID) {
// generating clickable anchor links and id
header.append(`<a href="#${this.id}" class="header-link" aria-hidden="true" title="Permalink">
<i class="fa fa-link" aria-hidden="true"></i>
</a>`);
// generating toc-nav li via headers in article
$('.toc-nav').append(`<li class="toc-entry toc-${this.localName}">
<a href="#${this.id}">${this.textContent}</a>
</li>`);
}
return this;
});
if ($articleCardHeaders.length === 0) {
$('.bd-toc').attr('style', 'display: none !important');
}
// active class on toc right sidebar on scroll
var addClassOnScroll = function () {
var windowTop = $(window).scrollTop();
$('.bd-content .article-card .card-body h2[id], .bd-content .article-card .card-body h3[id]').each(function (_, el) {
var offsetTop = $(el).offset().top;
var outerHeight = $(this).outerHeight(true);
if (windowTop > (offsetTop - 56) && windowTop < ( offsetTop + outerHeight)) {
var elId = $(el).attr('id');
$(".toc-nav .toc-entry a.active").removeClass('active');
$(".toc-nav .toc-entry a[href='#" + elId + "']").addClass('active');
}
});
};
$(window).on('scroll', function () {
addClassOnScroll();
});
// smooth scrolling
$('a[href*="#"]').click(function(e) {
if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
if (target.length) {
e.preventDefault();
const NAVBAR_HEIGHT = 62 + 5;
$('html, body').animate({
scrollTop: target.offset().top - NAVBAR_HEIGHT
}, 500, function() {
var $target = $(target);
$target.focus();
if ($target.is(":focus")) {
return false;
} else {
$target.attr('tabindex','-1');
$target.focus();
};
});
}
}
});
// collapse
// $('.collapse').collapse()
});