Skip to content

Commit

Permalink
Merge branch 'release/1.5.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Misplon committed Oct 5, 2018
2 parents d9d621d + cf27146 commit 6c2e386
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 93 deletions.
5 changes: 5 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
== Changelog ==

= 1.5.2 - 05 October 2018 =
* Resolved a problem with logo scaling when returning to the top of the page.
* Resolved a problem with logo scaling and Jetpack Lazy Images.
* Prevented FitVids.js from loading if user is viewing a Gutenberg page.

= 1.5.1 - 27 August 2018 =
* Closed the header search when clicking away.
* Resolve responsive sidebar behaviour problem.
Expand Down
6 changes: 4 additions & 2 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ function siteorigin_north_scripts() {
) );

// jQuery FitVids.
if ( ! class_exists( 'Jetpack' ) && siteorigin_setting( 'responsive_fitvids' ) ) {
if ( ! class_exists( 'Jetpack' ) && ! ( function_exists( 'has_blocks' ) && has_blocks() ) && siteorigin_setting( 'responsive_fitvids' ) ) {
wp_enqueue_script( 'jquery-fitvids', get_template_directory_uri() . '/js/jquery.fitvids' . SITEORIGIN_THEME_JS_PREFIX . '.js', array( 'jquery' ), '1.1', true );
}

Expand Down Expand Up @@ -383,7 +383,9 @@ function siteorigin_north_filter_comment_form_defaults( $defaults ){
/**
* Load Jetpack compatibility file.
*/
require get_template_directory() . '/inc/jetpack.php';
if ( class_exists( 'Jetpack' ) ) {
require get_template_directory() . '/inc/jetpack.php';
}

/**
* Load the theme settings file
Expand Down
26 changes: 26 additions & 0 deletions inc/jetpack.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,32 @@ function siteorigin_north_jetpack_setup() {
endif;
add_action( 'after_setup_theme', 'siteorigin_north_jetpack_setup' );

if ( Jetpack::is_module_active( 'lazy-images' ) ) :
if ( ! function_exists( 'siteorigin_north_jetpack_logo_not_lazy' ) ) {

function siteorigin_north_jetpack_logo_not_lazy( $blacklisted_classes ) {
$blacklisted_classes[] = 'custom-logo';

return $blacklisted_classes;
}
add_filter( 'jetpack_lazy_images_blacklisted_classes', 'siteorigin_north_jetpack_logo_not_lazy' );
}

if ( ! function_exists( 'siteorigin_north_jetpack_logo_not_lazy_class' ) ) {

function siteorigin_north_jetpack_logo_not_lazy_class( $attrs ) {
if ( ! empty( $attrs['class'] ) ) {
$attrs['class'] .= ' skip-lazy';
} else {
$attrs['class'] = 'skip-lazy';
}

return $attrs;
}
add_filter( 'siteorigin_north_logo_attributes', 'siteorigin_north_jetpack_logo_not_lazy_class' );
}
endif;

if ( ! function_exists( 'siteorigin_north_infinite_scroll_render' ) ) :
/**
* Custom render function for Infinite Scroll.
Expand Down
179 changes: 88 additions & 91 deletions js/north.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@

// Burst animation plugin.
(
function ( $ ) {
function( $ ) {

var mousePos = {x: 0, y: 0};
$( document ).mousemove( function ( e ) {
$( document ).mousemove( function( e ) {
mousePos = {
x: e.pageX,
y: e.pageY
};
} );

$.fn.burstAnimation = function ( options ) {
$.fn.burstAnimation = function( options ) {
var settings = $.extend( {
event: "click",
container: "parent"
}, options );

return $( this ).each( function () {
return $( this ).each( function() {
var $$ = $( this ),
$p = settings.container === 'parent' ? $$.parent() : $$.closest( settings.container ),
$o = $( '<div class="burst-animation-overlay"></div>' ),
Expand Down Expand Up @@ -60,7 +60,7 @@
};

$.fn.northSmoothScroll = function () {
$( this ).click( function ( e ) {
$( this ).click( function( e ) {
var $a = $( this );
var $target = $( '[name=' + this.hash.slice( 1 ) + ']' ).length ? $( '[name=' + this.hash.slice( 1 ) + ']' ) : $( $a.get( 0 ).hash );

Expand Down Expand Up @@ -96,33 +96,33 @@
}
)( jQuery );

jQuery( function ( $ ) {
jQuery( function( $ ) {

$( '.entry-meta a' ).hover(
function () {
function() {
$( this ).closest( 'li' ).addClass( 'hovering' );
},
function () {
$( this ).closest( 'li' ).removeClass( 'hovering' );
}
);

// Setup FitVids for entry content, panels and WooCommerce. Ignore Tableau.
if ( typeof $.fn.fitVids !== 'undefined' ) {
$( '.entry-content, .entry-content .panel, .woocommerce #main' ).fitVids( { ignore: '.tableauViz' } );
}
// Setup FitVids for entry content, panels and WooCommerce. Ignore Tableau.
if ( typeof $.fn.fitVids !== 'undefined' ) {
$( '.entry-content, .entry-content .panel, .woocommerce #main' ).fitVids( { ignore: '.tableauViz' } );
}

// This this is a touch device. We detect this through ontouchstart, msMaxTouchPoints and MaxTouchPoints.
if( 'ontouchstart' in document.documentElement || window.navigator.msMaxTouchPoints || window.navigator.MaxTouchPoints ) {
if ( 'ontouchstart' in document.documentElement || window.navigator.msMaxTouchPoints || window.navigator.MaxTouchPoints ) {
$('body').removeClass('no-touch');
}
if ( !$( 'body' ).hasClass( 'no-touch' ) ) {
if ( /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream ) {
if ( /iPad|iPhone|iPod/.test( navigator.userAgent ) && ! window.MSStream ) {
$( 'body' ).css( 'cursor', 'pointer' );
}
$( '.main-navigation #primary-menu').find('.menu-item-has-children > a' ).each( function() {
$( this ).click( function(e){
var link = $(this);
$( this ).click( function( e ){
var link = $( this );
e.stopPropagation();
link.parent().addClass( 'touch-drop' );

Expand Down Expand Up @@ -155,7 +155,7 @@ jQuery( function ( $ ) {
} );

var resetMenu = function () {
$( '.main-navigation ul ul' ).each( function () {
$( '.main-navigation ul ul' ).each( function() {
var $$ = $( this );
var width = Math.max.apply( Math, $$.find( '> li > a' ).map( function () {
return $( this ).width();
Expand All @@ -178,14 +178,14 @@ jQuery( function ( $ ) {
alignMenu();

// Add keyboard access to the menu.
$( '.menu-item' ).children( 'a' ).focus( function () {
$( '.menu-item' ).children( 'a' ).focus( function() {
$( this ).parents( 'ul, li' ).addClass( 'focus' );
} );
// Click event fires after focus event.
$( '.menu-item' ).children( 'a' ).click( function () {
$( '.menu-item' ).children( 'a' ).click( function() {
$( this ).parents( 'ul, li' ).removeClass( 'focus' );
} );
$( '.menu-item' ).children( 'a' ).focusout( function () {
$( '.menu-item' ).children( 'a' ).focusout( function() {
$( this ).parents( 'ul, li' ).removeClass( 'focus' );
} );

Expand All @@ -198,7 +198,7 @@ jQuery( function ( $ ) {

// Handle displaying the mobile menu.
var $mobileMenu = false;
$( '#mobile-menu-button' ).click( function ( e ) {
$( '#mobile-menu-button' ).click( function( e ) {
e.preventDefault();
var $$ = $( this );
$$.toggleClass( 'to-close' );
Expand Down Expand Up @@ -258,14 +258,14 @@ jQuery( function ( $ ) {

$mobileMenu.slideToggle( 'fast' );

$( '#mobile-navigation a' ).click(function(e) {
$( '#mobile-navigation a' ).click( function( e ) {
if ( ! $( this ).hasClass( 'has-dropdown' ) || ( typeof $( this ).attr( 'href' ) !== "undefined" && $( this ).attr( 'href' ) !== "#" ) ) {
if ( $mobileMenu.is( ':visible' ) ) {
$mobileMenu.slideUp( 'fast' );
}
$$.removeClass( 'to-close' );
}
});
} );

if ( siteoriginNorth.smoothScroll ) {
$( '#mobile-navigation a[href*="#"]:not([href="#"])' ).northSmoothScroll();
Expand All @@ -281,8 +281,7 @@ jQuery( function ( $ ) {
if ( ! $( '#scroll-to-top' ).hasClass( 'show' ) ) {
$( '#scroll-to-top' ).css( 'pointer-events', 'auto' ).addClass( 'show' );
}
}
else {
} else {
if ( $( '#scroll-to-top' ).hasClass( 'show' ) ) {
$( '#scroll-to-top' ).css( 'pointer-events', 'none' ).removeClass( 'show' );
}
Expand All @@ -292,18 +291,80 @@ jQuery( function ( $ ) {
sttWindowScroll();
$( window ).scroll( sttWindowScroll );
$( '#scroll-to-top' ).click( function () {
$( 'html,body' ).animate( {scrollTop: 0} );
$( 'html,body' ).animate( { scrollTop: 0 } );
} );

// Now lets do the sticky menu.
if ( $( '#masthead' ).hasClass( 'sticky-menu' ) ) {
var $mhs = false,
mhTop = false,
pageTop = $( '#page' ).offset().top,
$mh = $( '#masthead' ),
$tb = $( '#topbar' ),
$wpab = $( '#wpadminbar' );

// Sticky header shadow.
var smShadow = function() {
if ( $( window ).scrollTop() > 0 ) {
$( $mh ).addClass( 'floating' );
} else {
$( $mh ).removeClass( 'floating' );
}
};
smShadow();
$( window ).scroll( smShadow );

var mhPadding = {
top: parseInt( $mh.css( 'padding-top' ) ),
bottom: parseInt( $mh.css( 'padding-bottom' ) )
};

if ( $mh.data( 'scale-logo' ) ) {
var $img = $mh.find( '.site-branding img' ),
imgWidth = $img.width(),
imgHeight = $img.height();
scaledWidth = imgWidth * siteoriginNorth.logoScale;
scaledHeight = imgHeight * siteoriginNorth.logoScale;

var smResizeLogo = function () {
var $branding = $mh.find( '.site-branding > *' ),
top = window.pageYOffset || document.documentElement.scrollTop;

// Check if the menu is meant to be sticky or not, and if it is apply padding/class
if ( top > 0 ) {
$mh.css( {
'padding-top': mhPadding.top * siteoriginNorth.logoScale,
'padding-bottom': mhPadding.bottom * siteoriginNorth.logoScale
} );

} else {
$mh.css( {
'padding-top': mhPadding.top,
'padding-bottom': mhPadding.bottom
} );
}

if ( $img.length ) {
// If Scale == siteoriginNorth.logoScale, logo is completely scaled.
if ( $img.height() != scaledHeight || $img.width() != scaledWidth ) {
var scale = siteoriginNorth.logoScale + ( Math.max( 0, 48 - top ) / 48 * ( 1 - siteoriginNorth.logoScale ) );
$( '.site-branding img' ).css( {
width: imgWidth * scale,
height: imgHeight * scale,
'max-width' : 'none'
} );
}
} else {
if ( top > 0 ) {
$branding.css( 'transform', 'scale(' + siteoriginNorth.logoScale + ')' );
} else {
$branding.css( 'transform', 'scale(1)' );
}
}
};
smResizeLogo();
$( window ).scroll( smResizeLogo ).resize( smResizeLogo );
}

var smSetup = function() {

if ( $mhs === false ) {
Expand Down Expand Up @@ -346,73 +407,9 @@ jQuery( function ( $ ) {
}

}

smSetup();
$( window ).resize( smSetup ).scroll( smSetup );

// Sticky header shadow.
var smShadow = function() {
if ( $( window ).scrollTop() > 0 ) {
$( $mh ).addClass( 'floating' );
}
else {
$( $mh ).removeClass( 'floating' );
}
};
smShadow();
$( window ).scroll( smShadow );

var mhPadding = {
top: parseInt( $mh.css( 'padding-top' ) ),
bottom: parseInt( $mh.css( 'padding-bottom' ) )
};

if ( $mh.data( 'scale-logo' ) ) {
var $img = $mh.find( '.site-branding img' ),
imgWidth = $img.width(),
imgHeight = $img.height();
scaledWidth = imgWidth * siteoriginNorth.logoScale;
scaledHeight = imgHeight * siteoriginNorth.logoScale;

var smResizeLogo = function () {
var $branding = $mh.find( '.site-branding > *' ),
top = window.pageYOffset || document.documentElement.scrollTop;
top -= pageTop;

if ( top > 0 ) {
var scale = siteoriginNorth.logoScale + ( Math.max( 0, 48 - top ) / 48 * ( 1 - siteoriginNorth.logoScale ) );
// If Scale == siteoriginNorth.logoScale, logo is completely scaled.
if ( $img.height() != scaledHeight || $img.width() != scaledWidth ) {
if ( $img.length ) {
$img.css( {
width: imgWidth * scale,
height: imgHeight * scale,
'max-width' : 'none'
} );
}
else {
$branding.css( 'transform', 'scale(' + scale + ')' );
}

$mh.css( {
'padding-top': mhPadding.top * scale,
'padding-bottom': mhPadding.bottom * scale
} );
}
}
else {
if ( ! $img.length ) {
$branding.css( 'transform', 'scale(1)' );
}

$mh.css( {
'padding-top': mhPadding.top,
'padding-bottom': mhPadding.bottom
} );
}
};
smResizeLogo();
$( window ).scroll( smResizeLogo ).resize( smResizeLogo );
}
}

// Handle the header search.
Expand Down

0 comments on commit 6c2e386

Please sign in to comment.