/posts: add shift+F to unfavorite hotkey.

This commit is contained in:
evazion
2017-04-25 01:50:14 -05:00
parent 13189e60b8
commit 59a179fa15
2 changed files with 21 additions and 13 deletions

View File

@@ -175,19 +175,8 @@
Danbooru.keydown("a", "prev_page", Danbooru.Post.nav_prev);
Danbooru.keydown("d", "next_page", Danbooru.Post.nav_next);
Danbooru.keydown("f", "favorite", function(e) {
if ($("#add-to-favorites").is(":visible")) {
$("#add-to-favorites").click();
} else {
if (Danbooru.meta("current-user-id") == "") {
Danbooru.notice("You must be logged in to favorite posts");
} else {
Danbooru.notice("You have already favorited this post");
}
}
e.preventDefault();
});
Danbooru.keydown("f", "favorite", Danbooru.Post.favorite);
Danbooru.keydown("shift+f", "unfavorite", Danbooru.Post.unfavorite);
}
}
@@ -537,6 +526,24 @@
});
}
Danbooru.Post.favorite = function (e) {
if ($("#add-to-favorites").is(":visible")) {
$("#add-to-favorites").click();
} else {
if (Danbooru.meta("current-user-id") == "") {
Danbooru.notice("You must be logged in to favorite posts");
} else {
Danbooru.notice("You have already favorited this post");
}
}
};
Danbooru.Post.unfavorite = function (e) {
$.ajax("/favorites/" + Danbooru.meta("post-id") + ".js", {
type: "DELETE"
});
};
Danbooru.Post.initialize_saved_searches = function() {
$("#saved_search_labels").autocomplete({
minLength: 2,