1(function( $ ) { 2 'use strict'; 3 4 /** 5 * All of the code for your public-facing JavaScript source 6 * should reside in this file. 7 * 8 * Note: It has been assumed you will write jQuery code here, so the 9 * $ function reference has been prepared for usage within the scope 10 * of this function. 11 * 12 * This enables you to define handlers, for when the DOM is ready: 13 * 14 * $(function() { 15 * 16 * }); 17 * 18 * When the window is loaded: 19 * 20 * $( window ).load(function() { 21 * 22 * }); 23 * 24 * ...and/or other possibilities. 25 * 26 * Ideally, it is not considered best practise to attach more than a 27 * single DOM-ready or window-load handler for a particular page. 28 * Although scripts in the WordPress core, Plugins and Themes may be 29 * practising this, we should strive to set a better example in our own work. 30 */ 31 32 33 $(window).on('load resize', function(){ 34 35 var selector_mob = sticky_object.sticky_mobile_menu_selector; 36 var $selector_mob = $(sticky_object.sticky_mobile_menu_selector); 37 var mob_menu_offset = $selector_mob.offset(); 38 39 var $selector_desk = $(sticky_object.sticky_desktop_menu_selector); 40 41 if( $selector_desk[0] ) { 42 var width_desk = $selector_desk[0].getBoundingClientRect().width; 43 var height_desk = $selector_desk[0].getBoundingClientRect().height; 44 var desk_menu_offset = $selector_desk.offset(); 45 46 } 47 48 if($(window).width() < 768){ // Mobile 49 50 if( ! $(sticky_object.sticky_mobile_menu_selector).length ) { 51 console.log('Catch Sticky menu: Entered Sticky Element for mobile does not exist, change it in Dashboard / Settings / Catch Sticky Menu / Mobile Menu Selector.'); 52 return; 53 } 54 55 $(window).on('scroll', function() { 56 57 $selector_mob.removeClass('catchSticky'); 58 $selector_desk.removeClass('catchSticky'); 59 60 if( $(window).scrollTop() > mob_menu_offset.top ) { 61 62 var z_index = parseInt(sticky_object.sticky_z_index); 63 var opacity = parseFloat(sticky_object.sticky_opacity); 64 65 66 if(sticky_object.enable_only_on_home == 0){ 67 $selector_mob.addClass('mob-catchSticky'); 68 $selector_desk.addClass('mob-catchSticky'); 69 $selector_mob.css('top', '0'); 70 $selector_mob.css('background-color', sticky_object.sticky_background_color); 71 $selector_mob.css('z-index', z_index); 72 $selector_mob.css('opacity', opacity); 73 $selector_mob.css('border-radius', '0'); 74 $selector_mob.css('width', '100%'); 75 $('.mob-catchSticky .site-navigation').css('top', '0'); 76 $('.mob-catchSticky').css('left', '0'); 77 $('.mob-catchSticky').css('width', '100%'); 78 $('.mob-catchSticky .site-navigation li').css('background-color', sticky_object.sticky_background_color); 79 $('.mob-catchSticky .site-navigation li a').css('color', sticky_object.sticky_text_color); 80 $('.mob-catchSticky .site-navigation li a').css('font-size', sticky_object.sticky_mobile_font_size + 'em'); 81 82 83 } 84 else{ 85 $('.home ' + selector_mob ).addClass('mob-catchSticky'); 86 $('.home ' + selector_mob ).css('top', '0'); 87 $('.home ' + selector_mob ).css('background-color', sticky_object.sticky_background_color); 88 $('.home ' + selector_mob ).css('z-index', z_index); 89 $('.home ' + selector_mob ).css('opacity', opacity); 90 $('.mob-catchSticky').css('border-radius', '0'); 91 $('.home ' + selector_mob ).css('width', '100%'); 92 $('.home .mob-catchSticky .site-navigation').css('top', '0'); 93 $('.home .mob-catchSticky .site-navigation li').css('background-color', sticky_object.sticky_background_color); 94 $('.home .mob-catchSticky .site-navigation li a').css('color', sticky_object.sticky_text_color); 95 $('.home .mob-catchSticky .site-navigation li a').css('font-size', sticky_object.sticky_mobile_font_size + 'em'); 96 97 // $(' .home .mob-catchSticky .site-navigation li a').css('font-size', sticky_object.sticky_text_font_size); 98 } 99 } 100 else { 101 $('.mob-catchSticky .site-navigation li').removeAttr('style'); 102 $('.mob-catchSticky .site-navigation li a').removeAttr('style'); 103 $('.home .mob-catchSticky .site-navigation li').removeAttr('style'); 104 $('.home .mob-catchSticky .site-navigation li a').removeAttr('style'); 105 106 $selector_mob.removeAttr('style'); 107 $selector_desk.removeAttr('style'); 108 $selector_mob.removeClass('mob-catchSticky'); 109 $selector_desk.removeClass('mob-catchSticky'); 110 } 111 }); 112 } 113 else { // Desktop 114 115 if( ! $(sticky_object.sticky_desktop_menu_selector).length ) { 116 console.log('Catch Sticky menu: Entered Sticky Element for desktop does not exist, change it in Dashboard / Settings / Catch Sticky Menu / Desktop Menu Selector.'); 117 return; 118 } 119 120 $(window).on('scroll', function() { 121 122 $selector_mob.removeClass('mob-catchSticky'); 123 $selector_desk.removeClass('mob-catchSticky'); 124 125 if( $(window).scrollTop() > desk_menu_offset.top ) { 126 127 var adminBarHeight = 0; 128 129 if ($("#wpadminbar")[0]){ // Check if admin bar is enabled. 130 adminBarHeight = $('#wpadminbar').height(); 131 } 132 133 var z_index = parseInt(sticky_object.sticky_z_index); 134 var opacity = parseFloat(sticky_object.sticky_opacity); 135 136 if(sticky_object.enable_only_on_home == 0){ 137 138 $(sticky_object.sticky_desktop_menu_selector).addClass('catchSticky'); 139 $('.catchSticky').css('top', adminBarHeight + 'px'); 140 $('.catchSticky').css('background-color', sticky_object.sticky_background_color); 141 $('.catchSticky').css('z-index', z_index); 142 $('.catchSticky').css('opacity', opacity); 143 $('.catchSticky').css('width', width_desk); 144 $('.catchSticky').css('height', height_desk); 145 $('.catchSticky a').css('color', sticky_object.sticky_text_color); 146 $('.catchSticky a').css('font-size', sticky_object.sticky_desktop_font_size + 'px'); 147 148 } 149 else{ 150 //console.log(sticky_object); 151 $('.home ' + sticky_object.sticky_desktop_menu_selector).addClass('catchSticky'); 152 $('.home .catchSticky').css('top',adminBarHeight + 'px'); 153 $('.home .catchSticky').css('background-color', sticky_object.sticky_background_color); 154 $('.home .catchSticky').css('z-index', z_index); 155 $('.home .catchSticky').css('opacity', opacity); 156 $('.home .catchSticky').css('width', width_desk); 157 $('.home .catchSticky').css('height', height_desk); 158 $('.home .catchSticky a').css('font-size', sticky_object.sticky_desktop_font_size + 'px'); 159 $('.home .catchSticky a').css('color', sticky_object.sticky_text_color ); 160 161 162 } 163 } else { 164 $('.catchSticky a').removeAttr('style'); 165 $('.home .catchSticky a').removeAttr('style'); 166 $(sticky_object.sticky_desktop_menu_selector).removeClass('catchSticky'); 167 $(sticky_object.sticky_desktop_menu_selector).removeAttr('style'); 168 $(sticky_object.sticky__desktop_menu_selector + ' li').removeAttr('style'); 169 170 } 171 }); 172 } 173 }); 174})(jQuery); 175
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.