app/views/users/settings.html.erb
<form name="settingsForm" action="/save_settings" method='post' data-remote="true" class="mx-3">
<div class="emailSettings">
<h4><b><%=translation('users.settings.email_notifications_title')%></b></h4>
<hr style="width: 35%; margin-left: 0;" />
<p class="notif-desc"><b><%=translation('users.settings.notified_by_email')%></b></p>
<div style="display: inline-flex; justify-content: space-between; width: 90%;">
<span><%=translation('users.settings.direct_comment')%> </span>
<span>
<label class="switch">
<p> Notification switch </p>
<input type="checkbox" name="notify-comment-direct:false" <% unless UserTag.exists?(current_user.id, 'notify-comment-direct:false') %>checked<% end %>>
<span class="slider round"></span>
</label>
</span>
</div>
<br />
<br />
<div style="display: inline-flex; justify-content: space-between; width: 90%;">
<span><%=translation('users.settings.direct_likes')%> </span>
<span>
<label class="switch">
<p> Notification switch </p>
<input type="checkbox" name="notify-likes-direct:false" <% unless UserTag.exists?(current_user.id, 'notify-likes-direct:false') %>checked<% end %>>
<span class="slider round"></span>
</label>
</span>
</div>
<br />
<br />
<div style="display: inline-flex; justify-content: space-between; width: 90%;">
<span><%=translation('users.settings.indirect_comment')%> </span>
<span>
<label class="switch">
<p> Notification switch </p>
<input type="checkbox" name="notify-comment-indirect:false" <% unless UserTag.exists?(current_user.id, 'notify-comment-indirect:false') %>checked<% end %>>
<span class="slider round"></span>
</label>
</span>
</div>
<br />
<br />
<% if logged_in_as(['admin', 'moderator']) %>
<div style="display: inline-flex; justify-content: space-between; width: 90%;">
<span>Moderation emails </span>
<span>
<label class="switch">
<p> Notification switch </p>
<input type="checkbox" name="no-moderation-emails" <% unless UserTag.exists?(current_user.id, 'no-moderation-emails') %>checked<% end %>>
<span class="slider round"></span>
</label>
</span>
</div>
<br />
<br />
<% end %>
<br />
<h5><b><%= translation('users.settings.email_digests')%> </b></h5>
<p class="notif-desc"><b><%= translation('users.settings.email_notifications')%> </b></p>
<div style="display: inline-flex; justify-content: space-between; width: 90%;">
<span><%=translation('users.settings.weekly_digest')%> </span>
<span>
<label style=" vertical-align: middle;" class="switch">
<p> Notification switch </p>
<input type="checkbox" name="digest:weekly" <% if UserTag.exists?(current_user.id, 'digest:weekly') %>checked<% end %>>
<span class="slider round"></span>
</label>
</span>
</div>
<br />
<br />
<div style="display: inline-flex; justify-content: space-between; width: 90%;">
<span><%=translation('users.settings.daily_digest')%> </span>
<span>
<label style=" vertical-align: middle;" class="switch">
<p> Notification switch </p>
<input type="checkbox" name="digest:daily" <% if UserTag.exists?(current_user.id, 'digest:daily') %>checked<% end %>>
<span class="slider round"></span>
</label>
</span>
</div>
<br />
<br />
<% if current_user.can_moderate? %>
<div style="display: inline-flex; justify-content: space-between; width: 90%;">
<span><%=translation('users.settings.spam_weekly_digest')%> </span>
<span>
<label style=" vertical-align: middle;" class="switch">
<p> Notification switch </p>
<input type="checkbox" name="digest:weekly:spam" <% if UserTag.exists?(current_user.id, 'digest:weekly:spam') %>checked<% end %>>
<span class="slider round"></span>
</label>
</span>
</div>
<br />
<br />
<div style="display: inline-flex; justify-content: space-between; width: 90%;">
<span><%=translation('users.settings.spam_daily_digest')%> </span>
<span>
<label style=" vertical-align: middle;" class="switch">
<p> Notification switch </p>
<input type="checkbox" name="digest:daily:spam" <% if UserTag.exists?(current_user.id, 'digest:daily:spam') %>checked<% end %>>
<span class="slider round"></span>
</label>
</span>
</div>
<br />
<br />
<% end %>
<br />
<h4><b>Browser Notifications</b></h4>
<hr style="width: 35%; margin-left: 0;" />
<p class="notif-desc"><b><%=translation('users.settings.browser_notifications')%> </b></p>
<div style="display: inline-flex; justify-content: space-between; width: 90%;">
<span><%=translation('users.settings.mentioned')%></span>
<span>
<label style=" vertical-align: middle;" class="switch">
<p> Notification switch </p>
<input type="checkbox" name="notifications:mentioned" <% if UserTag.exists?(current_user.id, 'notifications:mentioned') %>checked<% end %>>
<span class="slider round"></span>
</label>
</span>
</div>
<br />
<br />
<div style="display: inline-flex; justify-content: space-between; width: 90%;">
<span><%=translation('users.settings.everything')%></span>
<span>
<label style=" vertical-align: middle;" class="switch">
<p> Notification switch </p>
<input type="checkbox" name="notifications:all" <% if UserTag.exists?(current_user.id, 'notifications:all') %>checked<% end %>>
<span class="slider round"></span>
</label>
</span>
</div>
<br />
<br />
<div style="display: inline-flex; justify-content: space-between; width: 90%;">
<span><%=translation('users.settings.likes')%></span>
<span>
<label style=" vertical-align: middle;" class="switch">
<p> Notification switch </p>
<input type="checkbox" name="notifications:like" <% if UserTag.exists?(current_user.id, 'notifications:like') %>checked<% end %>>
<span class="slider round"></span>
</label>
</span>
</div>
<br />
<!-- <div style="display: inline-flex; justify-content: space-between; width: 90%;">-->
<!-- <span>Do you want to be notified by email for comments on all posts you have commented on</span>-->
<!-- <span>-->
<!-- <label style=" vertical-align: middle;" class="switch">-->
<!-- <input type="checkbox" checked>-->
<!-- <span class="slider round"></span>-->
<!-- </label>-->
<!-- </span>-->
<!-- </div>-->
<!-- <br />-->
<!-- <br />-->
<!-- <div style="display: inline-flex; justify-content: space-between; width: 90%;">-->
<!-- <span>Do you want to be notified by email for likes on your posts</span>-->
<!-- <span>-->
<!-- <label style=" vertical-align: middle;" class="switch">-->
<!-- <input type="checkbox" checked>-->
<!-- <span class="slider round"></span>-->
<!-- </label>-->
<!-- </span>-->
<!-- </div>-->
<!-- <br />-->
<!-- <br />-->
<!-- <div style="display: inline-flex; justify-content: space-between; width: 90%;">-->
<!-- <span>Do you want to be notified by email for notifications for wiki page edits</span>-->
<!-- <span>-->
<!-- <label style=" vertical-align: middle;" class="switch">-->
<!-- <input type="checkbox">-->
<!-- <span class="slider round"></span>-->
<!-- </label>-->
<!-- </span>-->
<!-- </div>-->
<!-- <br />-->
<!-- <br />-->
</div>
<br />
<br />
<div class="page-footer">
<button type="submit" class="btn btn-success" id="save">Save</button>
<a type="button" class="btn btn-outline-secondary" href="/dashboard"><%=translation('users.settings.cancel')%></a>
</div>
</form>
<style>
.switch {
position: relative;
display: inline-block;
width: 30px;
height: 17px;
margin-left: 90%;
vertical-align: middle;
margin-top: 0;
margin-bottom: 0;
margin-right: 0;
}
.switch input, .switch p {display:none;}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 13px;
width: 13px;
left: 2px;
bottom: 2px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}
input:checked + .slider {
background-color: #2196F3;
}
input:focus + .slider {
box-shadow: 0 0 1px #2196F3;
}
input:checked + .slider:before {
-webkit-transform: translateX(13px);
-ms-transform: translateX(13px);
transform: translateX(13px);
}
/* Rounded sliders */
.slider.round {
border-radius: 17px;
}
.slider.round:before {
border-radius: 50%;
}
.notif-desc {
font-size: 1.1rem;
}
</style>
<script>
$(document).ready(function() {
$('#save').prop('disabled', true);
$(':input[type="checkbox"]').change(function() {
$('#save').prop('disabled', false);
});
$(':input[name="digest:daily"]').change(function () {
if($(':input[name="digest:daily"]').prop('checked') === true){
$(':input[name="digest:weekly"]').prop('checked', false);
}
});
$(':input[name="digest:weekly"]').change(function () {
if($(':input[name="digest:weekly"]').prop('checked') === true){
$(':input[name="digest:daily"]').prop('checked', false);
}
});
$(':input[name="digest:daily:spam"]').change(function () {
if($(':input[name="digest:daily:spam"]').prop('checked') === true){
$(':input[name="digest:weekly:spam"]').prop('checked', false);
}
});
$(':input[name="digest:weekly:spam"]').change(function () {
if($(':input[name="digest:weekly:spam"]').prop('checked') === true){
$(':input[name="digest:daily:spam"]').prop('checked', false);
}
});
});
</script>