Display NSFW channel warning

This commit is contained in:
Jeremy Zhang
2018-01-28 00:43:06 +00:00
parent 7e8b673424
commit e6422b118d
4 changed files with 42 additions and 3 deletions

View File

@ -891,10 +891,14 @@ p.mentioned span.chatmessage {
width: 302px;
}
#logout_btn {
#logout_btn, #proceed_nsfw_btn {
background-color: red;
}
#nsfwmodal i {
color: yellow;
}
#message-spinner {
position: fixed;
top: 50%;

View File

@ -179,6 +179,12 @@
inDuration: 400,
outDuration: 400,
});
$("#nsfwmodal").modal({
dismissible: true,
opacity: .3,
inDuration: 400,
outDuration: 400,
});
$("#usercard").modal({
opacity: .5,
});
@ -225,6 +231,17 @@
}
});
$("#proceed_nsfw_btn").click(function () {
var channel_id = $("#proceed_nsfw_btn").attr("channel_id");
var should_animate = parseInt($("#proceed_nsfw_btn").attr("should_animate"));
$("#nsfwmodal").modal("close");
select_channel(channel_id, should_animate, true);
});
$("#dismiss_nsfw_btn").click(function () {
$("#nsfwmodal").modal("close");
});
$( "#theme-selector" ).change(function () {
var theme = $("#theme-selector option:selected").val();
var keep_custom_css = $("#overwrite_theme_custom_css_checkbox").is(':checked');
@ -793,15 +810,21 @@
element.css("opacity", opacity);
}
function select_channel(channel_id, animate_it) {
function select_channel(channel_id, animate_it, acknowledge_nsfw) {
if (selected_channel != channel_id && guild_channels[channel_id] && guild_channels[channel_id].read) {
if (guild_channels[channel_id].channel.nsfw && !acknowledge_nsfw) {
$("#proceed_nsfw_btn").attr("channel_id", channel_id);
$("#proceed_nsfw_btn").attr("should_animate", animate_it ? 1 : 0);
$("#nsfwmodal").modal("open");
return;
}
if (animate_it) {
$("#guild-btn").sideNav("show");
$("#channel-"+channel_id)[0].scrollIntoView({behavior: "smooth"});
flashElement($("#channel-"+channel_id));
setTimeout(function () {
$("#guild-btn").sideNav("hide");
select_channel(channel_id);
select_channel(channel_id, false, true);
}, 1000);
return;
}