1/* global screenReaderText */ 2/** 3 * Theme functions file. 4 * 5 * Contains handlers for navigation and widget area. 6 */ 7 8( function( $ ) { 9 var body, masthead, menuToggle, siteNavigation, socialNavigation, siteHeaderMenu, resizeTimer; 10 11 function initMainNavigation( container ) { 12 13 14 // Add dropdown toggle that displays child menu items. 15 var dropdownToggle = $( '<button />', { 16 'class': 'dropdown-toggle', 17 'aria-expanded': false 18 } ).append( $( '<span />', { 19 'class': 'screen-reader-text', 20 text: screenReaderText.expand 21 } ) ); 22 23 container.find( '.menu-item-has-children > a' ).after( dropdownToggle ); 24 25 // Toggle buttons and submenu items with active children menu items. 26 container.find( '.current-menu-ancestor > button' ).addClass( 'toggled-on' ); 27 container.find( '.current-menu-ancestor > .sub-menu' ).addClass( 'toggled-on' ); 28 29 // Add menu items with submenus to aria-haspopup="true". 30 container.find( '.menu-item-has-children' ).attr( 'aria-haspopup', 'true' ); 31 32 container.find( '.dropdown-toggle' ).click( function( e ) { 33 var _this = $( this ), 34 screenReaderSpan = _this.find( '.screen-reader-text' ); 35 36 e.preventDefault(); 37 _this.toggleClass( 'toggled-on' ); 38 _this.next( '.children, .sub-menu' ).toggleClass( 'toggled-on' ); 39 40 // jscs:disable 41 _this.attr( 'aria-expanded', _this.attr( 'aria-expanded' ) === 'false' ? 'true' : 'false' ); 42 // jscs:enable 43 screenReaderSpan.text( screenReaderSpan.text() === screenReaderText.expand ? screenReaderText.collapse : screenReaderText.expand ); 44 } ); 45 } 46 initMainNavigation( $( '.main-navigation' ) ); 47 48 masthead = $( '#masthead' ); 49 menuToggle = masthead.find( '#menu-toggle' ); 50 siteHeaderMenu = masthead.find( '#site-header-menu' ); 51 siteNavigation = masthead.find( '#site-navigation' ); 52 socialNavigation = masthead.find( '#social-navigation' ); 53 54 // Enable menuToggle. 55 ( function() { 56 57 // Return early if menuToggle is missing. 58 if ( ! menuToggle.length ) { 59 return; 60 } 61 62 // Add an initial values for the attribute. 63 menuToggle.add( siteNavigation ).add( socialNavigation ).attr( 'aria-expanded', 'false' ); 64 65 menuToggle.on( 'click.twentysixteen', function() { 66 $( this ).add( siteHeaderMenu ).toggleClass( 'toggled-on' ); 67 68 // jscs:disable 69 $( this ).add( siteNavigation ).add( socialNavigation ).attr( 'aria-expanded', $( this ).add( siteNavigation ).add( socialNavigation ).attr( 'aria-expanded' ) === 'false' ? 'true' : 'false' ); 70 // jscs:enable 71 } ); 72 } )(); 73 74 // Fix sub-menus for touch devices and better focus for hidden submenu items for accessibility. 75 ( function() { 76 if ( ! siteNavigation.length || ! siteNavigation.children().length ) { 77 return; 78 } 79 80 // Toggle `focus` class to allow submenu access on tablets. 81 function toggleFocusClassTouchScreen() { 82 if ( window.innerWidth >= 910 ) { 83 $( document.body ).on( 'touchstart.twentysixteen', function( e ) { 84 if ( ! $( e.target ).closest( '.main-navigation li' ).length ) { 85 $( '.main-navigation li' ).removeClass( 'focus' ); 86 } 87 } ); 88 siteNavigation.find( '.menu-item-has-children > a' ).on( 'touchstart.twentysixteen', function( e ) { 89 var el = $( this ).parent( 'li' ); 90 91 if ( ! el.hasClass( 'focus' ) ) { 92 e.preventDefault(); 93 el.toggleClass( 'focus' ); 94 el.siblings( '.focus' ).removeClass( 'focus' ); 95 } 96 } ); 97 } else { 98 siteNavigation.find( '.menu-item-has-children > a' ).unbind( 'touchstart.twentysixteen' ); 99 } 100 } 101 102 if ( 'ontouchstart' in window ) { 103 $( window ).on( 'resize.twentysixteen', toggleFocusClassTouchScreen ); 104 toggleFocusClassTouchScreen(); 105 } 106 107 siteNavigation.find( 'a' ).on( 'focus.twentysixteen blur.twentysixteen', function() { 108 $( this ).parents( '.menu-item' ).toggleClass( 'focus' ); 109 } ); 110 } )(); 111 112 // Add the default ARIA attributes for the menu toggle and the navigations. 113 function onResizeARIA() { 114 if ( window.innerWidth < 910 ) { 115 if ( menuToggle.hasClass( 'toggled-on' ) ) { 116 menuToggle.attr( 'aria-expanded', 'true' ); 117 } else { 118 menuToggle.attr( 'aria-expanded', 'false' ); 119 } 120 121 if ( siteHeaderMenu.hasClass( 'toggled-on' ) ) { 122 siteNavigation.attr( 'aria-expanded', 'true' ); 123 socialNavigation.attr( 'aria-expanded', 'true' ); 124 } else { 125 siteNavigation.attr( 'aria-expanded', 'false' ); 126 socialNavigation.attr( 'aria-expanded', 'false' ); 127 } 128 129 menuToggle.attr( 'aria-controls', 'site-navigation social-navigation' ); 130 } else { 131 menuToggle.removeAttr( 'aria-expanded' ); 132 siteNavigation.removeAttr( 'aria-expanded' ); 133 socialNavigation.removeAttr( 'aria-expanded' ); 134 menuToggle.removeAttr( 'aria-controls' ); 135 } 136 } 137 138 // Add 'below-entry-meta' class to elements. 139 function belowEntryMetaClass( param ) { 140 if ( body.hasClass( 'page' ) || body.hasClass( 'search' ) || body.hasClass( 'single-attachment' ) || body.hasClass( 'error404' ) ) { 141 return; 142 } 143 144 $( '.entry-content' ).find( param ).each( function() { 145 var element = $( this ), 146 elementPos = element.offset(), 147 elementPosTop = elementPos.top, 148 entryFooter = element.closest( 'article' ).find( '.entry-footer' ), 149 entryFooterPos = entryFooter.offset(), 150 entryFooterPosBottom = entryFooterPos.top + ( entryFooter.height() + 28 ),
151 caption = element.closest( 'figure' ), 152 newImg; 153 154 // Add 'below-entry-meta' to elements below the entry meta. 155 if ( elementPosTop > entryFooterPosBottom ) { 156 157 // Check if full-size images and captions are larger than or equal to 840px. 158 if ( 'img.size-full' === param ) { 159 160 // Create an image to find native image width of resized images (i.e. max-width: 100%). 161 newImg = new Image(); 162 newImg.src = element.attr( 'src' ); 163 164 $( newImg ).load( function() { 165 if ( newImg.width >= 840 ) { 166 element.addClass( 'below-entry-meta' ); 167 168 if ( caption.hasClass( 'wp-caption' ) ) { 169 caption.addClass( 'below-entry-meta' ); 170 caption.removeAttr( 'style' ); 171 } 172 } 173 } ); 174 } else { 175 element.addClass( 'below-entry-meta' ); 176 } 177 } else { 178 element.removeClass( 'below-entry-meta' ); 179 caption.removeClass( 'below-entry-meta' ); 180 } 181 } ); 182 } 183 184 $( document ).ready( function() { 185 body = $( document.body ); 186 187 $( window ) 188 .on( 'load.twentysixteen', onResizeARIA ) 189 .on( 'resize.twentysixteen', function() { 190 clearTimeout( resizeTimer ); 191 resizeTimer = setTimeout( function() { 192 belowEntryMetaClass( 'img.size-full' ); 193 belowEntryMetaClass( 'blockquote.alignleft, blockquote.alignright' ); 194 }, 300 ); 195 onResizeARIA(); 196 } ); 197 198 belowEntryMetaClass( 'img.size-full' ); 199 belowEntryMetaClass( 'blockquote.alignleft, blockquote.alignright' ); 200 } ); 201} )( jQuery ); 202 203$j=jQuery.noConflict(); 204 205 206 207jQuery(document).ready(function($) { 208 209 function hideOwlControl() { 210 $('.owl-stage').each(function(){ 211 if ($(this).children().length == $(this).children('.active').length) 212 $(this).parent().siblings('.owl-controls').hide(); 213 else 214 $(this).parent().siblings('.owl-controls').show(); 215 }); 216 } 217 $(window).resize(function(){ 218 hideOwlControl(); 219 }); 220 221 var owl_products = $j('.owl-carousel'); 222 223 owl_products.on('initialized.owl.carousel', function(e) { 224 hideOwlControl() 225 }); // end initialized 226 227 owl_products.owlCarousel({ 228 loop:false, 229 margin:0, 230 autoplay:false, 231 responsiveClass:true, 232 233 234 responsive:{ 235 0:{ 236 items:1, 237 nav:false, 238 dots:true, 239 }, 240 700:{ 241 items:2, 242 nav:false, 243 dots:true, 244 }, 245 1000:{ 246 items:4, 247 nav:false, 248 dots:true, 249 } 250 }, 251 }); 252 253 var owl = $j('.owl-carousel-five-col'); 254 255 owl.owlCarousel({ 256 loop: false, 257 nav: false, 258 lazyLoad: true, 259 margin: 0, 260 autoplay:true, 261 autoplayTimeout:2000, 262 autoplayHoverPause:true, 263 responsive: { 264 0: { 265 items: 1, 266 dots: true, 267 }, 268 400: { 269 items: 2, 270 dots: true, 271 }, 272 600: { 273 items: 3, 274 dots: true, 275 }, 276 1000: { 277 items: 4, 278 dots: true, 279 } 280 281 } 282 }); 283 284 285 var owl_articles = $j('.owl-carousel-articles'); 286 287 owl_articles.owlCarousel({ 288 loop: true, 289 nav: false, 290 lazyLoad: true, 291 margin: 0, 292 autoplay: true, 293 autoplayTimeout: 4000, 294 smartSpeed: 500, 295 autoHeight: true, 296 autoplayHoverPause: true, 297 responsive: { 298 0: { 299 items: 1, 300 dots: true, 301 }, 302 } 303 }); 304 305}); 306 307 308// Päivämäärä tilinavauslomakkeelle 309// tehohydro.fi/tilinavaus 310 311jQuery(document).ready(function($) { 312 313 var fullDate = new Date() 314 315 //convert month to 2 digits 316 var twoDigitMonth = ((fullDate.getMonth() + 1) < 10 ? '0' : '') + (fullDate.getMonth() + 1); 317 318 var currentDate = fullDate.getDate() + "." + twoDigitMonth + "." + fullDate.getFullYear(); 319 320 $( "#tilinavauspvm").val(currentDate); 321 322}); 323 324 325jQuery(document).ready(function($) { 326$(window).bind('scroll', function () { 327 checkScrollPos(); 328}); 329function checkScrollPos() { 330 if ($(window).scrollTop() < 200) { 331 $('.site-header-menu').removeClass('fixed'); 332 } else { 333 $('.site-header-menu').addClass('fixed'); 334 } 335} 336});
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.