fixes #4006: Bring back the "edit tags" button to the sidebar

fixes #4011: Comment input field under posts is too big, goes slightly beyond view boundaries
fixes #4010: Incorrect dynamic tag counts
This commit is contained in:
Albert Yi
2018-12-12 11:39:54 -08:00
parent 77b42310eb
commit 8ac530a909
4 changed files with 12 additions and 4 deletions

View File

@@ -41,7 +41,7 @@ Post.initialize_all = function() {
var $fields_multiple = $('[data-autocomplete="tag-edit"]');
$fields_multiple.on("keypress.danbooru", Post.update_tag_count);
Post.update_tag_count();
$fields_multiple.on("click", Post.update_tag_count);
$(window).on('danbooru:initialize_saved_seraches', () => {
Post.initialize_saved_searches();
@@ -421,7 +421,7 @@ Post.initialize_excerpt = function() {
}
Post.initialize_post_sections = function() {
$("#post-sections li a").on("click.danbooru", function(e) {
$("#post-sections li a,#side-edit-link").on("click.danbooru", function(e) {
if (e.target.hash === "#comments") {
$("#comments").show();
$("#edit").hide();
@@ -432,6 +432,7 @@ Post.initialize_post_sections = function() {
$("#post_tag_string").focus().selectEnd().height($("#post_tag_string")[0].scrollHeight);
$("#recommended").hide();
$(document).trigger("danbooru:open-post-edit-tab");
Post.update_tag_count({target: $("#post_tag_string")});
} else if (e.target.hash === "#recommended") {
$("#comments").hide();
$("#edit").hide();
@@ -607,7 +608,7 @@ Post.update_tag_count = function(event) {
let count = 0;
if (event) {
let tags = $(event.target).val().match(/\S+/g);
let tags = [...new Set($(event.target).val().match(/\S+/g))];
if (tags) {
count = tags.length;
string = (count == 1) ? (count + " tag") : (count + " tags")

View File

@@ -1,5 +1,6 @@
import Uploads from './uploads';
import Utility from './utility';
import Post from './posts.js.erb';
let RelatedTag = {};
@@ -121,6 +122,8 @@ RelatedTag.toggle_tag = function(e) {
// The timeout is needed on Chrome since it will clobber the field attribute otherwise
setTimeout(function () { $field.prop('selectionStart', $field.val().length);}, 100);
e.preventDefault();
Post.update_tag_count({ target: $field });
}
RelatedTag.show = function(e) {

View File

@@ -343,10 +343,13 @@ div#c-posts {
}
textarea {
width: 100%;
margin-bottom: 0.25em;
}
#edit textarea {
width: 100%;
}
#favlist {
margin-left: 1em;
word-wrap: break-word;

View File

@@ -4,6 +4,7 @@
<% if CurrentUser.is_member? %>
<li><%= link_to "Favorite", favorites_path(:post_id => post.id), :remote => true, :method => :post, :id => "add-to-favorites", :"data-shortcut" => "f", style: ("display: none;" if @post.is_favorited?) %></li>
<li><%= link_to "Unfavorite", favorite_path(post), :remote => true, :method => :delete, :id => "remove-from-favorites", :"data-shortcut" => "shift+f", style: ("display: none;" if !@post.is_favorited?) %></li>
<li><%= link_to "Edit", "#edit", :id => "side-edit-link" %></li>
<li><%= link_to_if post.visible?, "Download", post.tagged_file_url + "?download=1", download: post.presenter.filename_for_download %></li>
<li id="add-to-pool-list"><%= link_to "Add to pool", "#", :id => "pool" %></li>
<% if post.is_note_locked? %>