summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNew Tobin Paradigm <email@mattatobin.com>2018-04-12 17:13:48 -0400
committerGitHub <noreply@github.com>2018-04-12 17:13:48 -0400
commit47354a0f29913df58a6c50fa8b34b1e817a368af (patch)
tree74f84dcfa34e534b331ebac354265f06ea5ff921
parent62ca5cf04a400282f896e1213c850dbe7a437e3b (diff)
parent1170e81edd38ec530d09fd6a3e76936657ff52ce (diff)
downloadUXP-47354a0f29913df58a6c50fa8b34b1e817a368af.tar
UXP-47354a0f29913df58a6c50fa8b34b1e817a368af.tar.gz
UXP-47354a0f29913df58a6c50fa8b34b1e817a368af.tar.lz
UXP-47354a0f29913df58a6c50fa8b34b1e817a368af.tar.xz
UXP-47354a0f29913df58a6c50fa8b34b1e817a368af.zip
Merge pull request #132 from janekptacijarabaci/notifications_settings_1
moebius#154: Notifications - user settings - the immediate duration of the alert
-rw-r--r--modules/libpref/init/all.js2
-rw-r--r--toolkit/components/alerts/resources/content/alert.css1
-rw-r--r--toolkit/components/alerts/resources/content/alert.js10
3 files changed, 10 insertions, 3 deletions
diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js
index 110f4384f..59f8de9ac 100644
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -4738,6 +4738,8 @@ pref("dom.webnotifications.requireinteraction.enabled", false);
// Alert animation effect, name is disableSlidingEffect for backwards-compat.
pref("alerts.disableSlidingEffect", false);
+// The immediate duration of the alert, in milliseconds.
+pref("alerts.durationImmediate", 20000);
// Show favicons in web notifications.
pref("alerts.showFavicons", false);
diff --git a/toolkit/components/alerts/resources/content/alert.css b/toolkit/components/alerts/resources/content/alert.css
index c4d94a543..81e5cdd35 100644
--- a/toolkit/components/alerts/resources/content/alert.css
+++ b/toolkit/components/alerts/resources/content/alert.css
@@ -3,7 +3,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#alertBox[animate] {
- animation-duration: 20s;
animation-fill-mode: both;
animation-name: alert-animation;
}
diff --git a/toolkit/components/alerts/resources/content/alert.js b/toolkit/components/alerts/resources/content/alert.js
index ead4d503f..ce60ab0fa 100644
--- a/toolkit/components/alerts/resources/content/alert.js
+++ b/toolkit/components/alerts/resources/content/alert.js
@@ -166,7 +166,12 @@ function prefillAlertInfo() {
}
function onAlertLoad() {
- const ALERT_DURATION_IMMEDIATE = 20000;
+ const ALERT_DURATION_IMMEDIATE_MIN = 4000;
+ const ALERT_DURATION_IMMEDIATE_MAX = 60000;
+ let alertDurationImmediate = Services.prefs.getIntPref("alerts.durationImmediate", ALERT_DURATION_IMMEDIATE_MIN);
+ alertDurationImmediate = alertDurationImmediate >= ALERT_DURATION_IMMEDIATE_MIN
+ && alertDurationImmediate <= ALERT_DURATION_IMMEDIATE_MAX
+ ? alertDurationImmediate : ALERT_DURATION_IMMEDIATE_MIN;
let alertTextBox = document.getElementById("alertTextBox");
let alertImageBox = document.getElementById("alertImageBox");
alertImageBox.style.minHeight = alertTextBox.scrollHeight + "px";
@@ -186,7 +191,7 @@ function onAlertLoad() {
// If the require interaction flag is set, prevent auto-closing the notification.
if (!gRequireInteraction) {
if (Services.prefs.getBoolPref("alerts.disableSlidingEffect")) {
- setTimeout(function() { window.close(); }, ALERT_DURATION_IMMEDIATE);
+ setTimeout(function() { window.close(); }, alertDurationImmediate);
} else {
let alertBox = document.getElementById("alertBox");
alertBox.addEventListener("animationend", function hideAlert(event) {
@@ -197,6 +202,7 @@ function onAlertLoad() {
window.close();
}
}, false);
+ alertBox.style.animationDuration = Math.round(alertDurationImmediate / 1000).toString() + "s";
alertBox.setAttribute("animate", true);
}
}