Rename badge setting to desktopNotifications
Also checks the browser status and display a warning message if it blocks desktop notifications
This commit is contained in:
parent
d03d5b7957
commit
bf9e50083b
@ -1109,6 +1109,11 @@ button,
|
|||||||
color: #2ecc40;
|
color: #2ecc40;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#settings .error {
|
||||||
|
color: #e74c3c;
|
||||||
|
margin-top: .2em;
|
||||||
|
}
|
||||||
|
|
||||||
#form {
|
#form {
|
||||||
background: #eee;
|
background: #eee;
|
||||||
border-top: 1px solid #ddd;
|
border-top: 1px solid #ddd;
|
||||||
|
@ -243,8 +243,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-sm-12">
|
<div class="col-sm-12">
|
||||||
<label class="opt">
|
<label class="opt">
|
||||||
<input id="badge" type="checkbox" name="badge">
|
<input id="desktopNotifications" type="checkbox" name="desktopNotifications">
|
||||||
Enable badge
|
Enable desktop notifications<br>
|
||||||
|
<div class="error" id="warnDisabledDesktopNotifications"><strong>Warning</strong>: Desktop notifications are blocked by your web browser</div>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-12">
|
<div class="col-sm-12">
|
||||||
|
@ -427,7 +427,7 @@ $(function() {
|
|||||||
var userStyles = $("#user-specified-css");
|
var userStyles = $("#user-specified-css");
|
||||||
var settings = $("#settings");
|
var settings = $("#settings");
|
||||||
var options = $.extend({
|
var options = $.extend({
|
||||||
badge: false,
|
desktopNotifications: false,
|
||||||
colors: false,
|
colors: false,
|
||||||
join: true,
|
join: true,
|
||||||
links: true,
|
links: true,
|
||||||
@ -487,11 +487,11 @@ $(function() {
|
|||||||
}).find("input")
|
}).find("input")
|
||||||
.trigger("change");
|
.trigger("change");
|
||||||
|
|
||||||
$("#badge").on("change", function() {
|
$("#desktopNotifications").on("change", function() {
|
||||||
var self = $(this);
|
var self = $(this);
|
||||||
if (self.prop("checked")) {
|
if (self.prop("checked")) {
|
||||||
if (Notification.permission !== "granted") {
|
if (Notification.permission !== "granted") {
|
||||||
Notification.requestPermission();
|
Notification.requestPermission(updateDesktopNotificationStatus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -689,7 +689,7 @@ $(function() {
|
|||||||
}
|
}
|
||||||
toggleFaviconNotification(true);
|
toggleFaviconNotification(true);
|
||||||
|
|
||||||
if (options.badge && Notification.permission === "granted") {
|
if (options.desktopNotifications && Notification.permission === "granted") {
|
||||||
var title;
|
var title;
|
||||||
var body;
|
var body;
|
||||||
|
|
||||||
@ -792,6 +792,8 @@ $(function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
windows.on("show", "#settings", updateDesktopNotificationStatus);
|
||||||
|
|
||||||
forms.on("submit", "form", function(e) {
|
forms.on("submit", "form", function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var event = "auth";
|
var event = "auth";
|
||||||
@ -918,6 +920,23 @@ $(function() {
|
|||||||
location.reload();
|
location.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateDesktopNotificationStatus(){
|
||||||
|
var checkbox = $("#desktopNotifications");
|
||||||
|
var warning = $("#warnDisabledDesktopNotifications");
|
||||||
|
|
||||||
|
if (Notification.permission === "denied"){
|
||||||
|
checkbox.attr("disabled", true);
|
||||||
|
checkbox.attr("checked", false);
|
||||||
|
warning.show();
|
||||||
|
} else {
|
||||||
|
if (Notification.permission === "default" && checkbox.prop("checked")){
|
||||||
|
checkbox.attr("checked", false);
|
||||||
|
}
|
||||||
|
checkbox.attr("disabled", false);
|
||||||
|
warning.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function sortable() {
|
function sortable() {
|
||||||
sidebar.sortable({
|
sidebar.sortable({
|
||||||
axis: "y",
|
axis: "y",
|
||||||
|
Loading…
Reference in New Issue
Block a user