From 9c0a961ab25e807ec2bf6ec4c2e7eb7b787e19a8 Mon Sep 17 00:00:00 2001 From: albert Date: Thu, 10 Mar 2011 17:59:42 -0500 Subject: [PATCH] major refactoring of javascripts --- app/controllers/favorites_controller.rb | 2 - app/controllers/tag_aliases_controller.rb | 19 +-- .../tag_implications_controller.rb | 19 +-- app/models/janitor_trial.rb | 4 + app/views/comment_votes/create.js.erb | 2 - .../comments/partials/show/_comment.html.erb | 3 +- app/views/favorites/create.js.erb | 2 + app/views/favorites/destroy.js.erb | 2 + app/views/pools/_secondary_links.html.erb | 2 +- .../posts/partials/show/_options.html.erb | 12 +- app/views/tag_aliases/destroy.js.erb | 1 + app/views/tag_aliases/edit.html.erb | 0 app/views/tag_aliases/index.html.erb | 4 +- .../_secondary_links.html.erb | 7 + app/views/tag_implications/destroy.js.erb | 1 + app/views/tag_implications/edit.html.erb | 0 app/views/tag_implications/index.html.erb | 121 +++++---------- app/views/tag_implications/new.html.erb | 33 ++-- app/views/tags/index.html.erb | 2 +- config/routes.rb | 3 + public/javascripts/compiled/default.js | 144 ++---------------- public/javascripts/src/app/application.js | 9 ++ public/javascripts/src/app/favorites.js | 47 ------ public/javascripts/src/app/post_moderation.js | 80 ---------- public/javascripts/src/app/utility.js | 8 +- public/stylesheets/compiled/default.css | 23 +++ public/stylesheets/src/default.scss | 32 ++++ script/custom/auto_compile.sh | 1 + 28 files changed, 168 insertions(+), 415 deletions(-) create mode 100644 app/views/favorites/create.js.erb create mode 100644 app/views/favorites/destroy.js.erb create mode 100644 app/views/tag_aliases/destroy.js.erb delete mode 100644 app/views/tag_aliases/edit.html.erb create mode 100644 app/views/tag_implications/_secondary_links.html.erb create mode 100644 app/views/tag_implications/destroy.js.erb delete mode 100644 app/views/tag_implications/edit.html.erb diff --git a/app/controllers/favorites_controller.rb b/app/controllers/favorites_controller.rb index 8a155f5a2..7bba9dc16 100644 --- a/app/controllers/favorites_controller.rb +++ b/app/controllers/favorites_controller.rb @@ -9,11 +9,9 @@ class FavoritesController < ApplicationController def create Post.find(params[:id]).add_favorite(CurrentUser.user) - render :nothing => true end def destroy Post.find(params[:id]).remove_favorite(CurrentUser.user) - render :nothing => true end end diff --git a/app/controllers/tag_aliases_controller.rb b/app/controllers/tag_aliases_controller.rb index 25fb9e3a7..d1823c5f6 100644 --- a/app/controllers/tag_aliases_controller.rb +++ b/app/controllers/tag_aliases_controller.rb @@ -1,17 +1,12 @@ class TagAliasesController < ApplicationController - before_filter :admin_only, :only => [:new, :edit, :create, :update, :destroy] - respond_to :html, :xml, :json + before_filter :admin_only, :only => [:new, :create, :destroy] + respond_to :html, :xml, :json, :js def new @tag_alias = TagAlias.new(params[:tag_alias]) respond_with(@tag_alias) end - def edit - @tag_alias = TagAlias.find(params[:id]) - respond_with(@tag_alias) - end - def index @search = TagAlias.search(params[:search]) @tag_aliases = @search.paginate(:page => params[:page]) @@ -20,19 +15,13 @@ class TagAliasesController < ApplicationController def create @tag_alias = TagAlias.create(params[:tag_alias]) - respond_with(@tag_alias) - end - - def update - @tag_alias = TagAlias.find(params[:id]) - @tag_alias.update_attributes(params[:tag_alias]) - respond_with(@tag_alias) + respond_with(@tag_alias, :location => tag_aliases_path(:search => {:id_eq => @tag_alias.id})) end def destroy @tag_alias = TagAlias.find(params[:id]) @tag_alias.destroy - respond_with(@tag_alias) + respond_with(@tag_alias, :location => tag_aliases_path) end def cache diff --git a/app/controllers/tag_implications_controller.rb b/app/controllers/tag_implications_controller.rb index 32630d1d4..67e5cdbe4 100644 --- a/app/controllers/tag_implications_controller.rb +++ b/app/controllers/tag_implications_controller.rb @@ -1,32 +1,21 @@ class TagImplicationsController < ApplicationController - before_filter :admin_only, :only => [:new, :edit, :create, :update, :destroy] - respond_to :html, :xml, :json + before_filter :admin_only, :only => [:new, :create, :destroy] + respond_to :html, :xml, :json, :js def new @tag_implication = TagImplication.new respond_with(@tag_implication) end - def edit - @tag_implication = TagImplication.find(params[:id]) - respond_with(@tag_implication) - end - def index @search = TagImplication.search(params[:search]) - @tag_implicationes = @search.paginate(:page => params[:page]) + @tag_implications = @search.paginate(:page => params[:page]) respond_with(@tag_implicationes) end def create @tag_implication = TagImplication.create(params[:tag_implication]) - respond_with(@tag_implication) - end - - def update - @tag_implication = TagImplication.find(params[:id]) - @tag_implication.update_attributes(params[:tag_implication]) - respond_with(@tag_implication) + respond_with(@tag_implication, :location => tag_implications_path(:search => {:id_eq => @tag_implication.id})) end def destroy diff --git a/app/models/janitor_trial.rb b/app/models/janitor_trial.rb index 63b2f3e7a..4e50c9446 100644 --- a/app/models/janitor_trial.rb +++ b/app/models/janitor_trial.rb @@ -10,6 +10,10 @@ class JanitorTrial < ActiveRecord::Base self.creator_id = CurrentUser.id end + def user_name=(name) + self.user_id = User.name_to_id(name) + end + 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." diff --git a/app/views/comment_votes/create.js.erb b/app/views/comment_votes/create.js.erb index f7d5baf61..740da5aa5 100644 --- a/app/views/comment_votes/create.js.erb +++ b/app/views/comment_votes/create.js.erb @@ -1,5 +1,3 @@ <% if @error %> alert("<%= escape_javascript(@error.to_s) %>"); -<% else %> - $("#score-for-comment-<%= @comment.id %>").html("<%= pluralize @comment.score, 'point' %>"); <% end %> diff --git a/app/views/comments/partials/show/_comment.html.erb b/app/views/comments/partials/show/_comment.html.erb index e2221d948..1dfc9f80c 100644 --- a/app/views/comments/partials/show/_comment.html.erb +++ b/app/views/comments/partials/show/_comment.html.erb @@ -6,13 +6,12 @@ <%= time_ago_in_words(comment.created_at) %> ago

-

<%= pluralize comment.score, "point" %>

<%= format_text(comment.body) %>
- +
  • Reply
  • <% if CurrentUser.user.is_janitor? || CurrentUser.user.id == comment.creator_id %>
  • <%= link_to "Delete", comment_path(comment.id), :confirm => "Do you really want to delete this comment?", :method => :delete %>
  • diff --git a/app/views/favorites/create.js.erb b/app/views/favorites/create.js.erb new file mode 100644 index 000000000..462528fcb --- /dev/null +++ b/app/views/favorites/create.js.erb @@ -0,0 +1,2 @@ +$("a#add-to-favorites").hide(); +$("a#remove-from-favorites").show(); diff --git a/app/views/favorites/destroy.js.erb b/app/views/favorites/destroy.js.erb new file mode 100644 index 000000000..96f3cf8cf --- /dev/null +++ b/app/views/favorites/destroy.js.erb @@ -0,0 +1,2 @@ +$("a#add-to-favorites").show(); +$("a#remove-from-favorites").hide(); diff --git a/app/views/pools/_secondary_links.html.erb b/app/views/pools/_secondary_links.html.erb index 20de63ab9..36f2d77b9 100644 --- a/app/views/pools/_secondary_links.html.erb +++ b/app/views/pools/_secondary_links.html.erb @@ -5,7 +5,7 @@ <% if @pool %>
  • |
  • <%= link_to "Show", pool_path(@pool) %>
  • -
  • <%= link_to "Search", posts_path(:tags => "pool:#{@pool.id}") %>
  • +
  • <%= link_to "Posts", posts_path(:tags => "pool:#{@pool.id}") %>
  • <%= link_to "Simple Edit", edit_pool_path(@pool) %>
  • <%= link_to "Advanced Edit", edit_pool_path(@pool, :advanced => true) %>
  • <% end %> diff --git a/app/views/posts/partials/show/_options.html.erb b/app/views/posts/partials/show/_options.html.erb index 1d05b0824..666b96342 100644 --- a/app/views/posts/partials/show/_options.html.erb +++ b/app/views/posts/partials/show/_options.html.erb @@ -1,16 +1,16 @@
      <%= resize_image_links(post, CurrentUser.user) %> -
    • <%= link_to "Favorite", "#", :id => "add-to-favorites" %> <%= wait_image("add-to-favorites-wait") %>
    • -
    • <%= link_to "Unfavorite", "#", :id => "remove-from-favorites" %> <%= wait_image("remove-from-favorites-wait") %>
    • +
    • <%= link_to "Favorite", favorite_path(post), :remote => true, :method => :post, :id => "add-to-favorites" %>
    • +
    • <%= link_to "Unfavorite", favorite_path(post), :remote => true, :method => :delete, :id => "remove-from-favorites" %>
    • <%= link_to "Translate", "#" %>
    • <%= link_to "Unapprove", new_unapproval_path(:post_id => post.id), :id => "unapprove" %>
    • <% if CurrentUser.is_janitor? %> -
    • <%= link_to "Approve", "#", :id => "approve" %> <%= wait_image("approve-wait") %>
    • -
    • <%= link_to "Disapprove", "#", :id => "disapprove" %> <%= wait_image("disapprove-wait") %>
    • +
    • <%= link_to "Approve", post_moderation_approve_path(:post_id => post.id), :remote => true, :method => :put, :id => "approve" %>
    • +
    • <%= link_to "Disapprove", post_moderation_disapprove_path(:post_id => post.id), :remote => true, :method => :put, :id => "disapprove" %>
    • <% end %> <% if CurrentUser.is_moderator? %> -
    • <%= link_to "Undelete", "#", :id => "undelete" %> <%= wait_image("undelete-wait") %>
    • -
    • <%= link_to "Delete", "#", :id => "delete" %> <%= wait_image("delete-wait") %>
    • +
    • <%= link_to "Undelete", post_moderation_undelete_path(:post_id => post.id), :remote => true, :method => :post, :id => "undelete" %>
    • +
    • <%= link_to "Delete", post_moderation_delete_path(:post_id => post.id), :remote => true, :method => :post, :id => "delete" %>
    • <% end %>
    • <%= link_to "Pool", "#", :id => "pool" %>
    \ No newline at end of file diff --git a/app/views/tag_aliases/destroy.js.erb b/app/views/tag_aliases/destroy.js.erb new file mode 100644 index 000000000..478611344 --- /dev/null +++ b/app/views/tag_aliases/destroy.js.erb @@ -0,0 +1 @@ +$("#tag-alias-<%= @tag_alias.id %>").remove(); diff --git a/app/views/tag_aliases/edit.html.erb b/app/views/tag_aliases/edit.html.erb deleted file mode 100644 index e69de29bb..000000000 diff --git a/app/views/tag_aliases/index.html.erb b/app/views/tag_aliases/index.html.erb index 7fbcc3039..150ba3dac 100644 --- a/app/views/tag_aliases/index.html.erb +++ b/app/views/tag_aliases/index.html.erb @@ -19,13 +19,13 @@ <% @tag_aliases.each do |tag_alias| %> - + <%= link_to tag_alias.antecedent_name, posts_path(:tags => tag_alias.antecedent_name) %> (<%= tag_alias.antecedent_tag.post_count rescue 0 %>) <%= link_to tag_alias.consequent_name, posts_path(:tags => tag_alias.consequent_name) %> (<%= tag_alias.consequent_tag.post_count rescue 0 %>) <%= link_to tag_alias.forum_topic_id, forum_topic_path(tag_alias.forum_topic_id) %> <% 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 %> diff --git a/app/views/tag_implications/_secondary_links.html.erb b/app/views/tag_implications/_secondary_links.html.erb new file mode 100644 index 000000000..cc6425c7b --- /dev/null +++ b/app/views/tag_implications/_secondary_links.html.erb @@ -0,0 +1,7 @@ +<% content_for(:secondary_links) do %> + +
  • <%= link_to "Listing", tag_implications_path %>
  • +
  • <%= link_to "Add", new_tag_implication_path %>
  • +
  • <%= link_to "Help", wiki_pages_path(:title => "help:tag_implications") %>
  • +
    +<% end %> diff --git a/app/views/tag_implications/destroy.js.erb b/app/views/tag_implications/destroy.js.erb new file mode 100644 index 000000000..f99b2b043 --- /dev/null +++ b/app/views/tag_implications/destroy.js.erb @@ -0,0 +1 @@ +$("#tag-implication-<%= @tag_implication.id %>").remove(); diff --git a/app/views/tag_implications/edit.html.erb b/app/views/tag_implications/edit.html.erb deleted file mode 100644 index e69de29bb..000000000 diff --git a/app/views/tag_implications/index.html.erb b/app/views/tag_implications/index.html.erb index 9a6ada9c9..ec415ae72 100644 --- a/app/views/tag_implications/index.html.erb +++ b/app/views/tag_implications/index.html.erb @@ -1,95 +1,42 @@ -
    - <% form_tag({:action => "index"}, :method => :get) do %> - <%= text_field_tag "query", params[:query] %> - <%= submit_tag "Search Implications" %> - <%= submit_tag "Search Aliases" %> - <% end %> -
    - -<% form_tag(:action => "update") do %> - - - - - - - - - - - - - - - - <% @implications.each do |i| %> - - - - - - - <% end %> - -
    PredicateConsequentReason
    - <% 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? %> - - <% end %> -
    ><%= link_to h(i.predicate.name), :controller => "post", :action => "index", :tags => i.predicate.name %> (<%= i.predicate.post_count %>)<%= link_to h(i.consequent.name), :controller => "post", :action => "index", :tags => i.consequent.name %> (<%= i.consequent.post_count %>)<%= h i.reason %>
    -<% end %> - -<% if @current_user.is_admin_or_higher? %> -
    style="display: none;"<% end %>> - <% form_tag(:action => "create") do %> -

    Add Implication

    - <% unless @current_user.is_anonymous? %> - <%= hidden_field_tag "tag_implication[creator_id]", @current_user.id %> +
    +
    + -<% end %> +
    <%= will_paginate(@implications) %>
    -<% content_for("subnavbar") do %> -
  • <%= link_to "List", :controller => "tag_implication", :action => "index" %>
  • -
  • <%= link_to "Add", :controller => "tag_implication", :action => "new" %>
  • -
  • <%= link_to "Help", :controller => "help", :action => "tag_implications" %>
  • -<% end %> - +<%= render "secondary_links" %> diff --git a/app/views/tag_implications/new.html.erb b/app/views/tag_implications/new.html.erb index 557d522ec..3824d7632 100644 --- a/app/views/tag_implications/new.html.erb +++ b/app/views/tag_implications/new.html.erb @@ -1,20 +1,13 @@ -<% form_tag(:controller => "forum", :action => "create") do %> -

    You can create a forum thread to suggest the creation of an implication.

    - - - - - - - - - - - - - - - - -
    <%= text_field "tag_implication", "predicate", :size => 40 %>
    <%= text_field "tag_implication", "consequent", :size => 40 %>
    <%= text_area "tag_implication", "reason", :rows => 10, :cols => 60 %>
    <%= submit_tag "Submit" %>
    -<% end %> +
    +
    +

    New Tag Implication

    + <%= simple_form_for(@tag_implication) do |f| %> + <%= f.input :antecedent_name, :label => "From" %> + <%= f.input :consequent_name, :label => "To" %> + <%= f.input :forum_topic_id, :label => "Forum" %> + <%= f.button :submit %> + <% end %> +
    +
    + +<%= render "secondary_links" %> \ No newline at end of file diff --git a/app/views/tags/index.html.erb b/app/views/tags/index.html.erb index d1b92424a..cb7536c93 100644 --- a/app/views/tags/index.html.erb +++ b/app/views/tags/index.html.erb @@ -12,7 +12,7 @@ <%= tag.post_count %> - <%= 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)) %> diff --git a/config/routes.rb b/config/routes.rb index d26d83851..58cd8e641 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -68,6 +68,9 @@ Danbooru::Application.routes.draw do end 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#destroy', :via => :delete, :as => 'pool_post' match '/post_moderation/moderate' => 'post_moderation#moderate' diff --git a/public/javascripts/compiled/default.js b/public/javascripts/compiled/default.js index d3d999587..4ea90514b 100644 --- a/public/javascripts/compiled/default.js +++ b/public/javascripts/compiled/default.js @@ -681,6 +681,15 @@ $(document).ready(function() { $(".comment-section[data-post-id=" + post_id + "] form").show(); $(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 $("#resize-links").hide(); @@ -779,12 +788,12 @@ $(document).ready(function() { this.j_alert("Error", msg); } - Danbooru.ajax_start = function(element) { - $(element).after(' ...'); + Danbooru.ajax_start = function(target) { + $(target).after(' '); } - Danbooru.ajax_stop = function(element) { - $(element).next("span.wait").remove(); + Danbooru.ajax_stop = function(target) { + $(target).next("img.wait").remove(); } })(); // PostModeMenu = { @@ -1079,8 +1088,6 @@ $(document).ready(function() { Danbooru.Favorite = {}; Danbooru.Favorite.initialize_all = function() { - this.initialize_add_to_favorites(); - this.initialize_remove_from_favorites(); this.hide_or_show_add_to_favorites_link(); } @@ -1099,51 +1106,6 @@ $(document).ready(function() { $("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() { @@ -1193,12 +1155,8 @@ $(document).ready(function() { Danbooru.PostModeration = {}; 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_delete_and_undelete_links(); - this.initialize_delete_link(); - this.initialize_undelete_link(); } Danbooru.PostModeration.hide_or_show_approve_and_disapprove_links = function() { @@ -1215,82 +1173,6 @@ $(document).ready(function() { $("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() { diff --git a/public/javascripts/src/app/application.js b/public/javascripts/src/app/application.js index 2c3ece0c3..bec828c0b 100644 --- a/public/javascripts/src/app/application.js +++ b/public/javascripts/src/app/application.js @@ -15,6 +15,15 @@ $(document).ready(function() { $(".comment-section[data-post-id=" + post_id + "] form").show(); $(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 $("#resize-links").hide(); diff --git a/public/javascripts/src/app/favorites.js b/public/javascripts/src/app/favorites.js index 4c058cc70..3a88f0860 100644 --- a/public/javascripts/src/app/favorites.js +++ b/public/javascripts/src/app/favorites.js @@ -2,8 +2,6 @@ Danbooru.Favorite = {}; Danbooru.Favorite.initialize_all = function() { - this.initialize_add_to_favorites(); - this.initialize_remove_from_favorites(); this.hide_or_show_add_to_favorites_link(); } @@ -22,51 +20,6 @@ $("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() { diff --git a/public/javascripts/src/app/post_moderation.js b/public/javascripts/src/app/post_moderation.js index 8b0cb63e7..a79e11b57 100644 --- a/public/javascripts/src/app/post_moderation.js +++ b/public/javascripts/src/app/post_moderation.js @@ -2,12 +2,8 @@ Danbooru.PostModeration = {}; 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_delete_and_undelete_links(); - this.initialize_delete_link(); - this.initialize_undelete_link(); } Danbooru.PostModeration.hide_or_show_approve_and_disapprove_links = function() { @@ -24,82 +20,6 @@ $("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() { diff --git a/public/javascripts/src/app/utility.js b/public/javascripts/src/app/utility.js index 5040faeca..78f6de496 100644 --- a/public/javascripts/src/app/utility.js +++ b/public/javascripts/src/app/utility.js @@ -11,11 +11,11 @@ this.j_alert("Error", msg); } - Danbooru.ajax_start = function(element) { - $(element).after(' ...'); + Danbooru.ajax_start = function(target) { + $(target).after(' '); } - Danbooru.ajax_stop = function(element) { - $(element).next("span.wait").remove(); + Danbooru.ajax_stop = function(target) { + $(target).next("img.wait").remove(); } })(); diff --git a/public/stylesheets/compiled/default.css b/public/stylesheets/compiled/default.css index b210be788..a87ff61ff 100644 --- a/public/stylesheets/compiled/default.css +++ b/public/stylesheets/compiled/default.css @@ -416,3 +416,26 @@ div.users div.new { /*** Uploads ***/ div.uploads div.new div#upload-guide-notice { 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; } diff --git a/public/stylesheets/src/default.scss b/public/stylesheets/src/default.scss index 2df028b94..afb55edbf 100644 --- a/public/stylesheets/src/default.scss +++ b/public/stylesheets/src/default.scss @@ -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; + } + } +} + diff --git a/script/custom/auto_compile.sh b/script/custom/auto_compile.sh index f7f00ba17..e8030a48a 100755 --- a/script/custom/auto_compile.sh +++ b/script/custom/auto_compile.sh @@ -2,5 +2,6 @@ while true ; do script/custom/compile_javascripts ; + sass public/stylesheets/src/default.scss public/stylesheets/compiled/default.css ; sleep 1 ; done