% if allow_tinymce?(controller) %>
<%= yield :tinymce %>
<% end %>
<% if Rails.env.test? %>
<% end %>
<%= javascript_include_tag "jquery.scrollTo.min", "jquery.livequery.min", "rails", "application", "bootstrap/bootstrap-dropdown.min", "jquery-shuffle", "jquery.tokeninput.min", "jquery.trap.min", "ao3modal.min", "js.cookie.min", skip_pipeline: true %>
<%= javascript_include_tag "filters.min", skip_pipeline: true %>
<% if allow_tinymce?(controller) %>
<%= yield :tinymce_init %>
<% end %>
<% unless Rails.env.test? || current_user.try(:accepted_tos_version) == @current_tos_version || tos_exempt_page? %>
<%= javascript_tag do %>
// We can't rely on !window.localStorage to test localStorage support in
// browsers like Safari 9, which technically support it, but which have a
// storage length of 0 in private mode.
// Credit: https://github.com/getgrav/grav-plugin-admin/commit/cfe2188f10c4ca604e03c96f3e21537fda1cdf9a
function isSupported() {
var item = "localStoragePolyfill";
try {
localStorage.setItem(item, item);
localStorage.removeItem(item);
return true;
} catch (e) {
return false;
}
}
function acceptTOS() {
if (isSupported()) {
localStorage.setItem("accepted_tos", "<%= @current_tos_version %>");
} else {
Cookies.set("accepted_tos", "<%= @current_tos_version %>", { expires: 365 });
}
}
$j(document).ready(function() {
<% if current_user %>
<%# Users who haven't accepted this TOS need the popup. %>
$j("body").prepend("<%= escape_javascript(render "layouts/tos_prompt") %>");
<% elsif params[:tos] == "yes" %>
<%# Guests can bypass the popup using ?tos=yes in the URLs. %>
acceptTOS();
<% else %>
<%# Otherwise, guests who don't have the localStorage item or the
cookie need the popup.
We have to use JavaScript to remember their choice or risk issues
when full page caching is enabled. %>
if (localStorage.getItem("accepted_tos") !== "<%= @current_tos_version %>" && Cookies.get("accepted_tos") !== "<%= @current_tos_version %>") {
$j("body").prepend("<%= escape_javascript(render "layouts/tos_prompt") %>");
}
<% end %>
});
<% end %>
<% end %>
<% # Renders layouts/proxy_notice below skip links in layouts/application. %>
<% if %w(staging production).include?(Rails.env) %>
<%= javascript_tag do %>
$j(document).ready(function() {
var permitted_hosts = <%= ArchiveConfig.PERMITTED_HOSTS.to_json.html_safe %>;
var current_host = window.location.hostname;
if (!permitted_hosts.includes(current_host) && Cookies.get("proxy_notice") !== "0" && window.location.protocol !== "file:") {
$j("#skiplinks").after("<%= escape_javascript(render "layouts/proxy_notice") %>");
}
});
<% end %>
<% end %>
<%= yield :footer_js %>