Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function($, Drupal) {
- Drupal.behaviors.shptBlocksNavigation = {
- attach: function(context) {
- $('#block-shpt-theme-branding a').attr('id', '#home');
- $('#block-navigation', context).once('block-navigation').each(function() {
- var secondaryNavigation = $('.secondary-navigation');
- var isExpandingCollapsing = false;
- var isLearnExpanded = false;
- window.setTimeout(function() {
- $(window).trigger('resize');
- }, 500);
- $(window).on('resize scroll', function() {
- var windowTop = parseInt($(window).scrollTop()) + parseInt($('#sticky-container-top').height());
- var windowBottom = windowTop + parseInt($(window).height()) - 50;
- var learn = $('#learn');
- var learnTop = learn.offset().top;
- var learnBottom = learnTop + learn.height() - 50;
- var learnLink = $('.header-bar a, #block-shpt-theme-branding a').eq(1);
- if ($(this).width() < 640 && $('.main-menu').is(":visible")) {
- if ($(window).scrollTop() > 50) {
- $("button.menu-icon").css('box-shadow', '0 0 10px 1px #89939c');
- } else {
- $("button.menu-icon").css('box-shadow', 'none')
- }
- }
- var scrolledToIt = ((learnTop - 10) <= windowTop && learnBottom >= windowTop);
- var inViewPort = (windowTop <= learnTop && windowBottom >= learnBottom);
- if (scrolledToIt || inViewPort) {
- isLearnExpanded = true;
- if (!isExpandingCollapsing) {
- isExpandingCollapsing = true;
- if (inViewPort) {
- $('#main-menu .navigation-ul a').removeClass('is-active');
- learnLink.addClass('is-active in-view-port');
- }
- secondaryNavigation.slideDown('fast', function () {
- isExpandingCollapsing = false;
- if (!isLearnExpanded) {
- $(window).trigger('resize');
- }
- });
- }
- } else {
- isLearnExpanded = false;
- if (!isExpandingCollapsing) {
- isExpandingCollapsing = true;
- if (learnLink.hasClass('in-view-port')) {
- learnLink.removeClass('is-active in-view-port');
- }
- secondaryNavigation.slideUp('fast', function () {
- isExpandingCollapsing = false;
- if (isLearnExpanded) {
- $(window).trigger('resize');
- }
- });
- }
- }
- });
- });
- },
- };
- })(jQuery, Drupal);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement