Add wiki page edit shortcut

This commit is contained in:
Toks
2014-06-17 15:44:14 -04:00
parent dfb47199a0
commit beb3f1d542
2 changed files with 14 additions and 1 deletions

View File

@@ -6,6 +6,10 @@
if (Danbooru.meta("enable-auto-complete") === "true") {
this.initialize_autocomplete();
}
if (Danbooru.meta("enable-js-navigation") === "true") {
this.initialize_shortcuts();
}
}
}
@@ -44,6 +48,15 @@
$(field).data("uiAutocomplete")._renderItem = render_wiki_page;
});
}
Danbooru.WikiPage.initialize_shortcuts = function() {
if ($("#a-show").length) {
$(document).bind("keypress", "e", function(e) {
$("#wiki-page-edit-link")[0].click();
e.preventDefault();
});
}
}
})();
$(document).ready(function() {

View File

@@ -16,7 +16,7 @@
<% unless @wiki_page.new_record? %>
<li><%= link_to "History", wiki_page_versions_path(:search => {:wiki_page_id => @wiki_page.id}) %></li>
<% if CurrentUser.is_member? %>
<li><%= link_to "Edit", edit_wiki_page_path(@wiki_page) %></li>
<li><%= link_to "Edit", edit_wiki_page_path(@wiki_page), :id => "wiki-page-edit-link" %></li>
<% end %>
<% if CurrentUser.is_janitor? %>
<li><%= link_to "Delete", wiki_page_path(@wiki_page), :remote => true, :method => :delete, :data => {:confirm => "Are you sure you want to delete this wiki page?"} %></li>