1 2 /* 3 * 4 * Javascript PRO Functions 5 * ------------------------------------------------ 6 * WP Mobile Menu 7 * Copyright WP Mobile Menu 2018 - http://www.wpmobilemenu.com 8 * 9 * 10 * 11 */ 12 13 "use strict"; 14 var previousTerm = ''; 15 16 jQuery( document ).ready( function($) { 17 18 19 20 $( document ).on( 'click, mouseover', '.mobmenu-language-wrapper .mm-active-flag' , function ( e ) { 21 e.preventDefault(); 22 $( '.mobmenu-language-wrapper li' ).show(); 23 }); 24 25 $( document ).on( 'mouseleave', '.mobmenu-language-wrapper' , function ( e ) { 26 e.preventDefault(); 27 $( '.mobmenu-language-wrapper li:not(.mm-active-flag)' ).hide(); 28 }); 29 30 $( document ).on( 'click', '.mobmenu-language-selector li.mm-current-language' , function ( e ) { 31 e.preventDefault(); 32 $( '.mobmenu-language-selector' ).toggleClass( 'language-selector-opened' ); 33 }); 34 35 $( document ).on( 'click', '.sliding-back-menu' , function ( e ) { 36 jQuery(this).parent().removeClass( 'show-sub-menu' ); 37 jQuery('.show-sub').removeClass( 'show-sub' ); 38 e.stopPropagation(); 39 }); 40 41 $( ".mobmenu-search" ).click(function() { 42 43 if ( $( 'html').hasClass( 'show-mob-menu-search' ) ) { 44 $( '.mob-menu-search-form' ).fadeOut(); 45 $( '.mobmenu-search-holder' ).slideUp( 800 ); 46 $( '.mobmenu-ajax-search-results' ).slideUp( 800 ); 47 $( '.mobmenu-search .mob-search-cancel-button' ).hide(); 48 $( '.mobmenu-search .mob-search-button' ).show(); 49 $( 'html' ).removeClass( 'show-mob-menu-search' ); 50 } else { 51 52 $( '.mob-menu-search-form' ).fadeIn( 800 ); 53 $( '.mobmenu-search-holder' ).slideDown(); 54 $( '.mobmenu-search .mob-search-cancel-button' ).show(); 55 $( '.mobmenu-search .mob-search-button' ).hide(); 56 $( '.mob-menu-search-field' ).focus(); 57 $( 'html').addClass( 'show-mob-menu-search' ); 58 59 } 60 }); 61 62 $( '.header-ajax-search .mob-menu-search-field' ).on( 'keyup', function( e ){ 63 64 var searchTerm = $( this ).val(); 65 e.preventDefault(); 66 67 if ( searchTerm == previousTerm ) return; 68 previousTerm = searchTerm; 69 70 if ( searchTerm && searchTerm.length > 2 ) { 71 var types = ''; 72 73 if ( $( '#post_type' ).length ) { 74 types = $( '#post_type' ).val(); 75 } 76 77 $.ajax({
78 url : frontend.ajaxurl, 79 data : { 80 action : 'mobile_menu_search__premium_only', 81 terms : searchTerm, 82 post_types: types, 83 }, 84 type : 'POST', 85 success : function( response ) { 86 $( '.mobmenu-ajax-search-results').html( response ).show(); 87 }, 88 error : function(error){ 89 console.log(error); 90 } 91 }) 92 } 93 else { 94 $( '.mobmenu-ajax-search-results' ).html( '' ).hide(); 95 } 96 }); 97 98 $( document ).on( 'click', '.mobmenu-tabs-header li' , function ( e ) { 99 100 e.preventDefault(); 101 $( '.active-tab' ).removeClass( 'active-tab' ); 102 $( this ).addClass( 'active-tab' ); 103 $( '.mobmenu-tabs-container .mobmenu-tab' ).hide(); 104 $('.' + $( this ).attr('data-tab-id')).show(); 105 }); 106 107 }); 108 109 //Function that will hide/show the header/footer when scrolling down. 110 jQuery( function($){ 111 112 // Autohide Header. 113 if ( $( 'body' ).hasClass( 'mob-menu-autohide-header' ) ) { 114 var lastScrollTop = 0, delta = 5, scrollAmount = 0; 115 $( window ).scroll( function( event ){ 116 var st = $(this).scrollTop(); 117 var htmlTop = $('html').scrollTop(); 118 119 if ( htmlTop < jQuery('.mob-menu-header-holder').height() ) { 120 $( '.mob-menu-header-holder' ).removeClass( 'hide-mm-element' ); 121 return; 122 } 123 124 if ( $(window).height() + htmlTop + 80 > $(document).height() ) { 125 $( '.mobmenu-footer-menu-holder' ).removeClass( 'hide-mm-element' ); 126 return; 127 } 128 129 if ( Math.abs(lastScrollTop - st) <= delta ) 130 return; 131 132 if ( st > lastScrollTop ) { 133 //Scroll Down. 134 $( '.mob-menu-header-holder' ).addClass( 'hide-mm-element' ); 135 scrollAmount = 0; 136 if ( $( 'body' ).hasClass( 'mob-menu-autohide-footer' ) ) { 137 $( '.mobmenu-footer-menu-holder' ).removeClass( 'hide-mm-element' ); 138 } 139 140 } else { 141 //Scroll Up. 142 if ( scrollAmount > 40 ) { 143 $( '.mob-menu-header-holder' ).removeClass( 'hide-mm-element' ); 144 } 145 scrollAmount += (lastScrollTop - st); 146 if ( $( 'body' ).hasClass( 'mob-menu-autohide-footer' ) ) { 147 $( '.mobmenu-footer-menu-holder' ).addClass( 'hide-mm-element' ); 148 } 149 } 150 151 lastScrollTop = st; 152 153 }); 154 } 155 156 // Autohide Footer.
157 if ( $( 'body' ).hasClass( 'mob-menu-autohide-footer' ) ) { 158 var lastScrollTop = 0, delta = 5, scrollAmount = 0;; 159 $( window ).scroll( function( event ){ 160 var st = $(this).scrollTop(); 161 162 if ( Math.abs(lastScrollTop - st) <= delta ) 163 return; 164 165 if ( st > lastScrollTop ) { 166 //Scroll Down. 167 $( '.mobmenu-footer-menu-holder' ).addClass( 'hide-mm-element' ); 168 scrollAmount = 0; 169 170 } else { 171 //Scroll Up. 172 if ( scrollAmount > 40 ) { 173 $( '.mobmenu-footer-menu-holder' ).removeClass( 'hide-mm-element' ); 174 } 175 scrollAmount += (lastScrollTop - st); 176 } 177 178 lastScrollTop = st; 179 180 }); 181 } 182 });
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.