kollapsminoriteten/wp-content/plugins/jetpack/modules/calypsoify/mods-gutenberg.js

41 lines
1.2 KiB
JavaScript
Raw Normal View History

2019-11-15 23:26:29 +01:00
/* eslint-disable no-var */
/* global wp, calypsoifyGutenberg */
2020-09-15 14:30:05 +02:00
jQuery( function ( $ ) {
2019-11-15 23:26:29 +01:00
if (
wp &&
wp.data &&
wp.data.select &&
! wp.data.select( 'core/edit-post' ).isFeatureActive( 'fullscreenMode' )
) {
wp.data.dispatch( 'core/edit-post' ).toggleFeature( 'fullscreenMode' );
}
2020-09-15 14:30:05 +02:00
var editPostHeaderInception = setInterval( function () {
2020-05-06 17:20:49 +02:00
// Legacy selector for Gutenberg plugin < v7.7
var legacyButton = $( '.edit-post-fullscreen-mode-close__toolbar a' );
// Updated selector for Gutenberg plugin => v7.7
var newButton = $( '.edit-post-header .edit-post-fullscreen-mode-close' );
var hasLegacyButton = legacyButton && legacyButton.length;
var hasNewButton = newButton && newButton.length;
// Keep trying until we find one of the close buttons.
if ( ! ( hasLegacyButton || hasNewButton ) ) {
2019-11-15 23:26:29 +01:00
return;
}
clearInterval( editPostHeaderInception );
2020-05-06 17:20:49 +02:00
var theButton = legacyButton;
if ( hasNewButton ) {
theButton = newButton;
}
theButton.attr( 'href', calypsoifyGutenberg.closeUrl );
2019-11-15 23:26:29 +01:00
} );
2020-09-15 14:30:05 +02:00
$( 'body.revision-php a' ).each( function () {
2019-11-15 23:26:29 +01:00
var href = $( this ).attr( 'href' );
$( this ).attr( 'href', href.replace( '&classic-editor', '' ) );
} );
} );