1jQuery(document).ready(function($) { 2 3 "use strict"; 4 5 var KEYCODE_TAB = 9; 6 7 /** 8 * Close popups on escape key. 9 */ 10 $( document ).on( 'keydown', function( event ) { 11 if ( event.keyCode === 27 ) { 12 event.preventDefault(); 13 $( '.mt-form-wrap.search-activate' ).removeClass( 'search-activate' ); 14 $( '.sidebar-header.activate' ).removeClass( 'activate' ); 15 } 16 }) 17 18 /** 19 * Header sticky sidebar show/hide. 20 */ 21 $(function() { 22 $(".mt-sidebar-menu-toggle").on("click", function(e) { 23 $(".sidebar-header").toggleClass("activate"); 24 var element = document.querySelector( '.sidebar-header-sticky-form-wrapper' ); 25 var focusable = element.querySelectorAll( 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'); 26 var firstFocusable = focusable[0]; 27 var lastFocusable = focusable[focusable.length - 1]; 28 wp_diary_focus_trap( firstFocusable, lastFocusable ); 29 }); 30 $('.sidebar-header').on("click", function(e) { 31 if ( $(e.target).parents().hasClass('sticky-header-sidebar') ) { 32 $(".sidebar-header").addClass("activate"); 33 } else { 34 $(".sidebar-header").removeClass("activate"); 35 var focusClass = $(".sidebar-header.mt-form-close").data( 'focus' ); 36 $( '.' + focusClass ).find( 'a' ).focus(); 37 } 38 }); 39 }); 40 41 /** 42 * Header Search script 43 */ 44 $('.mt-menu-search .mt-search-icon').click(function() { 45 $('.mt-menu-search .mt-form-wrap').toggleClass('search-activate'); 46 var element = document.querySelector( '.mt-form-wrap.search-activate' ); 47 var focusable = element.querySelectorAll( 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'); 48 var firstFocusable = focusable[0]; 49 var lastFocusable = focusable[focusable.length - 1]; 50 wp_diary_focus_trap( firstFocusable, lastFocusable ); 51 }); 52 53 $('.mt-menu-search .mt-form-close').click(function() { 54 $('.mt-menu-search .mt-form-wrap').removeClass('search-activate'); 55 var focusClass = $( this ).data( "focus" ); 56 $( '.' + focusClass ).find( 'a' ).focus(); 57 }); 58 59 $('.mt-slider').slick({ 60 dots: false, 61 autoplay: true, 62 autoplaySpeed: 5000, 63 infinite: true, 64 speed: 2000, 65 slidesToShow: 1, 66 centerMode: true, 67 nextArrow: ' <span class="slick-next">Next <i class="fa fa-arrow-right"></i> </span>', 68 prevArrow: ' <span class="slick-prev"><i class="fa fa-arrow-left"></i> Previous</span>', 69 centerPadding: '360px', 70 slidesToScroll: 1, 71 responsive: [ 72 { 73 breakpoint: 1400, 74 settings: { 75 slidesToShow: 1, 76 infinite: true, 77 centerPadding: '200px' 78 } 79 }, 80 { 81 breakpoint: 1200, 82 settings: { 83 slidesToShow: 1, 84 infinite: true, 85 centerPadding: '0px' 86 } 87 } 88 // You can unslick at a given breakpoint now by adding: 89 // settings: "unslick" 90 // instead of a settings object 91 ] 92 }); 93 94 $('.mt-gallery-slider').slick({ 95 autoplay: false, 96 infinite: true, 97 nextArrow: ' <span class="slick-next"> <i class="fa fa-arrow-right"></i> </span>', 98 prevArrow: ' <span class="slick-prev"><i class="fa fa-arrow-left"></i></span>', 99 speed: 500, 100 fade: true, 101 cssEase: 'linear' 102 }); 103 104 var grid = document.querySelector( 105 '.wp-diary-content-masonry' 106 ), 107 masonry; 108 109 if ( 110 grid && 111 typeof Masonry !== undefined && 112 typeof imagesLoaded !== undefined 113 ) { 114 imagesLoaded( grid, function( instance ) { 115 masonry = new Masonry( grid, { 116 itemSelector: '.hentry' 117 } ); 118 } ); 119 } 120 121 /** 122 * Settings about WOW animation 123 */ 124 var wowOption = wpdiaryObject.wow_effect; 125 if( wowOption === 'on' ) { 126 new WOW().init(); 127 } 128 129 /** 130 * Settings about sticky menu 131 */ 132 var stickyOption = wpdiaryObject.menu_sticky; 133 if( stickyOption === 'on' ) { 134 var wpAdminBar = $('#wpadminbar'); 135 if ( wpAdminBar.length ) { 136 $(".main-menu-wrapper").sticky({topSpacing:wpAdminBar.height()}); 137 } else { 138 $(".main-menu-wrapper").sticky({topSpacing:0}); 139 } 140 } 141 142 /** 143 * Scroll To Top 144 */ 145 $(window).scroll(function() { 146 if ($(this).scrollTop() > 1000) { 147 $('#mt-scrollup').fadeIn('slow'); 148 } else { 149 $('#mt-scrollup').fadeOut('slow'); 150 } 151 });
152 $('#mt-scrollup').click(function() { 153 $("html, body").animate({ 154 scrollTop: 0 155 }, 600); 156 return false; 157 }); 158 159 /** 160 * Responsive 161 */ 162 $('.menu-toggle').click(function(event) { 163 $('#site-navigation').slideToggle('slow'); 164 var element = document.querySelector( '.main-navigation' ); 165 var focusable = element.querySelectorAll( 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'); 166 var firstFocusable = focusable[0]; 167 var lastFocusable = focusable[focusable.length - 1]; 168 wp_diary_focus_trap( firstFocusable, lastFocusable ); 169 }); 170 171 $('#site-navigation .mt-form-close').click(function(event) { 172 $('#site-navigation').slideToggle('slow'); 173 var focusClass = $( this ).data( "focus" ); 174 $( '.' + focusClass ).find( 'a' ).focus(); 175 }); 176 177 /** 178 * responsive sub menu toggle 179 */ 180 $('<a class="sub-toggle" href="javascript:void(0);"><i class="fa fa-angle-right"></i></a>').insertAfter('#site-navigation .menu-item-has-children>a, #site-navigation .page_item_has_children>a'); 181 182 $('#site-navigation .sub-toggle').click(function() { 183 $(this).parent('.menu-item-has-children').children('ul.sub-menu').first().slideToggle('1000'); 184 jQuery(this).parent('.page_item_has_children').children('ul.children').first().slideToggle('1000'); 185 $(this).children('.fa-angle-right').first().toggleClass('fa-angle-down'); 186 }); 187 188 /** 189 * pretty photo in gallery item 190 */ 191 var pretty_photo = wpdiaryObject.pretty_photo; 192 if( pretty_photo === 'on' ){ 193 $('.gallery-item a').each(function() { 194 var galId = $(this).parents().eq(2).attr('id'); 195 $(this).attr('rel', 'prettyPhoto['+galId+']'); 196 }); 197 198 /** 199 * Gutenberg compatible pretty photo in gallery item 200 */ 201 $('.blocks-gallery-item a').each(function() { 202 $(this).attr('rel', 'prettyPhoto[]'); 203 }); 204 205 /* 206 * pretty photo 207 */ 208 $("a[rel^='prettyPhoto']").prettyPhoto({ 209 show_title: false, 210 deeplinking: false, 211 social_tools: '' 212 }); 213 } 214 215 /** 216 * Focus trap in popup. 217 */ 218 function wp_diary_focus_trap( firstFocusable, lastFocusable ) { 219 $(document).on('keydown', function(e) { 220 if (e.key === 'Tab' || e.keyCode === KEYCODE_TAB) { 221 if ( e.shiftKey ) /* shift + tab */ { 222 if (document.activeElement === firstFocusable) { 223 lastFocusable.focus(); 224 e.preventDefault(); 225 } 226 } else /* tab */ { 227 if (document.activeElement === lastFocusable) { 228 firstFocusable.focus(); 229 e.preventDefault(); 230 } 231 } 232 } 233 }); 234 } 235});
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.