major refactoring of javascripts

This commit is contained in:
albert
2011-03-10 17:59:42 -05:00
parent efa6856b4a
commit 9c0a961ab2
28 changed files with 168 additions and 415 deletions

View File

@@ -9,11 +9,9 @@ class FavoritesController < ApplicationController
def create def create
Post.find(params[:id]).add_favorite(CurrentUser.user) Post.find(params[:id]).add_favorite(CurrentUser.user)
render :nothing => true
end end
def destroy def destroy
Post.find(params[:id]).remove_favorite(CurrentUser.user) Post.find(params[:id]).remove_favorite(CurrentUser.user)
render :nothing => true
end end
end end

View File

@@ -1,17 +1,12 @@
class TagAliasesController < ApplicationController class TagAliasesController < ApplicationController
before_filter :admin_only, :only => [:new, :edit, :create, :update, :destroy] before_filter :admin_only, :only => [:new, :create, :destroy]
respond_to :html, :xml, :json respond_to :html, :xml, :json, :js
def new def new
@tag_alias = TagAlias.new(params[:tag_alias]) @tag_alias = TagAlias.new(params[:tag_alias])
respond_with(@tag_alias) respond_with(@tag_alias)
end end
def edit
@tag_alias = TagAlias.find(params[:id])
respond_with(@tag_alias)
end
def index def index
@search = TagAlias.search(params[:search]) @search = TagAlias.search(params[:search])
@tag_aliases = @search.paginate(:page => params[:page]) @tag_aliases = @search.paginate(:page => params[:page])
@@ -20,19 +15,13 @@ class TagAliasesController < ApplicationController
def create def create
@tag_alias = TagAlias.create(params[:tag_alias]) @tag_alias = TagAlias.create(params[:tag_alias])
respond_with(@tag_alias) respond_with(@tag_alias, :location => tag_aliases_path(:search => {:id_eq => @tag_alias.id}))
end
def update
@tag_alias = TagAlias.find(params[:id])
@tag_alias.update_attributes(params[:tag_alias])
respond_with(@tag_alias)
end end
def destroy def destroy
@tag_alias = TagAlias.find(params[:id]) @tag_alias = TagAlias.find(params[:id])
@tag_alias.destroy @tag_alias.destroy
respond_with(@tag_alias) respond_with(@tag_alias, :location => tag_aliases_path)
end end
def cache def cache

View File

@@ -1,32 +1,21 @@
class TagImplicationsController < ApplicationController class TagImplicationsController < ApplicationController
before_filter :admin_only, :only => [:new, :edit, :create, :update, :destroy] before_filter :admin_only, :only => [:new, :create, :destroy]
respond_to :html, :xml, :json respond_to :html, :xml, :json, :js
def new def new
@tag_implication = TagImplication.new @tag_implication = TagImplication.new
respond_with(@tag_implication) respond_with(@tag_implication)
end end
def edit
@tag_implication = TagImplication.find(params[:id])
respond_with(@tag_implication)
end
def index def index
@search = TagImplication.search(params[:search]) @search = TagImplication.search(params[:search])
@tag_implicationes = @search.paginate(:page => params[:page]) @tag_implications = @search.paginate(:page => params[:page])
respond_with(@tag_implicationes) respond_with(@tag_implicationes)
end end
def create def create
@tag_implication = TagImplication.create(params[:tag_implication]) @tag_implication = TagImplication.create(params[:tag_implication])
respond_with(@tag_implication) respond_with(@tag_implication, :location => tag_implications_path(:search => {:id_eq => @tag_implication.id}))
end
def update
@tag_implication = TagImplication.find(params[:id])
@tag_implication.update_attributes(params[:tag_implication])
respond_with(@tag_implication)
end end
def destroy def destroy

View File

@@ -10,6 +10,10 @@ class JanitorTrial < ActiveRecord::Base
self.creator_id = CurrentUser.id self.creator_id = CurrentUser.id
end end
def user_name=(name)
self.user_id = User.name_to_id(name)
end
def send_dmail def send_dmail
body = "You have been selected as a test janitor. You can now approve pending posts and have access to the moderation interface.\n\nOver the next several weeks your approvals will be monitored. If the majority of them are quality uploads, then you will be promoted to full janitor status which grants you the ability to delete and undelete posts, ban users, and revert tag changes from vandals. If you fail the trial period, you will be demoted back to your original level and you'll receive a negative user record indicating you previously attempted and failed a test janitor trial.\n\nThere is a minimum quota of 5 approvals a week to indicate that you are being active. Remember, the goal isn't to approve as much as possible. It's to filter out borderline-quality art.\n\nIf you have any questions please respond to this message." body = "You have been selected as a test janitor. You can now approve pending posts and have access to the moderation interface.\n\nOver the next several weeks your approvals will be monitored. If the majority of them are quality uploads, then you will be promoted to full janitor status which grants you the ability to delete and undelete posts, ban users, and revert tag changes from vandals. If you fail the trial period, you will be demoted back to your original level and you'll receive a negative user record indicating you previously attempted and failed a test janitor trial.\n\nThere is a minimum quota of 5 approvals a week to indicate that you are being active. Remember, the goal isn't to approve as much as possible. It's to filter out borderline-quality art.\n\nIf you have any questions please respond to this message."

View File

@@ -1,5 +1,3 @@
<% if @error %> <% if @error %>
alert("<%= escape_javascript(@error.to_s) %>"); alert("<%= escape_javascript(@error.to_s) %>");
<% else %>
$("#score-for-comment-<%= @comment.id %>").html("<%= pluralize @comment.score, 'point' %>");
<% end %> <% end %>

View File

@@ -6,13 +6,12 @@
<%= time_ago_in_words(comment.created_at) %> ago <%= time_ago_in_words(comment.created_at) %> ago
</time> </time>
</p> </p>
<p><span class="comment-score" id="score-for-comment-<%= comment.id %>"><%= pluralize comment.score, "point" %></span></p>
</div> </div>
<div class="content"> <div class="content">
<div> <div>
<%= format_text(comment.body) %> <%= format_text(comment.body) %>
</div> </div>
<menu> <menu>
<li><span class="link">Reply</span></li> <li><span class="link">Reply</span></li>
<% if CurrentUser.user.is_janitor? || CurrentUser.user.id == comment.creator_id %> <% if CurrentUser.user.is_janitor? || CurrentUser.user.id == comment.creator_id %>
<li><%= link_to "Delete", comment_path(comment.id), :confirm => "Do you really want to delete this comment?", :method => :delete %></li> <li><%= link_to "Delete", comment_path(comment.id), :confirm => "Do you really want to delete this comment?", :method => :delete %></li>

View File

@@ -0,0 +1,2 @@
$("a#add-to-favorites").hide();
$("a#remove-from-favorites").show();

View File

@@ -0,0 +1,2 @@
$("a#add-to-favorites").show();
$("a#remove-from-favorites").hide();

View File

@@ -5,7 +5,7 @@
<% if @pool %> <% if @pool %>
<li>|</li> <li>|</li>
<li><%= link_to "Show", pool_path(@pool) %></li> <li><%= link_to "Show", pool_path(@pool) %></li>
<li><%= link_to "Search", posts_path(:tags => "pool:#{@pool.id}") %></li> <li><%= link_to "Posts", posts_path(:tags => "pool:#{@pool.id}") %></li>
<li><%= link_to "Simple Edit", edit_pool_path(@pool) %></li> <li><%= link_to "Simple Edit", edit_pool_path(@pool) %></li>
<li><%= link_to "Advanced Edit", edit_pool_path(@pool, :advanced => true) %></li> <li><%= link_to "Advanced Edit", edit_pool_path(@pool, :advanced => true) %></li>
<% end %> <% end %>

View File

@@ -1,16 +1,16 @@
<ul> <ul>
<%= resize_image_links(post, CurrentUser.user) %> <%= resize_image_links(post, CurrentUser.user) %>
<li><%= link_to "Favorite", "#", :id => "add-to-favorites" %> <%= wait_image("add-to-favorites-wait") %></li> <li><%= link_to "Favorite", favorite_path(post), :remote => true, :method => :post, :id => "add-to-favorites" %></li>
<li><%= link_to "Unfavorite", "#", :id => "remove-from-favorites" %> <%= wait_image("remove-from-favorites-wait") %></li> <li><%= link_to "Unfavorite", favorite_path(post), :remote => true, :method => :delete, :id => "remove-from-favorites" %></li>
<li><%= link_to "Translate", "#" %></li> <li><%= link_to "Translate", "#" %></li>
<li><%= link_to "Unapprove", new_unapproval_path(:post_id => post.id), :id => "unapprove" %></li> <li><%= link_to "Unapprove", new_unapproval_path(:post_id => post.id), :id => "unapprove" %></li>
<% if CurrentUser.is_janitor? %> <% if CurrentUser.is_janitor? %>
<li><%= link_to "Approve", "#", :id => "approve" %> <%= wait_image("approve-wait") %></li> <li><%= link_to "Approve", post_moderation_approve_path(:post_id => post.id), :remote => true, :method => :put, :id => "approve" %></li>
<li><%= link_to "Disapprove", "#", :id => "disapprove" %> <%= wait_image("disapprove-wait") %></li> <li><%= link_to "Disapprove", post_moderation_disapprove_path(:post_id => post.id), :remote => true, :method => :put, :id => "disapprove" %></li>
<% end %> <% end %>
<% if CurrentUser.is_moderator? %> <% if CurrentUser.is_moderator? %>
<li><%= link_to "Undelete", "#", :id => "undelete" %> <%= wait_image("undelete-wait") %></li> <li><%= link_to "Undelete", post_moderation_undelete_path(:post_id => post.id), :remote => true, :method => :post, :id => "undelete" %></li>
<li><%= link_to "Delete", "#", :id => "delete" %> <%= wait_image("delete-wait") %></li> <li><%= link_to "Delete", post_moderation_delete_path(:post_id => post.id), :remote => true, :method => :post, :id => "delete" %></li>
<% end %> <% end %>
<li><%= link_to "Pool", "#", :id => "pool" %></li> <li><%= link_to "Pool", "#", :id => "pool" %></li>
</ul> </ul>

View File

@@ -0,0 +1 @@
$("#tag-alias-<%= @tag_alias.id %>").remove();

View File

@@ -19,13 +19,13 @@
</thead> </thead>
<tbody> <tbody>
<% @tag_aliases.each do |tag_alias| %> <% @tag_aliases.each do |tag_alias| %>
<tr> <tr id="tag-alias-<%= tag_alias.id %>">
<td><%= link_to tag_alias.antecedent_name, posts_path(:tags => tag_alias.antecedent_name) %> (<%= tag_alias.antecedent_tag.post_count rescue 0 %>)</td> <td><%= link_to tag_alias.antecedent_name, posts_path(:tags => tag_alias.antecedent_name) %> (<%= tag_alias.antecedent_tag.post_count rescue 0 %>)</td>
<td><%= link_to tag_alias.consequent_name, posts_path(:tags => tag_alias.consequent_name) %> (<%= tag_alias.consequent_tag.post_count rescue 0 %>)</td> <td><%= link_to tag_alias.consequent_name, posts_path(:tags => tag_alias.consequent_name) %> (<%= tag_alias.consequent_tag.post_count rescue 0 %>)</td>
<td><%= link_to tag_alias.forum_topic_id, forum_topic_path(tag_alias.forum_topic_id) %></td> <td><%= link_to tag_alias.forum_topic_id, forum_topic_path(tag_alias.forum_topic_id) %></td>
<td> <td>
<% if CurrentUser.is_admin? %> <% if CurrentUser.is_admin? %>
<%= link_to "Delete", :url => tag_alias_path(tag_alias), :remote => true, :method => :delete, :confirm => "Are you sure you want to delete this alias?" %> <%= link_to "Delete", tag_alias_path(tag_alias), :remote => true, :method => :delete, :confirm => "Are you sure you want to delete this alias?" %>
<% end %> <% end %>
</td> </td>
</tr> </tr>

View File

@@ -0,0 +1,7 @@
<% content_for(:secondary_links) do %>
<menu>
<li><%= link_to "Listing", tag_implications_path %></li>
<li><%= link_to "Add", new_tag_implication_path %></li>
<li><%= link_to "Help", wiki_pages_path(:title => "help:tag_implications") %></li>
</menu>
<% end %>

View File

@@ -0,0 +1 @@
$("#tag-implication-<%= @tag_implication.id %>").remove();

View File

@@ -1,95 +1,42 @@
<div style="margin-bottom: 1em;"> <div id="c-tag-implications">
<% form_tag({:action => "index"}, :method => :get) do %> <div id="a-index">
<%= text_field_tag "query", params[:query] %> <div class="search">
<%= submit_tag "Search Implications" %> <% form_tag(tag_implications_path, :method => :get) do %>
<%= submit_tag "Search Aliases" %> <%= text_field_tag "query", params[:query] %>
<% end %> <%= submit_tag "Search Aliases" %>
</div> <%= submit_tag "Search Implications" %>
<% form_tag(:action => "update") do %>
<table class="highlightable" width="100%">
<thead>
<tr>
<th width="1%"></th>
<th width="19%">Predicate</th>
<th width="20%">Consequent</th>
<th width="60%">Reason</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="4">
<% if @current_user.is_admin_or_higher? %>
<%= button_to_function "Select pending", "$$('.pending').each(function(x) {x.checked = true})" %>
<%= submit_tag "Approve" %>
<%= button_to_function "Delete", "$('reason-box').show(); $('reason').focus()" %>
<% end %>
<% if @current_user.is_admin_or_higher? %>
<%= button_to_function "Add", "$('add-box').show().scrollTo(); $('tag_implication_predicate').focus()" %>
<% else %>
<%= button_to_function "Add", "window.location = '/forum/new?type=impl'" %>
<% end %>
<% if @current_user.is_admin_or_higher? %>
<div id="reason-box" style="display: none; margin-top: 1em;">
<strong>Reason:</strong>
<%= text_field_tag "reason", "", :size => 40 %>
<%= submit_tag "Delete" %>
</div>
<% end %>
</td>
</tr>
</tfoot>
<tbody>
<% @implications.each do |i| %>
<tr class="<%= cycle 'even', 'odd' %> <%= i.is_pending? ? 'pending-tag' : nil %>">
<td><input type="checkbox" value="1" name="implications[<%= i.id %>]" <%= i.is_pending? ? 'class="pending"' : nil %>></td>
<td><%= link_to h(i.predicate.name), :controller => "post", :action => "index", :tags => i.predicate.name %> (<%= i.predicate.post_count %>)</td>
<td><%= link_to h(i.consequent.name), :controller => "post", :action => "index", :tags => i.consequent.name %> (<%= i.consequent.post_count %>)</td>
<td><%= h i.reason %></td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
<% if @current_user.is_admin_or_higher? %>
<div id="add-box" <% unless params[:to_name] %>style="display: none;"<% end %>>
<% form_tag(:action => "create") do %>
<h4>Add Implication</h4>
<% unless @current_user.is_anonymous? %>
<%= hidden_field_tag "tag_implication[creator_id]", @current_user.id %>
<% end %> <% end %>
</div>
<table>
<table width="100%" class="highlightable">
<thead>
<tr> <tr>
<th><label for="tag_implication_predicate">Predicate</label></th> <th width="20%">From</th>
<td><%= text_field "tag_implication", "predicate", :size => 40, :value => params[:from_name] %></td> <th width="20%">To</th>
</tr> <th width="20%">Reference</th>
<tr> <th width="40%"></th>
<th><label for="tag_implication_consequent">Consequent</label></th> </tr>
<td><%= text_field "tag_implication", "consequent", :size => 40, :value => params[:to_name] %></td> </thead>
</tr> <tbody>
<tr> <% @tag_implications.each do |tag_implication| %>
<th><label for="tag_implication_reason">Reason</label></th> <tr id="tag-implication-<%= tag_implication.id %>">
<td><%= text_area "tag_implication", "reason", :size => "40x2", :value => params[:reason] %></td> <td><%= link_to tag_implication.antecedent_name, posts_path(:tags => tag_implication.antecedent_name) %> (<%= tag_implication.antecedent_tag.post_count rescue 0 %>)</td>
</tr> <td><%= link_to tag_implication.consequent_name, posts_path(:tags => tag_implication.consequent_name) %> (<%= tag_implication.consequent_tag.post_count rescue 0 %>)</td>
<tr> <td><%= link_to tag_implication.forum_topic_id, forum_topic_path(tag_implication.forum_topic_id) %></td>
<td colspan="2"><%= submit_tag "Submit" %></td> <td>
</tr> <% if CurrentUser.is_admin? %>
</table> <%= link_to "Delete", tag_implication_path(tag_implication), :remote => true, :method => :delete, :confirm => "Are you sure you want to delete this implication?" %>
<% end %> <% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div> </div>
<% end %> </div>
<div id="paginator"> <div id="paginator">
<%= will_paginate(@implications) %> <%= will_paginate(@implications) %>
</div> </div>
<% content_for("subnavbar") do %> <%= render "secondary_links" %>
<li><%= link_to "List", :controller => "tag_implication", :action => "index" %></li>
<li><%= link_to "Add", :controller => "tag_implication", :action => "new" %></li>
<li><%= link_to "Help", :controller => "help", :action => "tag_implications" %></li>
<% end %>

View File

@@ -1,20 +1,13 @@
<% form_tag(:controller => "forum", :action => "create") do %> <div id="c-tag-aliases">
<p>You can create a forum thread to suggest the creation of an implication.</p> <div id="a-new">
<table> <h1>New Tag Implication</h1>
<tr> <%= simple_form_for(@tag_implication) do |f| %>
<th><label for="tag_implication_predicate">From</label></th> <%= f.input :antecedent_name, :label => "From" %>
<td><%= text_field "tag_implication", "predicate", :size => 40 %></td> <%= f.input :consequent_name, :label => "To" %>
</tr> <%= f.input :forum_topic_id, :label => "Forum" %>
<tr> <%= f.button :submit %>
<th><label for="tag_implication_consequent">To</label></th> <% end %>
<td><%= text_field "tag_implication", "consequent", :size => 40 %></td> </div>
</tr> </div>
<tr>
<th><label for="tag_implication_reason">Reason</label></th> <%= render "secondary_links" %>
<td><%= text_area "tag_implication", "reason", :rows => 10, :cols => 60 %></td>
</tr>
<tr>
<td colspan="2"><%= submit_tag "Submit" %></td>
</tr>
</table>
<% end %>

View File

@@ -12,7 +12,7 @@
<tr> <tr>
<td><%= tag.post_count %></td> <td><%= tag.post_count %></td>
<td class="tag-category-<%= tag.category_name %>"> <td class="tag-category-<%= tag.category_name %>">
<%= link_to("?", wiki_pages_path(:search => {:title_equals => tag.name})) %> <%= link_to("?", wiki_pages_path(:title => tag.name)) %>
<%= link_to(tag.name, posts_path(:tags => tag.name)) %> <%= link_to(tag.name, posts_path(:tags => tag.name)) %>
</td> </td>
</tr> </tr>

View File

@@ -68,6 +68,9 @@ Danbooru::Application.routes.draw do
end end
resources :wiki_page_versions, :only => [:index] resources :wiki_page_versions, :only => [:index]
match '/favorites/:id' => 'favorites#create', :via => :post, :as => "favorite"
match '/favorites/:id' => 'favorites#destroy', :via => :delete, :as => "favorite"
match '/favorites' => 'favorites#index', :via => :get, :as => "favorites"
match '/pool_post' => 'pools_posts#create', :via => :post, :as => 'pool_post' match '/pool_post' => 'pools_posts#create', :via => :post, :as => 'pool_post'
match '/pool_post' => 'pools_posts#destroy', :via => :delete, :as => 'pool_post' match '/pool_post' => 'pools_posts#destroy', :via => :delete, :as => 'pool_post'
match '/post_moderation/moderate' => 'post_moderation#moderate' match '/post_moderation/moderate' => 'post_moderation#moderate'

View File

@@ -681,6 +681,15 @@ $(document).ready(function() {
$(".comment-section[data-post-id=" + post_id + "] form").show(); $(".comment-section[data-post-id=" + post_id + "] form").show();
$(this).hide(); $(this).hide();
}); });
// Ajax links
$("a[data-remote=true]").click(function(e) {
Danbooru.ajax_start(e.target);
})
$("a[data-remote=true]").ajaxComplete(function(e) {
Danbooru.ajax_stop(e.target);
})
// Image resize sidebar // Image resize sidebar
$("#resize-links").hide(); $("#resize-links").hide();
@@ -779,12 +788,12 @@ $(document).ready(function() {
this.j_alert("Error", msg); this.j_alert("Error", msg);
} }
Danbooru.ajax_start = function(element) { Danbooru.ajax_start = function(target) {
$(element).after(' <span class="wait">...</span>'); $(target).after(' <img src="/images/wait.gif" width="15" height="5" class="wait">');
} }
Danbooru.ajax_stop = function(element) { Danbooru.ajax_stop = function(target) {
$(element).next("span.wait").remove(); $(target).next("img.wait").remove();
} }
})(); })();
// PostModeMenu = { // PostModeMenu = {
@@ -1079,8 +1088,6 @@ $(document).ready(function() {
Danbooru.Favorite = {}; Danbooru.Favorite = {};
Danbooru.Favorite.initialize_all = function() { Danbooru.Favorite.initialize_all = function() {
this.initialize_add_to_favorites();
this.initialize_remove_from_favorites();
this.hide_or_show_add_to_favorites_link(); this.hide_or_show_add_to_favorites_link();
} }
@@ -1099,51 +1106,6 @@ $(document).ready(function() {
$("a#remove-from-favorites").hide(); $("a#remove-from-favorites").hide();
} }
} }
Danbooru.Favorite.initialize_add_to_favorites = function() {
$("a#add-to-favorites").click(function(e) {
e.preventDefault();
$.ajax({
type: "post",
url: "/favorites",
data: {
id: Danbooru.meta("post-id")
},
beforeSend: function() {
Danbooru.ajax_start(e.target);
},
success: function() {
$("a#add-to-favorites").hide();
$("a#remove-from-favorites").show();
},
complete: function() {
Danbooru.ajax_stop(e.target);
}
});
});
}
Danbooru.Favorite.initialize_remove_from_favorites = function() {
$("a#remove-from-favorites").click(function(e) {
e.preventDefault();
$.ajax({
type: "delete",
url: "/favorites/" + Danbooru.meta("post-id"),
beforeSend: function() {
Danbooru.ajax_start(e.target);
},
success: function() {
$("a#add-to-favorites").show();
$("a#remove-from-favorites").hide();
},
complete: function() {
Danbooru.ajax_stop(e.target);
}
});
});
}
})(); })();
$(document).ready(function() { $(document).ready(function() {
@@ -1193,12 +1155,8 @@ $(document).ready(function() {
Danbooru.PostModeration = {}; Danbooru.PostModeration = {};
Danbooru.PostModeration.initialize_all = function() { Danbooru.PostModeration.initialize_all = function() {
this.initialize_approve_link();
this.initialize_disapprove_link();
this.hide_or_show_approve_and_disapprove_links(); this.hide_or_show_approve_and_disapprove_links();
this.hide_or_show_delete_and_undelete_links(); this.hide_or_show_delete_and_undelete_links();
this.initialize_delete_link();
this.initialize_undelete_link();
} }
Danbooru.PostModeration.hide_or_show_approve_and_disapprove_links = function() { Danbooru.PostModeration.hide_or_show_approve_and_disapprove_links = function() {
@@ -1215,82 +1173,6 @@ $(document).ready(function() {
$("a#undelete").hide(); $("a#undelete").hide();
} }
} }
Danbooru.PostModeration.initialize_delete_link = function() {
$("a#delete").click(function(e) {
e.preventDefault();
$.ajax({
type: "post",
url: "/post_moderation/delete.js",
data: {
post_id: Danbooru.meta("post-id")
},
beforeSend: function() {
Danbooru.ajax_start(e.target);
},
complete: function() {
Danbooru.ajax_stop(e.target);
}
});
});
}
Danbooru.PostModeration.initialize_undelete_link = function() {
$("a#undelete").click(function(e) {
e.preventDefault();
$.ajax({
type: "post",
url: "/post_moderation/undelete.js",
data: {
post_id: Danbooru.meta("post-id")
},
beforeSend: function() {
Danbooru.ajax_start(e.target);
},
complete: function() {
Danbooru.ajax_stop(e.target);
}
});
});
}
Danbooru.PostModeration.initialize_disapprove_link = function() {
$("a#disapprove").click(function(e) {
e.preventDefault();
$.ajax({
type: "put",
url: "/post_moderation/disapprove.js",
data: {
post_id: Danbooru.meta("post-id")
},
beforeSend: function() {
Danbooru.ajax_start(e.target);
},
complete: function() {
Danbooru.ajax_stop(e.target);
}
});
});
}
Danbooru.PostModeration.initialize_approve_link = function() {
$("a#approve").click(function(e) {
e.preventDefault();
$.ajax({
type: "put",
url: "/post_moderation/approve.js",
data: {
post_id: Danbooru.meta("post-id")
},
beforeSend: function() {
Danbooru.ajax_start(e.target);
},
complete: function() {
Danbooru.ajax_stop(e.target);
}
});
});
}
})(); })();
$(document).ready(function() { $(document).ready(function() {

View File

@@ -15,6 +15,15 @@ $(document).ready(function() {
$(".comment-section[data-post-id=" + post_id + "] form").show(); $(".comment-section[data-post-id=" + post_id + "] form").show();
$(this).hide(); $(this).hide();
}); });
// Ajax links
$("a[data-remote=true]").click(function(e) {
Danbooru.ajax_start(e.target);
})
$("a[data-remote=true]").ajaxComplete(function(e) {
Danbooru.ajax_stop(e.target);
})
// Image resize sidebar // Image resize sidebar
$("#resize-links").hide(); $("#resize-links").hide();

View File

@@ -2,8 +2,6 @@
Danbooru.Favorite = {}; Danbooru.Favorite = {};
Danbooru.Favorite.initialize_all = function() { Danbooru.Favorite.initialize_all = function() {
this.initialize_add_to_favorites();
this.initialize_remove_from_favorites();
this.hide_or_show_add_to_favorites_link(); this.hide_or_show_add_to_favorites_link();
} }
@@ -22,51 +20,6 @@
$("a#remove-from-favorites").hide(); $("a#remove-from-favorites").hide();
} }
} }
Danbooru.Favorite.initialize_add_to_favorites = function() {
$("a#add-to-favorites").click(function(e) {
e.preventDefault();
$.ajax({
type: "post",
url: "/favorites",
data: {
id: Danbooru.meta("post-id")
},
beforeSend: function() {
Danbooru.ajax_start(e.target);
},
success: function() {
$("a#add-to-favorites").hide();
$("a#remove-from-favorites").show();
},
complete: function() {
Danbooru.ajax_stop(e.target);
}
});
});
}
Danbooru.Favorite.initialize_remove_from_favorites = function() {
$("a#remove-from-favorites").click(function(e) {
e.preventDefault();
$.ajax({
type: "delete",
url: "/favorites/" + Danbooru.meta("post-id"),
beforeSend: function() {
Danbooru.ajax_start(e.target);
},
success: function() {
$("a#add-to-favorites").show();
$("a#remove-from-favorites").hide();
},
complete: function() {
Danbooru.ajax_stop(e.target);
}
});
});
}
})(); })();
$(document).ready(function() { $(document).ready(function() {

View File

@@ -2,12 +2,8 @@
Danbooru.PostModeration = {}; Danbooru.PostModeration = {};
Danbooru.PostModeration.initialize_all = function() { Danbooru.PostModeration.initialize_all = function() {
this.initialize_approve_link();
this.initialize_disapprove_link();
this.hide_or_show_approve_and_disapprove_links(); this.hide_or_show_approve_and_disapprove_links();
this.hide_or_show_delete_and_undelete_links(); this.hide_or_show_delete_and_undelete_links();
this.initialize_delete_link();
this.initialize_undelete_link();
} }
Danbooru.PostModeration.hide_or_show_approve_and_disapprove_links = function() { Danbooru.PostModeration.hide_or_show_approve_and_disapprove_links = function() {
@@ -24,82 +20,6 @@
$("a#undelete").hide(); $("a#undelete").hide();
} }
} }
Danbooru.PostModeration.initialize_delete_link = function() {
$("a#delete").click(function(e) {
e.preventDefault();
$.ajax({
type: "post",
url: "/post_moderation/delete.js",
data: {
post_id: Danbooru.meta("post-id")
},
beforeSend: function() {
Danbooru.ajax_start(e.target);
},
complete: function() {
Danbooru.ajax_stop(e.target);
}
});
});
}
Danbooru.PostModeration.initialize_undelete_link = function() {
$("a#undelete").click(function(e) {
e.preventDefault();
$.ajax({
type: "post",
url: "/post_moderation/undelete.js",
data: {
post_id: Danbooru.meta("post-id")
},
beforeSend: function() {
Danbooru.ajax_start(e.target);
},
complete: function() {
Danbooru.ajax_stop(e.target);
}
});
});
}
Danbooru.PostModeration.initialize_disapprove_link = function() {
$("a#disapprove").click(function(e) {
e.preventDefault();
$.ajax({
type: "put",
url: "/post_moderation/disapprove.js",
data: {
post_id: Danbooru.meta("post-id")
},
beforeSend: function() {
Danbooru.ajax_start(e.target);
},
complete: function() {
Danbooru.ajax_stop(e.target);
}
});
});
}
Danbooru.PostModeration.initialize_approve_link = function() {
$("a#approve").click(function(e) {
e.preventDefault();
$.ajax({
type: "put",
url: "/post_moderation/approve.js",
data: {
post_id: Danbooru.meta("post-id")
},
beforeSend: function() {
Danbooru.ajax_start(e.target);
},
complete: function() {
Danbooru.ajax_stop(e.target);
}
});
});
}
})(); })();
$(document).ready(function() { $(document).ready(function() {

View File

@@ -11,11 +11,11 @@
this.j_alert("Error", msg); this.j_alert("Error", msg);
} }
Danbooru.ajax_start = function(element) { Danbooru.ajax_start = function(target) {
$(element).after(' <span class="wait">...</span>'); $(target).after(' <img src="/images/wait.gif" width="15" height="5" class="wait">');
} }
Danbooru.ajax_stop = function(element) { Danbooru.ajax_stop = function(target) {
$(element).next("span.wait").remove(); $(target).next("img.wait").remove();
} }
})(); })();

View File

@@ -416,3 +416,26 @@ div.users div.new {
/*** Uploads ***/ /*** Uploads ***/
div.uploads div.new div#upload-guide-notice { div.uploads div.new div#upload-guide-notice {
margin-bottom: 2em; } margin-bottom: 2em; }
/*** notify ***/
.notify-container {
position: fixed;
top: 0;
left: 0;
width: 100%;
z-index: 1000; }
.notify-container .notify-notification {
position: relative; }
.notify-container .notify-notification .notify-background {
position: absolute;
top: 0;
left: 0;
width: 100%;
background-color: #333;
z-index: 1; }
.notify-container .notify-notification .notify-message {
position: relative;
z-index: 2;
padding: 20px;
text-align: center;
color: #FFF; }

View File

@@ -698,3 +698,35 @@ div.uploads {
} }
} }
} }
/*** notify ***/
.notify-container {
position: fixed;
top: 0;
left: 0;
width: 100%;
z-index: 1000;
.notify-notification {
position: relative;
.notify-background {
position: absolute;
top: 0;
left: 0;
width: 100%;
background-color: #333;
z-index: 1;
}
.notify-message {
position: relative;
z-index: 2;
padding: 20px;
text-align: center;
color: #FFF;
}
}
}

View File

@@ -2,5 +2,6 @@
while true ; do while true ; do
script/custom/compile_javascripts ; script/custom/compile_javascripts ;
sass public/stylesheets/src/default.scss public/stylesheets/compiled/default.css ;
sleep 1 ; sleep 1 ;
done done