ep_desktop_notifications 11.0.22 → 11.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/desktop_notifications.js
CHANGED
|
@@ -1,20 +1,36 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const settings = require('ep_etherpad-lite/node/utils/Settings');
|
|
5
|
-
let checkedState = '';
|
|
3
|
+
const {padToggle} = require('ep_plugin_helpers/pad-toggle-server');
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
// Parallel User Settings + Pad Wide Settings checkboxes for "Desktop
|
|
6
|
+
// Notifications". Helper owns markup, storage, broadcast, enforce, and i18n.
|
|
7
|
+
const desktopToggle = padToggle({
|
|
8
|
+
pluginName: 'ep_desktop_notifications',
|
|
9
|
+
settingId: 'desktopNotifications',
|
|
10
|
+
l10nId: 'ep_desktop_notifications.desktopNotifications',
|
|
11
|
+
defaultLabel: 'Desktop Notifications',
|
|
12
|
+
defaultEnabled: true,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
// The previous version honored a top-level `ep_desktop_notifications_default`
|
|
16
|
+
// key with inverted semantics (truthy = default off). Translate to the
|
|
17
|
+
// helper's nested `defaultEnabled` so existing installs keep their behavior.
|
|
18
|
+
exports.loadSettings = async (hookName, args) => {
|
|
19
|
+
const root = args && args.settings;
|
|
20
|
+
if (root) {
|
|
21
|
+
const ps = (root.ep_desktop_notifications = root.ep_desktop_notifications || {});
|
|
22
|
+
if (typeof ps.defaultEnabled !== 'boolean' &&
|
|
23
|
+
typeof root.ep_desktop_notifications_default === 'boolean') {
|
|
24
|
+
ps.defaultEnabled = !root.ep_desktop_notifications_default;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return desktopToggle.loadSettings(hookName, args);
|
|
16
28
|
};
|
|
17
29
|
|
|
30
|
+
exports.clientVars = desktopToggle.clientVars;
|
|
31
|
+
exports.eejsBlock_mySettings = desktopToggle.eejsBlock_mySettings;
|
|
32
|
+
exports.eejsBlock_padSettings = desktopToggle.eejsBlock_padSettings;
|
|
33
|
+
|
|
18
34
|
exports.eejsBlock_styles = (hookName, args, cb) => {
|
|
19
35
|
const url = '../static/plugins/ep_desktop_notifications/static/css/desktop_notifications.css';
|
|
20
36
|
args.content += `<link href="${url}" rel='stylesheet'>`;
|
package/ep.json
CHANGED
|
@@ -2,12 +2,17 @@
|
|
|
2
2
|
"parts": [
|
|
3
3
|
{
|
|
4
4
|
"name": "ep_desktop_notifications",
|
|
5
|
+
"hooks": {
|
|
6
|
+
"loadSettings": "ep_desktop_notifications/desktop_notifications",
|
|
7
|
+
"clientVars": "ep_desktop_notifications/desktop_notifications",
|
|
8
|
+
"eejsBlock_mySettings": "ep_desktop_notifications/desktop_notifications",
|
|
9
|
+
"eejsBlock_padSettings": "ep_desktop_notifications/desktop_notifications",
|
|
10
|
+
"eejsBlock_styles": "ep_desktop_notifications/desktop_notifications"
|
|
11
|
+
},
|
|
5
12
|
"client_hooks": {
|
|
6
13
|
"postAceInit": "ep_desktop_notifications/static/js/desktop_notifications:postAceInit",
|
|
7
|
-
"chatNewMessage": "ep_desktop_notifications/static/js/desktop_notifications:chatNewMessage"
|
|
8
|
-
|
|
9
|
-
"hooks": {
|
|
10
|
-
"eejsBlock_mySettings": "ep_desktop_notifications/desktop_notifications"
|
|
14
|
+
"chatNewMessage": "ep_desktop_notifications/static/js/desktop_notifications:chatNewMessage",
|
|
15
|
+
"handleClientMessage_CLIENT_MESSAGE": "ep_desktop_notifications/static/js/desktop_notifications:handleClientMessage_CLIENT_MESSAGE"
|
|
11
16
|
}
|
|
12
17
|
}
|
|
13
18
|
]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ep_desktop_notifications",
|
|
3
|
-
"version": "11.0.
|
|
3
|
+
"version": "11.0.24",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"desktop",
|
|
6
6
|
"notifications",
|
|
@@ -34,5 +34,8 @@
|
|
|
34
34
|
"scripts": {
|
|
35
35
|
"lint": "eslint .",
|
|
36
36
|
"lint:fix": "eslint --fix ."
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"ep_plugin_helpers": "^0.5.2"
|
|
37
40
|
}
|
|
38
41
|
}
|
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/* global webkitNotifications */
|
|
3
3
|
|
|
4
|
+
// Sub-path import keeps the client bundle clean — the top-level
|
|
5
|
+
// `ep_plugin_helpers` index pulls in server-only modules.
|
|
6
|
+
const {padToggle} = require('ep_plugin_helpers/pad-toggle');
|
|
7
|
+
const padcookie = require('ep_etherpad-lite/static/js/pad_cookie').padcookie;
|
|
8
|
+
|
|
9
|
+
// Same config as the server-side instance — must agree on pluginName,
|
|
10
|
+
// settingId, l10nId, and defaultLabel so checkbox ids and clientVars line up.
|
|
11
|
+
const desktopToggle = padToggle({
|
|
12
|
+
pluginName: 'ep_desktop_notifications',
|
|
13
|
+
settingId: 'desktopNotifications',
|
|
14
|
+
l10nId: 'ep_desktop_notifications.desktopNotifications',
|
|
15
|
+
defaultLabel: 'Desktop Notifications',
|
|
16
|
+
defaultEnabled: true,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
// Re-export so the helper sees pad-wide broadcasts and refreshes our state
|
|
20
|
+
// when another user toggles the pad-wide checkbox.
|
|
21
|
+
exports.handleClientMessage_CLIENT_MESSAGE = desktopToggle.handleClientMessage_CLIENT_MESSAGE;
|
|
22
|
+
|
|
4
23
|
const DesktopNotifications = {
|
|
5
24
|
/* compatilibility layer */
|
|
6
25
|
notificationSupported: () => !!window.Notification || !!window.webkitNotifications,
|
|
@@ -108,29 +127,24 @@ const postAceInit = (hook, context) => {
|
|
|
108
127
|
DesktopNotifications.status = false;
|
|
109
128
|
DesktopNotifications.helpShown = false;
|
|
110
129
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
if ($optionsDesktopNotifications.is(':checked')) {
|
|
120
|
-
DesktopNotifications.handleNotificationPermission(
|
|
121
|
-
DesktopNotifications.notificationPermission()
|
|
122
|
-
);
|
|
123
|
-
} else {
|
|
124
|
-
DesktopNotifications.disable();
|
|
125
|
-
}
|
|
130
|
+
// The README documents `?DesktopNotifications=true|false` as a way to
|
|
131
|
+
// override the toggle. Now that the helper persists per-user state in
|
|
132
|
+
// padcookie, write the URL value into the cookie before init reads it
|
|
133
|
+
// — that way the override survives reload, matching the original intent.
|
|
134
|
+
const urlOverride = DesktopNotifications.getParam('DesktopNotifications');
|
|
135
|
+
if (urlOverride === 'true') padcookie.setPref('desktopNotifications', true);
|
|
136
|
+
else if (urlOverride === 'false') padcookie.setPref('desktopNotifications', false);
|
|
126
137
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
138
|
+
desktopToggle.init({
|
|
139
|
+
onChange: (enabled) => {
|
|
140
|
+
if (enabled) {
|
|
141
|
+
DesktopNotifications.handleNotificationPermission(
|
|
142
|
+
DesktopNotifications.notificationPermission()
|
|
143
|
+
);
|
|
144
|
+
} else {
|
|
145
|
+
DesktopNotifications.disable();
|
|
146
|
+
}
|
|
147
|
+
},
|
|
134
148
|
});
|
|
135
149
|
};
|
|
136
150
|
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
<p>
|
|
2
|
-
<input type="checkbox" data-l10n-id="ep_desktop_notifications.desktopNotifications" id="options-desktopNotifications" <%= checked %>></input>
|
|
3
|
-
<label for="options-desktopNotifications" data-l10n-id="ep_desktop_notifications.desktopNotifications" aria-label="Desktop Notifications">Desktop Notifications</label>
|
|
4
|
-
</p>
|