js: clean up notice/error messaging.
This commit is contained in:
@@ -107,7 +107,7 @@ PostTooltip.on_disable_tooltips = function (event) {
|
||||
$(event.target).parents(".qtip").qtip("hide");
|
||||
|
||||
if (Utility.meta("current-user-id") === "") {
|
||||
$(window).trigger("danbooru:notice", '<a href="/session/new">Login</a> to disable tooltips permanently');
|
||||
Danbooru.notice('<a href="/session/new">Login</a> to disable tooltips permanently');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ PostTooltip.on_disable_tooltips = function (event) {
|
||||
method: "PUT",
|
||||
data: { "user[disable_post_tooltips]": "true" },
|
||||
}).then(function() {
|
||||
$(window).trigger("danbooru:notice", "Tooltips disabled; check your account settings to re-enable.");
|
||||
Danbooru.notice("Tooltips disabled; check your account settings to re-enable.");
|
||||
location.reload();
|
||||
});
|
||||
};
|
||||
|
||||
@@ -251,15 +251,15 @@ Post.initialize_links = function() {
|
||||
other_post_id: other_post_id
|
||||
},
|
||||
success: function(data) {
|
||||
$(window).trigger("danbooru:notice", "Successfully copied notes to <a href='" + other_post_id + "'>post #" + other_post_id + "</a>");
|
||||
Danbooru.notice("Successfully copied notes to <a href='" + other_post_id + "'>post #" + other_post_id + "</a>");
|
||||
},
|
||||
error: function(data) {
|
||||
if (data.status === 404) {
|
||||
$(window).trigger("danbooru:error", "Error: Invalid destination post");
|
||||
Danbooru.error("Error: Invalid destination post");
|
||||
} else if (data.responseJSON && data.responseJSON.reason) {
|
||||
$(window).trigger("danbooru:error", "Error: " + data.responseJSON.reason);
|
||||
Danbooru.error("Error: " + data.responseJSON.reason);
|
||||
} else {
|
||||
$(window).trigger("danbooru:error", "There was an error copying notes to <a href='" + other_post_id + "'>post #" + other_post_id + "</a>");
|
||||
Danbooru.error("There was an error copying notes to <a href='" + other_post_id + "'>post #" + other_post_id + "</a>");
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -467,14 +467,14 @@ Post.resize_ugoira_controls = function() {
|
||||
Post.notice_update = function(x) {
|
||||
if (x === "inc") {
|
||||
Post.pending_update_count += 1;
|
||||
$(window).trigger("danbooru:notice", "Updating posts (" + Post.pending_update_count + " pending)...", true);
|
||||
Danbooru.notice("Updating posts (" + Post.pending_update_count + " pending)...", true);
|
||||
} else {
|
||||
Post.pending_update_count -= 1;
|
||||
|
||||
if (Post.pending_update_count < 1) {
|
||||
$(window).trigger("danbooru:notice", "Posts updated");
|
||||
Danbooru.notice("Posts updated");
|
||||
} else {
|
||||
$(window).trigger("danbooru:notice", "Updating posts (" + Post.pending_update_count + " pending)...", true);
|
||||
Danbooru.notice("Updating posts (" + Post.pending_update_count + " pending)...", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -493,7 +493,7 @@ Post.update_data = function(data) {
|
||||
}
|
||||
|
||||
Post.vote = function(score, id) {
|
||||
$(window).trigger("danbooru:notice", "Voting...");
|
||||
Danbooru.notice("Voting...");
|
||||
|
||||
$.post("/posts/" + id + "/votes.js", {
|
||||
score: score
|
||||
@@ -518,7 +518,7 @@ Post.update = function(post_id, params) {
|
||||
},
|
||||
error: function(data) {
|
||||
Post.notice_update("dec");
|
||||
$(window).trigger("danbooru:error", 'There was an error updating <a href="/posts/' + post_id + '">post #' + post_id + '</a>');
|
||||
Danbooru.error(`There was an error updating <a href="/posts/${post_id}">post #${post_id}</a>`);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -534,7 +534,7 @@ Post.ban = function(post_id) {
|
||||
$("#post_" + post_id).remove();
|
||||
},
|
||||
error: function(data) {
|
||||
$(window).trigger("danbooru:error", 'There was an error updating <a href="/posts/' + post_id + '">post #' + post_id + '</a>');
|
||||
Danbooru.error(`There was an error updating <a href="/posts/${post_id}">post #${post_id}</a>`);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -545,13 +545,13 @@ Post.approve = function(post_id) {
|
||||
{"post_id": post_id}
|
||||
).fail(function(data) {
|
||||
var message = $.map(data.responseJSON.errors, function(msg, attr) { return msg; }).join("; ");
|
||||
$(window).trigger("danbooru:error", "Error: " + message);
|
||||
Danbooru.error("Error: " + message);
|
||||
}).done(function(data) {
|
||||
var $post = $("#post_" + post_id);
|
||||
if ($post.length) {
|
||||
$post.data("flags", $post.data("flags").replace(/pending/, ""));
|
||||
$post.removeClass("post-status-pending");
|
||||
$(window).trigger("danbooru:notice", "Approved post #" + post_id);
|
||||
Danbooru.notice("Approved post #" + post_id);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -111,14 +111,4 @@ $.fn.selectEnd = function() {
|
||||
})
|
||||
}
|
||||
|
||||
$(function() {
|
||||
$(window).on("danbooru:notice", function(event, msg) {
|
||||
Utility.notice(msg);
|
||||
})
|
||||
|
||||
$(window).on("danbooru:error", function(event, msg) {
|
||||
Utility.error(msg);
|
||||
})
|
||||
});
|
||||
|
||||
export default Utility
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<% if @bulk_update_request.errors.any? %>
|
||||
$(window).trigger("danbooru:error", <%= j @bulk_update_request.errors.full_messages.join(',') %>);
|
||||
Danbooru.error(<%= j @bulk_update_request.errors.full_messages.join(',') %>);
|
||||
<% else %>
|
||||
if ($("#a-index").length) {
|
||||
$("#request-status-for-<%= @bulk_update_request.id %>").html("queued");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<% if @error %>
|
||||
$(window).trigger("danbooru:error", "<%= j @error.to_s %>");
|
||||
Danbooru.error("<%= j @error.to_s %>");
|
||||
<% elsif @comment_vote.errors.any? %>
|
||||
$(window).trigger("danbooru:error", "<%= j @comment_vote.errors.full_messages.join('; ') %>");
|
||||
Danbooru.error("<%= j @comment_vote.errors.full_messages.join('; ') %>");
|
||||
<% elsif @comment_vote.is_negative? %>
|
||||
$(".comment[data-comment-id=<%= @comment.id %>]").remove();
|
||||
<% end %>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<% if @error %>
|
||||
$(window).trigger("danbooru:error", "<%= j @error.to_s %>");
|
||||
Danbooru.error("<%= j @error.to_s %>");
|
||||
<% else %>
|
||||
$("#comment-vote-up-link-for-<%= @comment.id %>").show();
|
||||
$("#comment-vote-down-link-for-<%= @comment.id %>").show();
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
$(window).trigger("danbooru:notice", "Message marked as not spam");
|
||||
$("#spam-links").hide();
|
||||
Danbooru.notice("Message marked as not spam");
|
||||
$("#spam-links").hide();
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
$(window).trigger("danbooru:notice", "Message marked as spam");
|
||||
$("#spam-links").hide();
|
||||
Danbooru.notice("Message marked as spam");
|
||||
$("#spam-links").hide();
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
$(window).trigger("danbooru:notice", "Added post to favorite group <%= escape_javascript(@favorite_group.pretty_name) %>");
|
||||
Danbooru.notice("Added post to favorite group <%= escape_javascript(@favorite_group.pretty_name) %>");
|
||||
$("#add-to-favgroup-dialog").dialog("close");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<% if @forum_post_vote.invalid? %>
|
||||
$(window).trigger("danbooru:error", <%= raw @forum_post_vote.errors.full_messages.join("; ").to_json %>);
|
||||
Danbooru.error(<%= raw @forum_post_vote.errors.full_messages.join("; ").to_json %>);
|
||||
<% else %>
|
||||
$(window).trigger("danbooru:notice", "Voted");
|
||||
var code = <%= raw render(partial: "forum_post_votes/list", locals: {forum_post: @forum_post, votes: @forum_post.votes}).to_json %>;
|
||||
$("#forum-post-votes-for-<%= @forum_post.id %>").html(code);
|
||||
Danbooru.notice("Voted");
|
||||
var code = <%= raw render(partial: "forum_post_votes/list", locals: {forum_post: @forum_post, votes: @forum_post.votes}).to_json %>;
|
||||
$("#forum-post-votes-for-<%= @forum_post.id %>").html(code);
|
||||
<% end %>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
$(window).trigger("danbooru:notice", "Unvoted");
|
||||
Danbooru.notice("Unvoted");
|
||||
var code = <%= raw render(partial: "forum_post_votes/list", locals: {forum_post: @forum_post, votes: @forum_post.votes}).to_json %>;
|
||||
$("#forum-post-votes-for-<%= @forum_post.id %>").html(code);
|
||||
|
||||
@@ -78,14 +78,10 @@
|
||||
if (typeof window.Danbooru !== "object") {
|
||||
window.Danbooru = {};
|
||||
}
|
||||
window.Danbooru.notice = function(msg) {
|
||||
console.warn("Danbooru.notice will be deprecated. Use $(window).trigger('danbooru:notice', msg) instead.")
|
||||
$(window).trigger("danbooru:notice", msg);
|
||||
}
|
||||
window.Danbooru.error = function(msg) {
|
||||
console.warn("Danbooru.error will be deprecated. Use $(window).trigger('danbooru:error', msg) instead.")
|
||||
$(window).trigger("danbooru:error", msg);
|
||||
}
|
||||
|
||||
window.Danbooru.notice = Danbooru.Utility.notice;
|
||||
window.Danbooru.error = Danbooru.Utility.error;
|
||||
|
||||
window._paq = window._paq || [];
|
||||
<% if CurrentUser.is_member? && !CurrentUser.opt_out_tracking? %>
|
||||
window._paq.push(["setUserId", '<%= CurrentUser.id %>']);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<% if @api_key.errors.any? %>
|
||||
$(window).trigger("danbooru:error", "<%= j @api_key.errors.full_messages.join(', ') %>");
|
||||
Danbooru.error("<%= j @api_key.errors.full_messages.join(', ') %>");
|
||||
<% else %>
|
||||
$("#api-key").text("<%= j @api_key.key %>");
|
||||
$("#api-key-created").html("<%= j compact_time @api_key.created_at %>");
|
||||
$("#api-key-updated").html("<%= j compact_time @api_key.updated_at %>");
|
||||
|
||||
$(window).trigger("danbooru:notice", "API key regenerated.");
|
||||
Danbooru.notice("API key regenerated.");
|
||||
<% end %>
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<% if @approval.errors.any? %>
|
||||
$(window).trigger("danbooru:error", "Error: " + <%= @approval.errors.full_messages.join("; ").to_json.html_safe %>);
|
||||
Danbooru.error("Error: " + <%= @approval.errors.full_messages.join("; ").to_json.html_safe %>);
|
||||
<% else %>
|
||||
if ($("#c-posts #a-show").length) {
|
||||
location.reload();
|
||||
} else if ($("#c-moderator-post-queues").length) {
|
||||
$("#c-moderator-post-queues #post-<%= @approval.post.id %>").hide();
|
||||
$(window).trigger("danbooru:modqueue_increment_processed");
|
||||
$(window).trigger("danbooru:notice", "Post was approved");
|
||||
Danbooru.notice("Post was approved");
|
||||
}
|
||||
<% end %>
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<% if @post_disapproval.errors.any? %>
|
||||
$(window).trigger("danbooru:error", "Error: " + <%= @post_disapproval.errors.full_messages.join("; ").to_json.html_safe %>);
|
||||
Danbooru.error("Error: " + <%= @post_disapproval.errors.full_messages.join("; ").to_json.html_safe %>);
|
||||
<% else %>
|
||||
if ($("#c-posts #a-show").length) {
|
||||
location.reload();
|
||||
} else if ($("#c-moderator-post-queues").length) {
|
||||
$("#c-moderator-post-queues #post-<%= @post_disapproval.post.id %>").hide();
|
||||
$(window).trigger("danbooru:modqueue_increment_processed");
|
||||
$(window).trigger("danbooru:notice", "Post was hidden");
|
||||
Danbooru.notice("Post was hidden");
|
||||
}
|
||||
<% end %>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<% if @post.errors.any? %>
|
||||
$(window).trigger("danbooru:error", "<%= j @post.errors.full_messages.join('; ') %>");
|
||||
Danbooru.error("<%= j @post.errors.full_messages.join('; ') %>");
|
||||
<% elsif @error %>
|
||||
$(window).trigger("danbooru:error", "<%= j @error.to_s %>");
|
||||
Danbooru.error("<%= j @error.to_s %>");
|
||||
<% else %>
|
||||
$(window).trigger("danbooru:notice", "Post was permanently deleted");
|
||||
Danbooru.notice("Post was permanently deleted");
|
||||
<% end %>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
$("#c-posts #delete").show();
|
||||
$("#c-posts #undelete").hide();
|
||||
$(window).trigger("danbooru:notice", "Post was undeleted");
|
||||
Danbooru.notice("Post was undeleted");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<% if @error %>
|
||||
$(window).trigger("danbooru:error", "<%= j @error.to_s %>");
|
||||
Danbooru.error("<%= j @error.to_s %>");
|
||||
<% else %>
|
||||
location.reload();
|
||||
<% end %>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
var errors = "<%= j @post_appeal.errors.full_messages.join("; ") %>";
|
||||
if (errors.length > 0) {
|
||||
$(window).trigger("danbooru:error", errors);
|
||||
Danbooru.error(errors);
|
||||
} else {
|
||||
$(window).trigger("danbooru:notice", "Post appealed");
|
||||
Danbooru.notice("Post appealed");
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
var errors = <%= @post_flag.errors.full_messages.to_json.html_safe %>;
|
||||
if (errors.length > 0) {
|
||||
$(window).trigger("danbooru:error", errors.join("; "));
|
||||
Danbooru.error(errors.join("; "));
|
||||
} else {
|
||||
$(window).trigger("danbooru:notice", "Post flagged");
|
||||
Danbooru.notice("Post flagged");
|
||||
$("a#approve").show();
|
||||
$("a#disapprove").show();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<% if @saved_search.errors.any? %>
|
||||
$(window).trigger("danbooru:error", "<%= j @saved_search.errors.full_messages.join(', ') %>");
|
||||
Danbooru.error("<%= j @saved_search.errors.full_messages.join(', ') %>");
|
||||
<% else %>
|
||||
$(window).trigger("danbooru:notice", "Search '<%= j @saved_search.query %>' was saved");
|
||||
Danbooru.notice("Search '<%= j @saved_search.query %>' was saved");
|
||||
<% end %>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
$(window).trigger("danbooru:notice", "Search '<%= j @saved_search.query %>' was deleted");
|
||||
Danbooru.notice("Search '<%= j @saved_search.query %>' was deleted");
|
||||
$("#saved-searches-nav").html("<%= j render('saved_searches/interface', :saved_searches => CurrentUser.user.saved_searches) %>");
|
||||
$(window).trigger("danbooru:initialize_saved_searches");
|
||||
$("#saved-search-<%= @saved_search.id %>").remove();
|
||||
|
||||
Reference in New Issue
Block a user