assets/themes/j1/core/js/template.js in j1-template-2022.3.0.rc1 vs assets/themes/j1/core/js/template.js in j1-template-2022.3.0
- old
+ new
@@ -2521,39 +2521,34 @@
}); // -----------------------------------------------------------------------
// In-page smooth scroll
// -----------------------------------------------------------------------
// bind click event to all headlines generated by AsciiDoctor
// for smooth-scroll (in-page)
- // jadams,2022-06-10: unused code - smooth scrolling managed by
- // (page height) observer
// -----------------------------------------------------------------------
- // $('.sect1, .sect2 .sect3, .sect4, .sect5, .sect6').on('click', function (e) {
- // img_link = (e.target.localName == 'img') ? true : false;
- // page_link = document.querySelector('[id="' + decodeURI(anchor_id).split('#').join('') + '"]') ? true : false;
- // anchor_id = e.target.hash ? e.target.hash : false;
- // classname = e.target.className ? e.target.className : '';
- // nav_link = typeof classname == 'string' ? classname.includes('nav-link') : false; // skip BS nav links
- // scrollOffset = j1.getScrollOffset();
- // anchorTop = $(anchor_id).offset().top ? true : false;
- //
- // if (anchor_id && anchor_id.includes('void')) anchor_id = false;
- //
- // // skip scrolling if a click on an image detected
- // if (img_link) {
- // return true;
- // }
- //
- // if (anchor_id && !nav_link || page_link) {
- // logger.debug('\n' + 'click event on headline detected: ' + anchor_id);
- //
- // $('html, body').animate({
- // scrollTop: + scrollOffset
- // }, scrollDuration);
- // e.preventDefault ? e.preventDefault() : e.returnValue = false;
- // }
- // });
- // bind click event to all HTML elements of class '.badge' (Bootstrap)
+
+ $('.sect1, .sect2 .sect3, .sect4, .sect5, .sect6').on('click', function (e) {
+ img_link = e.target.localName == 'img' ? true : false;
+ page_link = document.querySelector('[id="' + decodeURI(anchor_id).split('#').join('') + '"]') ? true : false;
+ anchor_id = e.target.hash ? e.target.hash : false;
+ classname = e.target.className ? e.target.className : '';
+ nav_link = typeof classname == 'string' ? classname.includes('nav-link') : false; // skip BS nav links
+
+ scrollOffset = j1.getScrollOffset();
+ if (anchor_id && anchor_id.includes('void')) anchor_id = false; // skip scrolling if a click on an image detected
+
+ if (img_link) {
+ return true;
+ }
+
+ if (anchor_id && !nav_link || page_link) {
+ logger.debug('\n' + 'click event on headline detected: ' + anchor_id);
+ $('html, body').animate({
+ scrollTop: $(anchor_id).offset().top + scrollOffset
+ }, scrollDuration);
+ e.preventDefault ? e.preventDefault() : e.returnValue = false;
+ }
+ }); // bind click event to all HTML elements of class '.badge' (Bootstrap)
// for smooth-scroll (in-page) to a '<div>' element
// -----------------------------------------------------------------------
$('.badge').on('click', function (e) {
anchor_id = e.target.hash ? e.target.hash : false;
@@ -2699,11 +2694,11 @@
// https://stackoverflow.com/questions/4770025/how-to-disable-scrolling-temporarily
// https://stackoverflow.com/questions/5963669/whats-the-difference-between-event-stoppropagation-and-event-preventdefault
// -----------------------------------------------------------------------
- $('.quicklink-nav').each(function () {
+ $('.attr-nav').each(function () {
// ---------------------------------------------------------------------
// QuickSearch
//
if ($('li.quicksearch')) {
logger.debug('register OPEN event for QuickSearch');
@@ -2752,36 +2747,25 @@
$('#' + defaultOptions.nav_bar.container_id).show();
e.stopPropagation(); // don't bubble up the event
});
} // END QuickSearch
// ---------------------------------------------------------------------
- // Translator dialog
+ // Translator
//
if ($('li.translate')) {
logger.debug('register SHOW event for J1 Translator');
$('li.translate > a', this).on('click', function (e) {
j1.translator.showDialog();
});
} // END Translator
// ---------------------------------------------------------------------
- // NBI Notebooks dialog
+ // CookieConsent
//
- if ($('li.nbi-notebooks')) {
- logger.debug('register SHOW event for J1 NBI');
- $('li.nbi-notebooks > a', this).on('click', function (e) {
- j1.adapter.nbinteract.showDialog();
- });
- } // END NBI Notebooks
- // ---------------------------------------------------------------------
- // CookieConsent dialog
- //
-
-
if ($('li.cookie-consent')) {
logger.debug('register SHOW event for J1 CookieConsent');
$('li.cookie-consent > a', this).on('click', function (e) {
j1.cookieConsent.showDialog();
});
@@ -2925,13 +2909,13 @@
// });
$('.megamenu-fw', this).each(function () {
$('.title', this).off('click');
$('a.dropdown-toggle', this).off('click');
- $('.content').removeClass('animate__animated ');
+ $('.content').removeClass('animated');
});
- $('.dropdown-menu', this).addClass('animate__animated ');
+ $('.dropdown-menu', this).addClass('animated');
$('li.dropdown', this).on('mouseenter', function (e) {
$menu = $('.dropdown-menu', this).eq(0);
$dropDown = $(this);
$menu.removeClass($getOut);
$menu.removeClass('open');
@@ -2968,11 +2952,11 @@
var windowHeight = $(window).height(),
windowWidth = $(window).width();
$('.nav-full').css('height', windowHeight + 'px');
$('.wrap-full-menu').css('height', windowHeight + 'px');
$('.wrap-full-menu').css('width', windowWidth + 'px');
- $('.navbar-collapse').addClass('animate__animated ');
+ $('.navbar-collapse').addClass('animated');
$('.navbar-toggle').each(function () {
var getId = $(this).data('target');
$(this).off('click');
$(this).on('click', function (e) {
e.preventDefault();
@@ -3103,21 +3087,23 @@
var logger;
var logText;
logger = log4javascript.getLogger('j1.core.scrollSmooth'); // indicator|check currently NOT used
// if (isCssSmoothScrollSupported()) { }
- logText = '\n' + 'run module scrollSmooth';
- logger.debug(logText);
+ logText = 'run module scrollSmooth';
+ logger.info(logText);
var duration = options.duration;
var offset = options.offset; // var pageUrl = options.location.hash
// ? stripHash(options.location.href)
// : options.location.href;
this.scrollTo(target, {
duration: duration,
offset: offset,
callback: false
});
+ logText = 'scrollSmooth finished';
+ logger.info(logText);
},
// -------------------------------------------------------------------------
// scrollTo
// NOTE: Calculate the tgt (HTML heading element including the hash)
// This makes ids that start with a number to work:
\ No newline at end of file