Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 61 additions & 7 deletions assets/src/blocks/godam-gallery-v2/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -508,25 +508,39 @@
}

.godam-gallery-v2-modal {

/* Vertical room reserved above the iframe for the close button, which sits
* outside it (button height plus the gap beneath it) — mirrors the
* godam/video lightbox. Without it the iframe could take the full 86vh and
* push the button off screen. */
--godam-gallery-v2-close-gap: 54px;

position: fixed;
inset: 50% auto auto 50%;
transform: translate(-50%, -50%) scale(0.96);

/* Nudge down by half the reserved strip so the button-plus-iframe is centred
* as one unit, which keeps the button on screen at any viewport height. */
transform: translate(-50%, calc(-50% + var(--godam-gallery-v2-close-gap) / 2)) scale(0.96);
width: min(92vw, 960px);
height: min(86vh, 720px);
height: min(calc(86vh - var(--godam-gallery-v2-close-gap)), 720px);
background: #111;
border-radius: 16px;
overflow: hidden;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
opacity: 0;
visibility: hidden;
pointer-events: none;
transition: opacity 0.2s ease, transform 0.2s ease;
z-index: 999999;

/* dvh accounts for mobile browser chrome; vh above is the fallback. */
@supports (height: 86dvh) {
height: min(calc(86dvh - var(--godam-gallery-v2-close-gap)), 720px);
Comment thread
KMchaudhary marked this conversation as resolved.
Resolved
}

&.is-active {
opacity: 1;
visibility: visible;
transform: translate(-50%, -50%) scale(1);
transform: translate(-50%, calc(-50% + var(--godam-gallery-v2-close-gap) / 2)) scale(1);
pointer-events: auto;
}
}
Expand All @@ -536,13 +550,26 @@
width: 100%;
height: 100%;
border: 0;

/* The modal itself can no longer clip (the close button lives outside its
* top edge), so the iframe rounds its own corners. */
border-radius: inherit;
background: #111;
}

/* Sits above the iframe, aligned to its right edge — outside the video area so
* it can never collide with the player's own transcript / share buttons, which
* live in the top-right corner of the video. Same placement as the
* godam/video lightbox close button. */
.godam-gallery-v2-modal__close {
position: fixed;
top: max(24px, env(safe-area-inset-top, 0px) + 16px);
right: max(24px, env(safe-area-inset-right, 0px) + 16px);
position: absolute;
bottom: calc(100% + 10px);

/* Aligned to the iframe's right edge, except on a notched device held in
* landscape: there the cutout can reach past the modal's own side margin
* (at least 4vw, since the modal is min(92vw, 960px) wide), so pull the
* button inward by whatever the margin does not already clear. */
right: max(0px, env(safe-area-inset-right, 0px) - 4vw);
display: inline-flex;
align-items: center;
justify-content: center;
Expand Down Expand Up @@ -644,9 +671,36 @@ body.godam-gallery-v2-modal-open {
}

.godam-gallery-v2-modal {

/* Full-screen modal: nothing to reserve above the iframe. The unit is
* required — a unitless 0 would make the `calc()` that mixes it with a
* percentage invalid, dropping the centring transform. */
/* stylelint-disable-next-line length-zero-no-unit */
--godam-gallery-v2-close-gap: 0px;

width: 100vw;
height: 100vh;
border-radius: 0;

/* dvh keeps the full-screen modal — and so the close button, its only
* exit control — clear of the mobile browser chrome that 100vh sits
* behind. vh above is the fallback. */
@supports (height: 100dvh) {
height: 100dvh;
}
}

/* No room above a full-screen iframe, so the button stays overlaid on it as
* before — just moved to the left, clear of the player's transcript / share
* buttons in the top-right corner. (`absolute` rather than the old `fixed`:
* the modal's transform makes it the containing block for both, so the two
* resolve identically here, and `absolute` says so plainly.) */
.godam-gallery-v2-modal__close {
position: absolute;
top: max(24px, env(safe-area-inset-top, 0px) + 16px);
right: auto;
bottom: auto;
left: max(24px, env(safe-area-inset-left, 0px) + 16px);
}

.godam-gallery-v2-modal__nav--prev {
Expand Down
42 changes: 29 additions & 13 deletions assets/src/blocks/godam-player/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ function VideoEdit( {
playerHeight,
showShareButton,
showTranscription,
showInLightbox,
} = attributes;
const [ temporaryURL, setTemporaryURL ] = useState( attributes.blob );
const [ defaultPoster, setDefaultPoster ] = useState( '' );
Expand Down Expand Up @@ -429,22 +430,26 @@ function VideoEdit( {
}
}, [ id, src, attributes.seo, isVideoSelecting, setAttributes ] );

// When autoplay is enabled, hoverSelect is incompatible — reset it to 'none'.
// Only apply this when autoplay is toggled on after mount so older content
// hoverSelect is incompatible with both autoplay and "Show in lightbox" (the
// lightbox poster shows nothing but the play icon) — reset it to 'none'.
// Only apply this when one of them is toggled on after mount so older content
// is not rewritten as a side effect of opening the editor.
const previousAutoplayRef = useRef( autoplay );
const previousHoverBlockersRef = useRef( { autoplay, showInLightbox } );

useEffect( () => {
const previousAutoplay = previousAutoplayRef.current;
if ( previousAutoplay === autoplay ) {
const previous = previousHoverBlockersRef.current;
if ( previous.autoplay === autoplay && previous.showInLightbox === showInLightbox ) {
return;
}
previousAutoplayRef.current = autoplay;
previousHoverBlockersRef.current = { autoplay, showInLightbox };

if ( autoplay && attributes.hoverSelect !== 'none' ) {
const turnedOn = ( ! previous.autoplay && autoplay ) ||
( ! previous.showInLightbox && showInLightbox );

if ( turnedOn && attributes.hoverSelect !== 'none' ) {
setAttributes( { hoverSelect: 'none' } );
}
}, [ autoplay ] ); // eslint-disable-line react-hooks/exhaustive-deps
}, [ autoplay, showInLightbox ] ); // eslint-disable-line react-hooks/exhaustive-deps

// Keep overridden SEO thumbnail synced with block poster.
useEffect( () => {
Expand Down Expand Up @@ -843,6 +848,19 @@ function VideoEdit( {
</>
);

// Autoplay plays the video where it stands and the lightbox turns it into a
// click-to-open poster; either way hovering has nothing left to do. Mirrors
// the frontend guard in inc/templates/godam-player.php.
const hoverOptionsLockedReason = ( () => {
if ( autoplay ) {
return __( 'Hover option is disabled when autoplay is on.', 'godam' );
}
if ( showInLightbox ) {
return __( 'Hover option is disabled when the video opens in a lightbox.', 'godam' );
}
return null;
} )();

const hoverOptionsPanelContent = (
<ToggleGroupControl
__nextHasNoMarginBottom
Expand All @@ -851,9 +869,7 @@ function VideoEdit( {
data-test-id="godam-video-control-hover-select"
value={ attributes.hoverSelect || 'none' }
onChange={ ( value ) => setAttributes( { hoverSelect: value ?? 'none' } ) }
help={ autoplay
? __( 'Hover option is disabled when autoplay is on.', 'godam' )
: __( 'Choose the action to perform on video hover.', 'godam' ) }
help={ hoverOptionsLockedReason ?? __( 'Choose the action to perform on video hover.', 'godam' ) }
>
<ToggleGroupControlOption value="show-player-controls" label={ __( 'Show player', 'godam' ) } />
<ToggleGroupControlOption value="start-preview" label={ __( 'Start Preview', 'godam' ) } />
Expand Down Expand Up @@ -1042,8 +1058,8 @@ function VideoEdit( {
) }
{ ! isInsideQueryLoop && (
<PanelBody title={ __( 'Hover Options', 'godam' ) } data-test-id="godam-video-panel-hover-options">
{ /* Hover Options are disabled when autoplay is enabled or API key is invalid */ }
{ ( ! window.pluginInfo?.validApiKey || autoplay )
{ /* Hover Options are disabled when autoplay or "Show in lightbox" is enabled, or the API key is invalid */ }
{ ( ! window.pluginInfo?.validApiKey || hoverOptionsLockedReason )
? <div className="godam-components-disabled"><Disabled>{ hoverOptionsPanelContent }</Disabled></div>
: hoverOptionsPanelContent
}
Expand Down
11 changes: 7 additions & 4 deletions assets/src/css/admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1129,10 +1129,13 @@ to ensure proper responsiveness and avoid layout issues.
}
}

// Visual "disabled" state for Elementor controls that are locked while
// autoplay is on (Muted + Hover Option). Mirrors the block's disabled
// SelectControl: visible, low-contrast, non-interactive.
.elementor-control.godam-elementor-autoplay-locked.godam-control-is-disabled {
// Visual "disabled" state for Elementor controls another setting has taken over
// — autoplay locks Muted + Hover Option, "Show in lightbox" locks Hover Option.
// editor.js decides which lock owns which control and adds
// `godam-control-is-disabled`. Mirrors the block's disabled SelectControl:
// visible, low-contrast, non-interactive.
.elementor-control.godam-elementor-autoplay-locked.godam-control-is-disabled,
.elementor-control.godam-elementor-lightbox-locked.godam-control-is-disabled {
opacity: 0.5;
pointer-events: none;

Expand Down
40 changes: 40 additions & 0 deletions assets/src/css/godam-player.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2523,6 +2523,46 @@ body.godam-share-modal-open {
cursor: pointer;
}

/* Closed state: the inline player is a click-to-open poster, so it shows the
* play icon and nothing else. `godam-lightbox-open` is added by modalManager.js
* while this player is the one inside the modal — that is where the real
* controls belong.
*
* `!important` is only needed to out-rank Video.js's own
* `.vjs-has-started .vjs-control-bar` and the hover-to-reveal rules earlier in
* this file. The rule is deliberately subtractive — nothing here ever re-shows
* the bar — so `.vjs-controls-disabled` / `.vjs-error` keep their own behaviour
* inside the lightbox. */
.godam-video-wrapper.godam-show-in-lightbox:not(.godam-lightbox-open) {

/* stylelint-disable-next-line no-descending-specificity -- closed-state override of the earlier control-bar/button rules; it only removes them from the poster. */
.vjs-control-bar,
.vjs-button.godam-share-button,
.vjs-button.godam-transcript-button,
.godam-transcript-panel {
display: none !important;
}

/* A CTA, hotspot or form layer shown at the timestamp the viewer closed on
* would otherwise stay overlaid on the poster. Only the display is suppressed,
* so the layer's own state survives and it comes back on reopening. */
.easydam-layer {
display: none !important;
}

/* The poster is a button, so it keeps its play icon even when Video.js has
* controls switched off — which also hides the big play button. That happens
* for a video rendered without playback controls, and temporarily whenever a
* form/CTA layer is on screen, since formLayerManager only switches controls
* back on when the layer is dismissed: closing mid-layer would otherwise leave
* a poster with no way in. An errored player keeps Video.js's own empty state.
* Matches `.custom-play-image` too — it replaces the button and inherits its
* classes (see controlsManager.setupCustomPlayButton). */
.video-js:not(.vjs-error) .vjs-big-play-button {
display: block !important;
}
}

/* Prevent the page from scrolling behind an open modal. */
body.godam-player-modal-open {
overflow: hidden;
Expand Down
36 changes: 26 additions & 10 deletions assets/src/js/elementor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ import apiFetch from '@wordpress/api-fetch';
*/
import './controls/godam-media';

/**
* Controls that another setting can take over, flagged server-side by the widget.
*
* @type {string}
*/
const LOCKED_CONTROL_SELECTOR = '.elementor-control.godam-elementor-autoplay-locked, .elementor-control.godam-elementor-lightbox-locked';

/**
* Make specific SEO fields read-only in the GoDAM Video widget.
*/
Expand Down Expand Up @@ -321,20 +328,29 @@ function onSettingsChange( changedModel ) {
// Selection ring follows the poster, even when the user uploads via
// the godam-media tile above the grid.
scheduleThumbnailPickerRender();
} else if ( keys.indexOf( 'autoplay' ) !== -1 ) {
applyAutoplayLock( !! changed.autoplay && 'yes' === changed.autoplay );
} else if ( keys.indexOf( 'autoplay' ) !== -1 || keys.indexOf( 'show_in_lightbox' ) !== -1 ) {
applyControlLocks( changedModel );
}
}

/**
* Toggle a visual "disabled" state on controls flagged with the
* `godam-elementor-autoplay-locked` class (Muted + Hover Option), mirroring
* the block which disables them when Autoplay is on.
* Toggle a visual "disabled" state on controls another setting has taken over.
*
* Two independent locks, so each control is matched against the one that owns it
* rather than a single flag: Autoplay locks Muted + Hover Option, and "Show in
* lightbox" locks Hover Option (its inline render is a click-to-open poster, so
* there is nothing left to hover). Mirrors the block, which disables these
* controls rather than hiding them.
*
* @param {boolean} locked Whether autoplay is currently on.
* @param {Object} settings Backbone settings model of the widget.
*/
function applyAutoplayLock( locked ) {
document.querySelectorAll( '.elementor-control.godam-elementor-autoplay-locked' ).forEach( ( el ) => {
function applyControlLocks( settings ) {
const autoplayOn = 'yes' === settings?.get?.( 'autoplay' );
const lightboxOn = 'yes' === settings?.get?.( 'show_in_lightbox' );

document.querySelectorAll( LOCKED_CONTROL_SELECTOR ).forEach( ( el ) => {
const locked = ( autoplayOn && el.classList.contains( 'godam-elementor-autoplay-locked' ) ) ||
( lightboxOn && el.classList.contains( 'godam-elementor-lightbox-locked' ) );
el.classList.toggle( 'godam-control-is-disabled', locked );
} );
}
Expand Down Expand Up @@ -387,8 +403,8 @@ function hydrateWidget( model, view, panel ) {
panel.currentPageView.on( 'render', scheduleThumbnailPickerRender );
}

// Autoplay-lock doesn't depend on the picker DOM, so apply it on a short delay.
setTimeout( () => applyAutoplayLock( 'yes' === settings.get( 'autoplay' ) ), 100 );
// The control locks don't depend on the picker DOM, so apply them on a short delay.
setTimeout( () => applyControlLocks( settings ), 100 );

// Render the picker once Elementor has mounted its (conditional) control.
scheduleThumbnailPickerRender();
Expand Down
Loading
Loading