#1875: Add support for dialog when uploading

This commit is contained in:
Toks
2013-07-27 12:25:21 -04:00
parent e3ca0b26a7
commit f4864b42c6
3 changed files with 21 additions and 15 deletions

View File

@@ -28,16 +28,19 @@
this.initialize_post_image_resize_links(); this.initialize_post_image_resize_links();
this.initialize_post_image_resize_to_window_link(); this.initialize_post_image_resize_to_window_link();
this.initialize_similar(); this.initialize_similar();
this.initialize_edit_dialog();
if (Danbooru.meta("always-resize-images") === "true") { if (Danbooru.meta("always-resize-images") === "true") {
$("#image-resize-to-window-link").click(); $("#image-resize-to-window-link").click();
} }
} }
if ($("#image").length) {
this.initialize_edit_dialog();
}
} }
Danbooru.Post.initialize_edit_dialog = function(e) { Danbooru.Post.initialize_edit_dialog = function(e) {
$("#open-post-edit-dialog").button().click(this.open_edit_dialog); $("#open-edit-dialog").button().show().click(this.open_edit_dialog);
$("#toggle-related-tags-link").click(function(e) { $("#toggle-related-tags-link").click(function(e) {
if ($("#related-tags").is(":visible")) { if ($("#related-tags").is(":visible")) {
@@ -53,22 +56,23 @@
} }
Danbooru.Post.open_edit_dialog = function(e) { Danbooru.Post.open_edit_dialog = function(e) {
$("div.input:has(#post_tag_string)").prevAll().hide(); var $tag_string = $("#post_tag_string,#upload_tag_string");
$("#open-post-edit-dialog").hide(); $("div.input").has($tag_string).prevAll().hide();
$("#open-edit-dialog").hide();
$("#toggle-related-tags-link").show().click(); $("#toggle-related-tags-link").show().click();
$("#post_tag_string").css({"resize": "none", "width": "100%"}); $tag_string.css({"resize": "none", "width": "100%"});
$(window).scrollTop($("#image").offset().top); $(window).scrollTop($("#image").offset().top);
var dialog = $("<div/>").attr("id", "post-edit-dialog"); var dialog = $("<div/>").attr("id", "edit-dialog");
$("#form").appendTo(dialog); $("#form").appendTo(dialog);
dialog.dialog({ dialog.dialog({
title: "Edit", title: "Edit tags",
width: "auto", width: "auto",
drag: function(e, ui) { drag: function(e, ui) {
if (Danbooru.meta("enable-auto-complete") === "true") { if (Danbooru.meta("enable-auto-complete") === "true") {
$("#post_tag_string").data("uiAutocomplete").close(); $tag_string.data("uiAutocomplete").close();
} }
}, },
close: Danbooru.Post.close_edit_dialog close: Danbooru.Post.close_edit_dialog
@@ -86,13 +90,14 @@
} }
Danbooru.Post.close_edit_dialog = function(e, ui) { Danbooru.Post.close_edit_dialog = function(e, ui) {
$("#form").appendTo($("#edit")); $("#form").appendTo($("#c-posts #edit,#c-uploads #a-new"));
$("#post-edit-dialog").remove(); $("#edit-dialog").remove();
$("#related-tags").show(); $("#related-tags").show();
$("#toggle-related-tags-link").html("&raquo;").hide(); $("#toggle-related-tags-link").html("&raquo;").hide();
$("div.input:has(#post_tag_string)").prevAll().show(); var $tag_string = $("#post_tag_string,#upload_tag_string");
$("#open-post-edit-dialog").show(); $("div.input").has($tag_string).prevAll().show();
$("#post_tag_string").css({"resize": "", "width": ""}); $("#open-edit-dialog").show();
$tag_string.css({"resize": "", "width": ""});
} }
Danbooru.Post.initialize_tag_autocomplete = function() { Danbooru.Post.initialize_tag_autocomplete = function() {

View File

@@ -63,7 +63,7 @@
<div> <div>
<%= f.label :tag_string, "Tags" %> <%= f.label :tag_string, "Tags" %>
<%= f.text_area :tag_string, :size => "50x5", :value => post.presenter.categorized_tag_string + " " %> <%= f.text_area :tag_string, :size => "50x5", :value => post.presenter.categorized_tag_string + " " %>
<span id="open-post-edit-dialog" class="ui-icon ui-icon-arrow-1-ne" title="detach"/> <span id="open-edit-dialog" class="ui-icon ui-icon-arrow-1-ne" title="detach" style="display: none;"/>
</div> </div>
<%= button_tag "Related tags", :id => "related-tags-button", :type => "button" %> <%= button_tag "Related tags", :id => "related-tags-button", :type => "button" %>

View File

@@ -58,6 +58,7 @@
<div> <div>
<%= f.label :tag_string, "Tags" %> <%= f.label :tag_string, "Tags" %>
<%= f.text_area :tag_string, :size => "60x5" %> <%= f.text_area :tag_string, :size => "60x5" %>
<span id="open-edit-dialog" class="ui-icon ui-icon-arrow-1-ne" title="detach" style="display: none;"/>
</div> </div>
<%= button_tag "Related tags", :id => "related-tags-button", :type => "button" %> <%= button_tag "Related tags", :id => "related-tags-button", :type => "button" %>
@@ -77,7 +78,7 @@
</div> </div>
<div id="related-tags-container"> <div id="related-tags-container">
<h1>Related Tags</h1> <h1>Related Tags <a href="#" id="toggle-related-tags-link" style="display: none;">&laquo;</a></h1>
<div id="related-tags" class="related-tags"> <div id="related-tags" class="related-tags">
</div> </div>
</div> </div>