Skip to content

Commit

Permalink
Add window.WDNPluginsExecuting variable to amd-disable.js to track Pl…
Browse files Browse the repository at this point in the history
…ugins currently executing
  • Loading branch information
ericras committed May 11, 2023
1 parent 96a2d54 commit 1b194a4
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions js/amd-disable.js
@@ -1,14 +1,23 @@
define.origAmd = define.amd;
delete define.amd;
window.WDNPluginsExecuting = 0;

/**
* Files that need to call WDN.initializePlugin() after this point can
* use define.origAmd to restore define.amd before calling and then revert
* in an "after" callback function. An example:
* in an "after" callback function.
*
* A count of currently executing plugins is kept in window.WDNPluginsExecuting
* since plugins run asynchronously.
*
* An example:
*
* function initEventsBand() {
* define.amd = define.origAmd;
* delete define.origAmd;
* if (define.amd === undefined) {
* define.amd = define.origAmd;
* delete define.origAmd;
* }
* window.WDNPluginsExecuting++;
*
* var json = $("script[data-selector-json=wdn-events-band-settings]")['0'].innerHTML;
* var json = JSON.parse(json);
Expand All @@ -21,8 +30,11 @@ delete define.amd;
* );
*
* function enableAMDcallback() {
* define.origAmd = define.amd;
* delete define.amd;
* window.WDNPluginsExecuting--;
* if (define.origAmd === undefined && window.WDNPluginsExecuting === 0) {
* define.origAmd = define.amd;
* delete define.amd;
* }
* }
* }
*/

0 comments on commit 1b194a4

Please sign in to comment.