Skip to content

Commit

Permalink
Merge pull request #3001 from evazion/feat-unfav-hotkey
Browse files Browse the repository at this point in the history
/posts: add shift+F to unfavorite hotkey.
  • Loading branch information
r888888888 committed Apr 26, 2017
2 parents 6842056 + 59a179f commit 9f19e2b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
33 changes: 20 additions & 13 deletions app/assets/javascripts/posts.js
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions app/views/static/keyboard_shortcuts.html.erb
Expand Up @@ -29,6 +29,7 @@
<li><kbd class="key">a</kbd> Previous post</li>
<li><kbd class="key">d</kbd> Next post</li>
<li><kbd class="key">f</kbd> Favorite post</li>
<li><kbd class="key">shift</kbd>+<kbd class="key">f</kbd> Unfavorite post</li>
<li><kbd class="key">g</kbd> Add post to favorite group</li>
<li><kbd class="key">1</kbd>, <kbd class="key">2</kbd>, <kbd class="key">3</kbd>... Add post to favorite group #N</li>
<li><kbd class="key">r</kbd> Go to random post</li>
Expand Down

0 comments on commit 9f19e2b

Please sign in to comment.