summaryrefslogtreecommitdiff
path: root/ext/js/app/popup-factory.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-10-31 21:45:57 -0400
committerGitHub <noreply@github.com>2021-10-31 21:45:57 -0400
commit2dc8394c72570d949fc129dea8d744ba04394e2d (patch)
tree8c9f6b9d2ab4909b948c0039882b4ff38042d2f0 /ext/js/app/popup-factory.js
parentf978819a3335cda7bc0e2414522cdf34f3dfa4e5 (diff)
JSDoc update (#1996)
* Update core.js docs to include types. * Update docs
Diffstat (limited to 'ext/js/app/popup-factory.js')
-rw-r--r--ext/js/app/popup-factory.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/ext/js/app/popup-factory.js b/ext/js/app/popup-factory.js
index 096d145e..05ab1942 100644
--- a/ext/js/app/popup-factory.js
+++ b/ext/js/app/popup-factory.js
@@ -22,7 +22,14 @@
* PopupWindow
*/
+/**
+ * A class which is used to generate and manage popups.
+ */
class PopupFactory {
+ /**
+ * Creates a new instance.
+ * @param {number} frameId The frame ID of the host frame.
+ */
constructor(frameId) {
this._frameId = frameId;
this._frameOffsetForwarder = new FrameOffsetForwarder(frameId);
@@ -32,6 +39,9 @@ class PopupFactory {
// Public functions
+ /**
+ * Prepares the instance for use.
+ */
prepare() {
this._frameOffsetForwarder.prepare();
yomichan.crossFrame.registerHandlers([
@@ -53,6 +63,16 @@ class PopupFactory {
]);
}
+ /**
+ * Gets or creates a popup based on a set of parameters
+ * @param {object} details
+ * @param {?number} [details.frameId] The ID of the frame that should host the popup.
+ * @param {?string} [details.id] A specific ID used to find an existing popup, or to assign to the new popup.
+ * @param {?string} [details.parentPopupId] The ID of the parent popup.
+ * @param {?number} [details.depth] A specific depth value to assign to the popup.
+ * @param {boolean} [details.popupWindow] Whether or not a separate popup window should be used, rather than an iframe.
+ * @param {boolean} [details.childrenSupported] Whether or not the popup is able to show child popups.
+ */
async getOrCreatePopup({
frameId=null,
id=null,
@@ -148,6 +168,13 @@ class PopupFactory {
}
}
+ /**
+ * Force all popups to have a specific visibility value.
+ * @param {boolean} value Whether or not the popups should be visible.
+ * @param {number} priority The priority of the override.
+ * @returns {string} A token which can be passed to clearAllVisibleOverride.
+ * @throws An exception is thrown if any popup fails to have its visibiltiy overridden.
+ */
async setAllVisibleOverride(value, priority) {
const promises = [];
const errors = [];
@@ -173,6 +200,11 @@ class PopupFactory {
throw errors[0];
}
+ /**
+ * Clears a visibility override that was generated by `setAllVisibleOverride`.
+ * @param {string} token The token returned from `setAllVisibleOverride`.
+ * @returns {boolean} `true` if the override existed and was removed, `false` otherwise.
+ */
async clearAllVisibleOverride(token) {
const results = this._allPopupVisibilityTokenMap.get(token);
if (typeof results === 'undefined') { return false; }