-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
177 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
( ( $ ) => { | ||
const llmsAdminNotifications = window?.llmsAdminNotifications || {}; | ||
|
||
if ( ! llmsAdminNotifications ) { | ||
return; | ||
} | ||
|
||
if ( llmsAdminNotifications?.paused === 'true' ) { | ||
return; | ||
} | ||
|
||
$.post( | ||
llmsAdminNotifications.ajaxurl, | ||
{ | ||
'action': 'llms_show_notification', | ||
'nonce': llmsAdminNotifications.nonce, | ||
}, | ||
( response ) => { | ||
console.log(response); | ||
Check failure on line 19 in src/js/admin-notifications.js
|
||
|
||
if ( ! response?.success ) { | ||
return; | ||
} | ||
|
||
const data = response?.data ?? {}; | ||
|
||
if ( ! data ) { | ||
return; | ||
} | ||
|
||
let insideWrap = document.querySelectorAll( '.lifterlms-settings form > .llms-inside-wrap' )[0]; | ||
Check failure on line 31 in src/js/admin-notifications.js
|
||
|
||
if ( ! insideWrap ) { | ||
insideWrap = document.querySelectorAll( '.lifterlms-settings .llms-inside-wrap > *' )[0]; | ||
Check failure on line 34 in src/js/admin-notifications.js
|
||
} | ||
|
||
if ( ! insideWrap ) { | ||
return; | ||
} | ||
|
||
// Convert response to DOM element. | ||
const parser= new DOMParser(); | ||
const parsed = parser.parseFromString( data, 'text/html' ); | ||
const div= parsed.querySelector( 'div' ); | ||
|
||
if ( ! div ) { | ||
return; | ||
} | ||
|
||
insideWrap.parentNode.insertBefore( div, insideWrap ); | ||
|
||
const id = div.getAttribute( 'id' )?.replace( 'llms-notice-', '' ); | ||
|
||
const dismissButton = div.querySelector( '.notice-dismiss' ); | ||
|
||
if ( ! dismissButton ) { | ||
return; | ||
} | ||
|
||
dismissButton.addEventListener( | ||
'click', | ||
() => { | ||
$.post( | ||
llmsAdminNotifications.ajaxurl, | ||
{ | ||
'action': 'llms_dismiss_notification', | ||
'nonce': llmsAdminNotifications.nonce, | ||
'id': id, | ||
}, | ||
( response ) => { | ||
if ( response?.success ) { | ||
div.remove(); | ||
} | ||
} | ||
); | ||
} | ||
); | ||
} | ||
); | ||
} )( jQuery ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters