diff options
author | Dan Finlay <542863+danfinlay@users.noreply.github.com> | 2018-04-25 00:51:18 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-25 00:51:18 +0800 |
commit | ac334d7b1a9cd8b6888f5c4f3309740d5df62474 (patch) | |
tree | 7498f29e899821d879b3f68a42b8995f42f80321 /app/scripts/lib/notification-manager.js | |
parent | 66ae4a948abbebdb513f9bd60d47fda36095e8df (diff) | |
parent | 0fbd389a509a2447d833192bbe854c586890d512 (diff) | |
download | tangerine-wallet-browser-ac334d7b1a9cd8b6888f5c4f3309740d5df62474.tar.gz tangerine-wallet-browser-ac334d7b1a9cd8b6888f5c4f3309740d5df62474.tar.zst tangerine-wallet-browser-ac334d7b1a9cd8b6888f5c4f3309740d5df62474.zip |
Merge pull request #4040 from MetaMask/dm-docs-2
Even more documentation for various controllers and libs.
Diffstat (limited to 'app/scripts/lib/notification-manager.js')
-rw-r--r-- | app/scripts/lib/notification-manager.js | 44 |
1 files changed, 37 insertions, 7 deletions
diff --git a/app/scripts/lib/notification-manager.js b/app/scripts/lib/notification-manager.js index 1fcb7cf69..5dfb42078 100644 --- a/app/scripts/lib/notification-manager.js +++ b/app/scripts/lib/notification-manager.js @@ -5,10 +5,18 @@ const width = 360 class NotificationManager { - // - // Public - // + /** + * A collection of methods for controlling the showing and hiding of the notification popup. + * + * @typedef {Object} NotificationManager + * + */ + /** + * Either brings an existing MetaMask notification window into focus, or creates a new notification window. New + * notification windows are given a 'popup' type. + * + */ showPopup () { this._getPopup((err, popup) => { if (err) throw err @@ -29,6 +37,10 @@ class NotificationManager { }) } + /** + * Closes a MetaMask notification if it window exists. + * + */ closePopup () { // closes notification popup this._getPopup((err, popup) => { @@ -38,10 +50,14 @@ class NotificationManager { }) } - // - // Private - // - + /** + * Checks all open MetaMask windows, and returns the first one it finds that is a notification window (i.e. has the + * type 'popup') + * + * @private + * @param {Function} cb A node style callback that to whcih the found notification window will be passed. + * + */ _getPopup (cb) { this._getWindows((err, windows) => { if (err) throw err @@ -49,6 +65,13 @@ class NotificationManager { }) } + /** + * Returns all open MetaMask windows. + * + * @private + * @param {Function} cb A node style callback that to which the windows will be passed. + * + */ _getWindows (cb) { // Ignore in test environment if (!extension.windows) { @@ -60,6 +83,13 @@ class NotificationManager { }) } + /** + * Given an array of windows, returns the first that has a 'popup' type, or null if no such window exists. + * + * @private + * @param {array} windows An array of objects containing data about the open MetaMask extension windows. + * + */ _getPopupIn (windows) { return windows ? windows.find((win) => { // Returns notification popup |