diff --git a/wp-content/themes/twentyseventeen/assets/images/svg-icons.svg b/wp-content/themes/twentyseventeen/assets/images/svg-icons.svg index d5f9ade..dc6f612 100644 --- a/wp-content/themes/twentyseventeen/assets/images/svg-icons.svg +++ b/wp-content/themes/twentyseventeen/assets/images/svg-icons.svg @@ -1,155 +1,162 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/wp-content/themes/twentyseventeen/assets/js/customize-controls.js b/wp-content/themes/twentyseventeen/assets/js/customize-controls.js index 8477975..0e14a3e 100644 --- a/wp-content/themes/twentyseventeen/assets/js/customize-controls.js +++ b/wp-content/themes/twentyseventeen/assets/js/customize-controls.js @@ -1,36 +1,36 @@ -/** - * Scripts within the customizer controls window. - * - * Contextually shows the color hue control and informs the preview - * when users open or close the front page sections section. - */ - -(function() { - wp.customize.bind( 'ready', function() { - - // Only show the color hue control when there's a custom color scheme. - wp.customize( 'colorscheme', function( setting ) { - wp.customize.control( 'colorscheme_hue', function( control ) { - var visibility = function() { - if ( 'custom' === setting.get() ) { - control.container.slideDown( 180 ); - } else { - control.container.slideUp( 180 ); - } - }; - - visibility(); - setting.bind( visibility ); - }); - }); - - // Detect when the front page sections section is expanded (or closed) so we can adjust the preview accordingly. - wp.customize.section( 'theme_options', function( section ) { - section.expanded.bind( function( isExpanding ) { - - // Value of isExpanding will = true if you're entering the section, false if you're leaving it. - wp.customize.previewer.send( 'section-highlight', { expanded: isExpanding }); - } ); - } ); - }); -})(); +/** + * Scripts within the customizer controls window. + * + * Contextually shows the color hue control and informs the preview + * when users open or close the front page sections section. + */ + +(function() { + wp.customize.bind( 'ready', function() { + + // Only show the color hue control when there's a custom color scheme. + wp.customize( 'colorscheme', function( setting ) { + wp.customize.control( 'colorscheme_hue', function( control ) { + var visibility = function() { + if ( 'custom' === setting.get() ) { + control.container.slideDown( 180 ); + } else { + control.container.slideUp( 180 ); + } + }; + + visibility(); + setting.bind( visibility ); + }); + }); + + // Detect when the front page sections section is expanded (or closed) so we can adjust the preview accordingly. + wp.customize.section( 'theme_options', function( section ) { + section.expanded.bind( function( isExpanding ) { + + // Value of isExpanding will = true if you're entering the section, false if you're leaving it. + wp.customize.previewer.send( 'section-highlight', { expanded: isExpanding }); + } ); + } ); + }); +})(); diff --git a/wp-content/themes/twentyseventeen/assets/js/customize-preview.js b/wp-content/themes/twentyseventeen/assets/js/customize-preview.js index e97dd83..de53f1b 100644 --- a/wp-content/themes/twentyseventeen/assets/js/customize-preview.js +++ b/wp-content/themes/twentyseventeen/assets/js/customize-preview.js @@ -1,150 +1,150 @@ -/** - * File customize-preview.js. - * - * Instantly live-update customizer settings in the preview for improved user experience. - */ - -(function( $ ) { - - // Collect information from customize-controls.js about which panels are opening. - wp.customize.bind( 'preview-ready', function() { - - // Initially hide the theme option placeholders on load. - $( '.panel-placeholder' ).hide(); - - wp.customize.preview.bind( 'section-highlight', function( data ) { - - // Only on the front page. - if ( ! $( 'body' ).hasClass( 'twentyseventeen-front-page' ) ) { - return; - } - - // When the section is expanded, show and scroll to the content placeholders, exposing the edit links. - if ( true === data.expanded ) { - $( 'body' ).addClass( 'highlight-front-sections' ); - $( '.panel-placeholder' ).slideDown( 200, function() { - $.scrollTo( $( '#panel1' ), { - duration: 600, - offset: { 'top': -70 } // Account for sticky menu. - }); - }); - - // If we've left the panel, hide the placeholders and scroll back to the top. - } else { - $( 'body' ).removeClass( 'highlight-front-sections' ); - // Don't change scroll when leaving - it's likely to have unintended consequences. - $( '.panel-placeholder' ).slideUp( 200 ); - } - }); - }); - - // Site title and description. - wp.customize( 'blogname', function( value ) { - value.bind( function( to ) { - $( '.site-title a' ).text( to ); - }); - }); - wp.customize( 'blogdescription', function( value ) { - value.bind( function( to ) { - $( '.site-description' ).text( to ); - }); - }); - - // Header text color. - wp.customize( 'header_textcolor', function( value ) { - value.bind( function( to ) { - if ( 'blank' === to ) { - $( '.site-title, .site-description' ).css({ - clip: 'rect(1px, 1px, 1px, 1px)', - position: 'absolute' - }); - // Add class for different logo styles if title and description are hidden. - $( 'body' ).addClass( 'title-tagline-hidden' ); - } else { - - // Check if the text color has been removed and use default colors in theme stylesheet. - if ( ! to.length ) { - $( '#twentyseventeen-custom-header-styles' ).remove(); - } - $( '.site-title, .site-description' ).css({ - clip: 'auto', - position: 'relative' - }); - $( '.site-branding, .site-branding a, .site-description, .site-description a' ).css({ - color: to - }); - // Add class for different logo styles if title and description are visible. - $( 'body' ).removeClass( 'title-tagline-hidden' ); - } - }); - }); - - // Color scheme. - wp.customize( 'colorscheme', function( value ) { - value.bind( function( to ) { - - // Update color body class. - $( 'body' ) - .removeClass( 'colors-light colors-dark colors-custom' ) - .addClass( 'colors-' + to ); - }); - }); - - // Custom color hue. - wp.customize( 'colorscheme_hue', function( value ) { - value.bind( function( to ) { - - // Update custom color CSS. - var style = $( '#custom-theme-colors' ), - hue = style.data( 'hue' ), - css = style.html(); - - // Equivalent to css.replaceAll, with hue followed by comma to prevent values with units from being changed. - css = css.split( hue + ',' ).join( to + ',' ); - style.html( css ).data( 'hue', to ); - }); - }); - - // Page layouts. - wp.customize( 'page_layout', function( value ) { - value.bind( function( to ) { - if ( 'one-column' === to ) { - $( 'body' ).addClass( 'page-one-column' ).removeClass( 'page-two-column' ); - } else { - $( 'body' ).removeClass( 'page-one-column' ).addClass( 'page-two-column' ); - } - } ); - } ); - - // Whether a header image is available. - function hasHeaderImage() { - var image = wp.customize( 'header_image' )(); - return '' !== image && 'remove-header' !== image; - } - - // Whether a header video is available. - function hasHeaderVideo() { - var externalVideo = wp.customize( 'external_header_video' )(), - video = wp.customize( 'header_video' )(); - - return '' !== externalVideo || ( 0 !== video && '' !== video ); - } - - // Toggle a body class if a custom header exists. - $.each( [ 'external_header_video', 'header_image', 'header_video' ], function( index, settingId ) { - wp.customize( settingId, function( setting ) { - setting.bind(function() { - if ( hasHeaderImage() ) { - $( document.body ).addClass( 'has-header-image' ); - } else { - $( document.body ).removeClass( 'has-header-image' ); - } - - if ( ! hasHeaderVideo() ) { - $( document.body ).removeClass( 'has-header-video' ); - } - } ); - } ); - } ); - -} )( jQuery ); +/** + * File customize-preview.js. + * + * Instantly live-update customizer settings in the preview for improved user experience. + */ + +(function( $ ) { + + // Collect information from customize-controls.js about which panels are opening. + wp.customize.bind( 'preview-ready', function() { + + // Initially hide the theme option placeholders on load. + $( '.panel-placeholder' ).hide(); + + wp.customize.preview.bind( 'section-highlight', function( data ) { + + // Only on the front page. + if ( ! $( 'body' ).hasClass( 'twentyseventeen-front-page' ) ) { + return; + } + + // When the section is expanded, show and scroll to the content placeholders, exposing the edit links. + if ( true === data.expanded ) { + $( 'body' ).addClass( 'highlight-front-sections' ); + $( '.panel-placeholder' ).slideDown( 200, function() { + $.scrollTo( $( '#panel1' ), { + duration: 600, + offset: { 'top': -70 } // Account for sticky menu. + }); + }); + + // If we've left the panel, hide the placeholders and scroll back to the top. + } else { + $( 'body' ).removeClass( 'highlight-front-sections' ); + // Don't change scroll when leaving - it's likely to have unintended consequences. + $( '.panel-placeholder' ).slideUp( 200 ); + } + }); + }); + + // Site title and description. + wp.customize( 'blogname', function( value ) { + value.bind( function( to ) { + $( '.site-title a' ).text( to ); + }); + }); + wp.customize( 'blogdescription', function( value ) { + value.bind( function( to ) { + $( '.site-description' ).text( to ); + }); + }); + + // Header text color. + wp.customize( 'header_textcolor', function( value ) { + value.bind( function( to ) { + if ( 'blank' === to ) { + $( '.site-title, .site-description' ).css({ + clip: 'rect(1px, 1px, 1px, 1px)', + position: 'absolute' + }); + // Add class for different logo styles if title and description are hidden. + $( 'body' ).addClass( 'title-tagline-hidden' ); + } else { + + // Check if the text color has been removed and use default colors in theme stylesheet. + if ( ! to.length ) { + $( '#twentyseventeen-custom-header-styles' ).remove(); + } + $( '.site-title, .site-description' ).css({ + clip: 'auto', + position: 'relative' + }); + $( '.site-branding, .site-branding a, .site-description, .site-description a' ).css({ + color: to + }); + // Add class for different logo styles if title and description are visible. + $( 'body' ).removeClass( 'title-tagline-hidden' ); + } + }); + }); + + // Color scheme. + wp.customize( 'colorscheme', function( value ) { + value.bind( function( to ) { + + // Update color body class. + $( 'body' ) + .removeClass( 'colors-light colors-dark colors-custom' ) + .addClass( 'colors-' + to ); + }); + }); + + // Custom color hue. + wp.customize( 'colorscheme_hue', function( value ) { + value.bind( function( to ) { + + // Update custom color CSS. + var style = $( '#custom-theme-colors' ), + hue = style.data( 'hue' ), + css = style.html(); + + // Equivalent to css.replaceAll, with hue followed by comma to prevent values with units from being changed. + css = css.split( hue + ',' ).join( to + ',' ); + style.html( css ).data( 'hue', to ); + }); + }); + + // Page layouts. + wp.customize( 'page_layout', function( value ) { + value.bind( function( to ) { + if ( 'one-column' === to ) { + $( 'body' ).addClass( 'page-one-column' ).removeClass( 'page-two-column' ); + } else { + $( 'body' ).removeClass( 'page-one-column' ).addClass( 'page-two-column' ); + } + } ); + } ); + + // Whether a header image is available. + function hasHeaderImage() { + var image = wp.customize( 'header_image' )(); + return '' !== image && 'remove-header' !== image; + } + + // Whether a header video is available. + function hasHeaderVideo() { + var externalVideo = wp.customize( 'external_header_video' )(), + video = wp.customize( 'header_video' )(); + + return '' !== externalVideo || ( 0 !== video && '' !== video ); + } + + // Toggle a body class if a custom header exists. + $.each( [ 'external_header_video', 'header_image', 'header_video' ], function( index, settingId ) { + wp.customize( settingId, function( setting ) { + setting.bind(function() { + if ( hasHeaderImage() ) { + $( document.body ).addClass( 'has-header-image' ); + } else { + $( document.body ).removeClass( 'has-header-image' ); + } + + if ( ! hasHeaderVideo() ) { + $( document.body ).removeClass( 'has-header-video' ); + } + } ); + } ); + } ); + +} )( jQuery ); diff --git a/wp-content/themes/twentyseventeen/assets/js/global.js b/wp-content/themes/twentyseventeen/assets/js/global.js index b6322de..b8a73ff 100644 --- a/wp-content/themes/twentyseventeen/assets/js/global.js +++ b/wp-content/themes/twentyseventeen/assets/js/global.js @@ -1,250 +1,250 @@ -/* global twentyseventeenScreenReaderText */ -(function( $ ) { - - // Variables and DOM Caching. - var $body = $( 'body' ), - $customHeader = $body.find( '.custom-header' ), - $branding = $customHeader.find( '.site-branding' ), - $navigation = $body.find( '.navigation-top' ), - $navWrap = $navigation.find( '.wrap' ), - $navMenuItem = $navigation.find( '.menu-item' ), - $menuToggle = $navigation.find( '.menu-toggle' ), - $menuScrollDown = $body.find( '.menu-scroll-down' ), - $sidebar = $body.find( '#secondary' ), - $entryContent = $body.find( '.entry-content' ), - $formatQuote = $body.find( '.format-quote blockquote' ), - isFrontPage = $body.hasClass( 'twentyseventeen-front-page' ) || $body.hasClass( 'home blog' ), - navigationFixedClass = 'site-navigation-fixed', - navigationHeight, - navigationOuterHeight, - navPadding, - navMenuItemHeight, - idealNavHeight, - navIsNotTooTall, - headerOffset, - menuTop = 0, - resizeTimer; - - // Ensure the sticky navigation doesn't cover current focused links. - $( '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() { - if ( $navigation.hasClass( 'site-navigation-fixed' ) ) { - var windowScrollTop = $( window ).scrollTop(), - fixedNavHeight = $navigation.height(), - itemScrollTop = $( this ).offset().top, - offsetDiff = itemScrollTop - windowScrollTop; - - // Account for Admin bar. - if ( $( '#wpadminbar' ).length ) { - offsetDiff -= $( '#wpadminbar' ).height(); - } - - if ( offsetDiff < fixedNavHeight ) { - $( window ).scrollTo( itemScrollTop - ( fixedNavHeight + 50 ), 0 ); - } - } - }); - - // Set properties of navigation. - function setNavProps() { - navigationHeight = $navigation.height(); - navigationOuterHeight = $navigation.outerHeight(); - navPadding = parseFloat( $navWrap.css( 'padding-top' ) ) * 2; - navMenuItemHeight = $navMenuItem.outerHeight() * 2; - idealNavHeight = navPadding + navMenuItemHeight; - navIsNotTooTall = navigationHeight <= idealNavHeight; - } - - // Make navigation 'stick'. - function adjustScrollClass() { - - // Make sure we're not on a mobile screen. - if ( 'none' === $menuToggle.css( 'display' ) ) { - - // Make sure the nav isn't taller than two rows. - if ( navIsNotTooTall ) { - - // When there's a custom header image or video, the header offset includes the height of the navigation. - if ( isFrontPage && ( $body.hasClass( 'has-header-image' ) || $body.hasClass( 'has-header-video' ) ) ) { - headerOffset = $customHeader.innerHeight() - navigationOuterHeight; - } else { - headerOffset = $customHeader.innerHeight(); - } - - // If the scroll is more than the custom header, set the fixed class. - if ( $( window ).scrollTop() >= headerOffset ) { - $navigation.addClass( navigationFixedClass ); - } else { - $navigation.removeClass( navigationFixedClass ); - } - - } else { - - // Remove 'fixed' class if nav is taller than two rows. - $navigation.removeClass( navigationFixedClass ); - } - } - } - - // Set margins of branding in header. - function adjustHeaderHeight() { - if ( 'none' === $menuToggle.css( 'display' ) ) { - - // The margin should be applied to different elements on front-page or home vs interior pages. - if ( isFrontPage ) { - $branding.css( 'margin-bottom', navigationOuterHeight ); - } else { - $customHeader.css( 'margin-bottom', navigationOuterHeight ); - } - - } else { - $customHeader.css( 'margin-bottom', '0' ); - $branding.css( 'margin-bottom', '0' ); - } - } - - // Set icon for quotes. - function setQuotesIcon() { - $( twentyseventeenScreenReaderText.quote ).prependTo( $formatQuote ); - } - - // Add 'below-entry-meta' class to elements. - function belowEntryMetaClass( param ) { - var sidebarPos, sidebarPosBottom; - - if ( ! $body.hasClass( 'has-sidebar' ) || ( - $body.hasClass( 'search' ) || - $body.hasClass( 'single-attachment' ) || - $body.hasClass( 'error404' ) || - $body.hasClass( 'twentyseventeen-front-page' ) - ) ) { - return; - } - - sidebarPos = $sidebar.offset(); - sidebarPosBottom = sidebarPos.top + ( $sidebar.height() + 28 ); - - $entryContent.find( param ).each( function() { - var $element = $( this ), - elementPos = $element.offset(), - elementPosTop = elementPos.top; - - // Add 'below-entry-meta' to elements below the entry meta. - if ( elementPosTop > sidebarPosBottom ) { - $element.addClass( 'below-entry-meta' ); - } else { - $element.removeClass( 'below-entry-meta' ); - } - }); - } - - /* - * Test if inline SVGs are supported. - * @link https://github.com/Modernizr/Modernizr/ - */ - function supportsInlineSVG() { - var div = document.createElement( 'div' ); - div.innerHTML = ''; - return 'http://www.w3.org/2000/svg' === ( 'undefined' !== typeof SVGRect && div.firstChild && div.firstChild.namespaceURI ); - } - - /** - * Test if an iOS device. - */ - function checkiOS() { - return /iPad|iPhone|iPod/.test(navigator.userAgent) && ! window.MSStream; - } - - /* - * Test if background-attachment: fixed is supported. - * @link http://stackoverflow.com/questions/14115080/detect-support-for-background-attachment-fixed - */ - function supportsFixedBackground() { - var el = document.createElement('div'), - isSupported; - - try { - if ( ! ( 'backgroundAttachment' in el.style ) || checkiOS() ) { - return false; - } - el.style.backgroundAttachment = 'fixed'; - isSupported = ( 'fixed' === el.style.backgroundAttachment ); - return isSupported; - } - catch (e) { - return false; - } - } - - // Fire on document ready. - $( document ).ready( function() { - - // If navigation menu is present on page, setNavProps and adjustScrollClass. - if ( $navigation.length ) { - setNavProps(); - adjustScrollClass(); - } - - // If 'Scroll Down' arrow in present on page, calculate scroll offset and bind an event handler to the click event. - if ( $menuScrollDown.length ) { - - if ( $( 'body' ).hasClass( 'admin-bar' ) ) { - menuTop -= 32; - } - if ( $( 'body' ).hasClass( 'blog' ) ) { - menuTop -= 30; // The div for latest posts has no space above content, add some to account for this. - } - if ( ! $navigation.length ) { - navigationOuterHeight = 0; - } - - $menuScrollDown.click( function( e ) { - e.preventDefault(); - $( window ).scrollTo( '#primary', { - duration: 600, - offset: { top: menuTop - navigationOuterHeight } - }); - }); - } - - adjustHeaderHeight(); - setQuotesIcon(); - belowEntryMetaClass( 'blockquote.alignleft, blockquote.alignright' ); - if ( true === supportsInlineSVG() ) { - document.documentElement.className = document.documentElement.className.replace( /(\s*)no-svg(\s*)/, '$1svg$2' ); - } - - if ( true === supportsFixedBackground() ) { - document.documentElement.className += ' background-fixed'; - } - }); - - // If navigation menu is present on page, adjust it on scroll and screen resize. - if ( $navigation.length ) { - - // On scroll, we want to stick/unstick the navigation. - $( window ).on( 'scroll', function() { - adjustScrollClass(); - adjustHeaderHeight(); - }); - - // Also want to make sure the navigation is where it should be on resize. - $( window ).resize( function() { - setNavProps(); - setTimeout( adjustScrollClass, 500 ); - }); - } - - $( window ).resize( function() { - clearTimeout( resizeTimer ); - resizeTimer = setTimeout( function() { - belowEntryMetaClass( 'blockquote.alignleft, blockquote.alignright' ); - }, 300 ); - setTimeout( adjustHeaderHeight, 1000 ); - }); - - // Add header video class after the video is loaded. - $( document ).on( 'wp-custom-header-video-loaded', function() { - $body.addClass( 'has-header-video' ); - }); - -})( jQuery ); +/* global twentyseventeenScreenReaderText */ +(function( $ ) { + + // Variables and DOM Caching. + var $body = $( 'body' ), + $customHeader = $body.find( '.custom-header' ), + $branding = $customHeader.find( '.site-branding' ), + $navigation = $body.find( '.navigation-top' ), + $navWrap = $navigation.find( '.wrap' ), + $navMenuItem = $navigation.find( '.menu-item' ), + $menuToggle = $navigation.find( '.menu-toggle' ), + $menuScrollDown = $body.find( '.menu-scroll-down' ), + $sidebar = $body.find( '#secondary' ), + $entryContent = $body.find( '.entry-content' ), + $formatQuote = $body.find( '.format-quote blockquote' ), + isFrontPage = $body.hasClass( 'twentyseventeen-front-page' ) || $body.hasClass( 'home blog' ), + navigationFixedClass = 'site-navigation-fixed', + navigationHeight, + navigationOuterHeight, + navPadding, + navMenuItemHeight, + idealNavHeight, + navIsNotTooTall, + headerOffset, + menuTop = 0, + resizeTimer; + + // Ensure the sticky navigation doesn't cover current focused links. + $( '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() { + if ( $navigation.hasClass( 'site-navigation-fixed' ) ) { + var windowScrollTop = $( window ).scrollTop(), + fixedNavHeight = $navigation.height(), + itemScrollTop = $( this ).offset().top, + offsetDiff = itemScrollTop - windowScrollTop; + + // Account for Admin bar. + if ( $( '#wpadminbar' ).length ) { + offsetDiff -= $( '#wpadminbar' ).height(); + } + + if ( offsetDiff < fixedNavHeight ) { + $( window ).scrollTo( itemScrollTop - ( fixedNavHeight + 50 ), 0 ); + } + } + }); + + // Set properties of navigation. + function setNavProps() { + navigationHeight = $navigation.height(); + navigationOuterHeight = $navigation.outerHeight(); + navPadding = parseFloat( $navWrap.css( 'padding-top' ) ) * 2; + navMenuItemHeight = $navMenuItem.outerHeight() * 2; + idealNavHeight = navPadding + navMenuItemHeight; + navIsNotTooTall = navigationHeight <= idealNavHeight; + } + + // Make navigation 'stick'. + function adjustScrollClass() { + + // Make sure we're not on a mobile screen. + if ( 'none' === $menuToggle.css( 'display' ) ) { + + // Make sure the nav isn't taller than two rows. + if ( navIsNotTooTall ) { + + // When there's a custom header image or video, the header offset includes the height of the navigation. + if ( isFrontPage && ( $body.hasClass( 'has-header-image' ) || $body.hasClass( 'has-header-video' ) ) ) { + headerOffset = $customHeader.innerHeight() - navigationOuterHeight; + } else { + headerOffset = $customHeader.innerHeight(); + } + + // If the scroll is more than the custom header, set the fixed class. + if ( $( window ).scrollTop() >= headerOffset ) { + $navigation.addClass( navigationFixedClass ); + } else { + $navigation.removeClass( navigationFixedClass ); + } + + } else { + + // Remove 'fixed' class if nav is taller than two rows. + $navigation.removeClass( navigationFixedClass ); + } + } + } + + // Set margins of branding in header. + function adjustHeaderHeight() { + if ( 'none' === $menuToggle.css( 'display' ) ) { + + // The margin should be applied to different elements on front-page or home vs interior pages. + if ( isFrontPage ) { + $branding.css( 'margin-bottom', navigationOuterHeight ); + } else { + $customHeader.css( 'margin-bottom', navigationOuterHeight ); + } + + } else { + $customHeader.css( 'margin-bottom', '0' ); + $branding.css( 'margin-bottom', '0' ); + } + } + + // Set icon for quotes. + function setQuotesIcon() { + $( twentyseventeenScreenReaderText.quote ).prependTo( $formatQuote ); + } + + // Add 'below-entry-meta' class to elements. + function belowEntryMetaClass( param ) { + var sidebarPos, sidebarPosBottom; + + if ( ! $body.hasClass( 'has-sidebar' ) || ( + $body.hasClass( 'search' ) || + $body.hasClass( 'single-attachment' ) || + $body.hasClass( 'error404' ) || + $body.hasClass( 'twentyseventeen-front-page' ) + ) ) { + return; + } + + sidebarPos = $sidebar.offset(); + sidebarPosBottom = sidebarPos.top + ( $sidebar.height() + 28 ); + + $entryContent.find( param ).each( function() { + var $element = $( this ), + elementPos = $element.offset(), + elementPosTop = elementPos.top; + + // Add 'below-entry-meta' to elements below the entry meta. + if ( elementPosTop > sidebarPosBottom ) { + $element.addClass( 'below-entry-meta' ); + } else { + $element.removeClass( 'below-entry-meta' ); + } + }); + } + + /* + * Test if inline SVGs are supported. + * @link https://github.com/Modernizr/Modernizr/ + */ + function supportsInlineSVG() { + var div = document.createElement( 'div' ); + div.innerHTML = ''; + return 'http://www.w3.org/2000/svg' === ( 'undefined' !== typeof SVGRect && div.firstChild && div.firstChild.namespaceURI ); + } + + /** + * Test if an iOS device. + */ + function checkiOS() { + return /iPad|iPhone|iPod/.test(navigator.userAgent) && ! window.MSStream; + } + + /* + * Test if background-attachment: fixed is supported. + * @link http://stackoverflow.com/questions/14115080/detect-support-for-background-attachment-fixed + */ + function supportsFixedBackground() { + var el = document.createElement('div'), + isSupported; + + try { + if ( ! ( 'backgroundAttachment' in el.style ) || checkiOS() ) { + return false; + } + el.style.backgroundAttachment = 'fixed'; + isSupported = ( 'fixed' === el.style.backgroundAttachment ); + return isSupported; + } + catch (e) { + return false; + } + } + + // Fire on document ready. + $( document ).ready( function() { + + // If navigation menu is present on page, setNavProps and adjustScrollClass. + if ( $navigation.length ) { + setNavProps(); + adjustScrollClass(); + } + + // If 'Scroll Down' arrow in present on page, calculate scroll offset and bind an event handler to the click event. + if ( $menuScrollDown.length ) { + + if ( $( 'body' ).hasClass( 'admin-bar' ) ) { + menuTop -= 32; + } + if ( $( 'body' ).hasClass( 'blog' ) ) { + menuTop -= 30; // The div for latest posts has no space above content, add some to account for this. + } + if ( ! $navigation.length ) { + navigationOuterHeight = 0; + } + + $menuScrollDown.click( function( e ) { + e.preventDefault(); + $( window ).scrollTo( '#primary', { + duration: 600, + offset: { top: menuTop - navigationOuterHeight } + }); + }); + } + + adjustHeaderHeight(); + setQuotesIcon(); + belowEntryMetaClass( 'blockquote.alignleft, blockquote.alignright' ); + if ( true === supportsInlineSVG() ) { + document.documentElement.className = document.documentElement.className.replace( /(\s*)no-svg(\s*)/, '$1svg$2' ); + } + + if ( true === supportsFixedBackground() ) { + document.documentElement.className += ' background-fixed'; + } + }); + + // If navigation menu is present on page, adjust it on scroll and screen resize. + if ( $navigation.length ) { + + // On scroll, we want to stick/unstick the navigation. + $( window ).on( 'scroll', function() { + adjustScrollClass(); + adjustHeaderHeight(); + }); + + // Also want to make sure the navigation is where it should be on resize. + $( window ).resize( function() { + setNavProps(); + setTimeout( adjustScrollClass, 500 ); + }); + } + + $( window ).resize( function() { + clearTimeout( resizeTimer ); + resizeTimer = setTimeout( function() { + belowEntryMetaClass( 'blockquote.alignleft, blockquote.alignright' ); + }, 300 ); + setTimeout( adjustHeaderHeight, 1000 ); + }); + + // Add header video class after the video is loaded. + $( document ).on( 'wp-custom-header-video-loaded', function() { + $body.addClass( 'has-header-video' ); + }); + +})( jQuery ); diff --git a/wp-content/themes/twentyseventeen/assets/js/html5.js b/wp-content/themes/twentyseventeen/assets/js/html5.js index 9c1f049..6199e92 100644 --- a/wp-content/themes/twentyseventeen/assets/js/html5.js +++ b/wp-content/themes/twentyseventeen/assets/js/html5.js @@ -1,326 +1,326 @@ -/** -* @preserve HTML5 Shiv 3.7.3 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed -*/ -;(function(window, document) { -/*jshint evil:true */ - /** version */ - var version = '3.7.3'; - - /** Preset options */ - var options = window.html5 || {}; - - /** Used to skip problem elements */ - var reSkip = /^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i; - - /** Not all elements can be cloned in IE **/ - var saveClones = /^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i; - - /** Detect whether the browser supports default html5 styles */ - var supportsHtml5Styles; - - /** Name of the expando, to work with multiple documents or to re-shiv one document */ - var expando = '_html5shiv'; - - /** The id for the the documents expando */ - var expanID = 0; - - /** Cached data for each document */ - var expandoData = {}; - - /** Detect whether the browser supports unknown elements */ - var supportsUnknownElements; - - (function() { - try { - var a = document.createElement('a'); - a.innerHTML = ''; - //if the hidden property is implemented we can assume, that the browser supports basic HTML5 Styles - supportsHtml5Styles = ('hidden' in a); - - supportsUnknownElements = a.childNodes.length == 1 || (function() { - // assign a false positive if unable to shiv - (document.createElement)('a'); - var frag = document.createDocumentFragment(); - return ( - typeof frag.cloneNode == 'undefined' || - typeof frag.createDocumentFragment == 'undefined' || - typeof frag.createElement == 'undefined' - ); - }()); - } catch(e) { - // assign a false positive if detection fails => unable to shiv - supportsHtml5Styles = true; - supportsUnknownElements = true; - } - - }()); - - /*--------------------------------------------------------------------------*/ - - /** - * Creates a style sheet with the given CSS text and adds it to the document. - * @private - * @param {Document} ownerDocument The document. - * @param {String} cssText The CSS text. - * @returns {StyleSheet} The style element. - */ - function addStyleSheet(ownerDocument, cssText) { - var p = ownerDocument.createElement('p'), - parent = ownerDocument.getElementsByTagName('head')[0] || ownerDocument.documentElement; - - p.innerHTML = 'x'; - return parent.insertBefore(p.lastChild, parent.firstChild); - } - - /** - * Returns the value of `html5.elements` as an array. - * @private - * @returns {Array} An array of shived element node names. - */ - function getElements() { - var elements = html5.elements; - return typeof elements == 'string' ? elements.split(' ') : elements; - } - - /** - * Extends the built-in list of html5 elements - * @memberOf html5 - * @param {String|Array} newElements whitespace separated list or array of new element names to shiv - * @param {Document} ownerDocument The context document. - */ - function addElements(newElements, ownerDocument) { - var elements = html5.elements; - if(typeof elements != 'string'){ - elements = elements.join(' '); - } - if(typeof newElements != 'string'){ - newElements = newElements.join(' '); - } - html5.elements = elements +' '+ newElements; - shivDocument(ownerDocument); - } - - /** - * Returns the data associated to the given document - * @private - * @param {Document} ownerDocument The document. - * @returns {Object} An object of data. - */ - function getExpandoData(ownerDocument) { - var data = expandoData[ownerDocument[expando]]; - if (!data) { - data = {}; - expanID++; - ownerDocument[expando] = expanID; - expandoData[expanID] = data; - } - return data; - } - - /** - * returns a shived element for the given nodeName and document - * @memberOf html5 - * @param {String} nodeName name of the element - * @param {Document|DocumentFragment} ownerDocument The context document. - * @returns {Object} The shived element. - */ - function createElement(nodeName, ownerDocument, data){ - if (!ownerDocument) { - ownerDocument = document; - } - if(supportsUnknownElements){ - return ownerDocument.createElement(nodeName); - } - if (!data) { - data = getExpandoData(ownerDocument); - } - var node; - - if (data.cache[nodeName]) { - node = data.cache[nodeName].cloneNode(); - } else if (saveClones.test(nodeName)) { - node = (data.cache[nodeName] = data.createElem(nodeName)).cloneNode(); - } else { - node = data.createElem(nodeName); - } - - // Avoid adding some elements to fragments in IE < 9 because - // * Attributes like `name` or `type` cannot be set/changed once an element - // is inserted into a document/fragment - // * Link elements with `src` attributes that are inaccessible, as with - // a 403 response, will cause the tab/window to crash - // * Script elements appended to fragments will execute when their `src` - // or `text` property is set - return node.canHaveChildren && !reSkip.test(nodeName) && !node.tagUrn ? data.frag.appendChild(node) : node; - } - - /** - * returns a shived DocumentFragment for the given document - * @memberOf html5 - * @param {Document} ownerDocument The context document. - * @returns {Object} The shived DocumentFragment. - */ - function createDocumentFragment(ownerDocument, data){ - if (!ownerDocument) { - ownerDocument = document; - } - if(supportsUnknownElements){ - return ownerDocument.createDocumentFragment(); - } - data = data || getExpandoData(ownerDocument); - var clone = data.frag.cloneNode(), - i = 0, - elems = getElements(), - l = elems.length; - for(;i