Skip to content

Commit

Permalink
refactor approach for redirecting on close modal
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoladj77 committed Jan 5, 2025
1 parent d07ba8e commit 458f2af
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
21 changes: 2 additions & 19 deletions core/common/assets/js/views/modal/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,8 @@ export default class extends Marionette.LayoutView {
onCloseModalClick() {
this._parent._parent._parent.hideModal();

if ( this.isFloatingButtonLibraryClose() ) {
$e.internal( 'document/save/set-is-modified', { status: false } );
window.location.href = elementor.config.admin_floating_button_admin_url;
}
}
const customEvent = new CustomEvent( 'core/modal/close' );

isFloatingButtonLibraryClose() {
return window.elementor && elementor.config?.admin_floating_button_admin_url &&
'floating-buttons' === elementor.config?.document?.type &&
(
this.$el
.closest( '.dialog-lightbox-widget-content' )
.find( '.elementor-template-library-template-floating_button' ).length ||
this.$el
.closest( '.dialog-lightbox-widget-content' )
.find( '#elementor-template-library-preview' ).length ||
this.$el
.closest( '.dialog-lightbox-widget-content' )
.find( '#elementor-template-library-templates-empty' ).length
);
window.dispatchEvent( customEvent );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ class FloatingButtonsLibraryModule extends elementorModules.editor.utils.Module
onElementorLoaded() {
this.component = $e.components.register( new Component( { manager: this } ) );
elementor.channels.editor.on( 'section:activated', this.hideAdvancedTab.bind( this ) );
window.addEventListener( 'core/modal/close', ( ) => {
if ( this.isFloatingButtonDocument() ) {
window.location.href = elementor.config.admin_floating_button_admin_url;
}
} );
}

hideAdvancedTab( sectionName, editor ) {
Expand Down

0 comments on commit 458f2af

Please sign in to comment.