1/** 2 * Vogue Custom JS Functionality 3 * 4 */ 5( function( $ ) { 6 7 jQuery( document ).ready( function() { 8 // Add button to sub-menu item to show nested pages / Only used on mobile 9 $( '.main-navigation li.page_item_has_children > a, .main-navigation li.menu-item-has-children > a' ).after( '<button class="menu-dropdown-btn"><i class="fas fa-angle-down"></i></button>' ); 10 $( '.main-navigation, .vogue-top-bar-menu' ).find( 'a' ).on( 'focus blur', function() { 11 $( this ).parents( 'li' ).toggleClass( 'focus' ); 12 } ); 13 // Mobile nav button functionality 14 $( '.menu-dropdown-btn' ).bind( 'click', function() { 15 $(this).parent().toggleClass( 'open-page-item' ); 16 }); 17 // The menu button 18 $( '.header-menu-button' ).click( function(e){ 19 $( 'body' ).toggleClass( 'show-main-menu' ); 20 var element = $( '#main-menu' ); 21 trapFocus( element ); 22 }); 23 24 $( '.main-menu-close, .main-navigation li.anchorlink' ).click( function(e){ 25 $( '.header-menu-button' ).click(); 26 $( '.header-menu-button' ).focus(); 27 }); 28 $( document ).on( 'keyup',function(evt) { 29 if ( $( 'body' ).hasClass( 'show-main-menu' ) && evt.keyCode == 27 ) { 30 $( '.header-menu-button' ).click(); 31 $( '.header-menu-button' ).focus(); 32 } 33 if ( $( 'body' ).hasClass( 'show-site-search' ) && evt.keyCode == 27 ) { 34 $( '.site-header .search-block' ).animate( { opacity: '0' }, 200 ); 35 $( 'body' ).removeClass( 'show-site-search' ); 36 $( '.menu-search' ).focus(); 37 } 38 }); 39 40 // Show / Hide Search 41 $( '.menu-search' ).on( 'click', function() { 42 $( 'body').addClass( 'show-site-search' ); 43 $( '.site-header .search-block' ).animate( { opacity: '1' }, 200 ); 44 $( '.site-header .search-field' ).focus(); 45 var element = $( '.search-block' ); 46 trapSearch( element ); 47 }); 48 49 // Scroll To Top Button Functionality 50 $(".scroll-to-top").bind("click", function() { 51 $('html, body').animate( { scrollTop: 0 }, 800 ); 52 }); 53 $(window).scroll(function(){ 54 if ($(this).scrollTop() > 400) { 55 $('.scroll-to-top').fadeIn(); 56 } else { 57 $('.scroll-to-top').fadeOut(); 58 } 59 }); 60 61 }); 62 63 $(window).resize(function () { 64 65 vogue_center_slider_elements(); 66 67 }).resize(); 68 69 $(window).on('load',function () { 70 71 $( '.side-aligned-social' ).removeClass( 'hide-side-social' ); 72 73 vogue_home_slider(); 74 75 }); 76 77 // Hide Search is user clicks anywhere else 78 $(document).mouseup(function (e) { 79 var container = $( '.site-header .search-block' ); 80 if ( !container.is( e.target ) && container.has( e.target ).length === 0 ) { 81 $( '.site-header .search-block' ).animate( { opacity: '0' }, 200 ); 82 $( 'body' ).removeClass( 'show-site-search' ); 83 } 84 }); 85 86 // Home Page Slider 87 function vogue_home_slider() { 88 var home_slider_random = $( '.home-slider-wrap' ).data( 'rand' ); 89 var home_slider_auto = $( '.home-slider-wrap' ).data( 'auto' ); 90 var home_slider_scroll_effect = $( '.home-slider-wrap' ).data( 'scroll' ); 91 var home_slider_poh = $( '.home-slider-wrap' ).data( 'poh' ); 92 93 $( '.home-slider' ).carouFredSel({ 94 responsive: true, 95 circular: true, 96 infinite: false, 97 width: 1200, 98 height: 'variable', 99 items: { 100 start: home_slider_random, 101 visible: 1, 102 width: 1200, 103 height: 'variable' 104 }, 105 onCreate: function(items) { 106 vogue_center_slider_elements(); 107 $( '.home-slider-wrap' ).removeClass( 'home-slider-remove' ); 108 }, 109 scroll: { 110 fx: home_slider_scroll_effect, 111 pauseOnHover: home_slider_poh, 112 duration: 450 113 }, 114 auto: home_slider_auto, 115 pagination: '.home-slider-pager', 116 prev: '.home-slider-prev', 117 next: '.home-slider-next' 118 }); 119 } 120 121 function vogue_center_slider_elements() { 122 $( '.home-slider-block' ).each( function( i ){ 123 $( this ).find( '.home-slider-block-inner').height( $( this ).find( '.home-slider-block-bg').outerHeight() ); 124 }); 125 } 126 127} )( jQuery ); 128 129function trapFocus( element, namespace ) { 130 var focusableEls = element.find( 'a, button' ); 131 var firstFocusableEl = focusableEls[0]; 132 var lastFocusableEl = focusableEls[focusableEls.length - 1]; 133 var KEYCODE_TAB = 9; 134
135 firstFocusableEl.focus(); 136 137 element.keydown( function(e) { 138 var isTabPressed = ( e.key === 'Tab' || e.keyCode === KEYCODE_TAB ); 139 140 if ( !isTabPressed ) { 141 return; 142 } 143 144 if ( e.shiftKey ) /* shift + tab */ { 145 if ( document.activeElement === firstFocusableEl ) { 146 lastFocusableEl.focus(); 147 e.preventDefault(); 148 } 149 } else /* tab */ { 150 if ( document.activeElement === lastFocusableEl ) { 151 firstFocusableEl.focus(); 152 e.preventDefault(); 153 } 154 } 155 156 }); 157} 158 159function trapSearch( element, namespace ) { 160 var focusableEls = element.find( 'input' ); 161 var firstFocusableEl = focusableEls[0]; 162 var lastFocusableEl = focusableEls[0]; 163 var KEYCODE_TAB = 9; 164 165 firstFocusableEl.focus(); 166 167 element.keydown( function(e) { 168 var isTabPressed = ( e.key === 'Tab' || e.keyCode === KEYCODE_TAB ); 169 170 if ( !isTabPressed ) { 171 return; 172 } 173 174 if ( e.shiftKey ) /* shift + tab */ { 175 if ( document.activeElement === firstFocusableEl ) {
176 lastFocusableEl.focus(); 177 e.preventDefault(); 178 } 179 } else /* tab */ { 180 if ( document.activeElement === lastFocusableEl ) { 181 firstFocusableEl.focus(); 182 e.preventDefault(); 183 } 184 } 185 186 }); 187}
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.