1/* global screenReaderText */ 2/** 3 * Theme functions file. 4 * 5 * Contains handlers for navigation and widget area. 6 * 7 * @version 1.0.3 8 */ 9 10( function($) { 11 // Variables and DOM Caching. 12 var $body = $( 'body' ), 13 sliderFade = $body.hasClass( 'slider-fade' ), 14 ukuNeo = $body.hasClass( 'uku-neo' ), 15 ukuSerif = $body.hasClass( 'uku-serif' ), 16 headerOffset, 17 menuTop = 0, 18 resizeTimer; 19 20 // Overlay (main menu + widget area) open/close 21 $('.overlay-open').on( 'click', function () { 22 $('html').addClass('overlay-show'); 23 $('body').addClass('overlay-show'); 24 }); 25 26 $('#overlay-close').on( 'click', function () { 27 $('html').removeClass('overlay-show'); 28 $('body').removeClass('overlay-show'); 29 }); 30 31 // Hide Desktop Off Canvas Menu on Click into main website area 32 $('#overlay-wrap').on( 'click', function () { 33 $('html').removeClass('overlay-show'); 34 $('body').removeClass('overlay-show'); 35 }); 36 37 // Mobile Widget Area open/close 38 $('#offcanvas-widgets-open').on( 'click', function () { 39 $('body').toggleClass('offcanvas-widgets-show'); 40 }); 41 42 // Comments open/close 43 $('#comments-toggle').on( 'click', function () { 44 $('body').toggleClass('comments-show'); 45 }); 46 47 $('.comments-link').on( 'click', function () { 48 $('body').addClass('comments-show'); 49 }); 50 51 // Desktio Search open/close 52 $('.search-open').on( 'click', function () { 53 $('body').toggleClass('desktop-search-show'); 54 }); 55 56 $('.search-close').on( 'click', function () { 57 $('body').removeClass('desktop-search-show'); 58 }); 59 60 // Off Canvas Cart open/close 61 $('.cart-offcanvas-open').on( 'click', function () { 62 $('body').toggleClass('offcanvascart-show'); 63 }); 64 65 $('.cart-close').on( 'click', function () { 66 $('body').removeClass('offcanvascart-show'); 67 }); 68 69 // Featured Posts Slider 70 if ( $.fn.slick ) { 71 $( document ).ready( function () { 72 73 if ( sliderFade ) { 74 $( '.featured-slider' ).slick( { 75 dots : false, 76 slidesToShow : 1, 77 autoplay : false, 78 cssEase : 'ease', 79 draggable : true, 80 pauseOnHover : false, 81 infinite : true, 82 adaptiveHeight: true, 83 fade : true, 84 } ); 85 } else { 86 $( '.featured-slider' ).slick( { 87 dots : false, 88 slidesToShow : 1, 89 autoplay : false, 90 cssEase : 'ease', 91 draggable : true, 92 pauseOnHover : false, 93 infinite : true, 94 adaptiveHeight: true, 95 } ); 96 } 97 } ); 98 } 99 100 // Fade In Animations (Uku Neo, Standard) 101 $('.fadein').viewportChecker({ 102 classToAdd: 'inview', // Class to add to the elements when they are visible 103 removeClassAfterAnimation: false 104 }); 105 106 // Fade + SlideIn In Animations (Uku Serif) 107 $('.type-product').viewportChecker({ 108 classToAdd: 'inview', // Class to add to the elements when they are visible 109 removeClassAfterAnimation: false // Remove added classes after animation has finished 110 }); 111 112 $('.product-category').viewportChecker({ 113 classToAdd: 'inview', // Class to add to the elements when they are visible 114 removeClassAfterAnimation: false 115 }); 116 117 $('.type-post').viewportChecker({ 118 classToAdd: 'inview', // Class to add to the elements when they are visible 119 removeClassAfterAnimation: false 120 }); 121 122 $('.instagram-pics li').viewportChecker({ 123 classToAdd: 'inview', // Class to add to the elements when they are visible 124 removeClassAfterAnimation: false 125 }); 126 127 $('.section-about-text').viewportChecker({ 128 classToAdd: 'inview', // Class to add to the elements when they are visible 129 removeClassAfterAnimation: false 130 }); 131 132 // Front page sticky headerimage 133 $(window).scroll(function() { 134 if($(window).scrollTop() > $(window).height()*1) 135 $('.container-all').addClass('scroll'); 136 }); 137 138 $(window).scroll(function() { 139 if($(window).scrollTop() < $(window).height()*1) 140 $('.container-all').removeClass('scroll'); 141 }); 142 143 // Sticky Desktop Header Bar 144 $(function() { 145 var stickyheader = $('.sticky-header'); 146 $(window).scroll(function() { 147 var scroll = $(window).scrollTop(); 148 149 if (scroll >= 200) { 150 $('body').addClass('header-stick'); 151 stickyheader.removeClass('hidden'); 152 } else { 153 $('body').removeClass('header-stick'); 154 stickyheader.addClass('hidden'); 155 } 156 }); 157 }); 158 159 // Sticky Last Sidebar Element 160 $(document).ready(function() { 161 if ( window.innerWidth >= 1060 && ukuSerif ) { 162 $(".blog #secondary .widget:last-child").stick_in_parent({ 163 parent: "#blog-wrap", 164 offset_top: 120 165 }); 166 } else if ( window.innerWidth >= 1060 ) { 167 $(".blog #secondary .widget:last-child").stick_in_parent({ 168 parent: "#blog-wrap", 169 offset_top: 80 170 }); 171 } 172 }); 173 174 175 176 // Sticky Last Sidebar Element - Single Post 177 $(document).ready(function() { 178 if ( window.innerWidth >= 1060 && ukuSerif ) { 179 $(".single-post #secondary .widget:last-child").stick_in_parent({ 180 parent: "#singlepost-wrap", 181 offset_top: 120 182 }); 183 } else if ( window.innerWidth >= 1060 ) { 184 $(".single-post #secondary .widget:last-child").stick_in_parent({ 185 parent: "#singlepost-wrap", 186 offset_top: 80 187 }); 188 } 189 }); 190 191 192 193 194 195 196 // Sticky Share Buttons - Single Post 197 $(document).ready(function() { 198 if ( window.innerWidth >= 1440 ) { 199 $(".sd-content").stick_in_parent({ 200 parent: "#singlepost-wrap", 201 offset_top: 80 202 }); 203 } 204 }); 205 206 // Responsive Videos. 207 $('#primary').fitVids(); 208 $('#singlepost-wrap').fitVids(); 209 210 // Add dropdown toggle that display child menu items. 211 $( '.menu-item-has-children > a' ).after( '<button class="dropdown-toggle" aria-expanded="false">' + screenReaderText.expand + '</button>' ); 212 213 // Toggle buttons and submenu items with active children menu items. 214 $( '.current-menu-ancestor > button' ).addClass( 'toggle-on' ); 215 $( '.current-menu-ancestor > .sub-menu' ).addClass( 'toggled-on' ); 216 217 $( '.dropdown-toggle' ).click( function( e ) { 218 var _this = $( this ); 219 e.preventDefault(); 220 _this.toggleClass( 'toggle-on' ); 221 _this.next( '.children, .sub-menu' ).toggleClass( 'toggled-on' ); 222 _this.attr( 'aria-expanded', _this.attr( 'aria-expanded' ) === 'false' ? 'true' : 'false' ); 223 _this.html( _this.html() === screenReaderText.expand ? screenReaderText.collapse : screenReaderText.expand ); 224 } ); 225 226 secondary = $( '#secondary' ); 227 button = $( '.site-branding' ).find( '.secondary-toggle' ); 228 229 // Enable menu toggle for small screens. 230 ( function() { 231 var menu, widgets, social; 232 if ( ! secondary || ! button ) { 233 return; 234 } 235 236 // Hide button if there are no widgets and the menus are missing or empty. 237 menu = secondary.find( '.nav-menu' ); 238 widgets = secondary.find( '#widget-area' ); 239 social = secondary.find( '#social-navigation' ); 240 if ( ! widgets.length && ! social.length && ( ! menu || ! menu.children().length ) ) { 241 button.hide(); 242 return; 243 } 244 245 button.on( 'click.uku', function() { 246 secondary.toggleClass( 'toggled-on' ); 247 secondary.trigger( 'resize' ); 248 $( this ).toggleClass( 'toggled-on' ); 249 if ( $( this, secondary ).hasClass( 'toggled-on' ) ) { 250 $( this ).attr( 'aria-expanded', 'true' ); 251 secondary.attr( 'aria-expanded', 'true' ); 252 } else { 253 $( this ).attr( 'aria-expanded', 'false' ); 254 secondary.attr( 'aria-expanded', 'false' ); 255 } 256 } ); 257 } )(); 258 259 // Smooth scroll to anchor and close overlay 260 261 // Select all links with hashes 262 $('a[href*="#"]') 263 // Remove links that don't actually link to anything 264 .not('[href="#"]') 265 .not('[href="#0"]') 266 .not('.wc-tabs li a') 267 .not('#offcanvas-widgets-open') 268 .click(function(event) { 269 // On-page links 270 if (
271 location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') 272 && 273 location.hostname == this.hostname 274 ) { 275 // Figure out element to scroll to 276 var target = $(this.hash); 277 target = target.length ? target : $('[name=' + this.hash.slice(1) + ']'); 278 // Does a scroll target exist? 279 if (target.length) { 280 // Only prevent default if animation is actually gonna happen 281 event.preventDefault(); 282 $('html, body').animate({ 283 scrollTop: target.offset().top 284 }, 700, function() { 285 // Callback after animation 286 // Must change focus! 287 var $target = $(target); 288 $target.focus(); 289 if ($target.is(":focus")) { // Checking if the target was focused 290 return false; 291 } else { 292 $target.attr('tabindex','-1'); // Adding tabindex for elements not focusable 293 $target.focus(); // Set focus again 294 }; 295 // Close overlay 296 $('html').removeClass('overlay-show'); 297 $('body').removeClass('overlay-show'); 298 }); 299 } 300 } 301 }); 302 303} )( 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.