1/* Custom Front-End jQuery scripts */ 2jQuery(document).ready(function($) { 3 4 "use strict"; 5 6 /* Nav Menu */ 7 $(function() { 8 9 $('.menu .sub-links').not($('.sub-menu .sub-links')).wrap('<div class="sub-menu" />');/* Fix for Custom Link only */ 10 11 $('.main-menu > ul > li > .sub-menu').each(function (index, element) { 12 if ($(element).children().hasClass('sub-posts') && $(element).children().hasClass('sub-links')) { 13 $(element).parent().addClass('sub-menu-two-columns menu-item-has-mega-menu'); 14 } else if ($(element).children().hasClass('sub-posts') && (!$(element).children().hasClass('sub-links'))) { 15 $(element).parent().addClass('sub-menu-full-width menu-item-has-mega-menu'); 16 } else if ($(element).parent().hasClass('columns-menu')) { 17 $(element).parent().addClass('sub-menu-columns'); 18 } else { 19 $(element).parent().addClass('sub-links-only'); 20 } 21 22 if ($(element).children().length) { 23 $(element).parent().addClass('link-arrow'); 24 } 25 }); 26 27 $('.sub-menu-columns > .sub-menu > .sub-links').each(function (index, element) { 28 var count = $(element).children().length; 29 $(element).parents('.sub-menu-columns').addClass('sub-menu-columns-'+count); 30 }); 31 32 $('.sub-menu').each(function (index, element) { 33 if ($(element).children().length === 0) { 34 $(element).remove(); 35 } 36 }); 37 38 $( '.main-menu li:has(ul),.main-menu .sub-links li,.secondary-menu li:has(ul)' ).doubleTapToGo(); 39 40 }); 41 42 43 /* Sticky menu */ 44 $('.main-menu-fixed').hcSticky({ 45 offResolutions: [-960], 46 stickTo: document, 47 wrapperClassName: 'sticky-menu-container' 48 }); 49 50 51 /* Mobile Menu */ 52 $(function() { 53 54 $('#mobile-menu-toggle').click(function(e) { 55 e.preventDefault(); 56 $('body').toggleClass("mobile-menu-open"); 57 }); 58 59 var mobile_menu = $('#pageslide'); 60 61 $('.main-menu').children().clone().removeAttr('id').appendTo($(mobile_menu)).wrap('<nav class="block main-menu-mobile" />'); 62 $('body:not(.hide-strip) .secondary-menu').children().clone().removeAttr('id').appendTo($(mobile_menu)).wrap('<nav class="block secondary-menu-mobile" />'); 63 64 $.each($(mobile_menu).find('.menu li').not('.sub-menu-full-width'), function() { 65 var children = $(this).find('> .sub-menu').children(); 66 $(this).find('> .sub-menu').before('<span class="sub-menu-arrow"></span>'); 67 }); 68 69 $(mobile_menu).find('.menu li .sub-menu').prepend('<span class="sub-menu-back"><i class="icomoon-arrow-left"></i></span>'); 70 71 var $sub_parent = $(mobile_menu).find('.sub-menu-arrow'); 72 var $sub_menu = $(mobile_menu).find('.sub-menu'); 73 74 $sub_parent.click(function(){ 75 var $that = $(this); 76 var $parent_menu = $that.parents('.menu'); 77 var $menu_index = $parent_menu.index(); 78 var $current_item = $that.next('.sub-menu'); 79 $parent_menu.addClass('sub-level-open'); 80 $current_item.addClass('sub-menu-open'); 81 }); 82 83 var $sub_back = $('.sub-menu-back'); 84 85 $sub_back.click(function(){ 86 var $that = $(this); 87 var $menuIndex = $that.parent().index(); 88 var $currentItem = $that.parent('.sub-menu'); 89 var $parent_menu = $that.parents('.menu'); 90 $currentItem.removeClass('sub-menu-open'); 91 $parent_menu.removeClass('sub-level-open'); 92 }); 93 94 }); 95 96 /* Mobile Search Form */ 97 $('.top-strip .mobile-search-button').click(function(){ 98 $('.top-strip').toggleClass("search-form-open"); 99 $('.top-strip .search-form input').focus(); 100 }); 101 102 103 /* Sliders */ 104 $(function() { 105 106 var $slider_arrows = { 107 prevArrow:'<a heref="#" class="slider-nav-arrow prev-arrow"></a>', 108 nextArrow:'<a heref="#" class="slider-nav-arrow next-arrow"></a>' 109 }; 110 111 $(function() { 112 // Posts slider 113 $('.posts-slider').slick( 114 $.extend({ 115 dots:true, 116 autoplay:true, 117 autoplaySpeed:5000, 118 adaptiveHeight:true 119 }, $slider_arrows) 120 ); 121 122 $('.posts-slider .slick-dots').each(function(){ 123 var slider_image_count = $(this).children().length; 124 $(this).append( '<li class="slider-image-count">' + slider_image_count + '</li>'); 125 }); 126 127 }); 128 129 // Widgets slider 130 $('.widget-slider').slick( 131 $.extend({ 132 autoplay:true, 133 autoplaySpeed:5000, 134 adaptiveHeight:true 135 }, $slider_arrows) 136 ); 137 138 // Featured Posts carousel 139 $('.featured-carousel').slick( 140 $.extend({ 141 rows:2, 142 vertical:true, 143 slidesToShow:2, 144 slidesToScroll:2, 145 infinite:false, 146 verticalSwiping:true, 147 appendArrows:$('.featured-posts .carousel-navigation'), 148 responsive:[ 149 { 150 breakpoint:750, 151 settings: { 152 vertical:false, 153 slidesToShow:1, 154 slidesToScroll:1, 155 infinite:true, 156 adaptiveHeight:true, 157 verticalSwiping:false 158 } 159 } 160 ] 161 }, $slider_arrows) 162 ); 163 164 165 $(function() { 166 167 var $FullWidthCarousel = $('.full-width-media .gallery-carousel'), 168 $AboveContentCarousel = $('.above-content-media .gallery-carousel'); 169 170 var $GalleryCaption = $('.gallery-caption'); 171 172 // Page Composer and Post Format carousel 173 $FullWidthCarousel.slick( 174 $.extend({ 175 dots:true, 176 centerMode:true, 177 variableWidth:true, 178 responsive: [{ 179 breakpoint:750, 180 settings: { 181 centerMode:false, 182 variableWidth:false, 183 adaptiveHeight:true, 184 } 185 }] 186 }, $slider_arrows) 187 ); 188 189 // Gallery Above the Content 190 $AboveContentCarousel.slick({ 191 arrows:false, 192 adaptiveHeight:true, 193 asNavFor:$GalleryCaption 194 }); 195 196 // Gallery Caption 197 $GalleryCaption.slick( 198 $.extend({ 199 dots:true, 200 fade:true, 201 adaptiveHeight:true, 202 asNavFor:$AboveContentCarousel 203 }, $slider_arrows) 204 ); 205 206 $([$FullWidthCarousel, $GalleryCaption]).each( function(){ 207 var $slider_image_count = $(this).find('.slick-dots li').length; 208 $(this).find('.slick-dots').append( '<li class="slider-image-count">' + $slider_image_count + '</li>'); 209 }); 210 211 }); 212 213 // Related posts 214 $('.related-posts').find('.carousel').slick( 215 $.extend({ 216 slidesToShow:3, 217 adaptiveHeight:true, 218 responsive: [{ 219 breakpoint:750, 220 settings: { 221 slidesToShow:1, 222 } 223 }] 224 }, $slider_arrows) 225 ); 226 227 // Authors widget 228 $(function(){ 229 230 var $carousel = $('.widget_ti_site_authors .carousel'); 231 var n = $carousel.find('.item').length; 232 if (n > 10) { 233 234 $carousel.slick( 235 $.extend({ 236 rows:2, 237 slidesToShow:5, 238 variableWidth:true, 239 }, $slider_arrows) 240 ); 241 242 $carousel.addClass('with-arrows'); 243 244 } 245 246 }); 247 248 // Latest Reviews Slider 249 $(function() { 250 251 var $carousel = $('.latest-reviews-carousel'); 252 253 $carousel.on('init', function(slick){ 254 $(this).addClass('carousel-initialized'); 255 }); 256 257 $carousel.slick({ 258 dots:true, 259 arrows:false, 260 infinite:false, 261 slidesToShow:4, 262 slidesToScroll:4, 263 adaptiveHeight:true, 264 responsive:[{ 265 breakpoint:960, 266 settings: { 267 slidesToShow:2, 268 slidesToScroll:2 269 } 270 },{ 271 breakpoint:750, 272 settings: { 273 slidesToShow:1, 274 slidesToScroll:1 275 } 276 }] 277 }); 278 279 }); 280 281 // Latest By Format Slider 282 $(function LatestFormatSlider() { 283 284 var Container = $('.media-posts'); 285 286 $(Container).each(function() { 287 288 var Slides = $(this).find('.media-post-slides'), 289 Thumbs = $(this).find('.media-post-thumbs'), 290 Details = $(this).find('.media-post-details'), 291 BgImage = $(this).find('.media-post-bg'); 292 293 Slides.on('init', function(slick){ 294 $(this).parents().eq(1).addClass('section-init'); 295 }); 296 297 Slides.on('beforeChange', function(event, slick, nextSlide) { 298 $(this).find('.media-content').empty(); 299 $(this).find('.entry-image').removeClass('content-loading content-added'); 300 }); 301 302 Slides.slick( 303 $.extend({ 304 slidesToShow:1, 305 fade:true, 306 asNavFor:Thumbs.add(Details).add(BgImage), 307 responsive: [{ 308 breakpoint:750, 309 settings: { 310 fade:false, 311 adaptiveHeight:true 312 } 313 }] 314 }, $slider_arrows) 315 ); 316 317 Details.slick({ 318 slidesToShow:1, 319 fade:true, 320 arrows:false, 321 asNavFor:Slides.add(Thumbs) 322 }); 323 324 Thumbs.slick({ 325 slidesToShow:3, 326 slidesToScroll:1, 327 centerMode:true, 328 centerPadding:0, 329 focusOnSelect:true, 330 dots:true, 331 arrows:false, 332 asNavFor:Slides.add(Details).add(BgImage) 333 }); 334 335 BgImage.slick({ 336 slidesToShow:1, 337 fade:true, 338 arrows:false, 339 asNavFor:Slides.add(Thumbs) 340 }); 341 342 }); 343 344 }); 345 346 // Single Rating. Add slider if more than six items were added 347 $('.rating-labels').slick( 348 $.extend({ 349 slidesToShow:7, 350 responsive:[{ 351 breakpoint:960, 352 settings: { 353 slidesToShow:4 354 } 355 }] 356 }, $slider_arrows) 357 ); 358 359 }); // end of sliders 360 361 362 /* Masonry Layout */ 363 $(function() { 364 var $m_container = $('.ltr .masonry-layout'); 365 $m_container.imagesLoaded( function() { 366 $m_container.masonry({ 367 itemSelector:'.post-item' 368 }); 369 }); 370 });
371 372 $(function() { // Right-To-Left direction 373 var $m_container = $('.rtl .masonry-layout'); 374 $m_container.imagesLoaded( function() { 375 $m_container.masonry({ 376 itemSelector:'.post-item', 377 isOriginLeft:false 378 }); 379 }); 380 }); 381 382 383 /* Tabs */ 384 var tabContainers = $('.tab-box .tab-box-content > div'); 385 tabContainers.addClass('tab-hidden').filter(':first').addClass('tab-visible'); 386 387 $('.tab-box .tab-box-button a').click(function(e) { 388 e.preventDefault(); 389 tabContainers.addClass('tab-hidden').removeClass('tab-visible'); 390 tabContainers.filter(this.hash).addClass('tab-visible').removeClass('tab-hidden'); 391 $('.tab-box .tab-box-button a').removeClass('active'); 392 $(this).addClass('active'); 393 }).filter(':first').click(); 394 395 396 /* WordPress Editor Gallery */ 397 if ( $().imgLiquid ){ 398 $('.custom-gallery').find('.gallery-item').imgLiquid({ 399 fill:true 400 }); 401 } 402 403 404 /* Sticky sidebar */ 405 $('.sidebar-fixed').hcSticky({ 406 top:70, 407 bottomEnd:0, 408 offResolutions:[-1024], 409 wrapperClassName:'sticky-bar-container' 410 }); 411 412 413 /* Force equal height in Grid layout */ 414 $('.grid-layout:not(".details-hover")').each(function() { 415 $(this).find('.entry-header').responsiveEqualHeightGrid(); 416 }); 417 418 419 /* Show an animation when images are loaded */ 420 $('.entry-image').on('inview', function(event, isInView) { 421 if (isInView) { 422 $(this).addClass('inview'); 423 } 424 }); 425 426 427 /* Show bottom single post slide dock */ 428 if ($('.slide-dock').length) { 429 430 var $random_post = $('.slide-dock'); 431 $('#footer').on('inview', function(event, isInView) { 432 if (isInView) { 433 $random_post.addClass('slide-dock-on'); 434 } else { 435 $random_post.removeClass('slide-dock-on'); 436 } 437 }); 438 439 $('.close-dock').click(function(e){ 440 e.preventDefault(); 441 $('.slide-dock').toggleClass('slide-dock-on slide-dock-off'); 442 }); 443 444 } 445 446 /* Sitemap toggle */ 447 $('.sitemap .row .trigger').click(function(e){ 448 e.preventDefault(); 449 $(this).toggleClass('active').next().slideToggle('fast'); 450 }); 451 452 453 /* LightBox */ 454 if ( $().swipebox ){ 455 $('.custom-gallery .gallery-item a').swipebox({ 456 hideBarsDelay:0 457 }); 458 459 $('.entry-content a[href$="jpg"],.entry-content a[href$="jpeg"],.entry-content a[href$="png"],.entry-content a[href$="gif"]').swipebox({ 460 hideBarsDelay:0 461 }); 462 } 463 464 465 /* Fluid Width Video */ 466 if ( $().fitVids ){ 467 $('.video-wrapper, .entry-content, .page-content, .advertising').fitVids({ignore:'[src*="youtube.com/subscribe_widget"]'}); 468 } 469 470 471 /* Social icons */ 472 $('.share-more').click(function(){ 473 $(this).toggleClass('share-more-opened'); 474 }); 475 476 477 /* Scroll to comments form */ 478 $('[href^="#comments"]').click(function(e){ 479 e.preventDefault(); 480 $('html, body').animate({scrollTop: $("#comments").offset().top}, 700); 481 }); 482 483 /* Back to Top link */ 484 $('.back-top').click(function(e){ 485 e.preventDefault(); 486 $('html, body').animate({scrollTop:0}, 'fast'); 487 }); 488 489});// - document ready
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.