Extend example extension code with more details

This commit is contained in:
the-djmaze 2023-11-27 01:51:23 +01:00
parent 5e2d9c4fb0
commit 7135af995d
6 changed files with 122 additions and 12 deletions

View file

@ -160,7 +160,7 @@ const
*/
screenOnRoute = (screenName, subPart) => {
screenName = screenName || defaultScreenName;
if (screenName && fireEvent('sm-show-screen', screenName, 1)) {
if (screenName && fireEvent('sm-show-screen', screenName + (subPart ? '/' + subPart : ''), 1)) {
// Close all popups
for (let vm of visiblePopups) {
(false === vm.onClose()) || vm.close();

View file

@ -408,14 +408,34 @@ and called in JavaScript using rl.pluginRemoteRequest().
### mailbox.inbox-unread-count
### mailbox.message-list.selector.go-up
### mailbox.message-list.selector.go-down
### mailbox.message.show
Use to show a specific message.
``` JavaScript
dispatchEvent(
new CustomEvent(
'mailbox.message.show',
{
detail: {
folder: 'INBOX',
uid: 1
},
cancelable: false
}
)
);
```
## audio
### audio.start
### audio.stop
### audio.api.stop
## Misc
### idle
### rl-layout
event.detail value is one of:
0. NoPreview
1. SidePreview
2. BottomPreview
### rl-view-model.create
event.detail = the ViewModel class

View file

@ -1,22 +1,108 @@
(rl => {
addEventListener('rl-view-model', e => {
/**
* Happens immediately after the ViewModel constructor
* event.detail contains the ViewModel class
*/
addEventListener('rl-view-model.create', event => {
console.dir({
'rl-view-model': e.detail
'rl-view-model.create': event.detail
});
});
/**
* e.detail value is one of:
* Happens after the full build (vm.onBuild()) and contains viewModelDom
* event.detail contains the ViewModel class
*/
addEventListener('rl-view-model', event => {
console.dir({
'rl-view-model': event.detail
});
});
/**
* event.detail value is one of:
* 0 = NoPreview
* 1 = SidePreview
* 2 = BottomPreview
*/
addEventListener('rl-layout', e => {
addEventListener('rl-layout', event => {
console.dir({
'rl-layout': e.detail
'rl-layout': event.detail
});
});
/**
* event.detail contains the FormData
* cancelable using event.preventDefault()
*/
addEventListener('sm-admin-login', event => {
console.dir({
'sm-admin-login': event.detail
});
});
/**
* event.detail contains { error: int, data: {JSON response} }
*/
addEventListener('sm-admin-login-response', event => {
console.dir({
'sm-admin-login-response': event.detail
});
});
/**
* event.detail contains the FormData
* cancelable using event.preventDefault()
*/
addEventListener('sm-user-login', event => {
console.dir({
'sm-user-login': event.detail
});
});
/**
* event.detail contains { error: int, data: {JSON response} }
*/
addEventListener('sm-user-login-response', event => {
console.dir({
'sm-user-login-response': event.detail
});
});
/**
* event.detail contains the screenname
* cancelable using event.preventDefault()
* Options are:
* - login (user or admin login screen)
* - mailbox (user folders and messages, also like: mailbox/INBOX/test, mailbox/Sent)
* - settings (user settings like: settings/accounts, settings/general, settings/filters)
* - one of the admin sections (like: settings, domains, branding)
*/
addEventListener('sm-show-screen', event => {
console.dir({
'sm-show-screen': event.detail
});
});
/**
* Use to show a specific message.
*/
/*
dispatchEvent(
new CustomEvent(
'mailbox.message.show',
{
detail: {
folder: 'INBOX',
uid: 1
},
cancelable: false
}
)
);
*/
class ExamplePopupView extends rl.pluginPopupView {
constructor() {
super('Example');
@ -50,6 +136,7 @@
afterHide() {}
}
ExamplePopupView.showModal(['param1', 'param2']);
/** Show the modal popup */
// ExamplePopupView.showModal(['param1', 'param2']);
})(window.rl);

View file

@ -37,6 +37,9 @@ class ExamplePlugin extends \RainLoop\Plugins\AbstractPlugin
$this->UseLangs(true); // start use langs folder
$this->addJs('example.js'); // add js file
$this->addJs('example.js', true); // add js file
// User Settings tab
$this->addJs('js/ExampleUserSettings.js'); // add js file
$this->addJsonHook('JsonGetExampleUserData', 'JsonGetExampleUserData');

View file

@ -8,9 +8,9 @@ class TwoFactorAuthPlugin extends \RainLoop\Plugins\AbstractPlugin
{
const
NAME = 'Two Factor Authentication',
VERSION = '2.16.6',
RELEASE = '2023-10-24',
REQUIRED = '2.15.2',
VERSION = '2.17.0',
RELEASE = '2023-11-27',
REQUIRED = '2.30.0',
CATEGORY = 'Login',
DESCRIPTION = 'Provides support for TOTP 2FA';

View file

@ -27,7 +27,7 @@
// https://github.com/the-djmaze/snappymail/issues/349
addEventListener('sm-show-screen', e => {
if ('settings' !== e.detail && rl.settings.get('SetupTwoFactor')) {
if (!e.detail.startsWith('settings') && rl.settings.get('SetupTwoFactor')) {
e.preventDefault();
forceTOTP();
}