Browse Source

Merge branch 'trunk' into update/blank-canvas-patterns

Kjell Reigstad 4 years ago
parent
commit
3ee3b8e9be

+ 2 - 2
independent-publisher-2/functions.php

@@ -213,12 +213,12 @@ function independent_publisher_2_scripts() {
 	wp_enqueue_script( 'independent-publisher-2-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20170317', true );
 
 	if ( ! is_active_sidebar( 'sidebar-1' ) ) {
-		wp_enqueue_script( 'independent-publisher-2-images', get_template_directory_uri() . '/js/independent-publisher-2.js', array( 'jquery' ), '20170406', true );
+		wp_enqueue_script( 'independent-publisher-2-images', get_template_directory_uri() . '/js/independent-publisher-2.js', array(), '20210111', true );
 	}
 
 	// If there's an active Video widget, and it's (hopefully) in the footer widget area
 	if ( is_active_widget( '','', 'media_video' ) && ( is_active_sidebar( 'sidebar-2' ) || is_active_sidebar( 'sidebar-3' ) || is_active_sidebar( 'sidebar-4' ) ) ) {
-		wp_enqueue_script( 'independent-publisher-2-video-widget', get_template_directory_uri() . '/js/video-widget.js', array( 'jquery' ), '20170608', true );
+		wp_enqueue_script( 'independent-publisher-2-video-widget', get_template_directory_uri() . '/js/video-widget.js', array(), '20210111', true );
 	}
 
 	wp_enqueue_script( 'independent-publisher-2-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20170315', true );

+ 16 - 11
independent-publisher-2/inc/script-wpcom.js

@@ -4,25 +4,30 @@
  * Handles toggling of body class name to help WordPress.com custom colors target color changes at different window sizes.
  * The Custom Colors plugin does not support media queries.
  */
-
- ( function( $ ) {
+( function() {
 	function checkWidth( init ) {
 		// If browser is resized, check width again
-		if ( $( window ).width() > 992 ) {
-			$( 'body' ).addClass( 'tablet-desktop' );
+		if ( window.innerWidth > 992 ) {
+			document.body.classList.add( 'tablet-desktop' );
 		}
 		else {
 			if ( ! init ) {
-				$( 'body' ).removeClass( 'tablet-desktop' );
+				document.body.classList.remove( 'tablet-desktop' );
 			}
 		}
 	}
 
-	$( document ).ready( function() {
+	function init() {
 		checkWidth( true );
+		window.addEventListener( 'resize', function() {
+			checkWidth( false);
+		} );
+	}
 
-		$( window ).resize( function() {
-			checkWidth( false );
-		});
-	});
-} )( jQuery );
+	// After DOM is ready.
+	if ( document.readyState !== 'loading' ) {
+		init();
+	} else {
+		document.addEventListener( 'DOMContentLoaded', init );
+	}
+} )();

+ 136 - 69
independent-publisher-2/js/independent-publisher-2.js

@@ -1,69 +1,136 @@
-( function( $ ) {
-
-    /*
-     * Wrap tiled galleries so we can outdent them
-     */
-    function galleryWrapper() {
-        var gallery = $( '.entry-content' ).find( '.tiled-gallery' );
-
-        //If this tiled gallery has not yet been wrapped, add a wrapper
-        if ( ! gallery.parent().hasClass( 'tiled-gallery-wrapper' ) ) {
-            gallery.wrap( '<div class="tiled-gallery-wrapper"></div>' );
-            gallery.resize();
-        }
-    }
-
-    /*
-     * Add an extra class to large images and videos to outdent them
-     */
-    function outdentMedia() {
-
-        $( '.entry-content img, .post-image-link img' ).each( function() {
-
-            var img = $( this ),
-                caption = $( this ).closest( 'figure' ),
-                new_img = new Image();
-
-                new_img.src = img.attr( 'src' );
-
-                $( new_img ).load( function() {
-
-                    var img_width = new_img.width;
-
-                    if ( img_width >= 1100
-                        && img.parents( '.tiled-gallery-item-large' ).length === 0
-                        && img.parents( '[class^="wp-block-"]' ).length === 0 ) {
-                            $( img ).addClass( 'size-big' );
-                     }
-
-                    if ( caption.hasClass( 'wp-caption' ) && img_width >= 1100 ) {
-                        caption.addClass( 'size-big' );
-                    }
-                } );
-        } );
-
-        $( '.entry-content .jetpack-video-wrapper' ).each( function() {
-            if ( $( this ).find( ':first-child' ).width >= 1100 ) {
-                $( this ).addClass( 'caption-big' );
-            }
-        } );
-    }
-
-    // After DOM is ready
-    $( document ).ready( function() {
-        galleryWrapper();
-        outdentMedia();
-    } );
-
-    // After window loads
-    $( window ).load( function() {
-        outdentMedia();
-    } );
-
-    // After window is resized or infinite scroll loads new posts
-    $( window ).on( 'resize post-load', function() {
-        galleryWrapper();
-        outdentMedia();
-    } );
-
-} )( jQuery );
+( function () {
+	// Helper matches function (not a polyfill), compatible with IE 11.
+	function matches( el, sel ) {
+		if ( Element.prototype.matches ) {
+			return el.matches( sel );
+		}
+
+		if ( Element.prototype.msMatchesSelector ) {
+			return el.msMatchesSelector( sel );
+		}
+	}
+
+	// Helper closest parent node function (not a polyfill) based on
+	// https://developer.mozilla.org/en-US/docs/Web/API/Element/closest#Polyfill
+	function closest( el, sel ) {
+		if ( el.closest ) {
+			return el.closest( sel );
+		}
+
+		var current = el;
+
+		do {
+			if ( matches( el, sel ) ) {
+				return current;
+			}
+			current = current.parentElement || current.parentNode;
+		} while ( current !== null && current.nodeType === 1 );
+
+		return null;
+	}
+
+	function emitResizeEvent() {
+		if ( typeof( Event ) === 'function' ) {
+			window.dispatchEvent( new Event( 'resize' ) );
+		} else {
+			var event = window.document.createEvent( 'UIEvents' );
+			event.initUIEvent( 'resize', true, false, window, 0 );
+			window.dispatchEvent( event );
+		}
+	}
+
+	function updatePage() {
+		galleryWrapper();
+		outdentMedia();
+	}
+
+	// Wrap tiled galleries so we can outdent them
+	function galleryWrapper() {
+		var galleries = document.querySelectorAll( '.entry-content .tiled-gallery' );
+		var shouldOutdent = false;
+
+		for( var i = 0; i < galleries.length; i++ ) {
+			var gallery = galleries[ i ];
+			var parent = gallery.parentNode;
+
+			// If this tiled gallery has not yet been wrapped, add a wrapper.
+			if ( parent && ! parent.classList.contains( 'tiled-gallery-wrapper' ) ) {
+				var div = document.createElement( 'div' );
+				parent.insertBefore( div, gallery );
+				parent.removeChild( gallery );
+				div.appendChild( gallery );
+				div.classList.add( 'tiled-gallery-wrapper' );
+
+				// Outdent in the next event loop.
+				shouldOutdent = true;
+			}
+		}
+
+		if ( shouldOutdent ) {
+			emitResizeEvent();
+		}
+	}
+
+	// Add an extra class to large images and videos to outdent them.
+	function outdentMedia() {
+		var images = document.querySelectorAll( '.entry-content img, .post-image-link img' );
+
+		for ( var i = 0; i < images.length; i++ ) {
+			var img = images[ i ];
+			var caption = closest( img, 'figure' );
+			var newImg = new Image();
+
+			newImg.addEventListener(
+				'load',
+				// Use an IIFE to avoid scoping issues.
+				( function ( img, caption, newImg ) {
+					return function () {
+						var imgWidth = newImg.offsetWidth;
+
+						if ( imgWidth >= 1100 &&
+								! closest( img, '.tiled-gallery-item-large' ) &&
+								! closest( img, '[class^="wp-block-"]' ) ) {
+							img.classList.add( 'size-big' );
+						}
+
+						if ( caption && caption.classList.contains( 'wp-caption' ) && imgWidth >= 1100 ) {
+							caption.classList.add( 'size-big' );
+						}
+					}
+				} )( img, caption, newImg )
+			);
+
+			newImg.src = img.getAttribute( 'src' );
+		}
+
+		var wrappers = document.querySelectorAll( '.entry-content .jetpack-video-wrapper' );
+
+		for ( var j = 0; j < wrappers.length; j++ ) {
+			var wrapper = wrappers[ j ];
+			var firstChild = wrapper.querySelector( ':first-child' );
+
+			if ( firstChild && firstChild.offsetWidth >= 1100 ) {
+				wrapper.classList.add( 'caption-big' );
+			}
+		}
+	}
+
+	// After DOM is ready.
+	if ( document.readyState !== 'loading' ) {
+		updatePage();
+	} else {
+		document.addEventListener( 'DOMContentLoaded', updatePage );
+	}
+
+	// After window loads.
+	if ( document.readyState === 'complete' ) {
+		outdentMedia();
+	} else {
+		window.addEventListener( 'load', outdentMedia );
+	}
+
+	// After window is resized or infinite scroll loads new posts
+	window.addEventListener( 'resize', updatePage );
+	document.body.addEventListener( 'is.post-load', updatePage );
+
+} )();

+ 10 - 4
independent-publisher-2/js/video-widget.js

@@ -1,9 +1,9 @@
 /*
  * Triggers resize event to make sure video widgets in the footer maintain the correct aspect ratio
  */
-( function( $ ) {
+( function() {
 
-    $( window ).on( 'load', function() {
+	function init() {
 		setTimeout( function(){
 			if ( typeof( Event ) === 'function' ) {
 				window.dispatchEvent( new Event( 'resize' ) );
@@ -13,6 +13,12 @@
 				window.dispatchEvent( event );
 			}
 		} );
-	});
+	}
 
-} )( jQuery );
+	if ( document.readyState === 'complete' ) {
+		init();
+	} else {
+		window.addEventListener( 'load', init );
+	}
+
+} )();

+ 0 - 8
seedlet/assets/css/style-editor.css

@@ -1506,14 +1506,6 @@ pre.wp-block-verse {
 	margin-bottom: var(--global--spacing-vertical);
 }
 
-[data-block] [data-block]:first-child {
-	margin-top: 0;
-}
-
-[data-block] [data-block]:nth-last-child(2) {
-	margin-bottom: 0;
-}
-
 /*
  * Custom gradients
 */

+ 0 - 9
seedlet/assets/sass/blocks/utilities/_editor.scss

@@ -149,15 +149,6 @@
 [data-block] {
 	margin-top: var(--global--spacing-vertical);
 	margin-bottom: var(--global--spacing-vertical);
-
-	[data-block]:first-child {
-		margin-top: 0;
-	}
-
-	// Needs to be the second-last child to avoid applying this to the appender.
-	[data-block]:nth-last-child(2) {
-		margin-bottom: 0;
-	}
 }
 
 /*

+ 3 - 0
seedlet/assets/sass/vendors/jetpack/blocks/_style.scss

@@ -7,3 +7,6 @@
 
 // Layout Grid
 @import "layout-grid/style";
+
+// Subscription 
+@import "subscription/style";

+ 4 - 0
seedlet/assets/sass/vendors/jetpack/blocks/subscription/_style.scss

@@ -0,0 +1,4 @@
+.wp-block-jetpack-subscriptions #subscribe-email > input {
+	line-height: normal; // Match the submit button line height.
+	width: 100%;
+}

+ 5 - 0
seedlet/style-rtl.css

@@ -4379,4 +4379,9 @@ button[data-load-more-btn],
 	padding-left: calc(var(--layout-grid--gutter-huge) + var(--layout-grid--background-offset)) !important;
 	padding-bottom: var(--layout-grid--gutter-huge) !important;
 	padding-right: calc(var(--layout-grid--gutter-huge) + var(--layout-grid--background-offset)) !important;
+}
+
+.wp-block-jetpack-subscriptions #subscribe-email > input {
+	line-height: normal;
+	width: 100%;
 }

+ 5 - 0
seedlet/style.css

@@ -4402,4 +4402,9 @@ button[data-load-more-btn],
 	padding-left: calc(var(--layout-grid--gutter-huge) + var(--layout-grid--background-offset)) !important;
 }
 
+.wp-block-jetpack-subscriptions #subscribe-email > input {
+	line-height: normal;
+	width: 100%;
+}
+
 /*# sourceMappingURL=style.css.map */

+ 3 - 0
spearhead/assets/sass/navigation.scss

@@ -29,6 +29,9 @@ $navigation-max-break-point: 'laptop-only';
 		@include media( $navigation-min-break-point ) {
 			padding: calc(0.5 * var(--primary-nav--padding)) calc( 2 * var(--primary-nav--padding) );
 			transition: all 0.15s ease;
+			text-align: right;
+			left: unset;
+			right: 0;
 
 			> .menu-item.menu-item-has-children {
 				padding: calc(0.5 * var(--primary-nav--padding)) calc( 2 * var(--primary-nav--padding) ) 0 0;

+ 3 - 0
spearhead/navigation-rtl.css

@@ -545,6 +545,9 @@
 	.woo-navigation div ul > li > .sub-menu {
 		padding: calc(0.5 * var(--primary-nav--padding)) calc( 2 * var(--primary-nav--padding));
 		transition: all 0.15s ease;
+		text-align: left;
+		right: unset;
+		left: 0;
 	}
 	.primary-navigation div ul > li > .sub-menu > .menu-item.menu-item-has-children,
 	.woo-navigation div ul > li > .sub-menu > .menu-item.menu-item-has-children {

+ 3 - 0
spearhead/navigation.css

@@ -545,6 +545,9 @@
 	.woo-navigation div ul > li > .sub-menu {
 		padding: calc(0.5 * var(--primary-nav--padding)) calc( 2 * var(--primary-nav--padding));
 		transition: all 0.15s ease;
+		text-align: right;
+		left: unset;
+		right: 0;
 	}
 	.primary-navigation div ul > li > .sub-menu > .menu-item.menu-item-has-children,
 	.woo-navigation div ul > li > .sub-menu > .menu-item.menu-item-has-children {