1( function( $ ) { 2 3 $( document ).ready( function() { 4 var currentListItem; 5 var topMenu = $( '#top-menu' ); 6 var diviHoverClasses = 'et-hover et-show-dropdown'; 7 var lastKey = new Date(); 8 var lastClick = new Date(); 9 10 $( this ).keyup( function( e ) { 11 update_top_menu_classes(); 12 $( '.et-search-field' ).focus( function() { 13 show_search(); 14 }).blur( function() { 15 hide_search(); 16 }); 17 }); 18 19 /** 20 * Add skiplink to page 21 */ 22 function skipTo( target ) { 23 var skiplink = '<a href="' + target + '" class="skip-link dtn-screen-reader-text">Skip to content</a>'; 24 $( target ).attr( 'tabindex', -1 ); 25 $( 'body' ).prepend( skiplink ); 26 } 27 28 skipTo( '#main-content' ); 29 30 /** 31 * Use js to focus for internal links 32 */ 33 $( 'a[href^="#"]' ).click( function() { 34 var content = $( '#' + $(this).attr( 'href' ).slice(1) ); 35 content.focus(); 36 }); 37 38 /** 39 * Only apply focus styles for keyboard usage. 40 */ 41 $( this ).on( 'focusin', function( e ) { 42 $( '.keyboard-outline' ).removeClass( 'keyboard-outline' ); 43 var wasByKeyboard = lastClick < lastKey 44 if( wasByKeyboard ) { 45 $( e.target ).addClass( 'keyboard-outline' ); 46 } 47 }); 48 $( this ).on( 'mousedown', function() { 49 lastClick = new Date(); 50 }); 51 $( this ).on( 'keydown', function() { 52 lastKey = new Date(); 53 }); 54 55 /** 56 * Allow 'Accordian' & 'Toggle' Divi modules to be focusable. 57 */ 58 $( '.et_pb_toggle' ).each( function() { 59 $( this ).attr( 'tabindex', 0 ); 60 }); 61 62 /** 63 * Expand 'Accordian' & 'Toggle' Divi modules when enter is hit while focused. 64 */ 65 $( document ).keypress( function( e ) { 66 if ( e.which == 13 ) { 67 $( '.et_pb_toggle:focus .et_pb_toggle_title' ).trigger( 'click' ); 68 } 69 }); 70 71 /** 72 * Update top navigation classes. 73 */ 74 function update_top_menu_classes() { 75 var currentLink = topMenu.find( 'a:focus' ); 76 currentListItem = currentLink.closest( 'li' ); 77 78 // check if focused on top level nav item 79 if ( topMenu.is( currentListItem.closest( 'ul' ) ) || topMenu.find( 'a:focus' ).length == 0 ) { 80 topMenu.find( 'li' ).removeClass( diviHoverClasses ) 81 } 82 83 // add appropriate divi hover classes if nav item has children 84 if ( $( currentListItem ).children( 'ul' ).length ) { 85 currentListItem.addClass( diviHoverClasses ); 86 } 87 } 88 89 /** 90 * Show the search. 91 * 92 * @since Divi v3.0.23 93 */ 94 function show_search() { 95 var $search_container = $( '.et_search_form_container' ); 96 97 if ( $search_container.hasClass( 'et_pb_is_animating' ) ) { 98 return; 99 } 100 101 $( '.et_menu_container' ).removeClass( 'et_pb_menu_visible et_pb_no_animation' ).addClass( 'et_pb_menu_hidden' ); 102 $search_container.removeClass( 'et_pb_search_form_hidden et_pb_no_animation' ).addClass( 'et_pb_search_visible et_pb_is_animating' ); 103 setTimeout( function() { 104 $( '.et_menu_container' ).addClass( 'et_pb_no_animation' ); 105 $search_container.addClass( 'et_pb_no_animation' ).removeClass( 'et_pb_is_animating' ); 106 }, 1000); 107 $search_container.find( 'input' ).focus(); 108 109 et_set_search_form_css(); 110 } 111 112 /** 113 * Hide the search. 114 * 115 * @since Divi v3.0.23 116 */ 117 function hide_search() { 118 if ( $( '.et_search_form_container' ).hasClass( 'et_pb_is_animating' ) ) { 119 return; 120 } 121 122 $( '.et_menu_container' ).removeClass( 'et_pb_menu_hidden et_pb_no_animation' ).addClass( 'et_pb_menu_visible' ); 123 $( '.et_search_form_container' ).removeClass('et_pb_search_visible et_pb_no_animation' ).addClass( 'et_pb_search_form_hidden et_pb_is_animating' ); 124 setTimeout( function() { 125 $( '.et_menu_container' ).addClass( 'et_pb_no_animation' ); 126 $( '.et_search_form_container' ).addClass( 'et_pb_no_animation' ).removeClass( 'et_pb_is_animating' ); 127 }, 1000); 128 } 129 130 /** 131 * Generate search form styles. 132 * 133 * @since Divi v3.0.23 134 */ 135 function et_set_search_form_css() { 136 var $search_container = $( '.et_search_form_container' ); 137 var $body = $( 'body' ); 138 if ( $search_container.hasClass( 'et_pb_search_visible' ) ) { 139 var header_height = $( '#main-header' ).innerHeight(), 140 menu_width = $( '#top-menu' ).width(), 141 font_size = $( '#top-menu li a' ).css( 'font-size' ); 142 $search_container.css( { 'height' : header_height + 'px' } );
143 $search_container.find( 'input' ).css( 'font-size', font_size ); 144 if ( ! $body.hasClass( 'et_header_style_left' ) ) { 145 $search_container.css( 'max-width', menu_width + 60 ); 146 } else { 147 $search_container.find( 'form' ).css( 'max-width', menu_width + 60 ); 148 } 149 } 150 } 151 152 }); 153 154})( 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.