From 92cec80b7317d11a58497619a9eb1aef87b50dca Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Sat, 26 Feb 2022 10:33:11 +0100 Subject: [PATCH] Improved plugin documentation --- dev/Knoin/AbstractViews.js | 11 +++++------ plugins/README.md | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/dev/Knoin/AbstractViews.js b/dev/Knoin/AbstractViews.js index 6c77911d3..568025aa7 100644 --- a/dev/Knoin/AbstractViews.js +++ b/dev/Knoin/AbstractViews.js @@ -60,7 +60,7 @@ export class AbstractViewPopup extends AbstractView this.keyScope.scope = name; this.modalVisible = ko.observable(false).extend({ rateLimit: 0 }); shortcuts.add('escape,close', '', name, () => { - if (this.modalVisible() && this.onClose()) { + if (this.modalVisible() && false !== this.onClose()) { this.closeCommand(); return false; } @@ -70,14 +70,13 @@ export class AbstractViewPopup extends AbstractView } // Happens when user hits Escape or Close key - onClose() { - return true; // false to prevent closing - } + // return false to prevent closing + onClose() {} /* onBeforeShow() {} // Happens before showModal() - onShow() {} // Happens after showModal() - afterShow() {} // Happens after showModal() animation transitionend + onShow() {} // Happens after showModal() + afterShow() {} // Happens after showModal() animation transitionend onHide() {} // Happens before animation transitionend afterHide() {} // Happens after animation transitionend diff --git a/plugins/README.md b/plugins/README.md index cf9090541..77dc6f107 100644 --- a/plugins/README.md +++ b/plugins/README.md @@ -17,6 +17,23 @@ JavaScript ```javascript class PluginPopupView extends rl.pluginPopupView { + // Happens when DOM is created + onBuild(dom) {} + + // Happens before showModal() + onBeforeShow(...params) {} + // Happens after showModal() + onShow(...params) {} + // Happens after showModal() animation transitionend + afterShow() {} + + // Happens when user hits Escape or Close key + // return false to prevent closing, use closeCommand() manually + onClose() {} + // Happens before animation transitionend + onHide() {} + // Happens after animation transitionend + afterHide() {} } PluginPopupView.showModal();