1(function($) { 2 "use strict"; 3 4 $(document).ready(function() { 5 6 // Fitvids 7 $('.post,.featured-image').fitVids(); 8 9 10 // Comments toggle 11 $('.comments-toggle').click(function(e) { 12 $('.comment-list,.comment-respond').slideToggle(400); 13 return false; 14 }); 15 16 17 // Search togle 18 $('.search-toggle').click(function(e) { 19 $('.search-drawer').attr('aria-expanded', ($('.search-drawer').attr('aria-expanded')=='false') ? 'true':'false').slideToggle(200); 20 21 $('.search-toggle span').toggle(); 22 $('.big-search .search-input').focus(); 23 return false; 24 }); 25 26 27 // Close the search drawer 28 function closeDrawer() { 29 $('.search-drawer').attr('aria-expanded','false').slideUp(200); 30 $('.search-toggle span').hide(); 31 $('.search-toggle span:first-child').show(); 32 } 33 34 35 // When search drawer is open, allow click on body to close 36 $('html').click(function() { 37 closeDrawer(); 38 }); 39 40 41 // Escape key closes drawer 42 $(document).keyup(function(e) { 43 if (e.keyCode == 27) { 44 // Hide any drawers that are open 45 closeDrawer(); 46 closeLightbox(); 47 } 48 }); 49 50 51 // Allow clicking in the drawer when it's open 52 $('.search-drawer').click(function(event){ 53 event.stopPropagation(); 54 }); 55 56 57 // Sort list toggle 58 $('.sort-list-toggle').click(function(e) { 59 $('.sort-list').slideToggle(); 60 return false; 61 }); 62 63 64 // Close the sort list to show posts on mobile 65 $(window).on('load resize', function() { 66 var current_width = $(window).width(); 67 68 // If width is below iPad size 69 if (current_width < 801) { 70 $('.sort-list a').click(function(e) { 71 setTimeout(function() { 72 $('.sort-list').slideUp(); 73 }, 400) 74 }); 75 76 closeDrawer(); 77 } 78 }); 79 80 81 // Scroll to comment on direct link 82 if ( document.location.href.indexOf('#comment') > -1 ) { 83 // Grab the comment ID from the url 84 var commentID = window.location.hash.substr(1); 85 86 // Show the comment form 87 $('.comment-list,.comment-respond').show(); 88 } 89 90 91 // Back to top 92 $('.back-to-top a').click(function(e) { 93 e.preventDefault(); 94 95 $('html,body').animate({ 96 scrollTop: 0 97 }, 700); 98 99 return false; 100 } ); 101 102 103 // Standardize drop menu types 104 $('.main-navigation .children').addClass('sub-menu'); 105 $('.main-navigation .page_item_has_children').addClass('menu-item-has-children'); 106 107 108 /** 109 * Mobile menu functionality 110 */ 111 112 // Toggle the mobile menu 113 $('.menu-toggle').click(function() { 114 $('.drawer').toggle(); 115 $(this).find('span').toggle(); 116 }); 117 118 // Append a clickable icon to mobile drop menus 119 var item = $('<button class="toggle-sub" aria-expanded="false"><i class="fa fa-angle-down"></i></button>'); 120 121 // Append clickable icon for mobile drop menu 122 if ($('.drawer .menu-item-has-children .toggle-sub').length == 0) { 123 $('.drawer .menu-item-has-children,.drawer .page_item_has_children').append(item); 124 } 125 126 // Show sub menu when toggle is clicked 127 $('.drawer .menu-item-has-children .toggle-sub').click(function(e) { 128 $(this).each(function() { 129 e.preventDefault(); 130 131 // Change aria expanded value 132 $(this).attr('aria-expanded', ($(this).attr('aria-expanded')=='false') ? 'true':'false'); 133 134 // Open the drop menu 135 $(this).closest('.menu-item-has-children').toggleClass('drop-open'); 136 $(this).prev('.sub-menu').toggleClass('drop-active'); 137 138 // Change the toggle icon 139 $(this).find('i').toggleClass('fa-angle-down').toggleClass('fa-angle-up'); 140 }); 141 }); 142 143 144 // Fetch ajax posts for footer category menu in the footer 145 var footer_drawer = $('#footer-category-menu a'); 146 147 footer_drawer.click(function (event) { 148 149 var cat_link = $(this).attr('data-object-id'); 150 151 if (typeof cat_link !== typeof undefined && cat_link !== false) { 152 153 event.preventDefault(); 154 155 var id = $(this).attr('data-object-id'); 156 var container = $('.category-wrap .post-container'); 157 var catHeader = $('.category-wrap .featured-header-category'); 158 159 var data = { 160 action: 'lenscap_category', 161 id: id 162 }; 163 164 // Fade out the category post container while loading 165 $('.category-wrap .post-container').addClass('post-loading'); 166 167 $.ajax({ 168 data: data, 169 type: "POST", 170 dataType: "json", 171 url: lenscap_js_vars.ajaxurl, 172 success: function(response) { 173 container.html(response.html); 174 catHeader.html(response.term_html); 175 $('.post-container').removeClass('post-loading'); 176 }, 177 error: function(response) { 178 container.html(response.html); 179 } 180 }); 181 182 $(this).parent().siblings().removeClass('current-menu-item'); 183 $(this).parent().addClass('current-menu-item'); 184 } 185 }); 186 187 188 // Click the first category link to use as a placeholder 189 $('.sort-list li:first-child a').click(); 190 191 192 // Infinite scroll 193 $( document.body ).on( "post-load", function () { 194 var $container = $('.index-posts'); 195 var $newItems = $('.new-infinite-posts').not('.is--replaced'); 196 var $elements = $newItems.find('.post'); 197 198 // Remove the empty elements that break the grid
199 $('.new-infinite-posts,.infinite-loader').remove(); 200 201 // Append IS posts 202 $container.append($elements); 203 }); 204 205 206 // Waypoint sticky 207 function stickyBanner() { 208 var $stickySidebar = $('.single .sticky-widget'); 209 var stickyAside; 210 var sidebarWidth = $('.single .post .entry-meta').width(); 211 212 if ($stickySidebar.length) { 213 stickyAside = new Waypoint.Sticky({ 214 element: $stickySidebar[0], 215 handler: function(direction) { 216 $('.stuck').css({ 217 'width': sidebarWidth + 'px', 218 }); 219 }, 220 }) 221 } 222 } 223 224 // Only run it on desktop 225 $(window).on('load', function() { 226 var current_width = $(window).width(); 227 228 if ( current_width > 768 ) { 229 var post_height = $('.single .entry-content').outerHeight(); 230 var $sticky_height = $('.meta-list'); 231 var totalHeight = 0; 232 233 // Calculate the size of the sidebar 234 $.each($sticky_height, function() { 235 totalHeight += $(this).height(); 236 }); 237 238 // If the sidebar is bigger than the post, add a min-height to the container so it all fits 239 if (post_height < totalHeight) { 240 $('.single .post .entry-meta').addClass('remove-stick'); 241 242 $('.single .post .entry-content').css({ 243 'min-height': totalHeight + 'px' 244 }); 245 } 246 247 // Only trigger the sticky if the page has been scrolled 248 var hasBeenTrigged = false; 249 $(window).scroll(function() { 250 if ($(this).scrollTop() >= 1 && !hasBeenTrigged) { 251 stickyBanner(); 252 hasBeenTrigged = true; 253 } 254 }); 255 } 256 }); 257 258 // Calculate the width of the sidebar on page load/resize 259 $(window).on("resize load", function() { 260 var current_width = $(window).width(); 261 262 // Only run it on desktop 263 if ( current_width > 768) { 264 var sidebarWidth = $('.single .entry-meta').width(); 265 266 $('.sticky-widget').css({ 267 'width': sidebarWidth + 'px' 268 }); 269 } 270 }); 271 272
273 // Unhook the sticky sidebar when it hits the bottom 274 var $isSticky = $('.single .entry-meta'); 275 if ($isSticky.length) { 276 $(window).scroll(function() { 277 var length = $('.single .entry-meta').height() - $('.single .sticky-wrapper').height() + $('.single .entry-meta').offset().top; 278 var scroll = $(this).scrollTop(); 279 280 if (scroll > length) { 281 // When we hit the bottom of the page, remove the fixed positioning 282 $('.stuck').addClass('bottom-stick'); 283 } else { 284 $('.stuck').removeClass('bottom-stick'); 285 } 286 }); 287 } 288 289 290 // Initialize responsive slides 291 var $slides = $('.featured-content-posts'); 292 $slides.responsiveSlides({ 293 auto: false, 294 speed: 200, 295 nav: true, 296 manualControls: '#hero-pager', 297 }); 298 299 300 $('.slide-navs .prev').click(function(e) { 301 $(this).closest('.featured-content-wrapper').find('.rslides_nav.prev').click(); 302 return false; 303 }); 304 305 $('.slide-navs .next').click(function(e) { 306 $(this).closest('.featured-content-wrapper').find('.rslides_nav.next').click(); 307 return false; 308 }); 309 310 311 // Add touch support to responsive slides 312 $('.featured-content-posts .rslides').each(function() { 313 $(this).swipe({ 314 swipeLeft: function() { 315 $(this).parent().find('.rslides_nav.prev').click(); 316 }, 317 swipeRight: function() { 318 $(this).parent().find('.rslides_nav.next').click(); 319 } 320 }); 321 }); 322 323 324 // Video/gallery lightbox toggle 325 $(document).on('click', '.excerpt-view .index-posts .preview-toggle', function(e) { 326 $(this).each(function() { 327 e.preventDefault(); 328 329 // Build the lightbox from the current post 330 var lightbox = $(this).closest('.format-video,.format-gallery').clone().addClass('video-lightbox').appendTo('.index-posts'); 331 332 // Remove the transform effects from the post 333 setTimeout(function() { 334 $('.video-lightbox').addClass('remove-transform'); 335 }, 4000); 336 337 $('.video-lightbox .index-image').click(false); 338 }); 339 }); 340 341 342 // Close the video lightbox 343 function closeLightbox() { 344 // Fade out the lightbox 345 $('.video-lightbox').addClass('fade-out'); 346 347 // Remove it from the DOM 348 setTimeout(function() { 349 $('.video-lightbox').remove(); 350 }, 500); 351 352 $('.video-lightbox').removeClass('remove-transform'); 353 } 354 355 356 // Close the video lightbox 357 $( document ).on( 'click', '.close-lightbox', function() { 358 closeLightbox(); 359 }); 360 361 $('.page-template-template-shop-homepage .testimonial-entry-title, .page-template-template-shop-homepage .testimonial-featured-image').click(false); 362 363 }); 364 365})(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.