#1875: Add shift-e shortcut for opening dialog

Additionally, fit the textarea's size to its contents on open.
This commit is contained in:
Toks
2013-07-27 13:57:12 -04:00
parent 20f0ade4e0
commit eeb5c861e4
2 changed files with 21 additions and 6 deletions

View File

@@ -40,7 +40,11 @@
}
Danbooru.Post.initialize_edit_dialog = function(e) {
$("#open-edit-dialog").button().show().click(this.open_edit_dialog);
$("#open-edit-dialog").button().show().click(function(e) {
$(window).scrollTop($("#image").offset().top);
Danbooru.Post.open_edit_dialog();
e.preventDefault();
});
$("#toggle-related-tags-link").click(function(e) {
if ($("#related-tags").is(":visible")) {
@@ -55,16 +59,13 @@
});
}
Danbooru.Post.open_edit_dialog = function(e) {
Danbooru.Post.open_edit_dialog = function() {
var $tag_string = $("#post_tag_string,#upload_tag_string");
$("div.input").has($tag_string).prevAll().hide();
$("#open-edit-dialog").hide();
$("#toggle-related-tags-link").show().click();
$tag_string.css({"resize": "none", "width": "100%"});
$(window).scrollTop($("#image").offset().top);
var dialog = $("<div/>").attr("id", "edit-dialog");
$("#form").appendTo(dialog);
dialog.dialog({
@@ -86,7 +87,8 @@
dialog.parent().css("opacity", 1);
});
e.preventDefault();
$tag_string.css({"resize": "none", "width": "100%"});
$tag_string.focus().selectEnd().height($tag_string[0].scrollHeight);
}
Danbooru.Post.close_edit_dialog = function(e, ui) {

View File

@@ -14,6 +14,19 @@
$("#tags, #search_name, #search_name_matches, #query").trigger("focus").selectEnd();
e.preventDefault();
});
if ($("#image").length) {
$(document).bind("keypress", "shift+e", function(e) {
if (!$("#edit-dialog").length) {
$("#edit").show();
$("#comments").hide();
$("#share").hide();
$("#related-tags-container").show();
Danbooru.Post.open_edit_dialog();
}
e.preventDefault();
});
}
}
Danbooru.Shortcuts.nav_scroll_down = function() {