posts: make thumbnail size setting persistent.
Make setting the thumbnail size persistent. The setting is stored in a `post_preview_size` cookie. This cookie can be overridden by the `size` URL param, like so: https://danbooru.donmai.us/posts?tags=touhou&size=180 The `size` param is mainly for testing different sizes without setting a cookie.
This commit is contained in:
@@ -25,6 +25,7 @@ Post.initialize_all = function() {
|
||||
if ($("#c-posts").length && $("#a-index").length) {
|
||||
this.initialize_excerpt();
|
||||
this.initialize_gestures();
|
||||
this.initialize_post_preview_size_menu();
|
||||
}
|
||||
|
||||
if ($("#c-posts").length && $("#a-show").length) {
|
||||
@@ -241,6 +242,19 @@ Post.toggle_relationship_preview = function(preview, preview_link) {
|
||||
}
|
||||
}
|
||||
|
||||
Post.initialize_post_preview_size_menu = function() {
|
||||
$(document).on("click.danbooru", ".post-preview-size-menu .popup-menu-content a", (e) => {
|
||||
let url = new URL($(e.target).get(0).href);
|
||||
let size = url.searchParams.get("size");
|
||||
|
||||
Cookie.put("post_preview_size", size);
|
||||
url.searchParams.delete("size");
|
||||
location.replace(url);
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
}
|
||||
|
||||
Post.view_original = function(e = null) {
|
||||
if (Utility.test_max_width(660)) {
|
||||
// Do the default behavior (navigate to image)
|
||||
|
||||
Reference in New Issue
Block a user