1(function($) { 2 "use strict"; 3 4 $(document).ready(function() { 5 6 $(window).on('load', function() { 7 var current_width = $(window).width(); 8 9 // Only run on desktop 10 if ( current_width > 768 ) { 11 12 // Find menu items with a drop menu and center them 13 $('.main-navigation li').each(function() { 14 if ($(this).find('ul:first-of-type').length > 0) { 15 var parent_width = $(this).outerWidth(true); 16 var child_width = $(this).find('ul').outerWidth(true); 17 var new_width = parseInt((child_width - parent_width) / 2); 18 $(this).find('ul').css('margin-left', -new_width + 'px'); 19 } 20 }); 21 } 22 }); 23 24 25 // Standardize drop menu types 26 $('.main-navigation .children').addClass('sub-menu'); 27 $('.main-navigation .page_item_has_children').addClass('menu-item-has-children'); 28 29 30 // Toggle the mobile menu 31 $('.menu-toggle').click(function() { 32 $('.mobile-navigation').toggleClass('toggle-active'); 33 $('.drawer').toggle(); 34 $(this).find('span').toggle(); 35 }); 36 37 // Append a clickable icon to mobile drop menus 38 var item = $('<button class="toggle-sub" aria-expanded="false"><i class="gbi gbicon-angle-down"></i></button>'); 39 40 // Append clickable icon for mobile drop menu 41 if ($('.drawer .menu-item-has-children .toggle-sub').length == 0) { 42 $('.drawer .menu-item-has-children,.drawer .page_item_has_children').append(item); 43 } 44 45 // Show sub menu when toggle is clicked 46 $('.drawer .menu-item-has-children .toggle-sub').click(function(e) { 47 $(this).each(function() { 48 e.preventDefault(); 49 50 // Change aria expanded value 51 $(this).attr('aria-expanded', ($(this).attr('aria-expanded')=='false') ? 'true':'false'); 52 53 // Open the drop menu 54 $(this).closest('.menu-item-has-children').toggleClass('drop-open'); 55 $(this).prev('.sub-menu').toggleClass('drop-active'); 56 57 // Change the toggle icon 58 $(this).find('i').toggleClass('gbicon-angle-down').toggleClass('gbicon-angle-up'); 59 }); 60 }); 61 62 // Scroll back to top 63 $('.back-to-top a, .sticky-title').click(function(e) { 64 e.preventDefault(); 65 66 $('html,body').animate({ 67 scrollTop: 0 68 }, 700); 69 70 return false; 71 } ); 72 73 74 // Infinite scroll 75 $(document.body).on('post-load', function () { 76 var $container = $('#post-wrap'); 77 var $newItems = $('.new-infinite-posts').not('.is--replaced'); 78 var $elements = $newItems.find('.post'); 79 80 // Remove the empty elements that break the grid 81 $('.new-infinite-posts,.infinite-loader').remove(); 82 83 // Append IS posts 84 $container.append($elements); 85 86 }); 87 88 }); 89 90})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.