Convert keyboard shortcuts to use data-shortcut.

This commit is contained in:
evazion
2018-08-11 16:39:45 -05:00
parent d369d38419
commit bbaadda1e3
25 changed files with 44 additions and 259 deletions

View File

@@ -1,5 +1,4 @@
import Utility from './utility'
import Post from './posts.js.erb'
let Shortcuts = {};
@@ -7,37 +6,6 @@ Shortcuts.initialize = function() {
Utility.keydown("s", "scroll_down", Shortcuts.nav_scroll_down);
Utility.keydown("w", "scroll_up", Shortcuts.nav_scroll_up);
Shortcuts.initialize_data_shortcuts();
Utility.keydown("q", "focus_search", function(e) {
$("#tags, #search_name, #search_name_matches, #query").trigger("focus").selectEnd();
e.preventDefault();
});
if ($("#image").length) { // post page or bookmarklet upload page
Utility.keydown("shift+e", "edit_dialog", function(e) {
if (Utility.meta("current-user-id") === "") { // anonymous
return;
}
if (!$("#edit-dialog").length) {
$("#edit").show();
$("#comments").hide();
$("#share").hide();
$("#post-sections li").removeClass("active");
$("#post-edit-link").parent("li").addClass("active");
$("#related-tags-container").show();
Post.open_edit_dialog();
}
e.preventDefault();
});
}
if ($("#c-posts #a-index, #c-favorites #a-index").length) {
Utility.keydown("r", "random", function(e) {
$("#random-post")[0].click();
});
}
}
// Bind keyboard shortcuts to links that have a `data-shortcut="..."` attribute. If multiple links have the