1/* global twentyseventeenScreenReaderText */ 2(function( $ ) { 3 4 // Variables and DOM Caching. 5 var $body = $( 'body' ), 6 $customHeader = $body.find( '.custom-header' ), 7 $branding = $customHeader.find( '.site-branding' ), 8 $navigation = $body.find( '.navigation-top' ), 9 $navWrap = $navigation.find( '.wrap' ), 10 $navMenuItem = $navigation.find( '.menu-item' ), 11 $menuToggle = $navigation.find( '.menu-toggle' ), 12 $menuScrollDown = $body.find( '.menu-scroll-down' ), 13 $sidebar = $body.find( '#secondary' ), 14 $entryContent = $body.find( '.entry-content' ), 15 $formatQuote = $body.find( '.format-quote blockquote' ), 16 $easingslider = $body.find( '.easingslider-container' ), 17 isFrontPage = $body.hasClass( 'twentyseventeen-front-page' ) || $body.hasClass( 'home blog' ), 18 navigationFixedClass = 'site-navigation-fixed', 19 navigationHeight, 20 navigationOuterHeight, 21 navPadding, 22 navMenuItemHeight, 23 idealNavHeight, 24 navIsNotTooTall, 25 headerOffset, 26 menuTop = 0, 27 /*Ajout SMI*/ 28 $navMenuScrollDown = $body.find( '.nav-menu-scroll-down' ), 29 /*fin SMI*/ 30 resizeTimer; 31 32 // Ensure the sticky navigation doesn't cover current focused links. 33 $( 'a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, [tabindex], [contenteditable]', '.site-content-contain' ).filter( ':visible' ).focus( function() { 34 if ( $navigation.hasClass( 'site-navigation-fixed' ) ) { 35 var windowScrollTop = $( window ).scrollTop(), 36 fixedNavHeight = $navigation.height(), 37 itemScrollTop = $( this ).offset().top, 38 offsetDiff = itemScrollTop - windowScrollTop; 39 40 // Account for Admin bar. 41 if ( $( '#wpadminbar' ).length ) { 42 offsetDiff -= $( '#wpadminbar' ).height(); 43 } 44 45 if ( offsetDiff < fixedNavHeight ) { 46 $( window ).scrollTo( itemScrollTop - ( fixedNavHeight + 50 ), 0 ); 47 } 48 } 49 }); 50 51 // Set properties of navigation. 52 function setNavProps() { 53 navigationHeight = $navigation.height(); 54 navigationOuterHeight = $navigation.outerHeight(); 55 navPadding = parseFloat( $navWrap.css( 'padding-top' ) ) * 4; 56 navMenuItemHeight = $navMenuItem.outerHeight() * 4; 57 idealNavHeight = navPadding + navMenuItemHeight; 58 navIsNotTooTall = navigationHeight <= idealNavHeight; 59 } 60 61 // Make navigation 'stick'. 62 function adjustScrollClass() { 63 64 // Make sure we're not on a mobile screen. 65 if ( 'none' === $menuToggle.css( 'display' ) ) { 66 67 // Make sure the nav isn't taller than two rows. 68 if ( navIsNotTooTall ) { 69 70 // When there's a custom header image or video, the header offset includes the height of the navigation. 71 if ( isFrontPage && ( $body.hasClass( 'has-header-image' ) || $body.hasClass( 'has-header-video' ) ) ) { 72 headerOffset = $customHeader.innerHeight() - navigationOuterHeight; 73 } else { 74 headerOffset = $customHeader.innerHeight(); 75 } 76 77 // If the scroll is more than the custom header, set the fixed class. 78 if ( $( window ).scrollTop() >= headerOffset ) { 79 $navigation.addClass( navigationFixedClass ); 80 } else { 81 $navigation.removeClass( navigationFixedClass ); 82 } 83 84 } else { 85 86 // Remove 'fixed' class if nav is taller than two rows. 87 $navigation.removeClass( navigationFixedClass ); 88 } 89 } 90 } 91 92 // Set margins of branding in header. 93 function adjustHeaderHeight() { 94 95 // With Easing Slider header 96 if( $branding.hasClass( 'smi_2017child_headerslider_branding_superposition' ) ) { 97 // Menu on top 98 if ( $navigation.hasClass( 'navigation-top-top' ) ) { 99 // Branding on top 100 if( $branding.hasClass( 'smi_2017child_branding_logo_vertical_top' ) ) { 101 var brandingH = $branding.height(); 102 var easingsliderH = $easingslider.height(); 103 $branding.css( 'margin-top', - easingsliderH ); 104 $branding.css( 'padding-bottom', 'calc( ' + (easingsliderH - brandingH) + 'px - 3rem )' ); 105 if( $body.hasClass( 'twentyseventeen-child-full-header' ) ) { 106 } else { 107 $customHeader.css( 'padding-top', navigationOuterHeight ); 108 } 109 // Branding NOT on top 110 } else { 111 $branding.css( 'margin-top', - $branding.outerHeight() ); 112 $customHeader.css( 'padding-top', navigationOuterHeight ); 113 } 114 // Menu NOT on top 115 } else { 116 // Branding on top 117 if( $branding.hasClass( 'smi_2017child_branding_logo_vertical_top' ) ) { 118 var brandingOH = $branding.outerHeight(); 119 var brandingH = $branding.height(); 120 var headerOH = $customHeader.outerHeight(); 121 $branding.css( 'margin-top', - headerOH +brandingH ); 122 $branding.css( 'margin-bottom', 'unset' ); 123 $branding.css( 'padding-bottom', 'calc( ' + ( headerOH - brandingH ) + 'px - 4rem )' ); 124 // Branding NOT on top 125 } else { 126 $branding.css( 'margin-top', 'calc( ' + ( - $branding.height() ) + 'px - 3rem' ); 127 if( $navigation.css( "position" ) === "relative" ) { // On small screens the menu position is fixed instead of absolute 128 $branding.css( 'padding-bottom', 0 ); // small screens 129 } else { 130 $branding.css( 'padding-bottom', navigationOuterHeight );
130 // no good on small screens 131 } 132 } 133 } 134 // With standard header 135 } else 136 if ( 'none' === $menuToggle.css( 'display' ) ) { 137 138 // class navigation-top-top is added to navigation-top in header.php when the navbar is on top of the header image rather than under 139 if ( isFrontPage ) { 140 if ( $navigation.hasClass( 'navigation-top-top' ) ) { 141 if( $branding.hasClass( 'smi_2017child_branding_logo_vertical_top' ) ) { 142 $branding.css( 'margin-top', navigationOuterHeight ); 143 } else { 144 $branding.css( 'margin-bottom', 'unset' ); 145 } 146 } else { 147 $branding.css( 'margin-bottom', navigationOuterHeight ); 148 } 149 } else { 150 if ( $navigation.hasClass( 'navigation-top-top' ) ) { 151 if( $body.hasClass( 'twentyseventeen-child-full-header' ) ) { 152 $branding.css( 'margin-top', navigationOuterHeight ); 153 $branding.css( 'padding-top', 0 ); 154 } else { 155 $customHeader.css( 'margin-top', navigationOuterHeight ); 156 } 157 } else { 158 $branding.css( 'margin-bottom', navigationOuterHeight ); 159 $branding.css( 'padding-top', 0 ); 160 //$customHeader.css( 'margin-bottom', navigationOuterHeight ); 161 } 162 } 163 164 } else { 165 $customHeader.css( 'margin-bottom', '0' ); 166 $branding.css( 'margin-bottom', '0' ); 167 } 168 } 169 170 // Set icon for quotes. 171 function setQuotesIcon() { 172 $( twentyseventeenScreenReaderText.quote ).prependTo( $formatQuote ); 173 } 174 175 // Add 'below-entry-meta' class to elements. 176 function belowEntryMetaClass( param ) { 177 var sidebarPos, sidebarPosBottom; 178 179 if ( ! $body.hasClass( 'has-sidebar' ) || ( 180 $body.hasClass( 'search' ) || 181 $body.hasClass( 'single-attachment' ) || 182 $body.hasClass( 'error404' ) || 183 $body.hasClass( 'twentyseventeen-front-page' ) 184 ) ) { 185 return; 186 } 187 188 sidebarPos = $sidebar.offset(); 189 sidebarPosBottom = sidebarPos.top + ( $sidebar.height() + 28 ); 190 191 $entryContent.find( param ).each( function() { 192 var $element = $( this ), 193 elementPos = $element.offset(), 194 elementPosTop = elementPos.top; 195 196 // Add 'below-entry-meta' to elements below the entry meta. 197 if ( elementPosTop > sidebarPosBottom ) { 198 $element.addClass( 'below-entry-meta' ); 199 } else { 200 $element.removeClass( 'below-entry-meta' ); 201 } 202 }); 203 } 204 205 /* 206 * Test if inline SVGs are supported. 207 * @link https://github.com/Modernizr/Modernizr/ 208 */ 209 function supportsInlineSVG() { 210 var div = document.createElement( 'div' ); 211 div.innerHTML = '<svg/>'; 212 return 'http://www.w3.org/2000/svg' === ( 'undefined' !== typeof SVGRect && div.firstChild && div.firstChild.namespaceURI ); 213 } 214 215 /** 216 * Test if an iOS device. 217 */ 218 function checkiOS() { 219 return /iPad|iPhone|iPod/.test(navigator.userAgent) && ! window.MSStream; 220 } 221 222 /* 223 * Test if background-attachment: fixed is supported. 224 * @link http://stackoverflow.com/questions/14115080/detect-support-for-background-attachment-fixed 225 */ 226 function supportsFixedBackground() { 227 var el = document.createElement('div'), 228 isSupported; 229 230 try { 231 if ( ! ( 'backgroundAttachment' in el.style ) || checkiOS() ) { 232 return false; 233 } 234 el.style.backgroundAttachment = 'fixed'; 235 isSupported = ( 'fixed' === el.style.backgroundAttachment ); 236 return isSupported; 237 } 238 catch (e) { 239 return false; 240 } 241 } 242 243 // Fire on document ready. 244 $( document ).ready( function() { 245 246 // If navigation menu is present on page, setNavProps and adjustScrollClass. 247 if ( $navigation.length ) { 248 setNavProps(); 249 adjustScrollClass(); 250 } 251 252 // If 'Scroll Down' arrow in present on page, calculate scroll offset and bind an event handler to the click event. 253 if ( $menuScrollDown.length ) { 254 255 if ( $( 'body' ).hasClass( 'admin-bar' ) ) { 256 menuTop -= 32; 257 } 258 if ( $( 'body' ).hasClass( 'blog' ) ) { 259 menuTop -= 30; // The div for latest posts has no space above content, add some to account for this. 260 } 261 if ( ! $navigation.length ) { 262 navigationOuterHeight = 0; 263 } 264 265 $menuScrollDown.click( function( e ) { 266 e.preventDefault(); 267 $( window ).scrollTo( '#primary', { 268 duration: 600, 269 offset: { top: menuTop - navigationOuterHeight } 270 }); 271 }); 272 } 273 274 adjustHeaderHeight(); 275 setQuotesIcon(); 276 /*Ajout SMI pour un scroll down sur tous les titre nav*/ 277 $navMenuScrollDown.click( function( e ) { 278 // grab target URL 279 var url = $(this).attr("href"); 280 // get # position 281 var index = url.indexOf("#"); 282 if(index == -1){ 283 return; 284 } 285 // extract the target id value 286 var targetId = url.substring(index); 287 288 e.preventDefault(); 289 // remove classes from any menu list items 290 $("a[href*='#']").parent().removeClass("current-menu-item current_page_item"); 291 // add classes to current menu item 292 $(this).closest("li").addClass("current-menu-item current_page_item"); 293 294 // scroll down 295 $( window ).scrollTo( targetId, {
296 duration: 800, 297 offset: { top: menuTop - navigationOuterHeight } 298 }); 299 }); 300 /*fin SMI*/ 301 302 // Adjusts the header height again a bit after the page finishes laoding 303 // In case VC Customizer changing the font makes the menu and the branding overlap when both are at the top 304 window.onload = function(){ 305 setTimeout(function(){ 306 setNavProps(); 307 adjustHeaderHeight(); 308 }, 500); 309 }; 310 311 312 if ( true === supportsInlineSVG() ) { 313 document.documentElement.className = document.documentElement.className.replace( /(\s*)no-svg(\s*)/, '$1svg$2' ); 314 } 315 316 if ( true === supportsFixedBackground() ) { 317 document.documentElement.className += ' background-fixed'; 318 } 319 }); 320 321 // If navigation menu is present on page, adjust it on scroll and screen resize. 322 if ( $navigation.length ) { 323 324 // On scroll, we want to stick/unstick the navigation. 325 $( window ).on( 'scroll', function() { 326 adjustScrollClass(); 327 adjustHeaderHeight(); 328 }); 329 330 // Also want to make sure the navigation is where it should be on resize. 331 $( window ).resize( function() { 332 setNavProps(); 333 setTimeout( adjustScrollClass, 500 ); 334 }); 335 } 336 337 $( window ).resize( function() { 338 clearTimeout( resizeTimer ); 339 resizeTimer = setTimeout( function() { 340 belowEntryMetaClass( 'blockquote.alignleft, blockquote.alignright' ); 341 }, 300 ); 342 setTimeout( adjustHeaderHeight, 1000 ); 343 }); 344 345 // Add header video class after the video is loaded. 346 $( document ).on( 'wp-custom-header-video-loaded', function() { 347 $body.addClass( 'has-header-video' ); 348 }); 349 350})( jQuery ); 351 352 353
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.