Skip to content

Commit

Permalink
Revert "Attach original AJAX framework events to Snowboard in Backend (
Browse files Browse the repository at this point in the history
…#1235)"

This reverts commit 4ff066f.
  • Loading branch information
LukeTowers committed Nov 6, 2024
1 parent 4ff066f commit 695b0a4
Show file tree
Hide file tree
Showing 13 changed files with 15 additions and 60 deletions.
2 changes: 1 addition & 1 deletion modules/backend/assets/css/winter.css
Original file line number Diff line number Diff line change
Expand Up @@ -1103,4 +1103,4 @@ html.cssanimations .fancy-layout *:not(.nested-form)>.form-widget>.layout-row>.f
.flyout-toggle i{margin:7px 0 0 6px;display:inline-block}
.flyout-toggle:hover i{color:#fff}
body.flyout-visible{overflow:hidden}
body.flyout-visible .flyout-overlay{background-color:rgba(0,0,0,0.3)}
body.flyout-visible .flyout-overlay{background-color:rgba(0,0,0,0.3)}
44 changes: 0 additions & 44 deletions modules/backend/assets/ui/js/ajax/Handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,12 @@ import { delegate } from 'jquery-events-to-dom-events';
*
* Functions:
* - Adds the "render" jQuery event to Snowboard requests that widgets use to initialise.
* - Hooks into the main jQuery AJAX workflow events of the original AJAX framework (`ajaxPromise` at the beginning
* of an AJAX request, `ajaxDone`/`ajaxRedirected`/`ajaxFail` at the end of the beginning of an AJAX requests)
* and simulates comparable Snowboard events to allow Snowboard functionality that acts on AJAX events to
* to function in the Backend (Flash messages, loader bar)
* - Ensures the CSRF token is included in requests.
*
* @copyright 2021 Winter.
* @author Ben Thomson <git@alfreido.com>
*/
export default class Handler extends Snowboard.Singleton {
construct() {
this.requests = [];
}

/**
* Event listeners.
*
Expand Down Expand Up @@ -54,42 +46,6 @@ export default class Handler extends Snowboard.Singleton {

// Add "render" event for backwards compatibility
window.jQuery(document).trigger('render');

// Add global events for AJAX queries and route them to the Snowboard global events and
// necessary UI functionality
delegate('ajaxPromise', ['event', 'context']);
delegate('ajaxDone', ['event', 'context', 'data']);
delegate('ajaxRedirected', ['event']);
delegate('ajaxFail', ['event', 'context', 'textStatus']);

document.addEventListener('$ajaxPromise', (event) => {
this.requests[event.target] = Promise.withResolvers();
this.snowboard.globalEvent('ajaxStart', this.requests[event.target].promise, {
element: event.target,
options: {},
});
});
document.addEventListener('$ajaxDone', (event) => {
this.requests[event.target].resolve(event.detail.data);
this.snowboard.globalEvent('ajaxDone', event.detail.data, {
element: event.target,
options: {},
});
});
document.addEventListener('$ajaxRedirected', (event) => {
this.requests[event.target].resolve();
this.snowboard.globalEvent('ajaxDone', event.detail.data, {
element: event.target,
options: {},
});
});
document.addEventListener('$ajaxFail', (event) => {
this.requests[event.target].reject(event.detail.textStatus);
this.snowboard.globalEvent('ajaxDone', event.detail.data, {
element: event.target,
options: {},
});
});
}

/**
Expand Down
2 changes: 1 addition & 1 deletion modules/backend/assets/ui/js/build/backend.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions modules/backend/formwidgets/codeeditor/assets/js/build-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -540,4 +540,4 @@ case'undo-resizing':this.undoResizing()
break}}
MediaManagerImageCropPopup.prototype.onSelectionChanged=function(c){this.updateSelectionSizeLabel(c.w,c.h)}
MediaManagerImageCropPopup.DEFAULTS={alias:undefined,onDone:undefined}
$.wn.mediaManager.imageCropPopup=MediaManagerImageCropPopup}(window.jQuery);
$.wn.mediaManager.imageCropPopup=MediaManagerImageCropPopup}(window.jQuery);
2 changes: 1 addition & 1 deletion modules/system/assets/js/build/system.debug.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion modules/system/assets/js/build/system.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions modules/system/assets/js/framework.combined-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

2 comments on commit 695b0a4

@LukeTowers
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Further work is required on this as it was causing the stripe loading indicator to be displayed twice on the Plugin Install page: https://winter.test/backend/system/updates/install

On a side note @bennothommo why does the snowboard event system not actually pass the event object itself to the listeners?

@bennothommo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LukeTowers there's no "event" object so to speak for Snowboard. An event is simply a trigger for a repository of callbacks or listeners assigned by an event name. It was mainly just to keep things simple.

Please sign in to comment.