diff options
Diffstat (limited to 'ext/js/app/popup-factory.js')
-rw-r--r-- | ext/js/app/popup-factory.js | 32 |
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; } |